1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftinit.c */
|
|
|
|
/* */
|
2000-07-14 08:16:47 +02:00
|
|
|
/* FreeType initialization layer (body). */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2016-01-13 11:54:10 +01:00
|
|
|
/* Copyright 1996-2016 by */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-06-05 07:26:15 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* The purpose of this file is to implement the following two */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* functions: */
|
|
|
|
/* */
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
/* FT_Add_Default_Modules(): */
|
|
|
|
/* This function is used to add the set of default modules to a */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* fresh new library object. The set is taken from the header file */
|
Another adjustment to header locations.
This change is a result of a discussion thread on freetype-devel
http://lists.nongnu.org/archive/html/freetype-devel/2015-06/msg00041.html
Re-introduce the `freetype2' subdirectory for all FreeType header
files after installation, and rename the `freetype2' subdirectory in
the git repository to `freetype'.
* include/freetype2: Renamed to...
* include/freetype: This.
* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS): Updated.
Update creation of `ftconfig.h'.
Install generated `ftconfig.h'.
* Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.
* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/freetype2.in: Updated.
* builds/unix/freetype-config.in: Updated.
* builds/unix/configure.raw: Don't check for `rmdir'.
* builds/unix/unix-def.in (DELDIR): Use `rm -rf', which is portable
according to the autoconf info manual.
* builds/unix/install.mk (install, uninstall,
distclean_project_unix): Update and simplify.
* builds/wince/*, builds/windows/*: Updated.
* devel/ft2build.h, include/ft2build.h: Updated.
* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.
* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.
* docs/*: Updated.
2015-06-25 13:04:57 +02:00
|
|
|
/* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */
|
Fix Savannah bug #45097.
We no longer `pollute' the namespace of possible header file names;
instead we move `ft2build.h' up by one level so that it gets
installed in the default include directory (e.g.,
/usr/local/include). After this commit, only `ft2build.h' stays in
the compiler's include path.
No visible changes for the user who follows the standard FreeType
header inclusion rules.
* include/*: Move to ...
* include/freetype2/*: This directory, except `ft2build.h'.
* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS), Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.
* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/install.mk (install, uninstall),
builds/unix/freetype2.in: Updated.
* builds/unix/freetype-config.in: Updated.
Emit -I directory only if it is not `/usr/include'.
* builds/wince/*, builds/windows/*: Updated.
* devel/ft2build.h, include/ft2build.h: Updated.
* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.
* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.
* docs/*: Updated.
2015-06-22 06:35:23 +02:00
|
|
|
/* Build System' for more information. */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* */
|
2000-05-31 08:55:12 +02:00
|
|
|
/* FT_Init_FreeType(): */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* This function creates a system object for the current platform, */
|
|
|
|
/* builds a library out of it, then calls FT_Default_Drivers(). */
|
|
|
|
/* */
|
|
|
|
/* Note that even if FT_Init_FreeType() uses the implementation of the */
|
|
|
|
/* system object defined at build time, client applications are still */
|
|
|
|
/* able to provide their own `ftsystem.c'. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_CONFIG_CONFIG_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_MODULE_H
|
2009-04-05 16:59:26 +02:00
|
|
|
#include "basepic.h"
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-02 23:31:32 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
1999-12-17 00:11:37 +01:00
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_init
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
#ifndef FT_CONFIG_OPTION_PIC
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
#undef FT_USE_MODULE
|
2000-08-01 19:05:20 +02:00
|
|
|
#ifdef __cplusplus
|
FT_USE_MODULE declares things as:
extern const FT_Module_Class
(or similar for C++). However, the actual types of the variables
being declared are often different, e.g., FT_Driver_ClassRec or
FT_Renderer_Class. (Some are, indeed, FT_Module_Class.)
This works with most C compilers (since those structs begin with an
FT_Module_Class struct), but technically it's undefined behavior.
To quote the ISO/IEC 9899:TC2 final committee draft, section 6.2.7
paragraph 2:
All declarations that refer to the same object or function shall
have compatible type; otherwise, the behavior is undefined.
(And they are not compatible types.)
Most C compilers don't reject (or even detect!) code which has this
issue, but the GCC LTO development branch compiler does. (It
outputs the types of the objects while generating .o files, along
with a bunch of other information, then compares them when doing the
final link-time code generation pass.)
Patch from Savannah bug #25133.
* src/base/ftinit.c (FT_USE_MODULE): Include variable type.
* builds/amiga/include/freetype/config/ftmodule.h,
include/freetype/config/ftmodule.h, */module.mk: Updated to declare
pass correct types to FT_USE_MODULE.
2008-12-21 11:29:30 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) extern "C" const type x;
|
2000-08-01 19:05:20 +02:00
|
|
|
#else
|
FT_USE_MODULE declares things as:
extern const FT_Module_Class
(or similar for C++). However, the actual types of the variables
being declared are often different, e.g., FT_Driver_ClassRec or
FT_Renderer_Class. (Some are, indeed, FT_Module_Class.)
This works with most C compilers (since those structs begin with an
FT_Module_Class struct), but technically it's undefined behavior.
To quote the ISO/IEC 9899:TC2 final committee draft, section 6.2.7
paragraph 2:
All declarations that refer to the same object or function shall
have compatible type; otherwise, the behavior is undefined.
(And they are not compatible types.)
Most C compilers don't reject (or even detect!) code which has this
issue, but the GCC LTO development branch compiler does. (It
outputs the types of the objects while generating .o files, along
with a bunch of other information, then compares them when doing the
final link-time code generation pass.)
Patch from Savannah bug #25133.
* src/base/ftinit.c (FT_USE_MODULE): Include variable type.
* builds/amiga/include/freetype/config/ftmodule.h,
include/freetype/config/ftmodule.h, */module.mk: Updated to declare
pass correct types to FT_USE_MODULE.
2008-12-21 11:29:30 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) extern const type x;
|
2000-08-01 19:05:20 +02:00
|
|
|
#endif
|
2000-01-10 18:19:45 +01:00
|
|
|
|
* include/freetype/config/ft2build.h (FT2_ROOT, FT2_CONFIG_ROOT):
Removed. ANSI C doesn't (explicitly) allow macro expansion in
arguments using `##'.
(FT2_PUBLIC_FILE, FT2_CONFIG_FILE, FT2_INTERNAL_FILE): Use directory
names directly. Make them configurable. Use `##' to strip leading
and trailing spaces from arguments.
* builds/unix/ft2unix.h: Adapted.
* src/base/ftsystem.c (ft_alloc, ft_realloc, ft_free, ft_io_stream,
ft_close_stream): Use FT_CALLBACK_DEF.
* builds/unix/ftsystem.c: Use new header scheme.
(FT_Done_Memory): Use free() from FT_Memory structure.
* src/base/ftinit.c, src/base/ftmac.c: Header scheme fixes.
* include/freetype/config/ft2build.h (FT2_CONFIG_ROOT,
FT2_PUBLIC_FILE, FT2_CONFIG_FILE, FT2_INTERNAL_FILE,
FT_SOURCE_FILE): Use `##' operator to be really ANSI C compliant.
2000-12-12 23:28:12 +01:00
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
#undef FT_USE_MODULE
|
FT_USE_MODULE declares things as:
extern const FT_Module_Class
(or similar for C++). However, the actual types of the variables
being declared are often different, e.g., FT_Driver_ClassRec or
FT_Renderer_Class. (Some are, indeed, FT_Module_Class.)
This works with most C compilers (since those structs begin with an
FT_Module_Class struct), but technically it's undefined behavior.
To quote the ISO/IEC 9899:TC2 final committee draft, section 6.2.7
paragraph 2:
All declarations that refer to the same object or function shall
have compatible type; otherwise, the behavior is undefined.
(And they are not compatible types.)
Most C compilers don't reject (or even detect!) code which has this
issue, but the GCC LTO development branch compiler does. (It
outputs the types of the objects while generating .o files, along
with a bunch of other information, then compares them when doing the
final link-time code generation pass.)
Patch from Savannah bug #25133.
* src/base/ftinit.c (FT_USE_MODULE): Include variable type.
* builds/amiga/include/freetype/config/ftmodule.h,
include/freetype/config/ftmodule.h, */module.mk: Updated to declare
pass correct types to FT_USE_MODULE.
2008-12-21 11:29:30 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
static
|
|
|
|
const FT_Module_Class* const ft_default_modules[] =
|
2000-10-24 07:44:59 +02:00
|
|
|
{
|
* include/freetype/config/ft2build.h (FT2_ROOT, FT2_CONFIG_ROOT):
Removed. ANSI C doesn't (explicitly) allow macro expansion in
arguments using `##'.
(FT2_PUBLIC_FILE, FT2_CONFIG_FILE, FT2_INTERNAL_FILE): Use directory
names directly. Make them configurable. Use `##' to strip leading
and trailing spaces from arguments.
* builds/unix/ft2unix.h: Adapted.
* src/base/ftsystem.c (ft_alloc, ft_realloc, ft_free, ft_io_stream,
ft_close_stream): Use FT_CALLBACK_DEF.
* builds/unix/ftsystem.c: Use new header scheme.
(FT_Done_Memory): Use free() from FT_Memory structure.
* src/base/ftinit.c, src/base/ftmac.c: Header scheme fixes.
* include/freetype/config/ft2build.h (FT2_CONFIG_ROOT,
FT2_PUBLIC_FILE, FT2_CONFIG_FILE, FT2_INTERNAL_FILE,
FT_SOURCE_FILE): Use `##' operator to be really ANSI C compliant.
2000-12-12 23:28:12 +01:00
|
|
|
#include FT_CONFIG_MODULES_H
|
2000-01-10 18:19:45 +01:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
#else /* FT_CONFIG_OPTION_PIC */
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
#define FT_EXTERNC extern "C"
|
|
|
|
#else
|
|
|
|
#define FT_EXTERNC extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* declare the module's class creation/destruction functions */
|
|
|
|
#undef FT_USE_MODULE
|
2012-02-11 08:29:47 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) \
|
|
|
|
FT_EXTERNC FT_Error \
|
|
|
|
FT_Create_Class_ ## x( FT_Library library, \
|
|
|
|
FT_Module_Class* *output_class ); \
|
|
|
|
FT_EXTERNC void \
|
|
|
|
FT_Destroy_Class_ ## x( FT_Library library, \
|
|
|
|
FT_Module_Class* clazz );
|
2009-04-05 16:59:26 +02:00
|
|
|
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
|
|
|
/* count all module classes */
|
|
|
|
#undef FT_USE_MODULE
|
2012-02-11 08:29:47 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x,
|
2009-04-05 16:59:26 +02:00
|
|
|
|
2010-06-08 08:37:11 +02:00
|
|
|
enum
|
|
|
|
{
|
2009-04-05 16:59:26 +02:00
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
FT_NUM_MODULE_CLASSES
|
|
|
|
};
|
|
|
|
|
2012-01-16 18:00:24 +01:00
|
|
|
/* destroy all module classes */
|
2009-04-05 16:59:26 +02:00
|
|
|
#undef FT_USE_MODULE
|
2012-02-11 08:29:47 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) \
|
|
|
|
if ( classes[i] ) \
|
|
|
|
{ \
|
|
|
|
FT_Destroy_Class_ ## x( library, classes[i] ); \
|
|
|
|
} \
|
|
|
|
i++;
|
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
|
|
|
|
FT_BASE_DEF( void )
|
|
|
|
ft_destroy_default_module_classes( FT_Library library )
|
|
|
|
{
|
2012-02-11 08:29:47 +01:00
|
|
|
FT_Module_Class* *classes;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_UInt i;
|
|
|
|
BasePIC* pic_container = (BasePIC*)library->pic_container.base;
|
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
|
|
|
|
if ( !pic_container->default_module_classes )
|
|
|
|
return;
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
memory = library->memory;
|
2009-04-05 16:59:26 +02:00
|
|
|
classes = pic_container->default_module_classes;
|
2012-02-11 08:29:47 +01:00
|
|
|
i = 0;
|
2009-04-05 16:59:26 +02:00
|
|
|
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
|
|
|
FT_FREE( classes );
|
2015-04-11 05:45:11 +02:00
|
|
|
pic_container->default_module_classes = NULL;
|
2009-04-05 16:59:26 +02:00
|
|
|
}
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
/* initialize all module classes and the pointer table */
|
|
|
|
#undef FT_USE_MODULE
|
2012-02-11 08:29:47 +01:00
|
|
|
#define FT_USE_MODULE( type, x ) \
|
|
|
|
error = FT_Create_Class_ ## x( library, &clazz ); \
|
|
|
|
if ( error ) \
|
|
|
|
goto Exit; \
|
2009-04-05 16:59:26 +02:00
|
|
|
classes[i++] = clazz;
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
FT_BASE_DEF( FT_Error )
|
|
|
|
ft_create_default_module_classes( FT_Library library )
|
|
|
|
{
|
2012-02-11 08:29:47 +01:00
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory;
|
[FT_CONFIG_OPTION_PIC] Fix g++ 4.6.2 compiler warnings.
* include/freetype/internal/ftdriver.h (FT_DEFINE_DRIVER),
include/freetype/internal/ftobjs.h (FT_DEFINE_RENDERER,
FT_DEFINE_MODULE), include/freetype/internal/ftserv.h
(FT_DEFINE_SERVICEDESCREC1, FT_DEFINE_SERVICEDESCREC2,
FT_DEFINE_SERVICEDESCREC3, FT_DEFINE_SERVICEDESCREC4,
FT_DEFINE_SERVICEDESCREC5, FT_DEFINE_SERVICEDESCREC6),
src/autofit/afpic.c (autofit_module_class_pic_init),
src/base/basepic.c (ft_base_pic_init), src/base/ftinit.c
(ft_create_default_module_classes), src/cff/cffparse.c
(FT_Create_Class_cff_field_handlers), src/cff/cffpic.c
(cff_driver_class_pic_init), src/pshinter/pshpic.c
(pshinter_module_class_pic_init), src/psnames/pspic.c
(psnames_module_class_pic_init), src/raster/rastpic.c
(ft_raster1_renderer_class_pic_init), src/sfnt/sfntpic.c
(sfnt_module_class_pic_init), src/sfnt/ttcmap.c
(FT_Create_Class_tt_cmap_classes), src/smooth/ftspic.c
(ft_smooth_renderer_class_pic_init), src/truetype/ttpic.c
(tt_driver_class_pic_init): Initialize allocation variable.
2012-08-27 11:23:41 +02:00
|
|
|
FT_Module_Class* *classes = NULL;
|
2012-02-11 08:29:47 +01:00
|
|
|
FT_Module_Class* clazz;
|
|
|
|
FT_UInt i;
|
|
|
|
BasePIC* pic_container = (BasePIC*)library->pic_container.base;
|
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
|
2012-01-16 18:00:24 +01:00
|
|
|
memory = library->memory;
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2015-04-11 05:45:11 +02:00
|
|
|
pic_container->default_module_classes = NULL;
|
2009-04-05 16:59:26 +02:00
|
|
|
|
2013-01-24 13:33:06 +01:00
|
|
|
if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) *
|
2012-02-11 08:29:47 +01:00
|
|
|
( FT_NUM_MODULE_CLASSES + 1 ) ) )
|
2009-04-05 16:59:26 +02:00
|
|
|
return error;
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
/* initialize all pointers to 0, especially the last one */
|
2012-02-11 08:29:47 +01:00
|
|
|
for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ )
|
2015-04-11 05:45:11 +02:00
|
|
|
classes[i] = NULL;
|
|
|
|
classes[FT_NUM_MODULE_CLASSES] = NULL;
|
2009-04-05 16:59:26 +02:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
Exit:
|
|
|
|
if ( error )
|
|
|
|
ft_destroy_default_module_classes( library );
|
|
|
|
else
|
|
|
|
pic_container->default_module_classes = classes;
|
2009-04-05 16:59:26 +02:00
|
|
|
|
2012-01-16 18:00:24 +01:00
|
|
|
return error;
|
2009-04-05 16:59:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_PIC */
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
|
2005-12-25 10:15:09 +01:00
|
|
|
/* documentation is in ftmodapi.h */
|
2000-11-07 18:21:11 +01:00
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FT_Add_Default_Modules( FT_Library library )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-10-24 07:44:59 +02:00
|
|
|
FT_Error error;
|
|
|
|
const FT_Module_Class* const* cur;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-29 05:14:25 +02:00
|
|
|
|
2012-02-11 08:29:47 +01:00
|
|
|
/* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */
|
2012-01-14 17:29:41 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_PIC
|
|
|
|
if ( !library )
|
|
|
|
return;
|
|
|
|
#endif
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2012-01-14 17:29:41 +01:00
|
|
|
/* GCC 4.6 warns the type difference:
|
|
|
|
* FT_Module_Class** != const FT_Module_Class* const*
|
|
|
|
*/
|
2012-02-11 08:29:47 +01:00
|
|
|
cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET;
|
2012-01-14 17:29:41 +01:00
|
|
|
|
|
|
|
/* test for valid `library' delayed to FT_Add_Module() */
|
2000-01-10 18:19:45 +01:00
|
|
|
while ( *cur )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
- MAJOR INTERNAL REDESIGN:
A lot of internal modifications have been performed lately on the
source in order to provide the following enhancements:
- more generic module support:
The FT_Module type is now defined to represent a handle to a given
module. The file <freetype/ftmodule.h> contains the FT_Module_Class
definition, as well as the module-loading public API
The FT_Driver type is still defined, and still represents a pointer
to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module,
FT_Get_Driver by FT_Get_Module, etc..
- support for generic glyph image types:
The FT_Renderer type is a pointer to a module used to perform various
operations on glyph image.
Each renderer is capable of handling images in a single format
(e.g. ft_glyph_format_outline). Its functions are used to:
- transform an glyph image
- render a glyph image into a bitmap
- return the control box (dimensions) of a given glyph image
The scan converters "ftraster.c" and "ftgrays.c" have been moved
to the new directory "src/renderer", and are used to provide two
default renderer modules.
One corresponds to the "standard" scan-converter, the other to the
"smooth" one.
The current renderer can be set through the new function
FT_Set_Renderer.
The old raster-related function FT_Set_Raster, FT_Get_Raster and
FT_Set_Raster_Mode have now disappeared, in favor of the new:
FT_Get_Renderer
FT_Set_Renderer
see the file <freetype/ftrender.h> for more details..
These changes were necessary to properly support different scalable
formats in the future, like bi-color glyphs, etc..
- glyph loader object:
A new internal object, called a 'glyph loader' has been introduced
in the base layer. It is used by all scalable format font drivers
to load glyphs and composites.
This object has been created to reduce the code size of each driver,
as each one of them basically re-implemented its functionality.
See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for
more information..
- FT_GlyphSlot had new fields:
In order to support extended features (see below), the FT_GlyphSlot
structure has a few new fields:
linearHoriAdvance: this field gives the linearly scaled (i.e.
scaled but unhinted) advance width for the glyph,
expressed as a 16.16 fixed pixel value. This
is useful to perform WYSIWYG text.
linearVertAdvance: this field gives the linearly scaled advance
height for the glyph (relevant in vertical glyph
layouts only). This is useful to perform
WYSIWYG text.
Note that the two above field replace the removed "metrics2" field
in the glyph slot.
advance: this field is a vector that gives the transformed
advance for the glyph. By default, it corresponds
to the advance width, unless FT_LOAD_VERTICAL_LAYOUT
was specified when calling FT_Load_Glyph or FT_Load_Char
bitmap_left: this field gives the distance in integer pixels from
the current pen position to the left-most pixel of
a glyph image WHEN IT IS A BITMAP. It is only valid
when the "format" field is set to
"ft_glyph_format_bitmap", for example, after calling
the new function FT_Render_Glyph.
bitmap_top: this field gives the distance in integer pixels from
the current pen position (located on the baseline) to
the top-most pixel of the glyph image WHEN IT IS A
BITMAP. Positive values correspond to upwards Y.
loader: this is a new private field for the glyph slot. Client
applications should not touch it..
- support for transforms and direct rendering in FT_Load_Glyph:
Most of the functionality found in <freetype/ftglyph.h> has been
moved to the core library. Hence, the following:
- a transform can be specified for a face through FT_Set_Transform.
this transform is applied by FT_Load_Glyph to scalable glyph images
(i.e. NOT TO BITMAPS) before the function returns, unless the
bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags..
- once a glyph image has been loaded, it can be directly converted to
a bitmap by using the new FT_Render_Glyph function. Note that this
function takes the glyph image from the glyph slot, and converts
it to a bitmap whose properties are returned in "face.glyph.bitmap",
"face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original
native image might be lost after the conversion.
- when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph
and FT_Load_Char functions will call FT_Render_Glyph automatically
when needed.
2000-06-22 02:17:42 +02:00
|
|
|
error = FT_Add_Module( library, *cur );
|
1999-12-17 00:11:37 +01:00
|
|
|
/* notify errors, but don't stop */
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( error )
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_TRACE0(( "FT_Add_Default_Module:"
|
|
|
|
" Cannot install `%s', error = 0x%x\n",
|
|
|
|
(*cur)->module_name, error ));
|
1999-12-29 01:22:24 +01:00
|
|
|
cur++;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-07-11 00:12:11 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
|
|
|
|
|
|
|
|
#define MAX_LENGTH 128
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set default properties derived from the `FREETYPE_PROPERTIES'
|
|
|
|
* environment variable.
|
|
|
|
*
|
|
|
|
* `FREETYPE_PROPERTIES' has the following syntax form (broken here into
|
|
|
|
* multiple lines for better readability)
|
|
|
|
*
|
|
|
|
* <optional whitespace>
|
|
|
|
* <module-name1> ':'
|
|
|
|
* <property-name1> '=' <property-value1>
|
|
|
|
* <whitespace>
|
|
|
|
* <module-name2> ':'
|
|
|
|
* <property-name2> '=' <property-value2>
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
|
|
|
|
* cff:no-stem-darkening=1 \
|
|
|
|
* autofitter:warping=1
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
ft_set_default_properties( FT_Library library )
|
|
|
|
{
|
|
|
|
const char* env;
|
|
|
|
const char* p;
|
|
|
|
const char* q;
|
|
|
|
|
|
|
|
char module_name[MAX_LENGTH + 1];
|
|
|
|
char property_name[MAX_LENGTH + 1];
|
|
|
|
char property_value[MAX_LENGTH + 1];
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
env = ft_getenv( "FREETYPE_PROPERTIES" );
|
|
|
|
if ( !env )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for ( p = env; *p; p++ )
|
|
|
|
{
|
|
|
|
/* skip leading whitespace and separators */
|
|
|
|
if ( *p == ' ' || *p == '\t' )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* read module name, followed by `:' */
|
|
|
|
q = p;
|
|
|
|
for ( i = 0; i < MAX_LENGTH; i++ )
|
|
|
|
{
|
|
|
|
if ( !*p || *p == ':' )
|
|
|
|
break;
|
|
|
|
module_name[i] = *p++;
|
|
|
|
}
|
|
|
|
module_name[i] = '\0';
|
|
|
|
|
|
|
|
if ( !*p || *p != ':' || p == q )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* read property name, followed by `=' */
|
|
|
|
q = ++p;
|
|
|
|
for ( i = 0; i < MAX_LENGTH; i++ )
|
|
|
|
{
|
|
|
|
if ( !*p || *p == '=' )
|
|
|
|
break;
|
|
|
|
property_name[i] = *p++;
|
|
|
|
}
|
|
|
|
property_name[i] = '\0';
|
|
|
|
|
|
|
|
if ( !*p || *p != '=' || p == q )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* read property value, followed by whitespace (if any) */
|
|
|
|
q = ++p;
|
|
|
|
for ( i = 0; i < MAX_LENGTH; i++ )
|
|
|
|
{
|
|
|
|
if ( !*p || *p == ' ' || *p == '\t' )
|
|
|
|
break;
|
|
|
|
property_value[i] = *p++;
|
|
|
|
}
|
|
|
|
property_value[i] = '\0';
|
|
|
|
|
|
|
|
if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* we completely ignore errors */
|
|
|
|
ft_property_string_set( library,
|
|
|
|
module_name,
|
|
|
|
property_name,
|
|
|
|
property_value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static void
|
|
|
|
ft_set_default_properties( FT_Library library )
|
|
|
|
{
|
|
|
|
FT_UNUSED( library );
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Init_FreeType( FT_Library *alibrary )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory;
|
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
/* check of `alibrary' delayed to `FT_New_Library' */
|
|
|
|
|
2000-05-31 08:55:12 +02:00
|
|
|
/* First of all, allocate a new system object -- this function is part */
|
2000-01-10 18:19:45 +01:00
|
|
|
/* of the system-specific component, i.e. `ftsystem.c'. */
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
memory = FT_New_Memory();
|
2000-01-10 18:19:45 +01:00
|
|
|
if ( !memory )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2000-06-29 05:14:25 +02:00
|
|
|
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unimplemented_Feature );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-06-29 05:14:25 +02:00
|
|
|
/* build a library out of it, then fill it with the set of */
|
|
|
|
/* default drivers. */
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2000-11-07 07:30:29 +01:00
|
|
|
error = FT_New_Library( memory, alibrary );
|
2007-03-06 13:06:56 +01:00
|
|
|
if ( error )
|
|
|
|
FT_Done_Memory( memory );
|
2007-03-05 19:23:25 +01:00
|
|
|
else
|
2000-11-07 07:30:29 +01:00
|
|
|
FT_Add_Default_Modules( *alibrary );
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2016-07-11 00:12:11 +02:00
|
|
|
ft_set_default_properties( *alibrary );
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Done_FreeType( FT_Library library )
|
2000-07-27 23:40:22 +02:00
|
|
|
{
|
2014-11-26 21:59:21 +01:00
|
|
|
FT_Memory memory;
|
2000-07-27 23:40:22 +02:00
|
|
|
|
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
if ( !library )
|
|
|
|
return FT_THROW( Invalid_Library_Handle );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2014-11-26 21:59:21 +01:00
|
|
|
memory = library->memory;
|
|
|
|
|
|
|
|
/* Discard the library object */
|
|
|
|
FT_Done_Library( library );
|
|
|
|
|
|
|
|
/* discard memory manager */
|
|
|
|
FT_Done_Memory( memory );
|
2000-07-27 23:40:22 +02:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* END */
|