Skip to content

Generic font families

Aleksey Chernov requested to merge generic-font-families into main
  • Added new global properties: PROP_GENERIC_*_FONT_FACE to specify generic font family faces:
    • PROP_GENERIC_SERIF_FONT_FACE - to specify Serif font
    • PROP_GENERIC_SANS_SERIF_FONT_FACE - to specify Sans Serif font
    • PROP_GENERIC_CURSIVE_FONT_FACE - to specify Cursive font
    • PROP_GENERIC_FANTASY_FONT_FACE - to specify Fantasy font
    • PROP_GENERIC_MONOSPACE_FONT_FACE - to specify Monospace font

This implements generic font family for the font-family CSS attribute.

  • LVFontManager: a new getFaceListFiltered() function has been added to get a list of fonts filtered by font family and optionally by language.

This can be used in the UI to get a list of fonts for a particular family. At the moment, it works correctly only for the monospace font family, since it is not possible to determine the rest of the families.

  • Added unit tests for new engine features.

  • A memory leak was found and fixed in the LVFreeTypeFontManager::checkFontLangCompat() function.

Screenshots:

For test file: https://gitlab.com/coolreader-ng/crengine-ng/-/blob/0.9.5/crengine/tests/data/generic-font-families-test.html

Before:

crengine-ng-0.9.4

After:

crengine-ng-0.9.5-pre

Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/font-family#values

Edited by Aleksey Chernov

Merge request reports