Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
3085d9bc
Commit
3085d9bc
authored
Oct 22, 2015
by
Salah-Eddin Shaban
Committed by
Jean-Baptiste Kempf
Oct 24, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freetype: font fallback for Fontconfig (Linux et al.)
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
e8793fde
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
178 additions
and
55 deletions
+178
-55
modules/text_renderer/freetype.c
modules/text_renderer/freetype.c
+3
-1
modules/text_renderer/platform_fonts.c
modules/text_renderer/platform_fonts.c
+167
-50
modules/text_renderer/platform_fonts.h
modules/text_renderer/platform_fonts.h
+3
-4
modules/text_renderer/text_layout.c
modules/text_renderer/text_layout.c
+5
-0
No files found.
modules/text_renderer/freetype.c
View file @
3085d9bc
...
@@ -1259,7 +1259,9 @@ static int Create( vlc_object_t *p_this )
...
@@ -1259,7 +1259,9 @@ static int Create( vlc_object_t *p_this )
goto
error
;
goto
error
;
#ifdef HAVE_FONTCONFIG
#ifdef HAVE_FONTCONFIG
p_sys
->
pf_select
=
FontConfig_Select
;
p_sys
->
pf_select
=
Generic_Select
;
p_sys
->
pf_get_family
=
FontConfig_GetFamily
;
p_sys
->
pf_get_fallbacks
=
FontConfig_GetFallbacks
;
FontConfig_BuildCache
(
p_filter
);
FontConfig_BuildCache
(
p_filter
);
#elif defined( __APPLE__ )
#elif defined( __APPLE__ )
#if !TARGET_OS_IPHONE
#if !TARGET_OS_IPHONE
...
...
modules/text_renderer/platform_fonts.c
View file @
3085d9bc
...
@@ -461,73 +461,190 @@ void FontConfig_BuildCache( filter_t *p_filter )
...
@@ -461,73 +461,190 @@ void FontConfig_BuildCache( filter_t *p_filter )
msg_Dbg
(
p_filter
,
"Took %ld microseconds"
,
(
long
)((
t2
-
t1
))
);
msg_Dbg
(
p_filter
,
"Took %ld microseconds"
,
(
long
)((
t2
-
t1
))
);
}
}
/***
const
vlc_family_t
*
FontConfig_GetFamily
(
filter_t
*
p_filter
,
const
char
*
psz_family
)
* \brief Selects a font matching family, bold, italic provided
***/
char
*
FontConfig_Select
(
filter_t
*
p_filter
,
const
char
*
family
,
bool
b_bold
,
bool
b_italic
,
int
*
i_idx
,
uni_char_t
codepoint
)
{
{
FcResult
result
=
FcResultMatch
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
FcPattern
*
pat
,
*
p_pat
;
FcChar8
*
val_s
;
FcBool
val_b
;
char
*
ret
=
NULL
;
FcConfig
*
config
=
NULL
;
VLC_UNUSED
(
p_filter
);
VLC_UNUSED
(
codepoint
);
/* Create a pattern and fills it */
char
*
psz_lc
=
ToLower
(
psz_family
);
pat
=
FcPatternCreate
();
if
(
!
pat
)
return
NULL
;
/* */
if
(
unlikely
(
!
psz_lc
)
)
FcPatternAddString
(
pat
,
FC_FAMILY
,
(
const
FcChar8
*
)
family
);
return
NULL
;
FcPatternAddBool
(
pat
,
FC_OUTLINE
,
FcTrue
);
FcPatternAddInteger
(
pat
,
FC_SLANT
,
b_italic
?
FC_SLANT_ITALIC
:
FC_SLANT_ROMAN
);
FcPatternAddInteger
(
pat
,
FC_WEIGHT
,
b_bold
?
FC_WEIGHT_EXTRABOLD
:
FC_WEIGHT_NORMAL
);
/* */
vlc_family_t
*
p_family
=
FcDefaultSubstitute
(
pat
);
vlc_dictionary_value_for_key
(
&
p_sys
->
family_map
,
psz_lc
);
if
(
!
FcConfigSubstitute
(
config
,
pat
,
FcMatchPattern
)
)
if
(
p_family
!=
kVLCDictionaryNotFound
)
{
{
FcPatternDestroy
(
pat
);
free
(
psz_lc
);
return
NULL
;
return
p_family
;
}
}
/* Find the best font for the pattern, destroy the pattern */
p_family
=
NewFamily
(
p_filter
,
psz_lc
,
&
p_sys
->
p_families
,
p_pat
=
FcFontMatch
(
config
,
pat
,
&
result
);
&
p_sys
->
family_map
,
psz_lc
);
FcPatternDestroy
(
pat
);
if
(
!
p_pat
||
result
==
FcResultNoMatch
)
return
NULL
;
free
(
psz_lc
);
if
(
!
p_family
)
return
NULL
;
bool
b_bold
,
b_italic
;
/* Check the new pattern */
for
(
int
i
=
0
;
i
<
4
;
++
i
)
if
(
(
FcResultMatch
!=
FcPatternGetBool
(
p_pat
,
FC_OUTLINE
,
0
,
&
val_b
)
)
||
(
val_b
!=
FcTrue
)
)
{
{
switch
(
i
)
{
case
0
:
b_bold
=
false
;
b_italic
=
false
;
break
;
case
1
:
b_bold
=
true
;
b_italic
=
false
;
break
;
case
2
:
b_bold
=
false
;
b_italic
=
true
;
break
;
case
3
:
b_bold
=
true
;
b_italic
=
true
;
break
;
}
int
i_index
=
0
;
FcResult
result
=
FcResultMatch
;
FcPattern
*
pat
,
*
p_pat
;
FcChar8
*
val_s
;
FcBool
val_b
;
char
*
psz_fontfile
=
NULL
;
FcConfig
*
config
=
NULL
;
/* Create a pattern and fill it */
pat
=
FcPatternCreate
();
if
(
!
pat
)
continue
;
/* */
FcPatternAddString
(
pat
,
FC_FAMILY
,
(
const
FcChar8
*
)
psz_family
);
FcPatternAddBool
(
pat
,
FC_OUTLINE
,
FcTrue
);
FcPatternAddInteger
(
pat
,
FC_SLANT
,
b_italic
?
FC_SLANT_ITALIC
:
FC_SLANT_ROMAN
);
FcPatternAddInteger
(
pat
,
FC_WEIGHT
,
b_bold
?
FC_WEIGHT_EXTRABOLD
:
FC_WEIGHT_NORMAL
);
/* */
FcDefaultSubstitute
(
pat
);
if
(
!
FcConfigSubstitute
(
config
,
pat
,
FcMatchPattern
)
)
{
FcPatternDestroy
(
pat
);
continue
;
}
/* Find the best font for the pattern, destroy the pattern */
p_pat
=
FcFontMatch
(
config
,
pat
,
&
result
);
FcPatternDestroy
(
pat
);
if
(
!
p_pat
||
result
==
FcResultNoMatch
)
continue
;
/* Check the new pattern */
if
(
(
FcResultMatch
!=
FcPatternGetBool
(
p_pat
,
FC_OUTLINE
,
0
,
&
val_b
)
)
||
(
val_b
!=
FcTrue
)
)
{
FcPatternDestroy
(
p_pat
);
continue
;
}
if
(
FcResultMatch
!=
FcPatternGetInteger
(
p_pat
,
FC_INDEX
,
0
,
&
i_index
)
)
{
i_index
=
0
;
}
if
(
FcResultMatch
!=
FcPatternGetString
(
p_pat
,
FC_FAMILY
,
0
,
&
val_s
)
)
{
FcPatternDestroy
(
p_pat
);
continue
;
}
if
(
FcResultMatch
==
FcPatternGetString
(
p_pat
,
FC_FILE
,
0
,
&
val_s
)
)
psz_fontfile
=
strdup
(
(
const
char
*
)
val_s
);
FcPatternDestroy
(
p_pat
);
FcPatternDestroy
(
p_pat
);
return
NULL
;
if
(
!
psz_fontfile
)
continue
;
NewFont
(
psz_fontfile
,
i_index
,
b_bold
,
b_italic
,
p_family
);
}
}
if
(
FcResultMatch
!=
FcPatternGetInteger
(
p_pat
,
FC_INDEX
,
0
,
i_idx
)
)
return
p_family
;
}
vlc_family_t
*
FontConfig_GetFallbacks
(
filter_t
*
p_filter
,
const
char
*
psz_family
,
uni_char_t
codepoint
)
{
VLC_UNUSED
(
codepoint
);
vlc_family_t
*
p_family
=
NULL
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
char
*
psz_lc
=
ToLower
(
psz_family
);
if
(
unlikely
(
!
psz_lc
)
)
return
NULL
;
p_family
=
vlc_dictionary_value_for_key
(
&
p_sys
->
fallback_map
,
psz_lc
);
if
(
p_family
!=
kVLCDictionaryNotFound
)
{
{
*
i_idx
=
0
;
free
(
psz_lc
);
return
p_family
;
}
}
else
if
(
FcResultMatch
!=
FcPatternGetString
(
p_pat
,
FC_FAMILY
,
0
,
&
val_s
)
)
p_family
=
NULL
;
const
char
*
psz_last_name
=
""
;
FcPattern
*
p_pattern
=
FcPatternCreate
();
FcValue
family
;
family
.
type
=
FcTypeString
;
family
.
u
.
s
=
(
const
FcChar8
*
)
psz_family
;
FcPatternAdd
(
p_pattern
,
FC_FAMILY
,
family
,
FcFalse
);
if
(
FcConfigSubstitute
(
NULL
,
p_pattern
,
FcMatchPattern
)
==
FcTrue
)
{
{
FcPatternDestroy
(
p_pat
);
FcDefaultSubstitute
(
p_pattern
);
return
NULL
;
FcResult
result
;
FcFontSet
*
p_font_set
=
FcFontSort
(
NULL
,
p_pattern
,
FcTrue
,
NULL
,
&
result
);
if
(
p_font_set
)
{
for
(
int
i
=
0
;
i
<
p_font_set
->
nfont
;
++
i
)
{
char
*
psz_name
=
NULL
;
FcPatternGetString
(
p_font_set
->
fonts
[
i
],
FC_FAMILY
,
0
,
(
FcChar8
**
)(
&
psz_name
)
);
/* Avoid duplicate family names */
if
(
strcasecmp
(
psz_last_name
,
psz_name
)
)
{
vlc_family_t
*
p_temp
=
NewFamily
(
p_filter
,
psz_name
,
&
p_family
,
NULL
,
NULL
);
if
(
unlikely
(
!
p_temp
)
)
{
FcFontSetDestroy
(
p_font_set
);
FcPatternDestroy
(
p_pattern
);
if
(
p_family
)
FreeFamilies
(
p_family
,
NULL
);
free
(
psz_lc
);
return
NULL
;
}
psz_last_name
=
p_temp
->
psz_name
;
}
}
FcFontSetDestroy
(
p_font_set
);
}
}
}
FcPatternDestroy
(
p_pattern
);
/* if( strcasecmp((const char*)val_s, family ) != 0 )
if
(
p_family
)
msg_Warn( p_filter, "fontconfig: selected font family is not"
vlc_dictionary_insert
(
&
p_sys
->
fallback_map
,
psz_lc
,
p_family
);
"the requested one: '%s' != '%s'\n",
(const char*)val_s, family ); */
if
(
FcResultMatch
==
FcPatternGetString
(
p_pat
,
FC_FILE
,
0
,
&
val_s
)
)
ret
=
strdup
(
(
const
char
*
)
val_s
);
FcPatternDestroy
(
p_pat
);
free
(
psz_lc
);
return
ret
;
return
p_family
;
}
}
#endif
#endif
...
...
modules/text_renderer/platform_fonts.h
View file @
3085d9bc
...
@@ -120,13 +120,12 @@ struct vlc_family_t
...
@@ -120,13 +120,12 @@ struct vlc_family_t
#define FB_NAME "fallback"
#define FB_NAME "fallback"
#ifdef HAVE_FONTCONFIG
#ifdef HAVE_FONTCONFIG
c
har
*
FontConfig_Select
(
filter_t
*
p_filter
,
const
char
*
family
,
c
onst
vlc_family_t
*
FontConfig_GetFamily
(
filter_t
*
p_filter
,
const
char
*
psz_family
);
bool
b_bold
,
bool
b_italic
,
vlc_family_t
*
FontConfig_GetFallbacks
(
filter_t
*
p_filter
,
const
char
*
psz_family
,
int
*
i_idx
,
uni_char_t
codepoint
);
uni_char_t
codepoint
);
void
FontConfig_BuildCache
(
filter_t
*
p_filter
);
void
FontConfig_BuildCache
(
filter_t
*
p_filter
);
#endif
#endif
#if defined( _WIN32 ) && !VLC_WINSTORE_APP
#if defined( _WIN32 ) && !VLC_WINSTORE_APP
char
*
Win32_Select
(
filter_t
*
p_filter
,
const
char
*
family
,
char
*
Win32_Select
(
filter_t
*
p_filter
,
const
char
*
family
,
bool
b_bold
,
bool
b_italic
,
bool
b_bold
,
bool
b_italic
,
...
...
modules/text_renderer/text_layout.c
View file @
3085d9bc
...
@@ -58,6 +58,11 @@
...
@@ -58,6 +58,11 @@
#include "text_layout.h"
#include "text_layout.h"
#include "freetype.h"
#include "freetype.h"
/* FontConfig */
#ifdef HAVE_FONTCONFIG
# define HAVE_FONT_FALLBACK
#endif
/*
/*
* Within a paragraph, run_desc_t represents a run of characters
* Within a paragraph, run_desc_t represents a run of characters
* having the same font face, size, and style, Unicode script
* having the same font face, size, and style, Unicode script
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment