Skip to content

Commit

Permalink
doc/examples/fonts.py: add create_context() & correct font loading
Browse files Browse the repository at this point in the history
io.fonts.add_font_from_file_ttf now takes 4 params:
the third param (font_config) was missing
  • Loading branch information
pthom committed Apr 20, 2022
1 parent c5a8ddb commit 1924985
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/examples/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def fb_to_window_factor(window):


def main():
imgui.create_context()
window = impl_glfw_init()
impl = GlfwRenderer(window)
font_scaling_factor = fb_to_window_factor(window)
Expand All @@ -43,14 +44,17 @@ def main():
io.font_global_scale = 1. / font_scaling_factor

# dictionary of font objects from our font directory
null_font_config = None
fonts = {
os.path.split(font_path)[-1]: io.fonts.add_font_from_file_ttf(
font_path,
FONT_SIZE_IN_PIXELS * font_scaling_factor,
null_font_config,
io.fonts.get_glyph_ranges_latin()
)
for font_path in FONTS_DIR
}

secondary_window_main_font = random.choice(list(fonts.values()))

impl.refresh_font_texture()
Expand Down

0 comments on commit 1924985

Please sign in to comment.