From d1d3cb8b6529848bd5facf640e9eb6f8f2769c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= Date: Fri, 19 Jul 2013 18:38:41 +0700 Subject: [PATCH 07/13] freetype: added a fake font lookup mechanism for iOS to use the packaged demo fonts --- modules/text_renderer/freetype.c | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c index cdc9243..e1dfea2 100644 --- a/modules/text_renderer/freetype.c +++ b/modules/text_renderer/freetype.c @@ -106,6 +106,9 @@ #include #if !TARGET_OS_IPHONE #include +#else +#include +#include #endif #include /* for MAXPATHLEN */ #undef HAVE_FONTCONFIG @@ -807,6 +810,40 @@ static char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname, 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 ? + CFSTR("OpenSans-Regular.ttf") : CFSTR("SourceCodePro-Regular.ttf"), + 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 @@ -1988,6 +2025,8 @@ static FT_Face LoadFace( filter_t *p_filter, #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 #elif defined( _WIN32 ) psz_fontfile = Win32_Select( p_filter, @@ -2889,6 +2928,9 @@ static int Create( vlc_object_t *p_this ) #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 #elif defined(_WIN32) psz_fontfile = Win32_Select( p_filter, psz_fontfamily, false, false, -- 1.7.12.4 (Apple Git-37)