0009-libass-fix-text-rendering-on-iOS-by-providing-a-font.patch 2.18 KB
Newer Older
1
From ee6637a68ac08ec0190464f6004cf42588c6e140 Mon Sep 17 00:00:00 2001
2 3
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
Date: Wed, 29 May 2013 13:25:54 +0200
4
Subject: [PATCH 09/17] libass: fix text rendering on iOS by providing a font
5 6 7 8 9 10 11
 lookup mechanism for the font shipped with Aspen

---
 modules/codec/libass.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
12
index aa38f1b..38961bc 100644
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
--- a/modules/codec/libass.c
+++ b/modules/codec/libass.c
@@ -29,6 +29,13 @@
 #   include "config.h"
 #endif
 
+#if defined (__APPLE__)
+#include <TargetConditionals.h>
+#if TARGET_OS_IPHONE
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+#endif
+
 #include <string.h>
 #include <limits.h>
 #include <assert.h>
@@ -213,6 +220,34 @@ static int Create( vlc_object_t *p_this )
 #if defined( __ANDROID__ )
     const char *psz_font = "/system/fonts/DroidSans-Bold.ttf";
     const char *psz_family = "Droid Sans Bold";
+#elif defined (__APPLE__)
+#if !TARGET_OS_IPHONE
+    const char *psz_font = NULL; /* We don't ship a default font with VLC */
+    const char *psz_family = "Arial"; /* Use Arial if we can't find anything more suitable */
+#else
+    CFURLRef fileURL;
39
+    fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("OpenSans-Regular.ttf"),
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
+                                      NULL,
+                                      NULL);
+    CFStringRef urlString = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
+    CFRelease(fileURL);
+
+    if (!urlString)
+        return VLC_EGENERIC;
+
+    CFIndex length = CFStringGetLength(urlString);
+    if (!length)
+        return VLC_EGENERIC;
+    length++;
+
+    char *psz_path = (char *)malloc(length);
+    CFStringGetCString(urlString, psz_path, length, kCFStringEncodingUTF8);
+    CFRelease(urlString);
+
+    const char *psz_font = (const char *)strdup(psz_path);
+    free(psz_path);
59
+    const char *psz_family = "Open Sans";
60 61 62 63 64
+#endif
 #else
     const char *psz_font = NULL; /* We don't ship a default font with VLC */
     const char *psz_family = "Arial"; /* Use Arial if we can't find anything more suitable */
-- 
65
1.8.3.4 (Apple Git-47)
66