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
|
|
|
/* */
|
2009-06-25 16:46:39 +02:00
|
|
|
/* Copyright 1996-2001, 2002, 2005, 2007, 2009 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 */
|
|
|
|
/* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */
|
|
|
|
/* 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
|
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
#ifndef FT_CONFIG_OPTION_PIC
|
|
|
|
|
- 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
|
|
|
|
|
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
|
|
|
#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
|
|
|
|
};
|
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
#else /* FT_CONFIG_OPTION_PIC */
|
|
|
|
|
|
|
|
#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
|
|
|
|
#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 );
|
|
|
|
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
|
|
|
|
|
|
|
/* count all module classes */
|
|
|
|
#undef FT_USE_MODULE
|
|
|
|
#define FT_USE_MODULE( type, x ) MODULE_CLASS_##x,
|
|
|
|
|
|
|
|
enum {
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
FT_NUM_MODULE_CLASSES
|
|
|
|
};
|
|
|
|
|
|
|
|
/* destroy all module classes */
|
|
|
|
#undef FT_USE_MODULE
|
|
|
|
#define FT_USE_MODULE( type, x ) \
|
|
|
|
if ( classes[i] ) { FT_Destroy_Class_##x(library, classes[i]); } \
|
|
|
|
i++; \
|
|
|
|
|
|
|
|
FT_BASE_DEF( void )
|
|
|
|
ft_destroy_default_module_classes( FT_Library library )
|
|
|
|
{
|
|
|
|
FT_Module_Class** classes;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_UInt i;
|
|
|
|
BasePIC* pic_container = library->pic_container.base;
|
|
|
|
|
|
|
|
if ( !pic_container->default_module_classes )
|
|
|
|
return;
|
|
|
|
|
|
|
|
memory = library->memory;
|
|
|
|
classes = pic_container->default_module_classes;
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
|
|
|
FT_FREE( classes );
|
|
|
|
pic_container->default_module_classes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initialize all module classes and the pointer table */
|
|
|
|
#undef FT_USE_MODULE
|
|
|
|
#define FT_USE_MODULE( type, x ) \
|
|
|
|
error = FT_Create_Class_##x(library, &clazz); \
|
|
|
|
if (error) goto Exit; \
|
|
|
|
classes[i++] = clazz;
|
|
|
|
|
|
|
|
FT_BASE_DEF( FT_Error )
|
|
|
|
ft_create_default_module_classes( FT_Library library )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory;
|
|
|
|
FT_Module_Class** classes;
|
|
|
|
FT_Module_Class* clazz;
|
|
|
|
FT_UInt i;
|
|
|
|
BasePIC* pic_container = library->pic_container.base;
|
|
|
|
|
|
|
|
memory = library->memory;
|
|
|
|
pic_container->default_module_classes = 0;
|
|
|
|
|
|
|
|
if ( FT_ALLOC(classes, sizeof(FT_Module_Class*) * (FT_NUM_MODULE_CLASSES + 1) ) )
|
|
|
|
return error;
|
|
|
|
/* initialize all pointers to 0, especially the last one */
|
|
|
|
for (i = 0; i < FT_NUM_MODULE_CLASSES; i++)
|
|
|
|
classes[i] = 0;
|
|
|
|
classes[FT_NUM_MODULE_CLASSES] = 0;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
#include FT_CONFIG_MODULES_H
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if (error) ft_destroy_default_module_classes( library );
|
|
|
|
else pic_container->default_module_classes = classes;
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_PIC */
|
1999-12-17 00:11:37 +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
|
|
|
|
|
|
|
/* test for valid `library' delayed to FT_Add_Module() */
|
2000-01-10 18:19:45 +01:00
|
|
|
|
2009-04-05 16:59:26 +02:00
|
|
|
cur = FT_DEFAULT_MODULES_GET;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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" ));
|
1999-12-17 00:11:37 +01:00
|
|
|
return FT_Err_Unimplemented_Feature;
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
{
|
2000-07-28 01:29:08 +02:00
|
|
|
if ( library )
|
2000-07-27 23:40:22 +02:00
|
|
|
{
|
|
|
|
FT_Memory memory = library->memory;
|
|
|
|
|
|
|
|
|
|
|
|
/* Discard the library object */
|
|
|
|
FT_Done_Library( library );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-27 23:40:22 +02:00
|
|
|
/* discard memory manager */
|
|
|
|
FT_Done_Memory( memory );
|
|
|
|
}
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
/* END */
|