diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2021-03-27 04:12:58 +0200 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2021-04-29 03:18:15 +0300 |
commit | db85ef4736108c12bf3e12939447840815c246ec (patch) | |
tree | 6667d39c78164b4790f4f82e1d4d837ad64035be /libass/ass_fontselect.c | |
parent | 2d2be3237d3422cd9ef7beebd1134b7cc5b3b474 (diff) | |
download | libass-db85ef4736108c12bf3e12939447840815c246ec.tar.bz2 libass-db85ef4736108c12bf3e12939447840815c246ec.tar.xz |
fontselect: coretext: get fallback font family name via FreeType
Since commit be0d1613f79a95073d18d96a60e1394abf9316a2,
get_fallback can return a name from Core Text that is different
from all names that match_fonts registers for the same font.
This causes font fallback to fail as find_fonts fails to
find any font having the name received from get_fallback.
(Moreover, libass will keep retrying fallback for other glyphs,
and the coretext match_fonts will keep readding the same fonts
over and over again.)
Commit 152d0484e98f118d01987138695cf40579c9e297 attempted
to fix font fallback by getting a full name from Core Text
instead of a family name when it was noticed that Core Text's
family name can come from TT_NAME_ID_TYPOGRAPHIC_FAMILY
in addition to TT_NAME_ID_FONT_FAMILY, which we fetch in
get_font_info, but the problem goes deeper: Core Text can return
Macintosh-platform names that don't match Microsoft-platform
names, or the font might have no Microsoft-platform names at all.
Furthermore, returning a full name breaks style matching:
get_fallback does not know about weight, slant etc. and is
expected to return a whole family of fonts that will be
lazy-loaded in its entirety (if applicable) and searched
through for the best stylistic match by find_fonts.
To fix fallback while preserving maximum name portability
in the spirit of be0d1613f79a95073d18d96a60e1394abf9316a2,
use the same API in get_fallback as is used in match_fonts
to look up a family name.
Note: this could be more efficient if ass_get_font_info
could be told to return just an arbitrary family name.
This fixes https://github.com/libass/libass/issues/457.
Diffstat (limited to 'libass/ass_fontselect.c')
-rw-r--r-- | libass/ass_fontselect.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libass/ass_fontselect.c b/libass/ass_fontselect.c index 6b62511..3013f4a 100644 --- a/libass/ass_fontselect.c +++ b/libass/ass_fontselect.c @@ -717,7 +717,7 @@ char *ass_font_select(ASS_FontSelector *priv, ASS_Library *library, if (!search_family || !*search_family) search_family = "Arial"; char *fallback_family = default_provider->funcs.get_fallback( - default_provider->priv, search_family, code); + default_provider->priv, library, search_family, code); if (fallback_family) { res = select_font(priv, library, fallback_family, bold, italic, |