[vlc-commits] Freetype: split OS X code to its own file
Jean-Baptiste Kempf
git at videolan.org
Sun Oct 25 19:26:50 CET 2015
vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Oct 25 19:26:04 2015 +0100| [e85a00c7fa77383bbd524974c1e12078661cd1e9] | committer: Jean-Baptiste Kempf
Freetype: split OS X code to its own file
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e85a00c7fa77383bbd524974c1e12078661cd1e9
---
modules/text_renderer/Makefile.am | 4 +-
modules/text_renderer/fonts/darwin.c | 129 ++++++++++++++++++++++++++++++++
modules/text_renderer/platform_fonts.c | 94 -----------------------
3 files changed, 132 insertions(+), 95 deletions(-)
diff --git a/modules/text_renderer/Makefile.am b/modules/text_renderer/Makefile.am
index fe3f00c..a40ab7e 100644
--- a/modules/text_renderer/Makefile.am
+++ b/modules/text_renderer/Makefile.am
@@ -17,7 +17,9 @@ endif
if HAVE_ANDROID
libfreetype_plugin_la_SOURCES += text_renderer/fonts/android.c
endif
-
+if HAVE_DARWIN
+libfreetype_plugin_la_SOURCES += text_renderer/fonts/darwin.c
+endif
libfreetype_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) $(FREETYPE_CFLAGS)
libfreetype_plugin_la_LIBADD = $(LIBM) $(FREETYPE_LIBS)
diff --git a/modules/text_renderer/fonts/darwin.c b/modules/text_renderer/fonts/darwin.c
new file mode 100644
index 0000000..78beed3
--- /dev/null
+++ b/modules/text_renderer/fonts/darwin.c
@@ -0,0 +1,129 @@
+/*****************************************************************************
+ * freetype.c : Put text on the video, using freetype2
+ *****************************************************************************
+ * Copyright (C) 2002 - 2015 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Sigmund Augdal Helberg <dnumgis at videolan.org>
+ * Gildas Bazin <gbazin at videolan.org>
+ * Bernie Purcell <bitmap at videolan.org>
+ * Jean-Baptiste Kempf <jb at videolan.org>
+ * Felix Paul Kühne <fkuehne at videolan.org>
+ * Salah-Eddin Shaban <salshaaban at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_filter.h> /* filter_sys_t */
+
+#include <TargetConditionals.h>
+#if !TARGET_OS_IPHONE
+# include <Carbon/Carbon.h>
+#endif
+#include <sys/param.h> /* for MAXPATHLEN */
+
+#include "../platform_fonts.h"
+#include "freetype.h"
+
+#if !TARGET_OS_IPHONE
+char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
+ bool b_bold, bool b_italic,
+ int *i_idx, uni_char_t codepoint )
+{
+ VLC_UNUSED( b_bold );
+ VLC_UNUSED( b_italic );
+ VLC_UNUSED( codepoint );
+ FSRef ref;
+ unsigned char path[MAXPATHLEN];
+ char * psz_path;
+
+ CFStringRef cf_fontName;
+ ATSFontRef ats_font_id;
+
+ *i_idx = 0;
+
+ if( psz_fontname == NULL )
+ return NULL;
+
+ msg_Dbg( p_filter, "looking for %s", psz_fontname );
+ cf_fontName = CFStringCreateWithCString( kCFAllocatorDefault, psz_fontname, kCFStringEncodingUTF8 );
+
+ ats_font_id = ATSFontFindFromName( cf_fontName, kATSOptionFlagsIncludeDisabledMask );
+
+ if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
+ {
+ msg_Dbg( p_filter, "ATS couldn't find %s by name, checking family", psz_fontname );
+ ats_font_id = ATSFontFamilyFindFromName( cf_fontName, kATSOptionFlagsDefault );
+
+ if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
+ {
+ msg_Dbg( p_filter, "ATS couldn't find either %s nor its family, checking PS name", psz_fontname );
+ ats_font_id = ATSFontFindFromPostScriptName( cf_fontName, kATSOptionFlagsDefault );
+
+ if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
+ {
+ msg_Err( p_filter, "ATS couldn't find %s (no font name, family or PS name)", psz_fontname );
+ CFRelease( cf_fontName );
+ return NULL;
+ }
+ }
+ }
+ CFRelease( cf_fontName );
+
+ if ( noErr != ATSFontGetFileReference( ats_font_id, &ref ) )
+ {
+ msg_Err( p_filter, "ATS couldn't get file ref for %s", psz_fontname );
+ return NULL;
+ }
+
+ /* i_idx calculation by searching preceding fontIDs */
+ /* with same FSRef */
+ {
+ ATSFontRef id2 = ats_font_id - 1;
+ FSRef ref2;
+
+ while ( id2 > 0 )
+ {
+ if ( noErr != ATSFontGetFileReference( id2, &ref2 ) )
+ break;
+ if ( noErr != FSCompareFSRefs( &ref, &ref2 ) )
+ break;
+
+ id2 --;
+ }
+ *i_idx = ats_font_id - ( id2 + 1 );
+ }
+
+ if ( noErr != FSRefMakePath( &ref, path, sizeof(path) ) )
+ {
+ msg_Err( p_filter, "failure when getting path from FSRef" );
+ return NULL;
+ }
+ msg_Dbg( p_filter, "found %s", path );
+
+ psz_path = strdup( (char *)path );
+
+ return psz_path;
+}
+#endif
diff --git a/modules/text_renderer/platform_fonts.c b/modules/text_renderer/platform_fonts.c
index 8a62a23..49f694c 100644
--- a/modules/text_renderer/platform_fonts.c
+++ b/modules/text_renderer/platform_fonts.c
@@ -40,16 +40,6 @@
#include <vlc_input.h> /* vlc_input_attachment_* */
#include <ctype.h>
-/* apple stuff */
-#ifdef __APPLE__
-# include <TargetConditionals.h>
-# if !TARGET_OS_IPHONE
-# include <Carbon/Carbon.h>
-# endif
-# include <sys/param.h> /* for MAXPATHLEN */
-# undef HAVE_FONTCONFIG
-#endif
-
#include "platform_fonts.h"
#include "freetype.h"
@@ -550,90 +540,6 @@ char* Generic_Select( filter_t *p_filter, const char* psz_family,
return File_Select( SYSTEM_DEFAULT_FONT_FILE );
}
-#ifdef __APPLE__
-#if !TARGET_OS_IPHONE
-char* MacLegacy_Select( filter_t *p_filter, const char* psz_fontname,
- bool b_bold, bool b_italic,
- int *i_idx, uni_char_t codepoint )
-{
- VLC_UNUSED( b_bold );
- VLC_UNUSED( b_italic );
- VLC_UNUSED( codepoint );
- FSRef ref;
- unsigned char path[MAXPATHLEN];
- char * psz_path;
-
- CFStringRef cf_fontName;
- ATSFontRef ats_font_id;
-
- *i_idx = 0;
-
- if( psz_fontname == NULL )
- return NULL;
-
- msg_Dbg( p_filter, "looking for %s", psz_fontname );
- cf_fontName = CFStringCreateWithCString( kCFAllocatorDefault, psz_fontname, kCFStringEncodingUTF8 );
-
- ats_font_id = ATSFontFindFromName( cf_fontName, kATSOptionFlagsIncludeDisabledMask );
-
- if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- {
- msg_Dbg( p_filter, "ATS couldn't find %s by name, checking family", psz_fontname );
- ats_font_id = ATSFontFamilyFindFromName( cf_fontName, kATSOptionFlagsDefault );
-
- if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- {
- msg_Dbg( p_filter, "ATS couldn't find either %s nor its family, checking PS name", psz_fontname );
- ats_font_id = ATSFontFindFromPostScriptName( cf_fontName, kATSOptionFlagsDefault );
-
- if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- {
- msg_Err( p_filter, "ATS couldn't find %s (no font name, family or PS name)", psz_fontname );
- CFRelease( cf_fontName );
- return NULL;
- }
- }
- }
- CFRelease( cf_fontName );
-
- if ( noErr != ATSFontGetFileReference( ats_font_id, &ref ) )
- {
- msg_Err( p_filter, "ATS couldn't get file ref for %s", psz_fontname );
- return NULL;
- }
-
- /* i_idx calculation by searching preceding fontIDs */
- /* with same FSRef */
- {
- ATSFontRef id2 = ats_font_id - 1;
- FSRef ref2;
-
- while ( id2 > 0 )
- {
- if ( noErr != ATSFontGetFileReference( id2, &ref2 ) )
- break;
- if ( noErr != FSCompareFSRefs( &ref, &ref2 ) )
- break;
-
- id2 --;
- }
- *i_idx = ats_font_id - ( id2 + 1 );
- }
-
- if ( noErr != FSRefMakePath( &ref, path, sizeof(path) ) )
- {
- msg_Err( p_filter, "failure when getting path from FSRef" );
- return NULL;
- }
- msg_Dbg( p_filter, "found %s", path );
-
- psz_path = strdup( (char *)path );
-
- return psz_path;
-}
-#endif
-#endif
-
#ifndef _WIN32
char* Dummy_Select( filter_t *p_filter, const char* psz_font,
bool b_bold, bool b_italic,
More information about the vlc-commits
mailing list