summaryrefslogtreecommitdiffstats
path: root/libass/ass_fontselect.h
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2021-03-27 04:12:58 +0200
committerOleg Oshmyan <chortos@inbox.lv>2021-04-29 03:18:15 +0300
commitdb85ef4736108c12bf3e12939447840815c246ec (patch)
tree6667d39c78164b4790f4f82e1d4d837ad64035be /libass/ass_fontselect.h
parent2d2be3237d3422cd9ef7beebd1134b7cc5b3b474 (diff)
downloadlibass-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.h')
-rw-r--r--libass/ass_fontselect.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/libass/ass_fontselect.h b/libass/ass_fontselect.h
index d029b0b..942ea00 100644
--- a/libass/ass_fontselect.h
+++ b/libass/ass_fontselect.h
@@ -144,12 +144,14 @@ typedef void (*SubstituteFontFunc)(void *priv, const char *name,
* fallbacks.
*
* \param priv font provider private data
+ * \param lib ASS_Library instance
* \param family original font family name (try matching a similar font) (never NULL)
* \param codepoint Unicode codepoint (UTF-32)
* \return output font family, allocated with malloc(), must be freed
* by caller.
*/
typedef char *(*GetFallbackFunc)(void *priv,
+ ASS_Library *lib,
const char *family,
uint32_t codepoint);