2000-07-08 21:51:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
2000-10-28 19:10:06 +02:00
|
|
|
/* t1gload.c */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* */
|
2000-10-28 19:10:06 +02:00
|
|
|
/* Type 1 Glyph Loader (body). */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* */
|
2001-06-28 19:49:10 +02:00
|
|
|
/* Copyright 1996-2001 by */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* 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-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "t1gload.h"
|
2000-12-08 03:42:29 +01:00
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_OUTLINE_H
|
|
|
|
#include FT_INTERNAL_POSTSCRIPT_AUX_H
|
2000-12-08 17:17:16 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "t1errors.h"
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
#include <string.h> /* for strcmp() */
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* 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-02-15 13:55:57 +01:00
|
|
|
#undef FT_COMPONENT
|
2000-10-28 19:10:06 +02:00
|
|
|
#define FT_COMPONENT trace_t1gload
|
2000-02-15 13:55:57 +01:00
|
|
|
|
2000-07-08 21:51:42 +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-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_Parse_Glyph( T1_Decoder decoder,
|
2001-06-27 11:26:46 +02:00
|
|
|
FT_UInt glyph_index )
|
2000-08-23 00:36:33 +02:00
|
|
|
{
|
2000-08-24 18:29:15 +02:00
|
|
|
T1_Face face = (T1_Face)decoder->builder.face;
|
|
|
|
T1_Font* type1 = &face->type1;
|
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
|
|
|
|
decoder->font_matrix = type1->font_matrix;
|
|
|
|
decoder->font_offset = type1->font_offset;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
|
|
|
return decoder->funcs.parse_charstrings(
|
|
|
|
decoder,
|
|
|
|
type1->charstrings [glyph_index],
|
|
|
|
type1->charstrings_len[glyph_index] );
|
2000-08-23 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_LOCAL_DEF FT_Error
|
|
|
|
T1_Compute_Max_Advance( T1_Face face,
|
|
|
|
FT_Int* max_advance )
|
2000-02-02 13:20:53 +01:00
|
|
|
{
|
2000-08-23 00:36:33 +02:00
|
|
|
FT_Error error;
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_DecoderRec decoder;
|
2000-08-23 00:36:33 +02:00
|
|
|
FT_Int glyph_index;
|
|
|
|
T1_Font* type1 = &face->type1;
|
2002-02-28 17:10:29 +01:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-02-02 13:20:53 +01:00
|
|
|
*max_advance = 0;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* initialize load decoder */
|
2000-08-23 00:36:33 +02:00
|
|
|
error = psaux->t1_decoder_funcs->init( &decoder,
|
|
|
|
(FT_Face)face,
|
|
|
|
0, /* size */
|
|
|
|
0, /* glyph slot */
|
|
|
|
(FT_Byte**)type1->glyph_names,
|
|
|
|
face->blend,
|
2001-10-18 13:49:26 +02:00
|
|
|
0,
|
2000-10-28 19:10:06 +02:00
|
|
|
T1_Parse_Glyph );
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( error )
|
2000-08-24 00:47:44 +02:00
|
|
|
return error;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-02-02 13:20:53 +01:00
|
|
|
decoder.builder.metrics_only = 1;
|
|
|
|
decoder.builder.load_points = 0;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
decoder.num_subrs = type1->num_subrs;
|
|
|
|
decoder.subrs = type1->subrs;
|
|
|
|
decoder.subrs_len = type1->subrs_len;
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* for each glyph, parse the glyph charstring and extract */
|
|
|
|
/* the advance width */
|
2000-01-27 15:02:04 +01:00
|
|
|
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
|
|
|
|
{
|
|
|
|
/* now get load the unscaled outline */
|
2000-10-28 19:10:06 +02:00
|
|
|
error = T1_Parse_Glyph( &decoder, glyph_index );
|
2000-01-27 15:02:04 +01:00
|
|
|
/* ignore the error if one occured - skip to next glyph */
|
|
|
|
}
|
|
|
|
|
|
|
|
*max_advance = decoder.builder.advance.x;
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
return T1_Err_Ok;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/********** *********/
|
|
|
|
/********** 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. *********/
|
|
|
|
/********** *********/
|
|
|
|
/********** The Type 1 hinter is located in `t1hint.c' *********/
|
|
|
|
/********** *********/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
FT_LOCAL_DEF FT_Error
|
|
|
|
T1_Load_Glyph( T1_GlyphSlot glyph,
|
|
|
|
T1_Size size,
|
|
|
|
FT_Int glyph_index,
|
|
|
|
FT_Int load_flags )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 00:36:33 +02:00
|
|
|
FT_Error error;
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_DecoderRec decoder;
|
2000-08-23 00:36:33 +02:00
|
|
|
T1_Face face = (T1_Face)glyph->root.face;
|
|
|
|
FT_Bool hinting;
|
|
|
|
T1_Font* type1 = &face->type1;
|
2002-02-28 17:10:29 +01:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
|
|
|
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Matrix font_matrix;
|
|
|
|
FT_Vector font_offset;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
2000-03-28 13:19:28 +02:00
|
|
|
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
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;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-06-19 10:28:24 +02:00
|
|
|
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
|
|
|
|
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-06-28 01:21:51 +02:00
|
|
|
glyph->root.format = ft_glyph_format_outline;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
error = decoder_funcs->init( &decoder,
|
|
|
|
(FT_Face)face,
|
|
|
|
(FT_Size)size,
|
|
|
|
(FT_GlyphSlot)glyph,
|
|
|
|
(FT_Byte**)type1->glyph_names,
|
|
|
|
face->blend,
|
2001-12-05 02:22:05 +01:00
|
|
|
FT_BOOL( hinting ),
|
2000-10-28 19:10:06 +02:00
|
|
|
T1_Parse_Glyph );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2000-08-23 00:36:33 +02:00
|
|
|
goto Exit;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-06-20 01:03:41 +02:00
|
|
|
decoder.builder.no_recurse = FT_BOOL(
|
|
|
|
( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
decoder.num_subrs = type1->num_subrs;
|
|
|
|
decoder.subrs = type1->subrs;
|
|
|
|
decoder.subrs_len = type1->subrs_len;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* now load the unscaled outline */
|
2000-10-28 19:10:06 +02:00
|
|
|
error = T1_Parse_Glyph( &decoder, glyph_index );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2000-08-23 00:36:33 +02:00
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
font_matrix = decoder.font_matrix;
|
|
|
|
font_offset = decoder.font_offset;
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* save new glyph tables */
|
2000-08-23 00:36:33 +02:00
|
|
|
decoder_funcs->done( &decoder );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* now, set the metrics -- this is rather simple, as */
|
|
|
|
/* the left side bearing is the xMin, and the top side */
|
|
|
|
/* bearing the yMax */
|
|
|
|
if ( !error )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-07-20 05:44:50 +02:00
|
|
|
glyph->root.outline.flags &= ft_outline_owner;
|
|
|
|
glyph->root.outline.flags |= ft_outline_reverse_fill;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* for composite glyphs, return only left side bearing and */
|
|
|
|
/* advance width */
|
2000-03-28 13:19:28 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-11-04 03:52:02 +01:00
|
|
|
FT_Slot_Internal internal = glyph->root.internal;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
|
|
|
|
glyph->root.metrics.horiAdvance = decoder.builder.advance.x;
|
2000-11-04 09:33:38 +01:00
|
|
|
internal->glyph_matrix = font_matrix;
|
|
|
|
internal->glyph_delta = font_offset;
|
|
|
|
internal->glyph_transformed = 1;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-03-28 13:19:28 +02:00
|
|
|
else
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_BBox cbox;
|
|
|
|
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
/* copy the _unscaled_ advance width */
|
2000-11-04 09:33:38 +01:00
|
|
|
metrics->horiAdvance = decoder.builder.advance.x;
|
|
|
|
glyph->root.linearHoriAdvance = decoder.builder.advance.x;
|
2000-11-04 03:52:02 +01:00
|
|
|
glyph->root.internal->glyph_transformed = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
/* make up vertical metrics */
|
|
|
|
metrics->vertBearingX = 0;
|
|
|
|
metrics->vertBearingY = 0;
|
|
|
|
metrics->vertAdvance = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-09-15 19:17:17 +02:00
|
|
|
glyph->root.linearVertAdvance = 0;
|
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
glyph->root.format = ft_glyph_format_outline;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-04-14 13:29:14 +02:00
|
|
|
if ( size && size->root.metrics.y_ppem < 24 )
|
2000-03-28 13:19:28 +02:00
|
|
|
glyph->root.outline.flags |= ft_outline_high_precision;
|
2000-03-30 10:43:03 +02:00
|
|
|
|
2001-12-20 10:36:21 +01:00
|
|
|
#if 1
|
2001-12-05 02:22:05 +01:00
|
|
|
/* apply the font matrix, if any */
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
|
2000-08-17 03:09:06 +02:00
|
|
|
|
|
|
|
FT_Outline_Translate( &glyph->root.outline,
|
2000-08-24 00:47:44 +02:00
|
|
|
font_offset.x,
|
|
|
|
font_offset.y );
|
2001-10-18 13:49:26 +02:00
|
|
|
#endif
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
|
2000-03-28 13:19:28 +02:00
|
|
|
{
|
|
|
|
/* scale the outline and the metrics */
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
- 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_Outline* cur = decoder.builder.base;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Vector* vec = cur->points;
|
|
|
|
FT_Fixed x_scale = glyph->x_scale;
|
|
|
|
FT_Fixed y_scale = glyph->y_scale;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* First of all, scale the points, if we are not hinting */
|
2001-10-18 13:49:26 +02:00
|
|
|
if ( !hinting )
|
|
|
|
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 );
|
|
|
|
}
|
2000-04-14 13:29:14 +02:00
|
|
|
|
|
|
|
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
/* 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-05-17 01:44:38 +02:00
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
|
|
|
|
metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
|
2001-12-14 15:52:58 +01:00
|
|
|
|
|
|
|
if ( hinting )
|
|
|
|
{
|
2001-12-16 09:17:33 +01:00
|
|
|
metrics->horiAdvance = ( metrics->horiAdvance + 32 ) & -64;
|
|
|
|
metrics->vertAdvance = ( metrics->vertAdvance + 32 ) & -64;
|
2001-12-14 15:52:58 +01:00
|
|
|
|
2001-12-16 09:17:33 +01:00
|
|
|
metrics->vertBearingX = ( metrics->vertBearingX + 32 ) & -64;
|
|
|
|
metrics->vertBearingY = ( metrics->vertBearingY + 32 ) & -64;
|
2001-12-14 15:52:58 +01:00
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-04-14 13:29:14 +02:00
|
|
|
|
|
|
|
/* compute the other metrics */
|
|
|
|
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-04-14 13:29:14 +02:00
|
|
|
/* grid fit the bounding box if necessary */
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( hinting )
|
2000-04-14 13:29:14 +02:00
|
|
|
{
|
|
|
|
cbox.xMin &= -64;
|
|
|
|
cbox.yMin &= -64;
|
2000-07-08 21:51:42 +02:00
|
|
|
cbox.xMax = ( cbox.xMax+63 ) & -64;
|
|
|
|
cbox.yMax = ( cbox.yMax+63 ) & -64;
|
2000-04-14 13:29:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
metrics->width = cbox.xMax - cbox.xMin;
|
|
|
|
metrics->height = cbox.yMax - cbox.yMin;
|
|
|
|
|
|
|
|
metrics->horiBearingX = cbox.xMin;
|
|
|
|
metrics->horiBearingY = cbox.yMax;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2001-03-04 22:53:08 +01:00
|
|
|
/* Set control data to the glyph charstrings. Note that this is */
|
|
|
|
/* _not_ zero-terminated. */
|
2001-02-28 10:36:13 +01:00
|
|
|
glyph->root.control_data = type1->charstrings [glyph_index];
|
|
|
|
glyph->root.control_len = type1->charstrings_len[glyph_index];
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
Exit:
|
2000-01-27 15:02:04 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
/* END */
|