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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From 46e8bdc28b1ca32ca4620e64a4159f64cfb0f301 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
  3. Date: Wed, 22 Jan 2014 13:55:16 +0100
  4. Subject: [PATCH 07/10] freetype: added a fake font lookup mechanism for iOS to
  5. use the packaged demo fonts
  6. ---
  7. modules/text_renderer/freetype.c | 2 ++
  8. modules/text_renderer/platform_fonts.c | 40 ++++++++++++++++++++++++++++++++++
  9. modules/text_renderer/platform_fonts.h | 3 +++
  10. 3 files changed, 45 insertions(+)
  11. diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
  12. index e562afc..378df0b 100644
  13. --- a/modules/text_renderer/freetype.c
  14. +++ b/modules/text_renderer/freetype.c
  15. @@ -1972,6 +1972,8 @@ static int Create( vlc_object_t *p_this )
  16. #elif defined( __APPLE__ )
  17. #if !TARGET_OS_IPHONE
  18. p_sys->pf_select = MacLegacy_Select;
  19. +#else
  20. + p_sys->pf_select = iOSFake_Select;
  21. #endif
  22. #elif defined( _WIN32 ) && defined( HAVE_GET_FONT_BY_FAMILY_NAME )
  23. p_sys->pf_select = Win32_Select;
  24. diff --git a/modules/text_renderer/platform_fonts.c b/modules/text_renderer/platform_fonts.c
  25. index 7869dba..deeaa7d 100644
  26. --- a/modules/text_renderer/platform_fonts.c
  27. +++ b/modules/text_renderer/platform_fonts.c
  28. @@ -42,6 +42,9 @@
  29. #include <TargetConditionals.h>
  30. #if !TARGET_OS_IPHONE
  31. #include <Carbon/Carbon.h>
  32. +#else
  33. +#include <CoreFoundation/CoreFoundation.h>
  34. +#include <vlc_url.h>
  35. #endif
  36. #include <sys/param.h> /* for MAXPATHLEN */
  37. #undef HAVE_FONTCONFIG
  38. @@ -405,6 +408,43 @@ char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
  39. return psz_path;
  40. }
  41. +#else
  42. +char *iOSFake_Select( filter_t *p_filter, const char* psz_fontname,
  43. + bool b_bold, bool b_italic, int i_size, int *i_idx )
  44. +{
  45. + VLC_UNUSED(p_filter);
  46. + VLC_UNUSED(psz_fontname);
  47. + VLC_UNUSED(b_bold);
  48. + VLC_UNUSED(b_italic);
  49. + VLC_UNUSED(i_size);
  50. + VLC_UNUSED(i_idx);
  51. +
  52. + CFURLRef fileURL;
  53. + fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(),
  54. + CFSTR("OpenSans-Regular.ttf"),
  55. + NULL,
  56. + NULL);
  57. + if (!fileURL)
  58. + return NULL;
  59. + CFStringRef urlString = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
  60. + CFRelease(fileURL);
  61. +
  62. + if (!urlString)
  63. + return NULL;
  64. +
  65. + CFIndex length = CFStringGetLength(urlString);
  66. + if (!length)
  67. + return NULL;
  68. + length++;
  69. +
  70. + char *psz_path = (char *)malloc(length);
  71. + CFStringGetCString(urlString, psz_path, length, kCFStringEncodingUTF8);
  72. + CFRelease(urlString);
  73. +
  74. + psz_path = strdup(psz_path);
  75. +
  76. + return psz_path;
  77. +}
  78. #endif
  79. #endif
  80. diff --git a/modules/text_renderer/platform_fonts.h b/modules/text_renderer/platform_fonts.h
  81. index cff52b1..40b25fb 100644
  82. --- a/modules/text_renderer/platform_fonts.h
  83. +++ b/modules/text_renderer/platform_fonts.h
  84. @@ -95,6 +95,9 @@ char* Win32_Select( filter_t *p_filter, const char* family,
  85. #if !TARGET_OS_IPHONE
  86. char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
  87. bool b_bold, bool b_italic, int i_size, int *i_idx );
  88. +#else
  89. +char *iOSFake_Select( filter_t *p_filter, const char* psz_fontname,
  90. + bool b_bold, bool b_italic, int i_size, int *i_idx );
  91. #endif
  92. #endif
  93. --
  94. 1.9.3 (Apple Git-50)