Commit e8793fde authored by Salah-Eddin Shaban's avatar Salah-Eddin Shaban Committed by Jean-Baptiste Kempf

freetype: font fallback structs and functions

This will close #5353 #2336 #4973 #5123 #5144 #5847 #7729 #7990 #8641 #12141 #12432
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 290ebe50
This diff is collapsed.
......@@ -29,14 +29,14 @@
#define VLC_FREETYPE_H
#include <vlc_text_style.h> /* text_style_t*/
#include <vlc_arrays.h>
typedef struct faces_cache_t
{
FT_Face *p_faces;
text_style_t *p_styles;
int i_faces_count;
int i_cache_size;
} faces_cache_t;
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_STROKER_H
#include "platform_fonts.h"
/*****************************************************************************
* filter_sys_t: freetype local data
......@@ -61,13 +61,48 @@ struct filter_sys_t
input_attachment_t **pp_font_attachments;
int i_font_attachments;
/* Font faces cache */
faces_cache_t faces_cache;
/*
* This is the master family list. It owns the lists of vlc_font_t's
* and should be freed using FreeFamiliesAndFonts()
*/
vlc_family_t *p_families;
char * (*pf_select) (filter_t *, const char* family,
bool bold, bool italic, int size,
int *index);
/*
* This maps a family name to a vlc_family_t within the master list
*/
vlc_dictionary_t family_map;
/*
* This maps a family name to a fallback list of vlc_family_t's.
* Fallback lists only reference the lists of vlc_font_t's within the
* master list, so they should be freed using FreeFamilies()
*/
vlc_dictionary_t fallback_map;
/* Font face cache */
vlc_dictionary_t face_map;
int i_fallback_counter;
int i_scale;
char * (*pf_select) (filter_t *, const char* family,
bool bold, bool italic,
int *index, uni_char_t codepoint);
/*
* Get a pointer to the vlc_family_t in the master list that matches psz_family.
* Add this family to the list if it hasn't been added yet.
*/
const vlc_family_t * (*pf_get_family) ( filter_t *p_filter, const char *psz_family );
/*
* Get the fallback list for psz_family from the system and cache
* it in fallback_map.
* On Windows fallback lists are populated progressively as required
* using Uniscribe, so we need the codepoint here.
*/
vlc_family_t * (*pf_get_fallbacks) ( filter_t *p_filter, const char *psz_family,
uni_char_t codepoint );
};
#define FT_FLOOR(X) ((X & -64) >> 6)
......@@ -76,23 +111,12 @@ struct filter_sys_t
#define FT_MulFix(v, s) (((v)*(s))>>16)
#endif
#ifdef __OS2__
typedef uint16_t uni_char_t;
# define FREETYPE_TO_UCS "UCS-2LE"
#else
typedef uint32_t uni_char_t;
# if defined(WORDS_BIGENDIAN)
# define FREETYPE_TO_UCS "UCS-4BE"
# else
# define FREETYPE_TO_UCS "UCS-4LE"
# endif
#endif
FT_Face LoadFace( filter_t *p_filter, const char *psz_fontfile, int i_idx,
const text_style_t *p_style );
FT_Face SelectAndLoadFace( filter_t *p_filter, const text_style_t *p_style,
uni_char_t codepoint );
FT_Face LoadFace( filter_t *p_filter, const text_style_t *p_style, int );
int ConvertToLiveSize( filter_t *p_filter, const text_style_t *p_style );
bool FaceStyleEquals( const text_style_t *p_style1,
const text_style_t *p_style2 );
#endif
This diff is collapsed.
......@@ -9,6 +9,7 @@
* Bernie Purcell <bitmap@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* Felix Paul Kühne <fkuehne@videolan.org>
* Salah-Eddin Shaban <salshaaban@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
......@@ -29,10 +30,28 @@
* Preamble
*****************************************************************************/
#ifndef PLATFORM_FONTS_H
#define PLATFORM_FONTS_H
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef __OS2__
typedef uint16_t uni_char_t;
# define FREETYPE_TO_UCS "UCS-2LE"
#else
typedef uint32_t uni_char_t;
# if defined(WORDS_BIGENDIAN)
# define FREETYPE_TO_UCS "UCS-4BE"
# else
# define FREETYPE_TO_UCS "UCS-4LE"
# endif
#endif
/* Default fonts */
#ifdef __APPLE__
# define SYSTEM_DEFAULT_FONT_FILE "/Library/Fonts/Arial Unicode.ttf"
......@@ -77,28 +96,100 @@
#define DEFAULT_MONOSPACE_FAMILY SYSTEM_DEFAULT_MONOSPACE_FAMILY
#endif
typedef struct vlc_font_t vlc_font_t;
struct vlc_font_t
{
vlc_font_t *p_next;
char *psz_fontfile;
int i_index;
bool b_bold;
bool b_italic;
FT_Face p_face;
};
typedef struct vlc_family_t vlc_family_t;
struct vlc_family_t
{
vlc_family_t *p_next;
char *psz_name;
vlc_font_t *p_fonts;
};
#define FB_LIST_ATTACHMENTS "attachments"
#define FB_LIST_DEFAULT "default"
#define FB_NAME "fallback"
#ifdef HAVE_FONTCONFIG
char* FontConfig_Select( filter_t *p_filter, const char* family,
bool b_bold, bool b_italic, int i_size, int *i_idx );
bool b_bold, bool b_italic,
int *i_idx, uni_char_t codepoint );
void FontConfig_BuildCache( filter_t *p_filter );
#endif
#if defined( _WIN32 ) && !VLC_WINSTORE_APP
char* Win32_Select( filter_t *p_filter, const char* family,
bool b_bold, bool b_italic, int i_size, int *i_idx );
bool b_bold, bool b_italic,
int *i_idx, uni_char_t codepoint );
#endif /* _WIN32 */
#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_size, int *i_idx );
bool b_bold, bool b_italic,
int *i_idx, uni_char_t codepoint );
#endif
#endif
char* Dummy_Select( filter_t *p_filter, const char* family,
bool b_bold, bool b_italic, int i_size, int *i_idx );
bool b_bold, bool b_italic,
int *i_idx, uni_char_t codepoint );
#define File_Select(a) Dummy_Select(NULL, a, 0, 0, NULL, 0)
char* Generic_Select( filter_t *p_filter, const char* family,
bool b_bold, bool b_italic,
int *i_idx, uni_char_t codepoint );
static inline void AppendFont( vlc_font_t **pp_list, vlc_font_t *p_font )
{
while( *pp_list )
pp_list = &( *pp_list )->p_next;
*pp_list = p_font;
}
static inline void AppendFamily( vlc_family_t **pp_list, vlc_family_t *p_family )
{
while( *pp_list )
pp_list = &( *pp_list )->p_next;
*pp_list = p_family;
}
vlc_family_t *NewFamily( filter_t *p_filter, const char *psz_family,
vlc_family_t **pp_list, vlc_dictionary_t *p_dict,
const char *psz_key );
/* This function takes ownership of psz_fontfile */
vlc_font_t *NewFont( char *psz_fontfile, int i_index,
bool b_bold, bool b_italic,
vlc_family_t *p_parent );
void FreeFamiliesAndFonts( vlc_family_t *p_family );
void FreeFamilies( void *p_families, void *p_obj );
vlc_family_t *InitDefaultList( filter_t *p_filter, const char *const *ppsz_default,
int i_size );
void DumpFamily( filter_t *p_filter, const vlc_family_t *p_family,
bool b_dump_fonts, int i_max_families );
void DumpDictionary( filter_t *p_filter, const vlc_dictionary_t *p_dict,
bool b_dump_fonts, int i_max_families );
char* ToLower( const char *psz_src );
#define File_Select(a) Dummy_Select(NULL, a, 0, 0, 0, NULL)
#endif //PLATFORM_FONTS_H
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment