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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From d24cb3abb7ca04201fc120665695109e86d2662d 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 03/14] 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 | 38 ++++++++++++++++++++++++++++++++++++++
  8. 1 file changed, 38 insertions(+)
  9. diff --git a/modules/codec/libass.c b/modules/codec/libass.c
  10. index 3d08717..7d90c1c 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,37 @@ 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("OpenSans-Regular.ttf"),
  37. + NULL,
  38. + NULL);
  39. + if (!fileURL)
  40. + return VLC_EGENERIC;
  41. +
  42. + CFStringRef urlString = CFURLCopyFileSystemPath(fileURL, kCFURLPOSIXPathStyle);
  43. + CFRelease(fileURL);
  44. +
  45. + if (!urlString)
  46. + return VLC_EGENERIC;
  47. +
  48. + CFIndex length = CFStringGetLength(urlString);
  49. + if (!length)
  50. + return VLC_EGENERIC;
  51. + length++;
  52. +
  53. + char *psz_path = (char *)malloc(length);
  54. + CFStringGetCString(urlString, psz_path, length, kCFStringEncodingUTF8);
  55. + CFRelease(urlString);
  56. +
  57. + const char *psz_font = (const char *)strdup(psz_path);
  58. + free(psz_path);
  59. + const char *psz_family = "Open Sans";
  60. +#endif
  61. #else
  62. const char *psz_font = NULL; /* We don't ship a default font with VLC */
  63. const char *psz_family = "Arial"; /* Use Arial if we can't find anything more suitable */
  64. --
  65. 2.6.3