2000-06-16 08:49:56 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* cidgload.c */
|
|
|
|
/* */
|
|
|
|
/* CID-keyed Type1 Glyph Loader (body). */
|
|
|
|
/* */
|
|
|
|
/* Copyright 1996-2000 by */
|
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
|
|
|
/* 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-06-01 05:27:48 +02:00
|
|
|
|
A complete revision of FreeType 2's GNU makefiles (of the library):
Tons of unnecessary stuff have been removed; only the essential rules
have been retained.
The source files now depend on all header files in include/freetype,
include/freetype/config, and include/freetype/internal. This is not
optimal, I know, and I'll try to improve this, but it is better than
before (namely no dependencies on `internal').
FTDEBUG_SRC has been added (similar to FTSYS_SRC) -- I don't know
exactly whether this is really useful, but it doesn't harm.
There is now more documentation in the makefiles itself.
io-frames.html: Use of <th>, <code>, and <var> for better tagging.
Reactivating of FT_DEBUG_LEVEL_xxx macros.
Added a lot of #include directives to make `multi' builds possible -- note
that currently the modules cid, t1, and t1z have clashing structures and
functions which means that you can only use one of these three modules for a
multi build.
Added some missing function declarations to (local) header files.
Renamed some T1_Open_Face() to CID_Open_Face() in the cid module -- a lot
of other functions should be renamed also...
Replaced many FT_xxx stuff with T1_xxx in t1z driver -- this isn't finished
yet...
Fixed FT_Free() to allow a NULL pointer without an assertion (this has
always been a valid assumption in FreeType, at least in FT 1.x).
A lot of other, minor fixes (mostly documentation).
2000-06-11 05:46:57 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#ifdef FT_FLAT_COMPILE
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#include "cidload.h"
|
|
|
|
#include "cidgload.h"
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#else
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#include <cid/cidload.h>
|
|
|
|
#include <cid/cidgload.h>
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#endif
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
#include <freetype/internal/ftdebug.h>
|
|
|
|
#include <freetype/internal/ftstream.h>
|
2000-07-01 01:12:55 +02:00
|
|
|
#include <freetype/ftoutln.h>
|
2000-06-16 08:49:56 +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. */
|
|
|
|
/* */
|
2000-06-01 05:27:48 +02:00
|
|
|
#undef FT_COMPONENT
|
2000-06-16 08:49:56 +02:00
|
|
|
#define FT_COMPONENT trace_cidgload
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
static
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Error cid_load_glyph( T1_Decoder* decoder,
|
|
|
|
FT_UInt glyph_index )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
CID_Face face = (CID_Face)decoder->builder.face;
|
|
|
|
CID_Info* cid = &face->cid;
|
|
|
|
FT_Byte* p;
|
|
|
|
FT_UInt entry_len = cid->fd_bytes + cid->gd_bytes;
|
|
|
|
FT_UInt fd_select;
|
|
|
|
FT_ULong off1, glyph_len;
|
|
|
|
FT_Stream stream = face->root.stream;
|
|
|
|
FT_Error error = 0;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* read the CID font dict index and charstring offset from the CIDMap */
|
|
|
|
if ( FILE_Seek( cid->data_offset + cid->cidmap_offset +
|
|
|
|
glyph_index * entry_len) ||
|
|
|
|
ACCESS_Frame( 2 * entry_len ) )
|
|
|
|
goto Exit;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
p = (FT_Byte*)stream->cursor;
|
|
|
|
fd_select = (FT_UInt) cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
|
|
|
|
off1 = (FT_ULong)cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
|
|
|
|
p += cid->fd_bytes;
|
|
|
|
glyph_len = cid_get_offset( &p, (FT_Byte)cid->gd_bytes ) - off1;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
FORGET_Frame();
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* now, if the glyph is not empty, set up the subrs array, and parse */
|
|
|
|
/* the charstrings */
|
|
|
|
if ( glyph_len > 0 )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
CID_FontDict* dict;
|
|
|
|
CID_Subrs* cid_subrs = face->subrs + fd_select;
|
|
|
|
FT_Byte* charstring;
|
|
|
|
FT_UInt lenIV;
|
|
|
|
FT_Memory memory = face->root.memory;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-25 08:47:11 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* setup subrs */
|
|
|
|
decoder->num_subrs = cid_subrs->num_subrs;
|
|
|
|
decoder->subrs = cid_subrs->code;
|
|
|
|
decoder->subrs_len = 0;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* setup font matrix */
|
|
|
|
dict = cid->font_dicts + fd_select;
|
|
|
|
lenIV = dict->private_dict.lenIV;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
decoder->font_matrix = dict->font_matrix;
|
|
|
|
decoder->font_offset = dict->font_offset;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* the charstrings are encoded (stupid!) */
|
|
|
|
/* load the charstrings, then execute it */
|
2000-06-25 08:47:11 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
if ( ALLOC( charstring, glyph_len ) )
|
2000-06-25 08:47:11 +02:00
|
|
|
goto Exit;
|
2000-06-29 05:14:25 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
if ( !FILE_Read_At( cid->data_offset + off1, charstring, glyph_len ) )
|
- 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
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
cid_decrypt( charstring, glyph_len, 4330 );
|
|
|
|
error = decoder->funcs.parse_charstrings( decoder,
|
|
|
|
charstring + lenIV,
|
|
|
|
glyph_len - lenIV );
|
- 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
|
|
|
}
|
2000-08-24 00:47:44 +02:00
|
|
|
|
|
|
|
FREE( charstring );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2000-07-01 00:24:36 +02: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
|
|
|
Exit:
|
|
|
|
return error;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-01 00:24:36 +02:00
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/********** *********/
|
|
|
|
/********** *********/
|
|
|
|
/********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
|
|
|
|
/********** *********/
|
|
|
|
/********** The following code is in charge of computing *********/
|
|
|
|
/********** the maximum advance width of the font. It *********/
|
|
|
|
/********** quickly processes each glyph charstring to *********/
|
|
|
|
/********** extract the value from either a `sbw' or `seac' *********/
|
|
|
|
/********** operator. *********/
|
|
|
|
/********** *********/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
LOCAL_FUNC
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error CID_Compute_Max_Advance( CID_Face face,
|
|
|
|
FT_Int* max_advance )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Error error;
|
|
|
|
T1_Decoder decoder;
|
|
|
|
FT_Int glyph_index;
|
|
|
|
|
|
|
|
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
*max_advance = 0;
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
/* Initialize load decoder */
|
2000-08-24 00:47:44 +02:00
|
|
|
error = psaux->t1_decoder_funcs->init( &decoder,
|
|
|
|
(FT_Face)face,
|
|
|
|
0, /* size */
|
|
|
|
0, /* glyph slot */
|
|
|
|
0, /* glyph names !!!! XXXXX */
|
|
|
|
0, /* blend == 0 */
|
|
|
|
cid_load_glyph );
|
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
decoder.builder.metrics_only = 1;
|
|
|
|
decoder.builder.load_points = 0;
|
|
|
|
|
2000-07-01 00:24:36 +02:00
|
|
|
/* for each glyph, parse the glyph charstring and extract */
|
|
|
|
/* the advance width */
|
2000-06-16 08:49:56 +02:00
|
|
|
for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
|
|
|
|
glyph_index++ )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
|
|
|
/* now get load the unscaled outline */
|
|
|
|
error = cid_load_glyph( &decoder, glyph_index );
|
2000-07-01 00:24:36 +02:00
|
|
|
/* ignore the error if one occurred - skip to next glyph */
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*max_advance = decoder.builder.advance.x;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
return T1_Err_Ok;
|
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
#endif /* 0 */
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/********** *********/
|
|
|
|
/********** *********/
|
|
|
|
/********** UNHINTED GLYPH LOADER *********/
|
|
|
|
/********** *********/
|
|
|
|
/********** The following code is in charge of loading a *********/
|
|
|
|
/********** single outline. It completely ignores hinting *********/
|
|
|
|
/********** and is used when FT_LOAD_NO_HINTING is set. *********/
|
|
|
|
/********** *********/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
LOCAL_FUNC
|
2000-06-28 01:20:35 +02:00
|
|
|
FT_Error CID_Load_Glyph( CID_GlyphSlot glyph,
|
|
|
|
CID_Size size,
|
2000-06-29 05:14:25 +02:00
|
|
|
FT_Int glyph_index,
|
|
|
|
FT_Int load_flags )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Error error;
|
|
|
|
T1_Decoder decoder;
|
|
|
|
CID_Face face = (CID_Face)glyph->root.face;
|
|
|
|
FT_Bool hinting;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
PSAux_Interface* psaux = (PSAux_Interface*)face->psaux;
|
|
|
|
FT_Matrix font_matrix;
|
|
|
|
FT_Vector font_offset;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
2000-06-01 05:27:48 +02:00
|
|
|
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
|
|
|
|
|
|
|
glyph->x_scale = size->root.metrics.x_scale;
|
|
|
|
glyph->y_scale = size->root.metrics.y_scale;
|
|
|
|
|
|
|
|
glyph->root.outline.n_points = 0;
|
|
|
|
glyph->root.outline.n_contours = 0;
|
|
|
|
|
|
|
|
hinting = ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
|
|
|
|
( load_flags & FT_LOAD_NO_HINTING ) == 0;
|
|
|
|
|
2000-07-23 23:27:52 +02:00
|
|
|
glyph->root.format = ft_glyph_format_outline;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
error = psaux->t1_decoder_funcs->init( &decoder,
|
|
|
|
(FT_Face)face,
|
|
|
|
(FT_Size)size,
|
|
|
|
(FT_GlyphSlot)glyph,
|
|
|
|
0, /* glyph names -- XXXX */
|
|
|
|
0, /* blend == 0 */
|
|
|
|
cid_load_glyph );
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
/* set up the decoder */
|
2000-08-24 00:47:44 +02:00
|
|
|
decoder.builder.no_recurse = (load_flags & FT_LOAD_NO_RECURSE) != 0;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
error = cid_load_glyph( &decoder, glyph_index );
|
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
font_matrix = decoder.font_matrix;
|
|
|
|
font_offset = decoder.font_offset;
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* save new glyph tables */
|
2000-08-24 00:47:44 +02:00
|
|
|
psaux->t1_decoder_funcs->done( &decoder );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* now, set the metrics -- this is rather simple, as */
|
2000-06-16 08:49:56 +02:00
|
|
|
/* the left side bearing is the xMin, and the top side */
|
2000-08-24 00:47:44 +02:00
|
|
|
/* bearing the yMax */
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( !error )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
glyph->root.outline.flags &= ft_outline_owner;
|
|
|
|
glyph->root.outline.flags |= ft_outline_reverse_fill;
|
|
|
|
|
|
|
|
/* for composite glyphs, return only left side bearing and */
|
|
|
|
/* advance width */
|
2000-06-01 05:27:48 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
|
|
|
{
|
|
|
|
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
|
|
|
|
glyph->root.metrics.horiAdvance = decoder.builder.advance.x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_BBox cbox;
|
|
|
|
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
/* copy the _unscaled_ advance width */
|
2000-07-01 00:24:36 +02:00
|
|
|
metrics->horiAdvance = decoder.builder.advance.x;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
/* make up vertical metrics */
|
|
|
|
metrics->vertBearingX = 0;
|
|
|
|
metrics->vertBearingY = 0;
|
|
|
|
metrics->vertAdvance = 0;
|
|
|
|
|
|
|
|
glyph->root.format = ft_glyph_format_outline;
|
|
|
|
|
|
|
|
if ( size && size->root.metrics.y_ppem < 24 )
|
|
|
|
glyph->root.outline.flags |= ft_outline_high_precision;
|
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
/* apply the font matrix */
|
|
|
|
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Outline_Translate( &glyph->root.outline,
|
|
|
|
font_offset.x,
|
|
|
|
font_offset.y );
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
|
|
|
/* scale the outline and the metrics */
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Outline* cur = decoder.builder.base;
|
|
|
|
FT_Vector* vec = cur->points;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Fixed x_scale = glyph->x_scale;
|
|
|
|
FT_Fixed y_scale = glyph->y_scale;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* First of all, scale the points */
|
|
|
|
for ( n = cur->n_points; n > 0; n--, vec++ )
|
|
|
|
{
|
|
|
|
vec->x = FT_MulFix( vec->x, x_scale );
|
|
|
|
vec->y = FT_MulFix( vec->y, y_scale );
|
|
|
|
}
|
|
|
|
|
|
|
|
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
|
|
|
|
|
|
|
|
/* Then scale the metrics */
|
|
|
|
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
|
2000-07-01 00:24:36 +02:00
|
|
|
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
|
|
|
|
metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the other metrics */
|
|
|
|
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
|
|
|
|
|
|
|
|
/* grid fit the bounding box if necessary */
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( hinting )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
|
|
|
cbox.xMin &= -64;
|
|
|
|
cbox.yMin &= -64;
|
2000-08-24 00:47:44 +02:00
|
|
|
cbox.xMax = ( cbox.xMax+63 ) & -64;
|
|
|
|
cbox.yMax = ( cbox.yMax+63 ) & -64;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
metrics->width = cbox.xMax - cbox.xMin;
|
|
|
|
metrics->height = cbox.yMax - cbox.yMin;
|
|
|
|
|
|
|
|
metrics->horiBearingX = cbox.xMin;
|
|
|
|
metrics->horiBearingY = cbox.yMax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
/* END */
|