diff options
author | Oleg Oshmyan <chortos@inbox.lv> | 2023-02-08 03:48:01 +0200 |
---|---|---|
committer | Oleg Oshmyan <chortos@inbox.lv> | 2024-01-21 17:41:10 +0200 |
commit | 57437f03b31120c507034aaf5e44addc88de9fc2 (patch) | |
tree | 6daf5677d1c7dff7b7a7b86c0da8e98fc5c32f96 | |
parent | ded34f4993cec00aeca058bc16eb944bf268ef24 (diff) | |
download | libass-57437f03b31120c507034aaf5e44addc88de9fc2.tar.bz2 libass-57437f03b31120c507034aaf5e44addc88de9fc2.tar.xz |
directwrite: add a backup source of name for fallback font
I don't know if it is actually _possible_ in practice for DirectWrite
to return zero WIN32_FAMILY_NAMES for a font, but we do currently guard
against this in ass_directwrite_info_template.h. Use the same logic here.
This name seems somewhat likely to fail to be found by match_fonts
depending on the exact font and version of the Windows environment,
but this is still better than not even trying.
-rw-r--r-- | libass/ass_directwrite.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libass/ass_directwrite.c b/libass/ass_directwrite.c index a914768..be579fd 100644 --- a/libass/ass_directwrite.c +++ b/libass/ass_directwrite.c @@ -568,7 +568,15 @@ static char *get_fallback(void *priv, ASS_Library *lib, hr = IDWriteFont_GetInformationalStrings(font, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &familyNames, &exists); - if (FAILED(hr) || !exists) { + if (SUCCEEDED(hr) && !exists) { + IDWriteFontFamily *fontFamily = NULL; + hr = IDWriteFont_GetFontFamily(font, &fontFamily); + if (SUCCEEDED(hr)) { + hr = IDWriteFontFamily_GetFamilyNames(fontFamily, &familyNames); + IDWriteFontFamily_Release(fontFamily); + } + } + if (FAILED(hr)) { IDWriteFont_Release(font); return NULL; } |