0003-libass-fix-text-rendering-on-iOS-by-providing-a-font.patch 2.22 KB
Newer Older
Felix Paul Kühne's avatar
Felix Paul Kühne committed
1
From 837dc0740a82c2c7cf734213ffc5e2b714a5775f 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 03/13] libass: fix text rendering on iOS by providing a font
5 6 7
 lookup mechanism for the font shipped with Aspen

---
8 9
 modules/codec/libass.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
10 11

diff --git a/modules/codec/libass.c b/modules/codec/libass.c
Felix Paul Kühne's avatar
Felix Paul Kühne committed
12
index 067ef6b..8460dad 100644
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
--- 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>
29
@@ -213,6 +220,37 @@ static int Create( vlc_object_t *p_this )
30 31 32 33 34 35 36 37 38 39 40 41
 #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;
+    fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("OpenSans-Regular.ttf"),
+                                      NULL,
+                                      NULL);
42 43 44
+    if (!fileURL)
+        return VLC_EGENERIC;
+
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
+    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);
+    const char *psz_family = "Open Sans";
+#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 */
-- 
Felix Paul Kühne's avatar
Felix Paul Kühne committed
68
2.5.1
69