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
634111a2
Commit
634111a2
authored
Sep 26, 2013
by
Jean-Baptiste Kempf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Freetype: split freetype init from Create
Signed-off-by:
Jean-Baptiste Kempf
<
jb@videolan.org
>
parent
fb9d7879
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
42 deletions
+61
-42
modules/text_renderer/freetype.c
modules/text_renderer/freetype.c
+61
-42
No files found.
modules/text_renderer/freetype.c
View file @
634111a2
...
@@ -2195,6 +2195,65 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
...
@@ -2195,6 +2195,65 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
*****************************************************************************
*****************************************************************************
* This function allocates and initializes a Clone vout method.
* This function allocates and initializes a Clone vout method.
*****************************************************************************/
*****************************************************************************/
static
int
Init_FT
(
vlc_object_t
*
p_this
,
const
char
*
psz_fontfile
,
const
int
fontindex
,
const
float
f_outline_thickness
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
/* */
int
i_error
=
FT_Init_FreeType
(
&
p_sys
->
p_library
);
if
(
i_error
)
{
msg_Err
(
p_filter
,
"couldn't initialize freetype"
);
goto
error
;
}
i_error
=
FT_New_Face
(
p_sys
->
p_library
,
psz_fontfile
?
psz_fontfile
:
""
,
fontindex
,
&
p_sys
->
p_face
);
if
(
i_error
==
FT_Err_Unknown_File_Format
)
{
msg_Err
(
p_filter
,
"file %s have unknown format"
,
psz_fontfile
?
psz_fontfile
:
"(null)"
);
goto
error
;
}
else
if
(
i_error
)
{
msg_Err
(
p_filter
,
"failed to load font file %s"
,
psz_fontfile
?
psz_fontfile
:
"(null)"
);
goto
error
;
}
i_error
=
FT_Select_Charmap
(
p_sys
->
p_face
,
ft_encoding_unicode
);
if
(
i_error
)
{
msg_Err
(
p_filter
,
"font has no unicode translation table"
);
goto
error
;
}
if
(
SetFontSize
(
p_filter
,
0
)
!=
VLC_SUCCESS
)
goto
error
;
p_sys
->
p_stroker
=
NULL
;
if
(
f_outline_thickness
>
0
.
001
)
{
i_error
=
FT_Stroker_New
(
p_sys
->
p_library
,
&
p_sys
->
p_stroker
);
if
(
i_error
)
msg_Err
(
p_filter
,
"Failed to create stroker for outlining"
);
}
return
VLC_SUCCESS
;
error:
if
(
p_sys
->
p_face
)
FT_Done_Face
(
p_sys
->
p_face
);
if
(
p_sys
->
p_library
)
FT_Done_FreeType
(
p_sys
->
p_library
);
return
VLC_EGENERIC
;
}
static
int
Create
(
vlc_object_t
*
p_this
)
static
int
Create
(
vlc_object_t
*
p_this
)
{
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
...
@@ -2203,7 +2262,7 @@ static int Create( vlc_object_t *p_this )
...
@@ -2203,7 +2262,7 @@ static int Create( vlc_object_t *p_this )
char
*
psz_fontname
=
NULL
;
char
*
psz_fontname
=
NULL
;
char
*
psz_monofontfile
=
NULL
;
char
*
psz_monofontfile
=
NULL
;
char
*
psz_monofontfamily
=
NULL
;
char
*
psz_monofontfamily
=
NULL
;
int
i_error
=
0
,
fontindex
=
0
,
monofontindex
=
0
;
int
fontindex
=
0
,
monofontindex
=
0
;
/* Allocate structure */
/* Allocate structure */
p_filter
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
p_filter
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
...
@@ -2314,46 +2373,8 @@ static int Create( vlc_object_t *p_this )
...
@@ -2314,46 +2373,8 @@ static int Create( vlc_object_t *p_this )
#endif
#endif
p_sys
->
style
.
psz_monofontname
=
psz_monofontfamily
;
p_sys
->
style
.
psz_monofontname
=
psz_monofontfamily
;
/* */
if
(
Init_FT
(
p_this
,
psz_fontname
,
fontindex
,
f_outline_thickness
)
!=
VLC_SUCCESS
)
i_error
=
FT_Init_FreeType
(
&
p_sys
->
p_library
);
if
(
i_error
)
{
msg_Err
(
p_filter
,
"couldn't initialize freetype"
);
goto
error
;
goto
error
;
}
i_error
=
FT_New_Face
(
p_sys
->
p_library
,
psz_fontfile
?
psz_fontfile
:
""
,
fontindex
,
&
p_sys
->
p_face
);
if
(
i_error
==
FT_Err_Unknown_File_Format
)
{
msg_Err
(
p_filter
,
"file %s have unknown format"
,
psz_fontfile
?
psz_fontfile
:
"(null)"
);
goto
error
;
}
else
if
(
i_error
)
{
msg_Err
(
p_filter
,
"failed to load font file %s"
,
psz_fontfile
?
psz_fontfile
:
"(null)"
);
goto
error
;
}
i_error
=
FT_Select_Charmap
(
p_sys
->
p_face
,
ft_encoding_unicode
);
if
(
i_error
)
{
msg_Err
(
p_filter
,
"font has no unicode translation table"
);
goto
error
;
}
if
(
SetFontSize
(
p_filter
,
0
)
!=
VLC_SUCCESS
)
goto
error
;
p_sys
->
p_stroker
=
NULL
;
if
(
f_outline_thickness
>
0
.
001
)
{
i_error
=
FT_Stroker_New
(
p_sys
->
p_library
,
&
p_sys
->
p_stroker
);
if
(
i_error
)
msg_Err
(
p_filter
,
"Failed to create stroker for outlining"
);
}
p_sys
->
pp_font_attachments
=
NULL
;
p_sys
->
pp_font_attachments
=
NULL
;
p_sys
->
i_font_attachments
=
0
;
p_sys
->
i_font_attachments
=
0
;
...
@@ -2371,8 +2392,6 @@ static int Create( vlc_object_t *p_this )
...
@@ -2371,8 +2392,6 @@ static int Create( vlc_object_t *p_this )
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
error:
if
(
p_sys
->
p_face
)
FT_Done_Face
(
p_sys
->
p_face
);
if
(
p_sys
->
p_library
)
FT_Done_FreeType
(
p_sys
->
p_library
);
#ifdef HAVE_STYLES
#ifdef HAVE_STYLES
free
(
psz_fontfile
);
free
(
psz_fontfile
);
free
(
psz_monofontfile
);
free
(
psz_monofontfile
);
...
...
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