1 /*****************************************************************************
2 * freetype.c : Put text on the video, using freetype2
3 *****************************************************************************
4 * Copyright (C) 2002 - 2012 VLC authors and VideoLAN
7 * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org>
8 * Gildas Bazin <gbazin@videolan.org>
9 * Bernie Purcell <bitmap@videolan.org>
10 * Jean-Baptiste Kempf <jb@videolan.org>
11 * Felix Paul Kühne <fkuehne@videolan.org>
12 * Salah-Eddin Shaban <salshaaban@gmail.com>
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation; either version 2.1 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this program; if not, write to the Free Software Foundation, Inc.,
26 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 *****************************************************************************/
29 /*****************************************************************************
31 *****************************************************************************/
33 #ifndef PLATFORM_FONTS_H
34 #define PLATFORM_FONTS_H
41 #include FT_FREETYPE_H
44 typedef uint16_t uni_char_t
;
45 # define FREETYPE_TO_UCS "UCS-2LE"
47 typedef uint32_t uni_char_t
;
48 # if defined(WORDS_BIGENDIAN)
49 # define FREETYPE_TO_UCS "UCS-4BE"
51 # define FREETYPE_TO_UCS "UCS-4LE"
57 # define SYSTEM_DEFAULT_FONT_FILE "/Library/Fonts/Arial Unicode.ttf"
58 # define SYSTEM_DEFAULT_FAMILY "Arial Unicode MS"
59 # define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/System/Library/Fonts/Monaco.dfont"
60 # define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monaco"
61 #elif defined( _WIN32 )
62 # define SYSTEM_DEFAULT_FONT_FILE "arial.ttf" /* Default path font found at run-time */
63 # define SYSTEM_DEFAULT_FAMILY "Arial"
64 # define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "cour.ttf"
65 # define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Courier New"
66 #elif defined( __OS2__ )
67 # define SYSTEM_DEFAULT_FONT_FILE "/psfonts/tnrwt_k.ttf"
68 # define SYSTEM_DEFAULT_FAMILY "Times New Roman WT K"
69 # define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/psfonts/mtsansdk.ttf"
70 # define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monotype Sans Duospace WT K"
71 #elif defined( __ANDROID__ )
72 # define SYSTEM_DEFAULT_FONT_FILE "/system/fonts/DroidSans-Bold.ttf"
73 # define SYSTEM_DEFAULT_FAMILY "Droid Sans"
74 # define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/system/fonts/DroidSansMono.ttf"
75 # define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monospace"
77 # define SYSTEM_DEFAULT_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeSerifBold.ttf"
78 # define SYSTEM_DEFAULT_FAMILY "Serif Bold"
79 # define SYSTEM_DEFAULT_MONOSPACE_FONT_FILE "/usr/share/fonts/truetype/freefont/FreeMono.ttf"
80 # define SYSTEM_DEFAULT_MONOSPACE_FAMILY "Monospace"
83 #ifndef DEFAULT_FONT_FILE
84 #define DEFAULT_FONT_FILE SYSTEM_DEFAULT_FONT_FILE
87 #ifndef DEFAULT_FAMILY
88 #define DEFAULT_FAMILY SYSTEM_DEFAULT_FAMILY
91 #ifndef DEFAULT_MONOSPACE_FONT_FILE
92 #define DEFAULT_MONOSPACE_FONT_FILE SYSTEM_DEFAULT_MONOSPACE_FONT_FILE
95 #ifndef DEFAULT_MONOSPACE_FAMILY
96 #define DEFAULT_MONOSPACE_FAMILY SYSTEM_DEFAULT_MONOSPACE_FAMILY
99 typedef struct vlc_font_t vlc_font_t
;
110 typedef struct vlc_family_t vlc_family_t
;
113 vlc_family_t
*p_next
;
118 #define FB_LIST_ATTACHMENTS "attachments"
119 #define FB_LIST_DEFAULT "default"
120 #define FB_NAME "fallback"
122 #ifdef HAVE_FONTCONFIG
123 const vlc_family_t
*FontConfig_GetFamily( filter_t
*p_filter
, const char *psz_family
);
124 vlc_family_t
*FontConfig_GetFallbacks( filter_t
*p_filter
, const char *psz_family
,
125 uni_char_t codepoint
);
126 void FontConfig_BuildCache( filter_t
*p_filter
);
129 #if defined( _WIN32 ) && !VLC_WINSTORE_APP
130 vlc_family_t
*Win32_GetFallbacks( filter_t
*p_filter
, const char *psz_family
,
131 uni_char_t codepoint
);
133 const vlc_family_t
*Win32_GetFamily( filter_t
*p_filter
, const char *psz_family
);
137 #if !TARGET_OS_IPHONE
138 char* MacLegacy_Select( filter_t
*p_filter
, const char* psz_fontname
,
139 bool b_bold
, bool b_italic
,
140 int *i_idx
, uni_char_t codepoint
);
145 #define ANDROID_SYSTEM_FONTS "file:///system/etc/system_fonts.xml"
146 #define ANDROID_FALLBACK_FONTS "file:///system/etc/fallback_fonts.xml"
147 #define ANDROID_VENDOR_FONTS "file:///vendor/etc/fallback_fonts.xml"
148 #define ANDROID_FONT_PATH "/system/fonts"
150 int Android_ParseSystemFonts( filter_t
*p_filter
, const char *psz_path
);
151 const vlc_family_t
*Android_GetFamily( filter_t
*p_filter
, const char *psz_family
);
152 vlc_family_t
*Android_GetFallbacks( filter_t
*p_filter
, const char *psz_family
,
153 uni_char_t codepoint
);
156 char* Dummy_Select( filter_t
*p_filter
, const char* family
,
157 bool b_bold
, bool b_italic
,
158 int *i_idx
, uni_char_t codepoint
);
160 #define File_Select(a) Dummy_Select(NULL, a, 0, 0, NULL, 0)
162 char* Generic_Select( filter_t
*p_filter
, const char* family
,
163 bool b_bold
, bool b_italic
,
164 int *i_idx
, uni_char_t codepoint
);
166 static inline void AppendFont( vlc_font_t
**pp_list
, vlc_font_t
*p_font
)
169 pp_list
= &( *pp_list
)->p_next
;
174 static inline void AppendFamily( vlc_family_t
**pp_list
, vlc_family_t
*p_family
)
177 pp_list
= &( *pp_list
)->p_next
;
182 vlc_family_t
*NewFamily( filter_t
*p_filter
, const char *psz_family
,
183 vlc_family_t
**pp_list
, vlc_dictionary_t
*p_dict
,
184 const char *psz_key
);
186 /* This function takes ownership of psz_fontfile */
187 vlc_font_t
*NewFont( char *psz_fontfile
, int i_index
,
188 bool b_bold
, bool b_italic
,
189 vlc_family_t
*p_parent
);
191 void FreeFamiliesAndFonts( vlc_family_t
*p_family
);
192 void FreeFamilies( void *p_families
, void *p_obj
);
195 vlc_family_t
*InitDefaultList( filter_t
*p_filter
, const char *const *ppsz_default
,
198 void DumpFamily( filter_t
*p_filter
, const vlc_family_t
*p_family
,
199 bool b_dump_fonts
, int i_max_families
);
201 void DumpDictionary( filter_t
*p_filter
, const vlc_dictionary_t
*p_dict
,
202 bool b_dump_fonts
, int i_max_families
);
204 char* ToLower( const char *psz_src
);
206 #endif //PLATFORM_FONTS_H