Jason Carr Posted March 19, 2019 Share Posted March 19, 2019 Hello all, my latest goal was to figure out a solution for theme developers for all three types of themes to be able to include custom fonts without having to create a custom plugin/DLL or requiring the end user to manually install them. Microsoft really made it way more of a pain than it should have been, so I was struggling with it for hours, but I finally have a good solution. Unfortunately it did require changes to the LaunchBox codebase, so this solution will only work going forward, for LaunchBox/Big Box 9.6-beta-7 and later. Previously it was not possible to automatically include custom fonts in startup themes, as plugins are not currently supported. This solution will allow you to use custom fonts in startup themes without requiring the user to manually install them, and this solution can be used for LaunchBox and Big Box themes as well (it's also now the recommended method). Here's an example of a TextBlock with a custom font: <TextBlock FontFamily="LAUNCHBOX_ROOT_FOLDER/Startup Themes/ExampleTheme/Blazed.ttf#Blazed" /> Obviously, only the FontFamily property is important here. It always starts with "LAUNCHBOX_ROOT_FOLDER", as LaunchBox and Big Box will automatically replace this with the LaunchBox folder, wherever it is located. This part was necessary because of Microsoft's bugs/security workarounds, none of which make sense, but it's impossible to load a font from a relative path in XAML without including it in a project or DLL, so LaunchBox just replaces this part with the full path to the LaunchBox folder. In the above case, the "LaunchBox\Startup Themes\ExampleTheme\Blazed.ttf" font will be used for that TextBlock element. Note the "#Blazed" portion at the end however; unfortunately you also have to include the pound sign, followed by the name of the font. You can find the name of the font by simply double-clicking the font file in Windows, and the name of the font will be displayed at the top of the Font Viewer application, next to "Font name:". I'm not sure why this is necessary, but it's another requirement in order to get the fonts working properly. Next, let's take a look at an example with a space in the font file and/or the font name: <TextBlock FontFamily="LAUNCHBOX_ROOT_FOLDER/Startup Themes/ExampleTheme/Hearty Script.ttf#Hearty Script" /> Simply putting it in as expected with spaces does work, so that should not be a concern. Let me know if anyone runs into any issues. I will say that I did find one font that just refused to work with WPF period, so if you can't seem to make it work, do try another font. Unfortunately it seems there are some fonts out there that are either just poorly made or incompatible with WPF for one reason or another. Thanks again all. Calling you all out here so that everyone is aware of this new feature. @faeran @Mr. RetroLust @RetroHumanoid @wallmachine @eatkinola @bbweiners @keltoigael @Jack. @y2guru @whoozwah @SNAK3ATER @Rincewind @CriticalCid @shro2016 @broskiplays @Grila @NJDave71 @Hexxxer @PhillsDoodles @Zombeaver @Omen @Cookz718 @viking @OrochiMishima @nosh @ea4492 @Maddoc1007 @vsilvalopes @damageinc86 @walter10h @skainlurmis @Scottad @Nyny77 @Sithel @Akezhar @Thanos Reigns 6 3 Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 19, 2019 Author Share Posted March 19, 2019 Thank you @wallmachine. Can you zip up and PM me the theme? Quote Link to comment Share on other sites More sharing options...
y2guru Posted March 20, 2019 Share Posted March 20, 2019 Works like a charm Jason!! one question though... currently i generate the code in the same way as @wallmachine for example.. Value="LAUNCHBOX_ROOT_FOLDER/Themes/PASC/Fonts/Let_s_go_Digital.ttf#Let's go Digital" and this works great when in BigBox, but when the Theme is ready for submission/review, should the code look like the following ? Value="LAUNCHBOX_ROOT_FOLDER/Startup Themes/PASC/Let_s_go_Digital.ttf#Let's go Digital" Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 20, 2019 Author Share Posted March 20, 2019 On 3/19/2019 at 4:43 AM, wallmachine said: This works for me only in PlatformWheel1FiltersView.xaml however not in the TextListView.xaml. PlatformWheel1FiltersView.xaml: <TextBlock Text="{Binding Path=ActivePlatform.TotalGameCount}" FontFamily="LAUNCHBOX_ROOT_FOLDER/Themes/Pandora/Fonts/Digital-Serial.ttf#Digital-Serial" /> <TextBlock Text=" GAMES AVAILABLE" FontFamily="LAUNCHBOX_ROOT_FOLDER/Themes/Pandora/Fonts/Digital-Serial.ttf#Digital-Serial" /> TextListView.xaml: <Setter Property="FontFamily" Value="LAUNCHBOX_ROOT_FOLDER/Themes/Pandora/Fonts/Digital-Serial.ttf#Digital-Serial" /> <Setter Property="Typography.Capitals" Value="AllSmallCaps" /> I'm confused here as to what's wrong. First I tested putting the new font solution in a copy of the default theme, in the TextListView.xaml, and it shows up just fine with that font. Then I loaded up your theme and it appears to be working properly with the font and the new solution. What am I missing? As far as I can tell, everything is working properly. Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 20, 2019 Author Share Posted March 20, 2019 3 hours ago, y2guru said: Works like a charm Jason!! one question though... currently i generate the code in the same way as @wallmachine for example.. Value="LAUNCHBOX_ROOT_FOLDER/Themes/PASC/Fonts/Let_s_go_Digital.ttf#Let's go Digital" and this works great when in BigBox, but when the Theme is ready for submission/review, should the code look like the following ? Value="LAUNCHBOX_ROOT_FOLDER/Startup Themes/PASC/Let_s_go_Digital.ttf#Let's go Digital" @y2guru It depends on whether you're creating a Startup Theme or a Big Box Theme. The different types of themes go into different folders. Quote Link to comment Share on other sites More sharing options...
wallmachine Posted March 20, 2019 Share Posted March 20, 2019 (edited) On 3/21/2019 at 5:32 AM, Jason Carr said: I'm confused here as to what's wrong. First I tested putting the new font solution in a copy of the default theme, in the TextListView.xaml, and it shows up just fine with that font. Then I loaded up your theme and it appears to be working properly with the font and the new solution. What am I missing? As far as I can tell, everything is working properly. In the TextListView.xaml it never lets me put it as uppercase font for the game names however the A-Z search is uppercase and text in Platform views. What it should look like. Edited May 8, 2019 by wallmachine Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 20, 2019 Author Share Posted March 20, 2019 3 minutes ago, wallmachine said: In the TextListView.xaml it never lets me put it as uppercase font for the game names however the A-Z search is uppercase. What it should look like. I see. So the uppercase thing is a separate issue than the font not loading. I was under the impression that the fonts were not loading as expected. At least we can cross that issue off the list. I'll do some quick research to see what might be going on with the uppercase thing. Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 20, 2019 Author Share Posted March 20, 2019 Just to clarify here for everyone in this thread, the new font solution above is working properly everywhere. @wallmachine's issue is an unrelated thing. @wallmachine After looking at your code, I'm guessing you'll probably need to set the all caps thing inside the ListBoxItemStyle instead of the ListBoxStyle, and you might need to put it deeper down into the template as well. Quote Link to comment Share on other sites More sharing options...
wallmachine Posted March 21, 2019 Share Posted March 21, 2019 10 hours ago, Jason Carr said: @wallmachine After looking at your code, I'm guessing you'll probably need to set the all caps thing inside the ListBoxItemStyle instead of the ListBoxStyle, and you might need to put it deeper down into the template as well. already tried that Quote Link to comment Share on other sites More sharing options...
LogicalEgo Posted March 21, 2019 Share Posted March 21, 2019 heck to the yes, this is way better than wrapping things in a .dll. I will go ahead and start making changes and get it ready for release. 1 Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 21, 2019 Author Share Posted March 21, 2019 6 minutes ago, keltoigael said: heck to the yes, this is way better than wrapping things in a .dll. I will go ahead and start making changes and get it ready for release. Thank you keltoi! I'm also excited to get all your themes up in the themes manager. The uploader is now available as well. Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 21, 2019 Author Share Posted March 21, 2019 12 hours ago, wallmachine said: already tried that Unfortunately I can't tinker with it for the moment; I just have too much stuff going on. If anyone's willing to help out wallmachine with a XAML styling issue, please speak up. Quote Link to comment Share on other sites More sharing options...
y2guru Posted March 21, 2019 Share Posted March 21, 2019 9 minutes ago, keltoigael said: heck to the yes, this is way better than wrapping things in a .dll. I will go ahead and start making changes and get it ready for release. I second that! a very elegant solution! 1 Quote Link to comment Share on other sites More sharing options...
Artik Posted March 27, 2019 Share Posted March 27, 2019 Thanks for this feature! Does it work with a plugin? I tried this but doesn't work <lbsc:GameList Name="Items" FontSize="15" FontFamily="LAUNCHBOX_ROOT_FOLDER/Startup Themes/CityHunter 2/Fonts/Blazed.ttf#Blazed"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDoubleClick"> <cal:ActionMessage MethodName="OnEnter" /> </i:EventTrigger> </i:Interaction.Triggers> </lbsc:GameList> Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 27, 2019 Author Share Posted March 27, 2019 25 minutes ago, Artik said: Thanks for this feature! Does it work with a plugin? I tried this but doesn't work <lbsc:GameList Name="Items" FontSize="15" FontFamily="LAUNCHBOX_ROOT_FOLDER/Startup Themes/CityHunter 2/Fonts/Blazed.ttf#Blazed"> <i:Interaction.Triggers> <i:EventTrigger EventName="MouseDoubleClick"> <cal:ActionMessage MethodName="OnEnter" /> </i:EventTrigger> </i:Interaction.Triggers> </lbsc:GameList> I'm guessing that setting the FontFamily on that control just doesn't work, as it specified somewhere further up the XAML tree. Quote Link to comment Share on other sites More sharing options...
Artik Posted March 27, 2019 Share Posted March 27, 2019 But I'm also trying in a classic bloc, couldn't get it working. Here is my FilterDetailsView.xaml bloc: <TextBlock Text="Details" FontFamily="LAUNCHBOX_ROOT_FOLDER/Startup Themes/CityHunter 2/Blazed.ttf#Blazed" FontSize="40" TextWrapping="Wrap" DockPanel.Dock="Top" > <TextBlock.Foreground> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FFFE1C1C" Offset="1"/> <GradientStop Color="#FFFF3737"/> </LinearGradientBrush> </TextBlock.Foreground> </TextBlock> Font "Blazed.ttf" is at the root of my "CityHunter 2" folder in "Themes", and new font is not applied And latest 9.6 version. Don't know what am I doing wrong Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 27, 2019 Author Share Posted March 27, 2019 @Artik We have it confirmed working for several people, so there has to be some kind of discrepancy somewhere. Where did you get that Blazed font? Did you rename the font file from something else? Hold up, nevermind. You have the file path wrong. Quote Link to comment Share on other sites More sharing options...
Artik Posted March 27, 2019 Share Posted March 27, 2019 (edited) Checked again and again, but I don't see where the path is wrong (Font downloaded from Dafont, and I checked the name. "#Blazed" is correct) Edited March 27, 2019 by Artik Quote Link to comment Share on other sites More sharing options...
Jason Carr Posted March 27, 2019 Author Share Posted March 27, 2019 1 minute ago, Artik said: Checked again and again, but I don't see where the path is wrong (Font downloaded from Dafont, and name #Blazed" is correct) Startup Themes vs. Themes. Quote Link to comment Share on other sites More sharing options...
Artik Posted March 27, 2019 Share Posted March 27, 2019 I can't believe ..... Tought was part of the synthax! It works now, thanks for help. I continue my work, and here another question I have. Still in the gamelisting, Can I change the font and size using the same .ttf ? (it's temporary small on purpose, and I'm using the "ListBox Scroll Center for BigBox" plugin to manage the fontsize. Is there a way to combine both for this listing? Custom font and small font size? Spent hours without success) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.