0008-freetype-added-a-fake-font-lookup-mechanism-for-iOS-.patch 2.88 KB
Newer Older
1
From 9ea4f35d454c219ddf96135fd29c2108fd98ec20 Mon Sep 17 00:00:00 2001
2
From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
3
Date: Fri, 19 Jul 2013 18:38:41 +0700
4 5
Subject: [PATCH 08/17] freetype: added a fake font lookup mechanism for iOS to
 use the packaged demo fonts
6 7

---
8
 modules/text_renderer/freetype.c | 42 ++++++++++++++++++++++++++++++++++++++++
9 10 11
 1 file changed, 42 insertions(+)

diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
12
index cdc9243..e1dfea2 100644
13 14 15 16 17 18 19 20 21 22 23 24
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -106,6 +106,9 @@
 #include <TargetConditionals.h>
 #if !TARGET_OS_IPHONE
 #include <Carbon/Carbon.h>
+#else
+#include <CoreFoundation/CoreFoundation.h>
+#include <vlc_url.h>
 #endif
 #include <sys/param.h>                         /* for MAXPATHLEN */
 #undef HAVE_FONTCONFIG
25
@@ -807,6 +810,40 @@ static char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
 
     return psz_path;
 }
+#else
+static char *iOSFake_Select( filter_t *p_filter, bool b_monospace, bool b_bold,
+                             bool b_italic )
+{
+    // included for future implementation
+    VLC_UNUSED(p_filter);
+    VLC_UNUSED(b_bold);
+    VLC_UNUSED(b_italic);
+    VLC_UNUSED(b_monospace);
+
+    CFURLRef fileURL;
+    fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), b_monospace ?
41
+                                      CFSTR("OpenSans-Regular.ttf") : CFSTR("SourceCodePro-Regular.ttf"),
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
+                                      NULL,
+                                      NULL);
+    CFStringRef urlString = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
+    CFRelease(fileURL);
+
+    if (!urlString)
+        return NULL;
+
+    CFIndex length = CFStringGetLength(urlString);
+    if (!length)
+        return NULL;
+    length++;
+
+    char *psz_path = (char *)malloc(length);
+    CFStringGetCString(urlString, psz_path, length, kCFStringEncodingUTF8);
+    CFRelease(urlString);
+
+    psz_path = strdup(psz_path);
+
+    return psz_path;
+}
 #endif
 #endif
 
66
@@ -1988,6 +2025,8 @@ static FT_Face LoadFace( filter_t *p_filter,
67 68 69 70 71 72
 #elif defined( __APPLE__ )
 #if !TARGET_OS_IPHONE
         psz_fontfile = MacLegacy_Select( p_filter, p_style->psz_fontname, false, false, -1, &i_idx );
+#else
+        psz_fontfile = iOSFake_Select( p_filter, false, false, false );
 #endif
73
 #elif defined( _WIN32 )
74
         psz_fontfile = Win32_Select( p_filter,
75
@@ -2889,6 +2928,9 @@ static int Create( vlc_object_t *p_this )
76 77 78 79 80 81 82
 #elif defined(__APPLE__)
 #if !TARGET_OS_IPHONE
     psz_fontfile = MacLegacy_Select( p_filter, psz_fontfamily, false, false, 0, &fontindex );
+#else
+    psz_fontfile = iOSFake_Select( p_filter, false, false, false );
+    psz_monofontfile = iOSFake_Select( p_filter, true, false, false );
 #endif
83
 #elif defined(_WIN32)
84 85
     psz_fontfile = Win32_Select( p_filter, psz_fontfamily, false, false,
-- 
86
1.8.3.4 (Apple Git-47)
87