@@ -13,19 +13,26 @@ folder you can find an example of a otf font.
1313Readme First
1414------------
1515
16- All loaded fonts glyphs are rendered into a single texture atlas ahead of time.
17- Adding/Removing/Modifying fonts will cause the font atlas to be rebuilt.
16+ All loaded fonts glyphs are rendered into a single texture atlas. Rendering occurs
17+ on-the-fly as characters are encountered in UI strings (item labels, input contents, etc. -
18+ anything that gets displayed in the viewport).
1819
19- You can use the style editor
20+ You can use the Fonts Manager tool
2021:py:func: `show_font_manager <dearpygui.dearpygui.show_font_manager> `
2122to browse your fonts and understand what's going on if you have an issue.
2223
2324Font Loading Instructions
2425-------------------------
2526
2627To add your own fonts, you must first create a font registry to
27- add fonts to. Next, add fonts to the registry. By default only basic latin
28- and latin supplement glyphs are added (0x0020 - 0x00FF).
28+ add fonts to. Next, add fonts to the registry.
29+
30+ For a font to take effect, it must be either bound globally with :py:func: `bind_font <dearpygui.dearpygui.bind_font> `
31+ or bound to a particular item with :py:func: `bind_item_font <dearpygui.dearpygui.bind_item_font> `.
32+ In the latter case, the font is "inherited" by all child item if it is bound to
33+ a container. To remove font binding and revert to the default font (or inherit from
34+ the parent item), call `bind_font `/`bind_item_font ` again, passing 0 in the `font `
35+ argument.
2936
3037.. code-block :: python
3138
@@ -39,13 +46,14 @@ and latin supplement glyphs are added (0x0020 - 0x00FF).
3946 default_font = dpg.add_font(" NotoSerifCJKjp-Medium.otf" , 20 )
4047 second_font = dpg.add_font(" NotoSerifCJKjp-Medium.otf" , 10 )
4148
49+ dpg.bind_font(default_font)
50+
4251 with dpg.window(label = " Font Example" , height = 200 , width = 200 ):
4352 dpg.add_button(label = " Default font" )
4453 b2 = dpg.add_button(label = " Secondary font" )
4554 dpg.add_button(label = " default" )
4655
4756 # set font of specific widget
48- dpg.bind_font(default_font)
4957 dpg.bind_item_font(b2, second_font)
5058
5159 dpg.show_font_manager()
@@ -59,8 +67,19 @@ and latin supplement glyphs are added (0x0020 - 0x00FF).
5967 Loading Specific Unicode Characters
6068-----------------------------------
6169
62- There are several ways to add specific characters from a font file.
63- You can use range hints, ranges, and specific characters. You can also remap characters.
70+ .. note ::
71+ This section previously described how to load specific characters from font file
72+ so that they are displayed in the UI correctly. Since DPG version 2.3, character
73+ glyphs are rendered automatically and there is no need to specify them in advance.
74+ This section is no longer relevant, and the functions `add_font_chars `, `add_font_range `,
75+ and `add_font_range_hint ` are obsolete and do nothing if you call them.
76+
77+ Remapping Characters
78+ -----------------------------------
79+
80+ For convenience, you can remap a character to a different character code and use
81+ this replacement in your text strings. In particular, it might be useful with icon
82+ fonts. Here is an example of how to do such remapping.
6483
6584.. code-block :: python
6685
@@ -71,26 +90,6 @@ You can use range hints, ranges, and specific characters. You can also remap cha
7190 with dpg.font_registry():
7291 with dpg.font(" NotoSerifCJKjp-Medium.otf" , 20 ) as font1:
7392
74- # add the default font range
75- dpg.add_font_range_hint(dpg.mvFontRangeHint_Default)
76-
77- # helper to add range of characters
78- # Options:
79- # mvFontRangeHint_Japanese
80- # mvFontRangeHint_Korean
81- # mvFontRangeHint_Chinese_Full
82- # mvFontRangeHint_Chinese_Simplified_Common
83- # mvFontRangeHint_Cyrillic
84- # mvFontRangeHint_Thai
85- # mvFontRangeHint_Vietnamese
86- dpg.add_font_range_hint(dpg.mvFontRangeHint_Japanese)
87-
88- # add specific range of glyphs
89- dpg.add_font_range(0x 3100 , 0x 3ff0 )
90-
91- # add specific glyphs
92- dpg.add_font_chars([0x 3105 , 0x 3107 , 0x 3108 ])
93-
9493 # remap や to %
9594 dpg.add_char_remap(0x 3084 , 0x 0025 )
9695
0 commit comments