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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From d1d3cb8b6529848bd5facf640e9eb6f8f2769c6d 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. Subject: [PATCH 07/13] freetype: added a fake font lookup mechanism for iOS
  5. to 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 cdc9243..e1dfea2 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. @@ -807,6 +810,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("OpenSans-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. @@ -1988,6 +2025,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. @@ -2889,6 +2928,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.12.4 (Apple Git-37)