0007-freetype-added-a-fake-font-lookup-mechanism-for-iOS-.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From 6a3762687d7c0e44e0a321c8a614bbe16ec1740e Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
  3. Date: Fri, 3 May 2013 14:21:19 +0200
  4. Subject: [PATCH 7/8] freetype: added a fake font lookup mechanism for iOS to
  5. use the packaged demo fonts
  6. ---
  7. modules/text_renderer/freetype.c | 42 ++++++++++++++++++++++++++++++++++++++
  8. 1 file changed, 42 insertions(+)
  9. diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
  10. index 1325d3e..a070edd 100644
  11. --- a/modules/text_renderer/freetype.c
  12. +++ b/modules/text_renderer/freetype.c
  13. @@ -106,6 +106,9 @@
  14. #include <TargetConditionals.h>
  15. #if !TARGET_OS_IPHONE
  16. #include <Carbon/Carbon.h>
  17. +#else
  18. +#include <CoreFoundation/CoreFoundation.h>
  19. +#include <vlc_url.h>
  20. #endif
  21. #include <sys/param.h> /* for MAXPATHLEN */
  22. #undef HAVE_FONTCONFIG
  23. @@ -818,6 +821,40 @@ static char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
  24. return psz_path;
  25. }
  26. +#else
  27. +static char *iOSFake_Select( filter_t *p_filter, bool b_monospace, bool b_bold,
  28. + bool b_italic )
  29. +{
  30. + // included for future implementation
  31. + VLC_UNUSED(p_filter);
  32. + VLC_UNUSED(b_bold);
  33. + VLC_UNUSED(b_italic);
  34. + VLC_UNUSED(b_monospace);
  35. +
  36. + CFURLRef fileURL;
  37. + fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), b_monospace ?
  38. + CFSTR("SourceSansPro-Regular.ttf") : CFSTR("SourceCodePro-Regular.ttf"),
  39. + NULL,
  40. + NULL);
  41. + CFStringRef urlString = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
  42. + CFRelease(fileURL);
  43. +
  44. + if (!urlString)
  45. + return NULL;
  46. +
  47. + CFIndex length = CFStringGetLength(urlString);
  48. + if (!length)
  49. + return NULL;
  50. + length++;
  51. +
  52. + char *psz_path = (char *)malloc(length);
  53. + CFStringGetCString(urlString, psz_path, length, kCFStringEncodingUTF8);
  54. + CFRelease(urlString);
  55. +
  56. + psz_path = strdup(psz_path);
  57. +
  58. + return psz_path;
  59. +}
  60. #endif
  61. #endif
  62. @@ -2004,6 +2041,8 @@ static FT_Face LoadFace( filter_t *p_filter,
  63. #elif defined( __APPLE__ )
  64. #if !TARGET_OS_IPHONE
  65. psz_fontfile = MacLegacy_Select( p_filter, p_style->psz_fontname, false, false, -1, &i_idx );
  66. +#else
  67. + psz_fontfile = iOSFake_Select( p_filter, false, false, false );
  68. #endif
  69. #elif defined( WIN32 )
  70. psz_fontfile = Win32_Select( p_filter,
  71. @@ -2920,6 +2959,9 @@ static int Create( vlc_object_t *p_this )
  72. #elif defined(__APPLE__)
  73. #if !TARGET_OS_IPHONE
  74. psz_fontfile = MacLegacy_Select( p_filter, psz_fontfamily, false, false, 0, &fontindex );
  75. +#else
  76. + psz_fontfile = iOSFake_Select( p_filter, false, false, false );
  77. + psz_monofontfile = iOSFake_Select( p_filter, true, false, false );
  78. #endif
  79. #elif defined(WIN32)
  80. psz_fontfile = Win32_Select( p_filter, psz_fontfamily, false, false,
  81. --
  82. 1.7.10.2 (Apple Git-33)