Fonts are applied to textual elements in the interface. All fonts are found and should be placed in the /Hearts of Iron IV/gfx/fonts/ folder.
Creating a New Font
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.5。 |
To create a new font you need to download a program called BMFont, which is used to generate the font page and descriptor file from a font.
Once you have BMFont installed, open it and import a font. To do this, click on the Options menu button and then the Font Settings button. Within the Font Settings menu, add your font file.
This will populate the font canvas with all the symbols supported by your chosen font. All your symbols should be highlighted for them to be included in the font file, for this reason you may choose to not include some symbols by not highlighting them, be it through the side bar or manually selecting them. This is not necessary unless you need your font to be a specific size.
Font Settings
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.5。 |
Having imported your font, it is time to setup how you want the font to look. To do this, open the Font Settings menu again. Below are the fields you need to change:
- Charset: set this to OEM - ANSI.
- Size: this is the font size for your font, set this to your desired size.
- Match char height: tick this so each character has the same height.
- Font smoothing: tick this if your font may look overly sharp in game.
- Outline thickness: if you want your font to have an outline, set the desired thickness here.
Export Options
Having setup your font, it is now time to setup how you want the font exported. To do this, open the Export Options menu. Below are the fields you may want to change:
- Padding: controls the padding between each character in the font image. Only needed if you intend to manually edit the font file and don't want the characters too close together.
- Spacing: controls the minimum space between character in the the font image. Set this to 1-1, or higher if you experience bleeding between characters.
- Width: controls the width of the font image. Make this higher if all the characters don't fit on one image.
- Height: controls the height of the font image. Make this higher if all the characters don't fit on one image.
- Channels: controls how the characters are composited. Set them all to glyph unless you have specified an outline, then set the alpha channel to outline, with the rest as glyph.
- Font descriptor: needs to be set to text.
- Textures: should be set to .tga or .dds
Saving the Font
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.5。 |
Having setup the font as you would like it, check that the characters all fit on one page by clicking on the Visualize button in the Options menu. If they don't you need to increase the size of the font image width and height.
Save the font.
Using a New Font
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.5。 |
Having saved your new font, you should now possess two files, a font image file (i.e. my_font.tga) and a font descriptor (i.e. my_font.fnt). Open your font descriptor file, as you need to edit it for compatibility with Hearts of Iron IV.
Once opened, you need to change the following lines:
- size: make the value a positive.
- unicode: delete the key and value.
- outline: delete the key and value if your font doesn't use an outline.
- pages=1: delete the key and value.
- packed=0: delete the key and value.
- alphaChnl=0: delete the key and value.
- redChnl=0: delete the key and value.
- greenChnl=0: delete the key and value.
- blueChnl=0: delete the key and value.
- page id=0: delete the key and value.
- file="x.tga": delete the key and value.
- chars count=216: delete the key and value.
- chnl=15: delete the key and value for every character.
Once you have done this, save your font descriptor file. It is now ready to be used in Hearts of Iron IV.
To make your new font available you need to add a .gfx definition for it in your mod files. Here is an example:
bitmapfonts = { bitmapfont = { name = "monofonto_tooltip" path = "gfx/fonts/monofonto_tooltip" color = 0xffffffff } }
Note you can change the localization color symbols effects by including the textcolors scope within your font:
bitmapfonts = { bitmapfont = { name = "monofonto_tooltip" path = "gfx/fonts/monofonto_tooltip" color = 0xffffffff textcolors = { G = { 86 172 91 } R = { 222 86 70 } Y = { 238 201 35 } H = { 238 203 35 } T = { 255 255 255 } } } }
If you want to change the map font, you need to override the tahoma_60 font definition with your own font.
Kerning
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.5。 |
Many fonts will not be exported with kerning information included in the font descriptor file. This can lead to character overlaps ingame which can be unsightly. To fix this, you need to add kerning information to your font descriptor file.
To do this, open your font descriptor file and add a new line following this format for each kerning pair:
kerning first=<symbol position> second=<symbol position> amount=<pixel width>
A symbol's position within a font can be seen in BMFont by looking in the lower right at the status bar when hovering over a symbol in the font canvas.
The pixel amount is the space between the first and second symbol.
You may have realized that manually creating each kerning pair is not very feasible. It is best to use a programming language (such as Python) to generate the kerning lines for you. Below is an example script you can use in Python 3.x or above:
file = open( "kerning.txt", "wt" ) # Add the symbol positions of the blank symbol slots here. exclude = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 , 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 127, 129, 141, 143, 144, 156, 173, 181] for x in range( 1, 255 ): for y in range(1, 255): if x not in exclude: if y not in exclude: file.write( "kerning first={0} second={1} amount=1\n".format( x, y ) ) file.close()
文件 | 效果 • 条件 • 定义 • 修正 • 修正列表 • 作用域 • 本地化 • on action • 数据结构 (标记, 临时标记, 国家别名, 变量, 数组) |
脚本 | 成就修改 • AI修改 • AI focuses • 自治领修改 • 权力平衡修改 • 剧本/标签 (游戏规则)• 建筑修改 • 人物修改 • 修饰性TAG修改 • 国家创建 • 军队修改 • 决议制作 • 装备修改 • 事件修改 • Idea修改 • 意识形态修改 • 军工商修改 • 国策制作 • 资源修改 • Scripted GUI • 科技制作 • 单位修改 |
地图 | 地图 • 省份 • 补给区域 • 战略区域 |
图形图像 | 界面 • 图形资产 • 实体模型 • 后期特效 • 离子效果 • 字体 |
装饰性 | 肖像 • 命名列表 • 音乐 • 音效 |
其他 | 控制台指令 • 故障排除 • 模组结构 • 成就代码分析 • Mod相关 • Nudger修改 |