mirror of
https://github.com/esphome/esphome.git
synced 2025-07-24 20:26:35 +00:00
fix 1bpp rendering (#8463)
This commit is contained in:
parent
e7d1072c85
commit
ce2e966005
@ -12,8 +12,8 @@ import esphome_glyphsets as glyphsets
|
|||||||
from freetype import (
|
from freetype import (
|
||||||
FT_LOAD_NO_BITMAP,
|
FT_LOAD_NO_BITMAP,
|
||||||
FT_LOAD_RENDER,
|
FT_LOAD_RENDER,
|
||||||
|
FT_LOAD_TARGET_MONO,
|
||||||
Face,
|
Face,
|
||||||
ft_pixel_mode_grays,
|
|
||||||
ft_pixel_mode_mono,
|
ft_pixel_mode_mono,
|
||||||
)
|
)
|
||||||
import requests
|
import requests
|
||||||
@ -509,7 +509,6 @@ async def to_code(config):
|
|||||||
glyph_args = {}
|
glyph_args = {}
|
||||||
data = []
|
data = []
|
||||||
bpp = config[CONF_BPP]
|
bpp = config[CONF_BPP]
|
||||||
mode = ft_pixel_mode_grays
|
|
||||||
scale = 256 // (1 << bpp)
|
scale = 256 // (1 << bpp)
|
||||||
size = config[CONF_SIZE]
|
size = config[CONF_SIZE]
|
||||||
# create the data array for all glyphs
|
# create the data array for all glyphs
|
||||||
@ -524,8 +523,9 @@ async def to_code(config):
|
|||||||
flags = FT_LOAD_RENDER
|
flags = FT_LOAD_RENDER
|
||||||
if bpp != 1:
|
if bpp != 1:
|
||||||
flags |= FT_LOAD_NO_BITMAP
|
flags |= FT_LOAD_NO_BITMAP
|
||||||
|
else:
|
||||||
|
flags |= FT_LOAD_TARGET_MONO
|
||||||
font.load_char(codepoint, flags)
|
font.load_char(codepoint, flags)
|
||||||
font.glyph.render(mode)
|
|
||||||
width = font.glyph.bitmap.width
|
width = font.glyph.bitmap.width
|
||||||
height = font.glyph.bitmap.rows
|
height = font.glyph.bitmap.rows
|
||||||
buffer = font.glyph.bitmap.buffer
|
buffer = font.glyph.bitmap.buffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user