0009-libass-fix-text-rendering-on-iOS-by-providing-a-font.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From 4b3e2f0a17466c066f94db0c6acd155d571e72fe Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
  3. Date: Wed, 29 May 2013 13:25:54 +0200
  4. Subject: [PATCH 9/9] libass: fix text rendering on iOS by providing a font
  5. lookup mechanism for the font shipped with Aspen
  6. ---
  7. modules/codec/libass.c | 35 +++++++++++++++++++++++++++++++++++
  8. 1 file changed, 35 insertions(+)
  9. diff --git a/modules/codec/libass.c b/modules/codec/libass.c
  10. index b32791c..b3fee5f 100644
  11. --- a/modules/codec/libass.c
  12. +++ b/modules/codec/libass.c
  13. @@ -29,6 +29,13 @@
  14. # include "config.h"
  15. #endif
  16. +#if defined (__APPLE__)
  17. +#include <TargetConditionals.h>
  18. +#if TARGET_OS_IPHONE
  19. +#include <CoreFoundation/CoreFoundation.h>
  20. +#endif
  21. +#endif
  22. +
  23. #include <string.h>
  24. #include <limits.h>
  25. #include <assert.h>
  26. @@ -213,6 +220,34 @@ static int Create( vlc_object_t *p_this )
  27. #if defined( __ANDROID__ )
  28. const char *psz_font = "/system/fonts/DroidSans-Bold.ttf";
  29. const char *psz_family = "Droid Sans Bold";
  30. +#elif defined (__APPLE__)
  31. +#if !TARGET_OS_IPHONE
  32. + const char *psz_font = NULL; /* We don't ship a default font with VLC */
  33. + const char *psz_family = "Arial"; /* Use Arial if we can't find anything more suitable */
  34. +#else
  35. + CFURLRef fileURL;
  36. + fileURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("SourceSansPro-Regular.ttf"),
  37. + NULL,
  38. + NULL);
  39. + CFStringRef urlString = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
  40. + CFRelease(fileURL);
  41. +
  42. + if (!urlString)
  43. + return VLC_EGENERIC;
  44. +
  45. + CFIndex length = CFStringGetLength(urlString);
  46. + if (!length)
  47. + return VLC_EGENERIC;
  48. + length++;
  49. +
  50. + char *psz_path = (char *)malloc(length);
  51. + CFStringGetCString(urlString, psz_path, length, kCFStringEncodingUTF8);
  52. + CFRelease(urlString);
  53. +
  54. + const char *psz_font = (const char *)strdup(psz_path);
  55. + free(psz_path);
  56. + const char *psz_family = "Source Sans Pro";
  57. +#endif
  58. #else
  59. const char *psz_font = NULL; /* We don't ship a default font with VLC */
  60. const char *psz_family = "Arial"; /* Use Arial if we can't find anything more suitable */
  61. --
  62. 1.7.12.4 (Apple Git-37)