Skip to content

Commit bd2aa87

Browse files
authored
Update the 'Using Fonts' page to include information on spacing adjustments and kerning pairs for image fonts (godotengine#10880)
* Update the 'Using Fonts' page to include information on spacing adjustments and kerning pairs for image fonts Closes godotengine#10855 Non-monospaced image fonts have been supported for quite some time, but the documentation has not yet been updated to reflect this. There are now some additional screenshots and examples of how to use the extra parameters in the Character Ranges, and how to use the Kerning Pairs list.
1 parent 3dbb51b commit bd2aa87

5 files changed

+32
-6
lines changed

tutorials/ui/gui_using_fonts.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,16 @@ Godot supports the BMFont (``.fnt``) bitmap font format. This is a format create
6868
by the `BMFont <https://www.angelcode.com/products/bmfont/>`__ program. Many
6969
BMFont-compatible programs also exist, like `BMGlyph <https://www.bmglyph.com/>`__ or web-based `fontcutter <https://github.com/fabienbk/fontcutter>`__.
7070

71-
Alternatively, you can import any image to be used as a bitmap font. This is
72-
only supported for **monospaced** fonts (fonts where each character has the same
73-
width). To do so, select the image in the FileSystem dock, go to the
74-
Import dock, change its import type to **Font Data (Monospace Image Font)** then
71+
Alternatively, you can import any image to be used as a bitmap font.
72+
To do so, select the image in the FileSystem dock, go to the
73+
Import dock, change its import type to **Font Data (Image Font)** then
7574
click **Reimport**:
7675

7776
.. figure:: img/using_fonts_bitmap_font_from_image_import_options.webp
7877
:align: center
79-
:alt: Changing import type to Font Data (Monospace Image Font)
78+
:alt: Changing import type to Font Data (Image Font)
8079

81-
Changing import type to **Font Data (Monospace Image Font)**
80+
Changing import type to **Font Data (Image Font)**
8281

8382
The font's character set layout can be in any order, but orders that match
8483
standard Unicode are recommended as they'll require far less configuration to
@@ -122,6 +121,33 @@ If your font image contains guides (in the form of lines between glyphs) or
122121
if spacing between characters appears incorrect, try adjusting **Character
123122
Margin**. This margin is applied for every imported glyph.
124123

124+
If you need finer control over character spacing than
125+
what the **Character Margin** options provide, you have more options.
126+
127+
For one, **Character Ranges** supports 3 additional arguments after the
128+
specified range of characters.
129+
These additional arguments control their positioning and spacing.
130+
They represent space advance, X axis offset, and Y axis offset in that order.
131+
They will change the space advance and offset of each character
132+
by the amount of pixels written. Space advance is most useful if, for example,
133+
your lowercase letters are thinner than your uppercase letters.
134+
135+
.. figure:: img/using_fonts_bitmap_font_advance_offsets_diagram.webp
136+
:align: center
137+
:alt: Diagram showing the advance and offset values being used in character ranges.
138+
139+
Do note that the offsets can cause your text to be cropped off the edge of your label boundaries.
140+
141+
Secondly, you can also set up **Kerning Pairs** for individual characters.
142+
Specify your kerning pair by typing two sets of characters separated by a space,
143+
then followed by another space, a number to specify how many extra/less pixels to
144+
space those two sets of characters when placed next to each other.
145+
146+
.. figure:: img/using_fonts_bitmap_kerning_pairs_example.webp
147+
148+
If needed, your kerning pair characters can be specified by Unicode character code
149+
by entering ``\uXXXX`` where XXXX is the hexadecimal value of the Unicode character.
150+
125151
Loading a font file
126152
-------------------
127153

27.4 KB
Loading
2.37 KB
Loading
3.2 KB
Loading
7.9 KB
Loading

0 commit comments

Comments
 (0)