summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2015-09-01 00:18:03 +0200
committerwm4 <wm4@nowhere>2015-09-01 13:53:01 +0200
commit72f751e3a5693ed2b7e935cb6c31ce18eed8d7b0 (patch)
tree67cc04daf2845e1a010c8b11161ba66601a8a996
parent28ee420508b3fcfc0c9ba5166ee3365e364be531 (diff)
downloadlibass-72f751e3a5693ed2b7e935cb6c31ce18eed8d7b0.tar.bz2
libass-72f751e3a5693ed2b7e935cb6c31ce18eed8d7b0.tar.xz
coretext: implement GetFallbackFunc
-rw-r--r--libass/ass_coretext.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/libass/ass_coretext.c b/libass/ass_coretext.c
index bf8a20a..35f10ff 100644
--- a/libass/ass_coretext.c
+++ b/libass/ass_coretext.c
@@ -262,6 +262,30 @@ static void match_fonts(ASS_Library *lib, ASS_FontProvider *provider,
}
#endif
+static char *get_fallback(void *priv, ASS_FontProviderMetaData *meta,
+ uint32_t codepoint)
+{
+ char *failed = meta->families[0];
+ CFStringRef name = CFStringCreateWithBytes(
+ 0, (UInt8 *)failed, sizeof(failed), kCFStringEncodingUTF8, false);
+ CTFontRef font = CTFontCreateWithName(name, 0, NULL);
+ uint32_t codepointle = OSSwapHostToLittleInt32(codepoint);
+ CFStringRef r = CFStringCreateWithBytes(
+ 0, (UInt8*)&codepointle, sizeof(codepointle),
+ kCFStringEncodingUTF32LE, false);
+ CTFontRef fb = CTFontCreateForString(font, r, CFRangeMake(0, 1));
+ CFStringRef cffamily = CTFontCopyFamilyName(fb);
+ char *family = cfstr2buf(cffamily);
+
+ CFRelease(name);
+ CFRelease(font);
+ CFRelease(r);
+ CFRelease(fb);
+ CFRelease(cffamily);
+
+ return family;
+}
+
static ASS_FontProviderFuncs coretext_callbacks = {
NULL,
check_glyph,
@@ -273,7 +297,7 @@ static ASS_FontProviderFuncs coretext_callbacks = {
match_fonts,
#endif
NULL,
- NULL
+ get_fallback
};
ASS_FontProvider *