JPLRepo Posted May 11, 2017 Share Posted May 11, 2017 KSP Font system. With the introduction of 1.3 and Localization several changes have been made inside KSP that set the base for the localization process. One of these changes is the introduction of a font system. The purpose of this document is to set a handy guide on how it works and what modders can do with this new font system. How does it work? All the game texts have been changed to use only 2 fonts, one for the MainMenu (JD-LCD) and another for all the rest of the KSP UI (NotoSans). These two fonts are considered the stock fonts of KSP and cannot be changed. That said however, KSP uses TMPro to handle all the UI/Text in the game and it allows us to create fallback fonts so you can create new fonts (sub-fonts) and attach them to the KSP stock fonts expanding the list of characters supported by KSP. The fallback font system works when you request a character in the font. For example, if you request a character let's say japanese letter A -> あ the font looks for it in the font character list and if the character is not found then it look for it in fallback fonts. NotoSans - Game Font This stock font contains the following characters of the Unicode standard (Basic Latin, C1 Controls and Latin-1 Supplement, Latin Extended-A, Latin Extended-B and Cyrillic). JD-LCD - MainMenu Font This stock font contains the follow characters of the Unicode standard (Basic Latin, C1 Controls and Latin-1 Supplement, Latin Extended-A, Latin Extended-B). Unicode standard reference: http://billposer.org/Linguistics/Computation/UnicodeRanges.html Additional to these stock fonts KSP contains several sub-fonts that handle additional characters for Russian, Japanese, Chinese and Korean and this is where the KSP font system enters into the scene. The KSP font system manages all sub-font related activities (load fonts, add them to a stock font, remove them, etc). The stock fonts and their character set cannot be changed, but all the KSP sub-fonts can be removed or replaced by custom fonts. Each sub-font is connected to a language code, this is done by design as the KSP font system manages and creates new sub-font without adding more character ranges to the existing stock fonts. How to add sub-fonts. Create a new Unity Project. Download/Import from the Unity AssetStore the TextMesh pro version 1.0.55 March 2017 Download KSP parttools and import the unity packages into a Unity project. You should have KSPAssets.dll and KSPAssetsCompiler.dll in your project. You can download it from here. Create a TMPro FontAsset with the desired font, following this tutorial https://www.youtube.com/watch?v=qzJNIGCFFtY Create a KSPFontAsset from the created TMP_FontAsset on the previous step by right clicking on the font and using the option “KSP Fonts/Generate KSPFontAsset”. You should now have 2 files as per the following image: Now you need to create a bundle name and associate the font assets. First you need to select the font files you want to include in your bundle and set a bundle name in the unity inspector. Select the New.. option to create a new bundle name. Type the name of your new bundle name. Now you should see that your font files have the bundle name associated with them. Make sure you assign the AssetBundle to both the TMPro asset file and the KSPFontAsset you created in step 5. Now we need to create an asset bundle of that font using the KSPAssetCompiler, First open the “KSPAssets/AssetCompiler” menu on the Unity top bar. This will bring up the Asset Compiler window and there you will see the bundle name you just created. You need to click on the create button to create the bundle definition file. Finally you only need to click on the “Build All as Fonts” button to start the bundle creation. After the process is complete a new folder AssetBundles will be created on your project root folder and there you will see your font bundle. Place that bundle anywhere in the GameData folder. The font will be loaded at the beginning of the game, you will the see the name of the bundle been loaded in the loading screen. Now you need to create a mod to activate the font by using the method AddGameSubFont or AddMenuSubFont of the FontLoader class depending on where you want the font to be active. You can follow the example below or read the mods API. Link to comment Share on other sites More sharing options...
JPLRepo Posted July 17, 2017 Author Share Posted July 17, 2017 There is a problem with the linking of TMPro free version for Part Tools. Here is a work around until we can fix Part Tools.http://forum.kerbalspaceprogram.com/index.php?/topic/161314-no-kspasset-in-unity-menu/&do=findComment&comment=3074505 Link to comment Share on other sites More sharing options...
Recommended Posts