diff --git a/esphome/components/font/__init__.py b/esphome/components/font/__init__.py index a405761c74..be88fdb957 100644 --- a/esphome/components/font/__init__.py +++ b/esphome/components/font/__init__.py @@ -12,8 +12,8 @@ import esphome_glyphsets as glyphsets from freetype import ( FT_LOAD_NO_BITMAP, FT_LOAD_RENDER, + FT_LOAD_TARGET_MONO, Face, - ft_pixel_mode_grays, ft_pixel_mode_mono, ) import requests @@ -509,7 +509,6 @@ async def to_code(config): glyph_args = {} data = [] bpp = config[CONF_BPP] - mode = ft_pixel_mode_grays scale = 256 // (1 << bpp) size = config[CONF_SIZE] # create the data array for all glyphs @@ -524,8 +523,9 @@ async def to_code(config): flags = FT_LOAD_RENDER if bpp != 1: flags |= FT_LOAD_NO_BITMAP + else: + flags |= FT_LOAD_TARGET_MONO font.load_char(codepoint, flags) - font.glyph.render(mode) width = font.glyph.bitmap.width height = font.glyph.bitmap.rows buffer = font.glyph.bitmap.buffer