Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
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-1.1
Commits
82dfc1b3
Commit
82dfc1b3
authored
Nov 22, 2009
by
JP Dinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Skins2: Invent ft2_strerror() to improve freetype2 error reporting.
parent
5988891f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
36 deletions
+144
-36
modules/gui/skins2/Modules.am
modules/gui/skins2/Modules.am
+2
-0
modules/gui/skins2/src/ft2_err.c
modules/gui/skins2/src/ft2_err.c
+68
-0
modules/gui/skins2/src/ft2_err.h
modules/gui/skins2/src/ft2_err.h
+34
-0
modules/gui/skins2/src/ft2_font.cpp
modules/gui/skins2/src/ft2_font.cpp
+38
-35
modules/gui/skins2/src/ft2_font.hpp
modules/gui/skins2/src/ft2_font.hpp
+2
-1
No files found.
modules/gui/skins2/Modules.am
View file @
82dfc1b3
...
...
@@ -113,6 +113,8 @@ SOURCES_skins2 = \
src/ft2_bitmap.hpp \
src/ft2_font.cpp \
src/ft2_font.hpp \
src/ft2_err.c \
src/ft2_err.h \
src/generic_bitmap.cpp \
src/generic_bitmap.hpp \
src/generic_font.hpp \
...
...
modules/gui/skins2/src/ft2_err.c
0 → 100644
View file @
82dfc1b3
/*****************************************************************************
* ft2_err.c: Provide a strerror() type function for freetype2
*****************************************************************************
* Copyright (C) 2009 the VideoLAN team
*
* Authors: JP Dinger <jpd (at) videolan (dot) org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <ft2build.h>
#include "ft2_err.h"
/* Warning: This file includes the error definitions header twice.
* Further, freetype2 errors are not contiguous, so instead of a sparse
* array we first look up the actual entry by linear search and only
* then return the actual error string. It could be improved to binary
* search (assuming the freetype2 source stays sorted), but error
* reporting shouldn't need to be efficient.
*/
#define FT_NOERRORDEF_( sym, num, str ) num,
#define FT_ERRORDEF_( sym, num, str ) num,
static
const
unsigned
short
ft2_errorindex
[]
=
{
#include FT_ERROR_DEFINITIONS_H
};
#undef FT_NOERRORDEF_
#undef FT_ERRORDEF_
#define FT_NOERRORDEF_( sym, num, str ) str,
#define FT_ERRORDEF_( sym, num, str ) str,
static
const
char
*
ft2_errorstrings
[]
=
{
#include FT_ERROR_DEFINITIONS_H
};
#undef FT_NOERRORDEF_
#undef FT_ERRORDEF_
enum
{
ft2_num_errors
=
sizeof
(
ft2_errorindex
)
/
sizeof
(
*
ft2_errorindex
)
};
const
char
*
ft2_strerror
(
unsigned
err
)
{
unsigned
i
;
for
(
i
=
0
;
i
<
ft2_num_errors
;
++
i
)
if
(
err
==
ft2_errorindex
[
i
]
)
break
;
return
i
<
ft2_num_errors
?
ft2_errorstrings
[
i
]
:
"An error freetype2 neglected to specify"
;
}
modules/gui/skins2/src/ft2_err.h
0 → 100644
View file @
82dfc1b3
/*****************************************************************************
* ft2_err.h: turn freetype2 errors into strings
*****************************************************************************
* Copyright (C) 2009 the VideoLAN team
*
* Authors: JP Dinger <jpd (at) videolan (dot) org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef FT2_ERR_H
#define FT2_ERR_H
#ifdef __cplusplus
extern
"C"
{
#endif
const
char
*
ft2_strerror
(
unsigned
err
);
#ifdef __cplusplus
}
#endif
#endif
modules/gui/skins2/src/ft2_font.cpp
View file @
82dfc1b3
...
...
@@ -22,8 +22,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <errno.h>
#include "ft2_font.hpp"
#include "ft2_bitmap.hpp"
#include "ft2_err.h"
#include "../utils/ustring.hpp"
#ifdef HAVE_FRIBIDI
...
...
@@ -40,59 +42,58 @@ FT2Font::FT2Font( intf_thread_t *pIntf, const string &rName, int size ):
FT2Font
::~
FT2Font
()
{
// Clear the glyph cache
GlyphMap_t
::
iterator
iter
;
for
(
iter
=
m_glyphCache
.
begin
();
iter
!=
m_glyphCache
.
end
();
++
iter
)
{
FT_Done_Glyph
(
(
*
iter
).
second
.
m_glyph
);
}
if
(
m_face
)
{
FT_Done_Face
(
m_face
);
}
if
(
m_lib
)
{
FT_Done_FreeType
(
m_lib
);
}
free
(
m_buffer
);
if
(
m_face
)
FT_Done_Face
(
m_face
);
if
(
m_lib
)
FT_Done_FreeType
(
m_lib
);
delete
[]
m_buffer
;
}
bool
FT2Font
::
init
()
{
int
err
;
unsigned
err
;
// Initialize libfreetype
if
(
FT_Init_FreeType
(
&
m_lib
)
)
if
(
err
=
FT_Init_FreeType
(
&
m_lib
)
)
{
msg_Err
(
getIntf
(),
"failed to initialize freetype"
);
msg_Err
(
getIntf
(),
"failed to initialize freetype (%s)"
,
ft2_strerror
(
err
)
);
return
false
;
}
// Open the font
FILE
*
file
=
fopen
(
m_name
.
c_str
(),
"rb"
);
if
(
file
)
if
(
!
file
)
{
msg_Dbg
(
getIntf
(),
"loading font %s"
,
m_name
.
c_str
()
);
}
else
{
msg_Dbg
(
getIntf
(),
"unable to open the font %s"
,
m_name
.
c_str
()
);
msg_Dbg
(
getIntf
(),
"failed to open font %s (%s)"
,
m_name
.
c_str
(),
strerror
(
errno
)
);
return
false
;
}
// Get the file size
msg_Dbg
(
getIntf
(),
"loading font %s"
,
m_name
.
c_str
()
);
fseek
(
file
,
0
,
SEEK_END
);
int
size
=
ftell
(
file
);
long
size
=
ftell
(
file
);
rewind
(
file
);
// Allocate the buffer
m_buffer
=
malloc
(
size
);
if
(
-
1
==
size
)
{
msg_Dbg
(
getIntf
(),
"fseek loading font %s (%s)"
,
m_name
.
c_str
(),
strerror
(
errno
)
);
fclose
(
file
);
return
false
;
}
m_buffer
=
new
(
std
::
nothrow
)
char
[
size
];
if
(
!
m_buffer
)
{
fclose
(
file
);
return
false
;
// Read the font data
}
fread
(
m_buffer
,
size
,
1
,
file
);
fclose
(
file
);
// Load the font from the buffer
err
=
FT_New_Memory_Face
(
m_lib
,
(
const
FT_Byte
*
)
m_buffer
,
size
,
0
,
&
m_face
);
if
(
err
==
FT_Err_Unknown_File_Format
)
...
...
@@ -102,22 +103,24 @@ bool FT2Font::init()
}
else
if
(
err
)
{
msg_Err
(
getIntf
(),
"error opening font (%s)"
,
m_name
.
c_str
()
);
msg_Err
(
getIntf
(),
"error opening font %s (%s)"
,
m_name
.
c_str
(),
ft2_strerror
(
err
)
);
return
false
;
}
// Select the charset
if
(
FT_Select_Charmap
(
m_face
,
ft_encoding_unicode
)
)
if
(
err
=
FT_Select_Charmap
(
m_face
,
ft_encoding_unicode
)
)
{
msg_Err
(
getIntf
(),
"font has no UNICODE table (%s)"
,
m_name
.
c_str
()
);
msg_Err
(
getIntf
(),
"font %s has no UNICODE table (%s)"
,
m_name
.
c_str
(),
ft2_strerror
(
err
)
);
return
false
;
}
// Set the pixel size
if
(
FT_Set_Pixel_Sizes
(
m_face
,
0
,
m_size
)
)
if
(
err
=
FT_Set_Pixel_Sizes
(
m_face
,
0
,
m_size
)
)
{
msg_Warn
(
getIntf
(),
"cannot set a pixel size of %d
(%s)"
,
m_size
,
m_
name
.
c_str
(
)
);
msg_Warn
(
getIntf
(),
"cannot set a pixel size of %d
for %s (%s)"
,
m_
size
,
m_name
.
c_str
(),
ft2_strerror
(
err
)
);
}
// Get the font metrucs
...
...
modules/gui/skins2/src/ft2_font.hpp
View file @
82dfc1b3
...
...
@@ -67,7 +67,7 @@ private:
/// File name
const
string
m_name
;
/// Buffer to store the font
void
*
m_buffer
;
char
*
m_buffer
;
/// Pixel size of the font
int
m_size
;
/// Handle to FT library
...
...
@@ -81,6 +81,7 @@ private:
/// Get the glyph corresponding to the given code
Glyph_t
&
getGlyph
(
uint32_t
code
)
const
;
bool
error
(
unsigned
err
,
const
char
*
msg
);
}
;
...
...
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