Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate manual modifications of font data to gen_font.py #3771

Open
obrusvit opened this issue May 4, 2024 · 1 comment
Open

Incorporate manual modifications of font data to gen_font.py #3771

obrusvit opened this issue May 4, 2024 · 1 comment
Labels
code Code improvements

Comments

@obrusvit
Copy link
Contributor

obrusvit commented May 4, 2024

If we run core/tools/codegen/gen_font.py script, it creates a diff in generated font definitions. This is because of manual changes done to individual glyps for better visual appearance on certain models. The changes are documented by commentary but IMHO they should be defined in the script so that manual changes to generated code are not necessary.

Changes are done to

  • font_unifont_regular_16
  • font_pixeloperatormono_regular_8
  • font_pixeloperator_regular_8
  • font_pixeloperator_bold_8
  • font_ttsatoshi_demibold_18.c and font_ttsatoshi_demibold_21.c - alternative numeral glyphs used
  • font_ttsatoshi_demibold_42.c - uppercase fonts completely removed to save space - they are not used anywhere at the moment

image

@obrusvit obrusvit added the code Code improvements label May 4, 2024
@obrusvit obrusvit added this to Firmware May 4, 2024
@obrusvit
Copy link
Contributor Author

Note on font_ttsatoshi_demibold_18/21.c. Numerals (0 - 9 mapped to glyph indices 1298-1307 as of #3954 . Done manually by modifying gen_font.py as follows. A systematic solution would be better.

def _load_char(self, c: str) -> None:
        glyph_map = {
            '0': 1298,
            '1': 1299,
            '2': 1300,
            '3': 1301,
            '4': 1302,
            '5': 1303,
            '6': 1304,
            '7': 1305,
            '8': 1306,
            '9': 1307,
        }

        if c in glyph_map:
            self.face.load_glyph(glyph_map[c], freetype.FT_LOAD_RENDER | freetype.FT_LOAD_TARGET_NORMAL)
        else:
            self.face.load_char(c, freetype.FT_LOAD_RENDER | freetype.FT_LOAD_TARGET_NORMAL)  # type: ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Code improvements
Projects
Status: No status
Development

No branches or pull requests

1 participant