summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Oshmyan <chortos@inbox.lv>2021-06-26 15:02:12 +0300
committerOleg Oshmyan <chortos@inbox.lv>2021-07-10 02:36:31 +0300
commite91d3f0d17b0f0efbb8957bad1d8d6d61ae44d4b (patch)
tree1e696ac8ff02f61b12e02f23f5a1ce688c7077b1
parentb4656109dbf9cf6384939f6475672b6db2d4a206 (diff)
downloadlibass-e91d3f0d17b0f0efbb8957bad1d8d6d61ae44d4b.tar.bz2
libass-e91d3f0d17b0f0efbb8957bad1d8d6d61ae44d4b.tar.xz
directwrite: reorder code to avoid possible unneeded allocation
-rw-r--r--libass/ass_directwrite.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/libass/ass_directwrite.c b/libass/ass_directwrite.c
index 4545bf5..89e1099 100644
--- a/libass/ass_directwrite.c
+++ b/libass/ass_directwrite.c
@@ -490,28 +490,27 @@ static char *get_fallback(void *priv, ASS_Library *lib,
IDWriteTextLayout_Release(text_layout);
IDWriteTextFormat_Release(text_format);
- // Now, just extract the first family name
- BOOL exists = FALSE;
- IDWriteLocalizedStrings *familyNames = NULL;
- hr = IDWriteFont_GetInformationalStrings(font,
- DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES,
- &familyNames, &exists);
- if (FAILED(hr) || !exists) {
- IDWriteFont_Release(font);
- return NULL;
- }
-
// DirectWrite may not have found a valid fallback, so check that
// the selected font actually has the requested glyph.
+ BOOL exists = FALSE;
if (codepoint > 0) {
hr = IDWriteFont_HasCharacter(font, codepoint, &exists);
if (FAILED(hr) || !exists) {
- IDWriteLocalizedStrings_Release(familyNames);
IDWriteFont_Release(font);
return NULL;
}
}
+ // Now, just extract the first family name
+ IDWriteLocalizedStrings *familyNames = NULL;
+ hr = IDWriteFont_GetInformationalStrings(font,
+ DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES,
+ &familyNames, &exists);
+ if (FAILED(hr) || !exists) {
+ IDWriteFont_Release(font);
+ return NULL;
+ }
+
char *family = get_utf8_name(familyNames, 0);
IDWriteLocalizedStrings_Release(familyNames);