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
47b7d83d
Commit
47b7d83d
authored
Aug 24, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freetype: simplify live style handling
parent
ee39258e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
95 deletions
+59
-95
modules/text_renderer/freetype.c
modules/text_renderer/freetype.c
+32
-79
modules/text_renderer/freetype.h
modules/text_renderer/freetype.h
+2
-2
modules/text_renderer/text_layout.c
modules/text_renderer/text_layout.c
+25
-14
No files found.
modules/text_renderer/freetype.c
View file @
47b7d83d
...
@@ -309,54 +309,6 @@ static int LoadFontsFromAttachments( filter_t *p_filter )
...
@@ -309,54 +309,6 @@ static int LoadFontsFromAttachments( filter_t *p_filter )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
int
GetFontSize
(
filter_t
*
p_filter
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
int
i_size
=
0
;
if
(
p_sys
->
p_forced_style
->
i_font_size
)
{
i_size
=
p_sys
->
p_forced_style
->
i_font_size
;
}
else
if
(
p_sys
->
p_forced_style
->
f_font_relsize
)
{
i_size
=
(
int
)
p_filter
->
fmt_out
.
video
.
i_height
*
p_sys
->
p_forced_style
->
f_font_relsize
;
}
else
if
(
p_sys
->
p_default_style
->
f_font_relsize
)
{
i_size
=
(
int
)
p_filter
->
fmt_out
.
video
.
i_height
*
p_sys
->
p_default_style
->
f_font_relsize
;
}
if
(
i_size
<=
0
)
{
msg_Warn
(
p_filter
,
"invalid fontsize, using %d"
,
FREETYPE_DEFAULT_FONT_SIZE
);
i_size
=
FREETYPE_DEFAULT_FONT_SIZE
;
}
return
i_size
;
}
static
int
SetFontSize
(
filter_t
*
p_filter
,
int
i_size
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
if
(
!
i_size
)
{
i_size
=
GetFontSize
(
p_filter
);
msg_Dbg
(
p_filter
,
"using fontsize: %i"
,
i_size
);
}
p_sys
->
p_style
->
i_font_size
=
i_size
;
if
(
FT_Set_Pixel_Sizes
(
p_sys
->
p_face
,
0
,
i_size
)
)
{
msg_Err
(
p_filter
,
"couldn't set font size to %d"
,
i_size
);
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
/*****************************************************************************
/*****************************************************************************
* RenderYUVP: place string in picture
* RenderYUVP: place string in picture
*****************************************************************************
*****************************************************************************
...
@@ -774,8 +726,6 @@ static inline int RenderAXYZ( filter_t *p_filter,
...
@@ -774,8 +726,6 @@ static inline int RenderAXYZ( filter_t *p_filter,
void
(
*
FillPicture
)(
picture_t
*
p_picture
,
int
,
int
,
int
,
int
),
void
(
*
FillPicture
)(
picture_t
*
p_picture
,
int
,
int
,
int
,
int
),
void
(
*
BlendPixel
)(
picture_t
*
,
int
,
int
,
int
,
int
,
int
,
int
,
int
)
)
void
(
*
BlendPixel
)(
picture_t
*
,
int
,
int
,
int
,
int
,
int
,
int
,
int
)
)
{
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
/* Create a new subpicture region */
/* Create a new subpicture region */
const
int
i_text_width
=
p_bbox
->
xMax
-
p_bbox
->
xMin
;
const
int
i_text_width
=
p_bbox
->
xMax
-
p_bbox
->
xMin
;
const
int
i_text_height
=
p_bbox
->
yMax
-
p_bbox
->
yMin
;
const
int
i_text_height
=
p_bbox
->
yMax
-
p_bbox
->
yMin
;
...
@@ -844,12 +794,12 @@ static inline int RenderAXYZ( filter_t *p_filter,
...
@@ -844,12 +794,12 @@ static inline int RenderAXYZ( filter_t *p_filter,
uint32_t
i_color
;
uint32_t
i_color
;
switch
(
g
)
{
/* Apply font alpha ratio to shadow/outline alpha */
switch
(
g
)
{
/* Apply font alpha ratio to shadow/outline alpha */
case
0
:
case
0
:
i_a
=
i_a
*
p_sys
->
p_style
->
i_shadow_alpha
/
255
;
i_a
=
i_a
*
ch
->
p_style
->
i_shadow_alpha
/
255
;
i_color
=
p_sys
->
p_style
->
i_shadow_color
;
i_color
=
ch
->
p_style
->
i_shadow_color
;
break
;
break
;
case
1
:
case
1
:
i_a
=
i_a
*
p_sys
->
p_style
->
i_outline_alpha
/
255
;
i_a
=
i_a
*
ch
->
p_style
->
i_outline_alpha
/
255
;
i_color
=
p_sys
->
p_style
->
i_outline_color
;
i_color
=
ch
->
p_style
->
i_outline_color
;
break
;
break
;
default:
default:
i_color
=
ch
->
p_style
->
i_font_color
;
i_color
=
ch
->
p_style
->
i_font_color
;
...
@@ -901,6 +851,8 @@ static void FillDefaultStyles( filter_t *p_filter )
...
@@ -901,6 +851,8 @@ static void FillDefaultStyles( filter_t *p_filter )
p_sys
->
p_default_style
->
i_shadow_color
=
var_InheritInteger
(
p_filter
,
"freetype-shadow-color"
);
p_sys
->
p_default_style
->
i_shadow_color
=
var_InheritInteger
(
p_filter
,
"freetype-shadow-color"
);
p_sys
->
p_default_style
->
i_shadow_color
=
VLC_CLIP
(
p_sys
->
p_default_style
->
i_shadow_color
,
0
,
0xFFFFFF
);
p_sys
->
p_default_style
->
i_shadow_color
=
VLC_CLIP
(
p_sys
->
p_default_style
->
i_shadow_color
,
0
,
0xFFFFFF
);
p_sys
->
p_default_style
->
i_font_size
=
0
;
p_sys
->
p_forced_style
->
i_font_size
=
var_InheritInteger
(
p_filter
,
"freetype-fontsize"
);
p_sys
->
p_forced_style
->
i_font_size
=
var_InheritInteger
(
p_filter
,
"freetype-fontsize"
);
p_sys
->
p_forced_style
->
f_font_relsize
=
var_InheritInteger
(
p_filter
,
"freetype-rel-fontsize"
);
p_sys
->
p_forced_style
->
f_font_relsize
=
var_InheritInteger
(
p_filter
,
"freetype-rel-fontsize"
);
if
(
p_sys
->
p_forced_style
->
f_font_relsize
)
if
(
p_sys
->
p_forced_style
->
f_font_relsize
)
...
@@ -958,7 +910,7 @@ static uni_char_t* SegmentsToTextAndStyles( filter_t *p_filter, const text_segme
...
@@ -958,7 +910,7 @@ static uni_char_t* SegmentsToTextAndStyles( filter_t *p_filter, const text_segme
pp_styles
=
pp_styles_realloc
;
pp_styles
=
pp_styles_realloc
;
// We're actually writing to a read only object, something's wrong with the conception.
// We're actually writing to a read only object, something's wrong with the conception.
text_style_t
*
p_style
=
text_style_Duplicate
(
p_filter
->
p_sys
->
p_style
);
text_style_t
*
p_style
=
text_style_Duplicate
(
p_filter
->
p_sys
->
p_
default_
style
);
if
(
p_style
==
NULL
)
if
(
p_style
==
NULL
)
{
{
free
(
pp_styles
);
free
(
pp_styles
);
...
@@ -997,9 +949,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region_out,
...
@@ -997,9 +949,6 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region_out,
if
(
!
p_region_in
)
if
(
!
p_region_in
)
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
/* Reset the default fontsize in case screen metrics have changed */
p_filter
->
p_sys
->
p_style
->
i_font_size
=
GetFontSize
(
p_filter
);
const
text_style_t
**
pp_styles
=
NULL
;
const
text_style_t
**
pp_styles
=
NULL
;
size_t
i_text_length
=
0
;
size_t
i_text_length
=
0
;
uni_char_t
*
psz_text
=
SegmentsToTextAndStyles
(
p_filter
,
p_region_in
->
p_text
,
&
i_text_length
,
&
pp_styles
);
uni_char_t
*
psz_text
=
SegmentsToTextAndStyles
(
p_filter
,
p_region_in
->
p_text
,
&
i_text_length
,
&
pp_styles
);
...
@@ -1126,7 +1075,11 @@ static int Init_FT( vlc_object_t *p_this,
...
@@ -1126,7 +1075,11 @@ static int Init_FT( vlc_object_t *p_this,
goto
error
;
goto
error
;
}
}
if
(
SetFontSize
(
p_filter
,
(
int
)
0
)
!=
VLC_SUCCESS
)
goto
error
;
if
(
FT_Set_Pixel_Sizes
(
p_sys
->
p_face
,
0
,
STYLE_DEFAULT_FONT_SIZE
)
)
{
msg_Err
(
p_filter
,
"couldn't set font size to %d"
,
STYLE_DEFAULT_FONT_SIZE
);
goto
error
;
}
i_error
=
FT_Stroker_New
(
p_sys
->
p_library
,
&
p_sys
->
p_stroker
);
i_error
=
FT_Stroker_New
(
p_sys
->
p_library
,
&
p_sys
->
p_stroker
);
if
(
i_error
)
if
(
i_error
)
...
@@ -1166,8 +1119,6 @@ static int Create( vlc_object_t *p_this )
...
@@ -1166,8 +1119,6 @@ static int Create( vlc_object_t *p_this )
return
VLC_ENOMEM
;
return
VLC_ENOMEM
;
}
}
p_sys
->
p_style
=
NULL
;
/* empty style for style overriding cases */
/* empty style for style overriding cases */
p_sys
->
p_forced_style
=
text_style_Create
(
STYLE_NO_DEFAULTS
);
p_sys
->
p_forced_style
=
text_style_Create
(
STYLE_NO_DEFAULTS
);
if
(
unlikely
(
!
p_sys
->
p_forced_style
))
if
(
unlikely
(
!
p_sys
->
p_forced_style
))
...
@@ -1230,16 +1181,6 @@ static int Create( vlc_object_t *p_this )
...
@@ -1230,16 +1181,6 @@ static int Create( vlc_object_t *p_this )
p_sys
->
pf_select
=
Dummy_Select
;
p_sys
->
pf_select
=
Dummy_Select
;
#endif
#endif
/* Set default style to current (FIXME: is current really used/needed?) */
p_sys
->
p_style
=
text_style_Duplicate
(
p_sys
->
p_default_style
);
if
(
!
p_sys
->
p_style
)
{
text_style_Delete
(
p_sys
->
p_default_style
);
text_style_Delete
(
p_sys
->
p_forced_style
);
free
(
p_sys
);
return
VLC_ENOMEM
;
}
/* */
/* */
psz_fontfile
=
p_sys
->
pf_select
(
p_filter
,
p_sys
->
p_default_style
->
psz_fontname
,
psz_fontfile
=
p_sys
->
pf_select
(
p_filter
,
p_sys
->
p_default_style
->
psz_fontname
,
false
,
false
,
p_sys
->
p_default_style
->
i_font_size
,
&
fontindex
);
false
,
false
,
p_sys
->
p_default_style
->
i_font_size
,
&
fontindex
);
...
@@ -1281,7 +1222,6 @@ static int Create( vlc_object_t *p_this )
...
@@ -1281,7 +1222,6 @@ static int Create( vlc_object_t *p_this )
error:
error:
free
(
psz_fontfile
);
free
(
psz_fontfile
);
free
(
psz_monofontfile
);
free
(
psz_monofontfile
);
text_style_Delete
(
p_sys
->
p_style
);
text_style_Delete
(
p_sys
->
p_default_style
);
text_style_Delete
(
p_sys
->
p_default_style
);
text_style_Delete
(
p_sys
->
p_forced_style
);
text_style_Delete
(
p_sys
->
p_forced_style
);
free
(
p_sys
);
free
(
p_sys
);
...
@@ -1329,7 +1269,6 @@ static void Destroy( vlc_object_t *p_this )
...
@@ -1329,7 +1269,6 @@ static void Destroy( vlc_object_t *p_this )
}
}
text_style_Delete
(
p_sys
->
p_default_style
);
text_style_Delete
(
p_sys
->
p_default_style
);
text_style_Delete
(
p_sys
->
p_style
);
text_style_Delete
(
p_sys
->
p_forced_style
);
text_style_Delete
(
p_sys
->
p_forced_style
);
Destroy_FT
(
p_this
);
Destroy_FT
(
p_this
);
...
@@ -1383,15 +1322,29 @@ static FT_Face LoadEmbeddedFace( filter_sys_t *p_sys, const char *psz_fontname,
...
@@ -1383,15 +1322,29 @@ static FT_Face LoadEmbeddedFace( filter_sys_t *p_sys, const char *psz_fontname,
return
NULL
;
return
NULL
;
}
}
int
ConvertToLiveSize
(
filter_t
*
p_filter
,
const
text_style_t
*
p_style
)
{
int
i_font_size
=
STYLE_DEFAULT_FONT_SIZE
;
if
(
p_style
->
i_font_size
)
{
i_font_size
=
p_style
->
i_font_size
;
}
else
if
(
p_style
->
f_font_relsize
)
{
i_font_size
=
(
int
)
p_filter
->
fmt_out
.
video
.
i_height
*
p_style
->
f_font_relsize
;
}
return
i_font_size
;
}
FT_Face
LoadFace
(
filter_t
*
p_filter
,
FT_Face
LoadFace
(
filter_t
*
p_filter
,
const
text_style_t
*
p_style
)
const
text_style_t
*
p_style
,
int
i_font_size
)
{
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
faces_cache_t
*
p_cache
=
&
p_sys
->
faces_cache
;
faces_cache_t
*
p_cache
=
&
p_sys
->
faces_cache
;
for
(
int
i
=
0
;
i
<
p_cache
->
i_faces_count
;
++
i
)
for
(
int
i
=
0
;
i
<
p_cache
->
i_faces_count
;
++
i
)
if
(
FaceStyleEquals
(
&
p_cache
->
p_styles
[
i
],
p_style
)
if
(
FaceStyleEquals
(
&
p_cache
->
p_styles
[
i
],
p_style
)
&&
p_cache
->
p_styles
[
i
].
i_font_size
==
p_style
->
i_font_size
&&
p_cache
->
p_styles
[
i
].
i_font_size
==
i_font_size
&&
!
(
(
p_cache
->
p_styles
[
i
].
i_style_flags
^
p_style
->
i_style_flags
)
&
STYLE_HALFWIDTH
)
)
&&
!
(
(
p_cache
->
p_styles
[
i
].
i_style_flags
^
p_style
->
i_style_flags
)
&
STYLE_HALFWIDTH
)
)
return
p_cache
->
p_faces
[
i
];
return
p_cache
->
p_faces
[
i
];
...
@@ -1449,12 +1402,12 @@ FT_Face LoadFace( filter_t *p_filter,
...
@@ -1449,12 +1402,12 @@ FT_Face LoadFace( filter_t *p_filter,
}
}
int
i_font_width
=
p_style
->
i_style_flags
&
STYLE_HALFWIDTH
int
i_font_width
=
p_style
->
i_style_flags
&
STYLE_HALFWIDTH
?
p_style
->
i_font_size
/
2
:
p_style
->
i_font_size
;
?
i_font_size
/
2
:
i_font_size
;
if
(
FT_Set_Pixel_Sizes
(
p_face
,
i_font_width
,
p_style
->
i_font_size
)
)
if
(
FT_Set_Pixel_Sizes
(
p_face
,
i_font_width
,
i_font_size
)
)
{
{
msg_Err
(
p_filter
,
msg_Err
(
p_filter
,
"Failed to set font size to %d"
,
p_style
->
i_font_size
);
"Failed to set font size to %d"
,
i_font_size
);
FT_Done_Face
(
p_face
);
FT_Done_Face
(
p_face
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1484,7 +1437,7 @@ FT_Face LoadFace( filter_t *p_filter,
...
@@ -1484,7 +1437,7 @@ FT_Face LoadFace( filter_t *p_filter,
}
}
text_style_t
*
p_face_style
=
p_cache
->
p_styles
+
p_cache
->
i_faces_count
;
text_style_t
*
p_face_style
=
p_cache
->
p_styles
+
p_cache
->
i_faces_count
;
p_face_style
->
i_font_size
=
p_style
->
i_font_size
;
p_face_style
->
i_font_size
=
i_font_size
;
p_face_style
->
i_style_flags
=
p_style
->
i_style_flags
;
p_face_style
->
i_style_flags
=
p_style
->
i_style_flags
;
p_face_style
->
psz_fontname
=
strdup
(
psz_fontname
);
p_face_style
->
psz_fontname
=
strdup
(
psz_fontname
);
p_cache
->
p_faces
[
p_cache
->
i_faces_count
]
=
p_face
;
p_cache
->
p_faces
[
p_cache
->
i_faces_count
]
=
p_face
;
...
...
modules/text_renderer/freetype.h
View file @
47b7d83d
...
@@ -51,7 +51,6 @@ struct filter_sys_t
...
@@ -51,7 +51,6 @@ struct filter_sys_t
FT_Stroker
p_stroker
;
/* handle to path stroker object */
FT_Stroker
p_stroker
;
/* handle to path stroker object */
text_style_t
*
p_default_style
;
text_style_t
*
p_default_style
;
text_style_t
*
p_style
;
/* Current Style */
text_style_t
*
p_forced_style
;
/* Renderer overridings */
text_style_t
*
p_forced_style
;
/* Renderer overridings */
/* More styles... */
/* More styles... */
...
@@ -90,7 +89,8 @@ typedef uint32_t uni_char_t;
...
@@ -90,7 +89,8 @@ typedef uint32_t uni_char_t;
#endif
#endif
FT_Face
LoadFace
(
filter_t
*
p_filter
,
const
text_style_t
*
p_style
);
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
,
bool
FaceStyleEquals
(
const
text_style_t
*
p_style1
,
const
text_style_t
*
p_style2
);
const
text_style_t
*
p_style2
);
...
...
modules/text_renderer/text_layout.c
View file @
47b7d83d
...
@@ -516,6 +516,7 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
...
@@ -516,6 +516,7 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
{
{
run_desc_t
*
p_run
=
p_paragraph
->
p_runs
+
i
;
run_desc_t
*
p_run
=
p_paragraph
->
p_runs
+
i
;
const
text_style_t
*
p_style
=
p_run
->
p_style
;
const
text_style_t
*
p_style
=
p_run
->
p_style
;
const
int
i_live_size
=
ConvertToLiveSize
(
p_filter
,
p_style
);
/*
/*
* When using HarfBuzz, this is where font faces are loaded.
* When using HarfBuzz, this is where font faces are loaded.
...
@@ -525,11 +526,11 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
...
@@ -525,11 +526,11 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
FT_Face
p_face
=
0
;
FT_Face
p_face
=
0
;
if
(
!
p_run
->
p_face
)
if
(
!
p_run
->
p_face
)
{
{
p_face
=
LoadFace
(
p_filter
,
p_style
);
p_face
=
LoadFace
(
p_filter
,
p_style
,
i_live_size
);
if
(
!
p_face
)
if
(
!
p_face
)
{
{
p_face
=
p_sys
->
p_face
;
p_face
=
p_sys
->
p_face
;
p_style
=
p_sys
->
p_style
;
p_style
=
p_sys
->
p_
default_
style
;
p_run
->
p_style
=
p_style
;
p_run
->
p_style
=
p_style
;
}
}
p_run
->
p_face
=
p_face
;
p_run
->
p_face
=
p_face
;
...
@@ -761,7 +762,8 @@ static int ZeroNsmAdvance( paragraph_t *p_paragraph )
...
@@ -761,7 +762,8 @@ static int ZeroNsmAdvance( paragraph_t *p_paragraph )
* have already been determined at this point, as well as the advance values.
* have already been determined at this point, as well as the advance values.
*/
*/
static
int
LoadGlyphs
(
filter_t
*
p_filter
,
paragraph_t
*
p_paragraph
,
static
int
LoadGlyphs
(
filter_t
*
p_filter
,
paragraph_t
*
p_paragraph
,
bool
b_use_glyph_indices
,
bool
b_overwrite_advance
)
bool
b_use_glyph_indices
,
bool
b_overwrite_advance
,
int
*
pi_max_advance_x
)
{
{
if
(
p_paragraph
->
i_size
<=
0
||
p_paragraph
->
i_runs_count
<=
0
)
if
(
p_paragraph
->
i_size
<=
0
||
p_paragraph
->
i_runs_count
<=
0
)
{
{
...
@@ -772,20 +774,23 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
...
@@ -772,20 +774,23 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
}
}
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
*
pi_max_advance_x
=
0
;
for
(
int
i
=
0
;
i
<
p_paragraph
->
i_runs_count
;
++
i
)
for
(
int
i
=
0
;
i
<
p_paragraph
->
i_runs_count
;
++
i
)
{
{
run_desc_t
*
p_run
=
p_paragraph
->
p_runs
+
i
;
run_desc_t
*
p_run
=
p_paragraph
->
p_runs
+
i
;
const
text_style_t
*
p_style
=
p_run
->
p_style
;
const
text_style_t
*
p_style
=
p_run
->
p_style
;
const
int
i_live_size
=
ConvertToLiveSize
(
p_filter
,
p_style
);
FT_Face
p_face
=
0
;
FT_Face
p_face
=
0
;
if
(
!
p_run
->
p_face
)
if
(
!
p_run
->
p_face
)
{
{
p_face
=
LoadFace
(
p_filter
,
p_style
);
p_face
=
LoadFace
(
p_filter
,
p_style
,
i_live_size
);
if
(
!
p_face
)
if
(
!
p_face
)
{
{
/* Uses the default font and style */
p_face
=
p_sys
->
p_face
;
p_face
=
p_sys
->
p_face
;
p_style
=
p_sys
->
p_style
;
p_style
=
p_sys
->
p_
default_
style
;
p_run
->
p_style
=
p_style
;
p_run
->
p_style
=
p_style
;
}
}
p_run
->
p_face
=
p_face
;
p_run
->
p_face
=
p_face
;
...
@@ -798,7 +803,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
...
@@ -798,7 +803,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
double
f_outline_thickness
=
double
f_outline_thickness
=
var_InheritInteger
(
p_filter
,
"freetype-outline-thickness"
)
/
100
.
0
;
var_InheritInteger
(
p_filter
,
"freetype-outline-thickness"
)
/
100
.
0
;
f_outline_thickness
=
VLC_CLIP
(
f_outline_thickness
,
0
.
0
,
0
.
5
);
f_outline_thickness
=
VLC_CLIP
(
f_outline_thickness
,
0
.
0
,
0
.
5
);
int
i_radius
=
(
p_style
->
i_font
_size
<<
6
)
*
f_outline_thickness
;
int
i_radius
=
(
i_live
_size
<<
6
)
*
f_outline_thickness
;
FT_Stroker_Set
(
p_sys
->
p_stroker
,
FT_Stroker_Set
(
p_sys
->
p_stroker
,
i_radius
,
i_radius
,
FT_STROKER_LINECAP_ROUND
,
FT_STROKER_LINECAP_ROUND
,
...
@@ -853,7 +858,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
...
@@ -853,7 +858,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
p_bitmaps
->
p_outline
=
0
;
p_bitmaps
->
p_outline
=
0
;
}
}
if
(
p_
filter
->
p_sys
->
p_
style
->
i_shadow_alpha
!=
STYLE_ALPHA_TRANSPARENT
)
if
(
p_style
->
i_shadow_alpha
!=
STYLE_ALPHA_TRANSPARENT
)
p_bitmaps
->
p_shadow
=
p_bitmaps
->
p_outline
?
p_bitmaps
->
p_shadow
=
p_bitmaps
->
p_outline
?
p_bitmaps
->
p_outline
:
p_bitmaps
->
p_glyph
;
p_bitmaps
->
p_outline
:
p_bitmaps
->
p_glyph
;
...
@@ -863,6 +868,10 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
...
@@ -863,6 +868,10 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
p_bitmaps
->
i_y_advance
=
p_face
->
glyph
->
advance
.
y
;
p_bitmaps
->
i_y_advance
=
p_face
->
glyph
->
advance
.
y
;
}
}
}
}
int
i_max_run_advance_x
=
FT_FLOOR
(
FT_MulFix
(
p_face
->
max_advance_width
,
p_face
->
size
->
metrics
.
x_scale
)
);
if
(
i_max_run_advance_x
>
*
pi_max_advance_x
)
*
pi_max_advance_x
=
i_max_run_advance_x
;
}
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
@@ -899,6 +908,7 @@ static int LayoutLine( filter_t *p_filter,
...
@@ -899,6 +908,7 @@ static int LayoutLine( filter_t *p_filter,
FT_Vector
pen
=
{
.
x
=
0
,
.
y
=
0
};
FT_Vector
pen
=
{
.
x
=
0
,
.
y
=
0
};
int
i_line_index
=
0
;
int
i_line_index
=
0
;
int
i_font_size
=
0
;
int
i_font_width
=
0
;
int
i_font_width
=
0
;
int
i_font_max_advance_y
=
0
;
int
i_font_max_advance_y
=
0
;
int
i_ul_offset
=
0
;
int
i_ul_offset
=
0
;
...
@@ -940,8 +950,9 @@ static int LayoutLine( filter_t *p_filter,
...
@@ -940,8 +950,9 @@ static int LayoutLine( filter_t *p_filter,
p_style
=
p_run
->
p_style
;
p_style
=
p_run
->
p_style
;
p_face
=
p_run
->
p_face
;
p_face
=
p_run
->
p_face
;
i_font_size
=
ConvertToLiveSize
(
p_filter
,
p_style
);
i_font_width
=
p_style
->
i_style_flags
&
STYLE_HALFWIDTH
?
i_font_width
=
p_style
->
i_style_flags
&
STYLE_HALFWIDTH
?
p_style
->
i_font_size
/
2
:
p_style
->
i_font_size
;
i_font_size
/
2
:
i_font_size
;
}
}
FT_Vector
pen_new
=
{
FT_Vector
pen_new
=
{
...
@@ -950,7 +961,7 @@ static int LayoutLine( filter_t *p_filter,
...
@@ -950,7 +961,7 @@ static int LayoutLine( filter_t *p_filter,
};
};
FT_Vector
pen_shadow
=
{
FT_Vector
pen_shadow
=
{
.
x
=
pen_new
.
x
+
p_sys
->
f_shadow_vector_x
*
(
i_font_width
<<
6
),
.
x
=
pen_new
.
x
+
p_sys
->
f_shadow_vector_x
*
(
i_font_width
<<
6
),
.
y
=
pen_new
.
y
+
p_sys
->
f_shadow_vector_y
*
(
p_style
->
i_font_size
<<
6
)
.
y
=
pen_new
.
y
+
p_sys
->
f_shadow_vector_y
*
(
i_font_size
<<
6
)
};
};
if
(
p_bitmaps
->
p_shadow
)
if
(
p_bitmaps
->
p_shadow
)
...
@@ -1240,6 +1251,7 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
...
@@ -1240,6 +1251,7 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
paragraph_t
*
p_paragraph
=
0
;
paragraph_t
*
p_paragraph
=
0
;
int
i_paragraph_start
=
0
;
int
i_paragraph_start
=
0
;
int
i_max_height
=
0
;
int
i_max_height
=
0
;
int
i_max_advance_x
=
0
;
for
(
int
i
=
0
;
i
<=
i_len
;
++
i
)
for
(
int
i
=
0
;
i
<=
i_len
;
++
i
)
{
{
...
@@ -1275,20 +1287,20 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
...
@@ -1275,20 +1287,20 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
if
(
ShapeParagraphHarfBuzz
(
p_filter
,
&
p_paragraph
)
)
if
(
ShapeParagraphHarfBuzz
(
p_filter
,
&
p_paragraph
)
)
goto
error
;
goto
error
;
if
(
LoadGlyphs
(
p_filter
,
p_paragraph
,
true
,
false
)
)
if
(
LoadGlyphs
(
p_filter
,
p_paragraph
,
true
,
false
,
&
i_max_advance_x
)
)
goto
error
;
goto
error
;
#elif defined HAVE_FRIBIDI
#elif defined HAVE_FRIBIDI
if
(
ShapeParagraphFriBidi
(
p_filter
,
p_paragraph
)
)
if
(
ShapeParagraphFriBidi
(
p_filter
,
p_paragraph
)
)
goto
error
;
goto
error
;
if
(
LoadGlyphs
(
p_filter
,
p_paragraph
,
false
,
true
)
)
if
(
LoadGlyphs
(
p_filter
,
p_paragraph
,
false
,
true
,
&
i_max_advance_x
)
)
goto
error
;
goto
error
;
if
(
RemoveZeroWidthCharacters
(
p_paragraph
)
)
if
(
RemoveZeroWidthCharacters
(
p_paragraph
)
)
goto
error
;
goto
error
;
if
(
ZeroNsmAdvance
(
p_paragraph
)
)
if
(
ZeroNsmAdvance
(
p_paragraph
)
)
goto
error
;
goto
error
;
#else
#else
if
(
LoadGlyphs
(
p_filter
,
p_paragraph
,
false
,
true
)
)
if
(
LoadGlyphs
(
p_filter
,
p_paragraph
,
false
,
true
,
&
i_max_advance_x
)
)
goto
error
;
goto
error
;
#endif
#endif
...
@@ -1296,8 +1308,7 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
...
@@ -1296,8 +1308,7 @@ int LayoutText( filter_t *p_filter, line_desc_t **pp_lines,
* Set max line width to allow for outline and shadow glyphs,
* Set max line width to allow for outline and shadow glyphs,
* and any extra width caused by visual reordering
* and any extra width caused by visual reordering
*/
*/
int
i_max_width
=
(
int
)
p_filter
->
fmt_out
.
video
.
i_visible_width
int
i_max_width
=
(
int
)
p_filter
->
fmt_out
.
video
.
i_visible_width
-
i_max_advance_x
;
-
2
*
p_filter
->
p_sys
->
p_style
->
i_font_size
;
if
(
LayoutParagraph
(
p_filter
,
p_paragraph
,
if
(
LayoutParagraph
(
p_filter
,
p_paragraph
,
i_max_width
,
pp_line
,
b_grid
)
)
i_max_width
,
pp_line
,
b_grid
)
)
goto
error
;
goto
error
;
...
...
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