update to freetype-2.1.10

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14097 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2005-09-01 06:40:20 +00:00
parent 5e7558d87c
commit b28111564b
215 changed files with 24418 additions and 14046 deletions
+2
View File
@@ -2227,12 +2227,14 @@ FT2_LIB = freetype ;
FT2_COMPONENTS ?= gzip # support for gzip-compressed files.
autohint # auto-hinter
autofit
base # base component (public APIs)
bdf # BDF font driver
cache # cache sub-system
cff # CFF/CEF font driver
cid # Postscript CID-keyed font driver
lzw # LZW routines
otvalid
pcf # PCF font driver
pfr # PFR/TrueDoc font driver
psaux # Common Postscript routines module
+49 -2
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType internal cache interface (specification). */
/* */
/* Copyright 2000-2001, 2002, 2003, 2004 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -248,7 +248,8 @@ FT_BEGIN_HEADER
error = FTC_Cache_NewNode( _cache, _hash, query, &_node ); \
\
_Ok: \
*(FTC_Node*)&(node) = _node; \
_pnode = (FTC_Node*)(void*)&(node); \
*_pnode = _node; \
FT_END_STMNT
#else /* !FTC_INLINE */
@@ -261,6 +262,52 @@ FT_BEGIN_HEADER
#endif /* !FTC_INLINE */
/*
* This macro, together with FTC_CACHE_TRYLOOP_END, defines a retry
* loop to flush the cache repeatedly in case of memory overflows.
*
* It is used when creating a new cache node, or within a lookup
* that needs to allocate data (e.g., the sbit cache lookup).
*
* Example:
*
* {
* FTC_CACHE_TRYLOOP( cache )
* error = load_data( ... );
* FTC_CACHE_TRYLOOP_END()
* }
*
*/
#define FTC_CACHE_TRYLOOP( cache ) \
{ \
FTC_Manager _try_manager = FTC_CACHE( cache )->manager; \
FT_UInt _try_count = 4; \
\
\
for (;;) \
{ \
FT_UInt _try_done;
#define FTC_CACHE_TRYLOOP_END() \
if ( !error || error != FT_Err_Out_Of_Memory ) \
break; \
\
_try_done = FTC_Manager_FlushN( _try_manager, _try_count ); \
if ( _try_done == 0 ) \
break; \
\
if ( _try_done == _try_count ) \
{ \
_try_count *= 2; \
if ( _try_count < _try_done || \
_try_count > _try_manager->num_nodes ) \
_try_count = _try_manager->num_nodes; \
} \
} \
}
/* */
FT_END_HEADER
+19 -1
View File
@@ -238,7 +238,7 @@ FT_BEGIN_HEADER
#define FTC_CACHE__GCACHE_CLASS( x ) \
FTC_GCACHE_CLASS( FTC_CACHE(x)->org_class )
#define FTC_CACHE__FAMILY_CLASS( x ) \
((FTC_MruListClass) FTC_CACHE__GCACHE_CLASS(x)->family_class)
( (FTC_MruListClass)FTC_CACHE__GCACHE_CLASS( x )->family_class )
/* convenience function; use it instead of FTC_Manager_Register_Cache */
@@ -255,6 +255,14 @@ FT_BEGIN_HEADER
FTC_Node *anode );
/* */
#define FTC_FAMILY_FREE( family, cache ) \
FTC_MruList_Remove( &FTC_GCACHE((cache))->families, \
(FTC_MruNode)(family) )
#ifdef FTC_INLINE
#define FTC_GCACHE_LOOKUP_CMP( cache, famcmp, nodecmp, hash, \
@@ -270,7 +278,17 @@ FT_BEGIN_HEADER
FTC_MRULIST_LOOKUP_CMP( &_gcache->families, _gquery, _fcompare, \
_gquery->family, error ); \
if ( !error ) \
{ \
FTC_Family _gqfamily = _gquery->family; \
\
\
_gqfamily->num_nodes++; \
\
FTC_CACHE_LOOKUP_CMP( cache, nodecmp, hash, query, node, error ); \
\
if ( --_gqfamily->num_nodes == 0 ) \
FTC_FAMILY_FREE( _gqfamily, _gcache ); \
} \
FT_END_STMNT
/* */
+6 -5
View File
@@ -4,7 +4,7 @@
/* */
/* Simple MRU list-cache (specification). */
/* */
/* Copyright 2000-2001, 2003, 2004 by */
/* Copyright 2000-2001, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -86,7 +86,7 @@ FT_BEGIN_HEADER
typedef struct FTC_MruListClassRec_ const * FTC_MruListClass;
typedef FT_Int
typedef FT_Bool
(*FTC_MruNode_CompareFunc)( FTC_MruNode node,
FT_Pointer key );
@@ -172,7 +172,7 @@ FT_BEGIN_HEADER
FT_BEGIN_STMNT \
FTC_MruNode* _pfirst = &(list)->nodes; \
FTC_MruNode_CompareFunc _compare = (FTC_MruNode_CompareFunc)(compare); \
FTC_MruNode _first, _node; \
FTC_MruNode _first, _node, *_pnode; \
\
\
error = 0; \
@@ -189,7 +189,8 @@ FT_BEGIN_HEADER
if ( _node != _first ) \
FTC_MruNode_Up( _pfirst, _node ); \
\
*(FTC_MruNode*)&(node) = _node; \
_pnode = (FTC_MruNode*)(void*)&(node); \
*_pnode = _node; \
goto _MruOk; \
} \
_node = _node->next; \
@@ -197,7 +198,7 @@ FT_BEGIN_HEADER
} while ( _node != _first) ; \
} \
\
error = FTC_MruList_New( (list), (key), (FTC_MruNode*)&(node) ); \
error = FTC_MruList_New( (list), (key), (FTC_MruNode*)(void*)&(node) ); \
_MruOk: \
; \
FT_END_STMNT
@@ -72,20 +72,23 @@ FT_BEGIN_HEADER
/* The size of an `int' type. */
#if FT_UINT_MAX == 0xFFFFFFFFUL
#define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
#elif FT_UINT_MAX == 0xFFFFU
#if FT_UINT_MAX == 0xFFFFUL
#define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
#elif FT_UINT_MAX > 0xFFFFFFFFU && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFU
#elif FT_UINT_MAX == 0xFFFFFFFFUL
#define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
#define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
#else
#error "Unsupported size of `int' type!"
#endif
/* The size of a `long' type. */
/* The size of a `long' type. A five-byte `long' (as used e.g. on the */
/* DM642) is recognized but avoided. */
#if FT_ULONG_MAX == 0xFFFFFFFFUL
#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
#elif FT_ULONG_MAX > 0xFFFFFFFFU && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFU
#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
#else
#error "Unsupported size of `long' type!"
@@ -18,6 +18,7 @@
#ifndef __FT_HEADER_H__
#define __FT_HEADER_H__
/*@***********************************************************************/
/* */
/* <Macro> */
@@ -92,6 +93,7 @@
/* */
/*************************************************************************/
/* configuration files */
/*************************************************************************/
@@ -362,6 +364,7 @@
/* */
#define FT_BDF_H <freetype/ftbdf.h>
/*************************************************************************/
/* */
/* @macro: */
@@ -410,6 +413,18 @@
#define FT_GLYPH_H <freetype/ftglyph.h>
/*************************************************************************/
/* */
/* @macro: */
/* FT_BITMAP_H */
/* */
/* @description: */
/* A macro used in #include statements to name the file containing */
/* the API of the optional bitmap conversion component. */
/* */
#define FT_BITMAP_H <freetype/ftbitmap.h>
/*************************************************************************/
/* */
/* @macro: */
@@ -529,6 +544,20 @@
/* */
#define FT_SFNT_NAMES_H <freetype/ftsnames.h>
/*************************************************************************/
/* */
/* @macro: */
/* FT_OPENTYPE_VALIDATE_H */
/* */
/* @description: */
/* A macro used in #include statements to name the file containing */
/* the optional FreeType 2 API used to validate OpenType tables */
/* (BASE, GDEF, GPOS, GSUB, JSTF). */
/* */
#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h>
/* */
#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
@@ -1,8 +1,12 @@
FT_USE_MODULE(autohint_module_class)
FT_USE_MODULE(autofit_module_class)
FT_USE_MODULE(tt_driver_class)
FT_USE_MODULE(t1_driver_class)
FT_USE_MODULE(cff_driver_class)
FT_USE_MODULE(t1cid_driver_class)
FT_USE_MODULE(pfr_driver_class)
FT_USE_MODULE(t42_driver_class)
FT_USE_MODULE(winfnt_driver_class)
FT_USE_MODULE(pcf_driver_class)
FT_USE_MODULE(bdf_driver_class)
FT_USE_MODULE(psaux_module_class)
FT_USE_MODULE(psnames_module_class)
FT_USE_MODULE(pshinter_module_class)
@@ -11,9 +15,5 @@ FT_USE_MODULE(sfnt_module_class)
FT_USE_MODULE(ft_smooth_renderer_class)
FT_USE_MODULE(ft_smooth_lcd_renderer_class)
FT_USE_MODULE(ft_smooth_lcdv_renderer_class)
FT_USE_MODULE(tt_driver_class)
FT_USE_MODULE(t1_driver_class)
FT_USE_MODULE(t42_driver_class)
FT_USE_MODULE(pfr_driver_class)
FT_USE_MODULE(winfnt_driver_class)
FT_USE_MODULE(otv_module_class)
FT_USE_MODULE(bdf_driver_class)
@@ -4,7 +4,7 @@
/* */
/* User-selectable configuration macros (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -446,7 +446,7 @@ FT_BEGIN_HEADER
/* work-around hinting system. Note that for the moment, the algorithm */
/* is only used when selected at runtime through the parameter tag */
/* FT_PARAM_TAG_UNPATENTED_HINTING; or when the debug hook */
/* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally actived */
/* FT_DEBUG_HOOK_UNPATENTED_HINTING is globally activated. */
/* */
#define TT_CONFIG_OPTION_UNPATENTED_HINTING
@@ -483,6 +483,16 @@ FT_BEGIN_HEADER
#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
/*************************************************************************/
/* */
/* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */
/* support for Apple's distortable font technology (fvar, gvar, cvar, */
/* and avar tables). This has many similarities to Type 1 Multiple */
/* Masters support. */
/* */
#define TT_CONFIG_OPTION_GX_VAR_SUPPORT
/*************************************************************************/
/*************************************************************************/
/**** ****/
@@ -540,23 +550,11 @@ FT_BEGIN_HEADER
/* */
/*
* The FT_CONFIG_OPTION_CHESTER_XXXX macros are used to toggle some recent
* improvements to the auto-hinter contributed by David Chester. They will
* most likely disappear completely in the next release. For now, you
* should always keep them defined.
* This temporary macro is used to control various optimizations for
* reducing the heap footprint of memory-mapped TrueType files.
*
*/
#define FT_CONFIG_OPTION_CHESTER_HINTS
#ifdef FT_CONFIG_OPTION_CHESTER_HINTS
#define FT_CONFIG_CHESTER_SMALL_F
#define FT_CONFIG_CHESTER_ASCENDER
#define FT_CONFIG_CHESTER_SERIF
#define FT_CONFIG_CHESTER_STEM
#define FT_CONFIG_CHESTER_BLUE_SCALE
#endif /* FT_CONFIG_OPTION_CHESTER_HINTS */
/* #define FT_OPTIMIZE_MEMORY */
FT_END_HEADER
@@ -33,6 +33,11 @@
#define __FTSTDLIB_H__
#include <stddef.h>
#define ft_ptrdiff_t ptrdiff_t
/**********************************************************************/
/* */
/* integer limits */
@@ -61,6 +66,7 @@
#include <limits.h>
#define FT_UINT_MAX UINT_MAX
#define FT_INT_MAX INT_MAX
#define FT_ULONG_MAX ULONG_MAX
+112 -38
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType high-level API and common types (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -44,7 +44,7 @@
/* */
#define FREETYPE_MAJOR 2
#define FREETYPE_MINOR 1
#define FREETYPE_PATCH 8
#define FREETYPE_PATCH 10
#include <ft2build.h>
@@ -172,6 +172,7 @@ FT_BEGIN_HEADER
/* FT_CharMapRec */
/* FT_Select_Charmap */
/* FT_Set_Charmap */
/* FT_Get_Charmap_Index */
/* */
/*************************************************************************/
@@ -188,34 +189,42 @@ FT_BEGIN_HEADER
/* instead. */
/* */
/* <Fields> */
/* width :: The glyph's width. */
/* width :: */
/* The glyph's width. */
/* */
/* height :: The glyph's height. */
/* height :: */
/* The glyph's height. */
/* */
/* horiBearingX :: Horizontal left side bearing. */
/* horiBearingX :: */
/* Left side bearing for horizontal layout. */
/* */
/* horiBearingY :: Horizontal top side bearing. */
/* horiBearingY :: */
/* Top side bearing for horizontal layout. */
/* */
/* horiAdvance :: Horizontal advance width. */
/* horiAdvance :: */
/* Advance width for horizontal layout. */
/* */
/* vertBearingX :: Vertical left side bearing. */
/* vertBearingX :: */
/* Left side bearing for vertical layout. */
/* */
/* vertBearingY :: Vertical top side bearing. */
/* vertBearingY :: */
/* Top side bearing for vertical layout. */
/* */
/* vertAdvance :: Vertical advance height. */
/* vertAdvance :: */
/* Advance height for vertical layout. */
/* */
typedef struct FT_Glyph_Metrics_
{
FT_Pos width; /* glyph width */
FT_Pos height; /* glyph height */
FT_Pos width;
FT_Pos height;
FT_Pos horiBearingX; /* left side bearing in horizontal layouts */
FT_Pos horiBearingY; /* top side bearing in horizontal layouts */
FT_Pos horiAdvance; /* advance width for horizontal layout */
FT_Pos horiBearingX;
FT_Pos horiBearingY;
FT_Pos horiAdvance;
FT_Pos vertBearingX; /* left side bearing in vertical layouts */
FT_Pos vertBearingY; /* top side bearing in vertical layouts */
FT_Pos vertAdvance; /* advance height for vertical layout */
FT_Pos vertBearingX;
FT_Pos vertBearingY;
FT_Pos vertAdvance;
} FT_Glyph_Metrics;
@@ -249,6 +258,7 @@ FT_BEGIN_HEADER
/* x_ppem :: The horizontal ppem value (in 26.6 fractional format). */
/* */
/* y_ppem :: The vertical ppem value (in 26.6 fractional format). */
/* Usually, this is the `nominal' pixel height of the font. */
/* */
/* <Note> */
/* The values in this structure are taken from the bitmap font. If */
@@ -262,10 +272,10 @@ FT_BEGIN_HEADER
/* where `size' is in points. */
/* */
/* Windows FNT: */
/* The `size', `x_ppem', and `y_ppem' parameters are not reliable: */
/* There exist fonts (e.g. app850.fon) which have a wrong size for */
/* some subfonts; since FNT files don't contain ppem but dpi values */
/* the computed x_ppem and y_ppem numbers are thus wrong also. */
/* The `size' parameter is not reliable: There exist fonts (e.g., */
/* app850.fon) which have a wrong size for some subfonts; x_ppem */
/* and y_ppem are thus set equal to pixel width and height given in */
/* in the Windows FNT header. */
/* */
/* TrueType embedded bitmaps: */
/* `size', `width', and `height' values are not contained in the */
@@ -1459,6 +1469,14 @@ FT_BEGIN_HEADER
/* Note that the app will need to know about the */
/* image format. */
/* */
/* lsb_delta :: The difference between hinted and unhinted */
/* left side bearing while autohinting is */
/* active. Zero otherwise. */
/* */
/* rsb_delta :: The difference between hinted and unhinted */
/* right side bearing while autohinting is */
/* active. Zero otherwise. */
/* */
/* <Note> */
/* If @FT_Load_Glyph is called with default flags (see */
/* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
@@ -1478,6 +1496,34 @@ FT_BEGIN_HEADER
/* position (e.g. coordinates [0,0] on the baseline). Of course, */
/* `slot->format' is also changed to `FT_GLYPH_FORMAT_BITMAP' . */
/* */
/* <Note> */
/* Here a small pseudo code fragment which shows how to use */
/* `lsb_delta' and `rsb_delta': */
/* */
/* { */
/* FT_Pos origin_x = 0; */
/* FT_Pos prev_rsb_delta = 0; */
/* */
/* */
/* for all glyphs do */
/* <compute kern between current and previous glyph and add it to */
/* `origin_x'> */
/* */
/* <load glyph with `FT_Load_Glyph'> */
/* */
/* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */
/* origin_x -= 64; */
/* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */
/* origin_x += 64; */
/* */
/* prev_rsb_delta = face->glyph->rsb_delta; */
/* */
/* <save glyph image, or render glyph, or ...> */
/* */
/* origin_x += face->glyph->advance.x; */
/* endfor */
/* } */
/* */
typedef struct FT_GlyphSlotRec_
{
FT_Library library;
@@ -1505,6 +1551,9 @@ FT_BEGIN_HEADER
void* control_data;
long control_len;
FT_Pos lsb_delta;
FT_Pos rsb_delta;
void* other;
FT_Slot_Internal internal;
@@ -1863,8 +1912,8 @@ FT_BEGIN_HEADER
/* @FT_Open_Face can be used to determine and/or check the font */
/* format of a given font resource. If the `face_index' field is */
/* negative, the function will _not_ return any face handle in */
/* `*face'; the return value is 0 if the font format is recognized, */
/* or non-zero otherwise. */
/* `*aface'; the function's return value is 0 if the font format is */
/* recognized, or non-zero otherwise. */
/* */
FT_EXPORT( FT_Error )
FT_Open_Face( FT_Library library,
@@ -1992,8 +2041,9 @@ FT_BEGIN_HEADER
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* When dealing with fixed-size faces (i.e., non-scalable formats), */
/* @FT_Set_Pixel_Sizes provides a more convenient interface. */
/* For BDF and PCF formats, this function uses the `PIXEL_SIZE' */
/* property of the bitmap font; the `char_width' parameter is */
/* ignored. */
/* */
FT_EXPORT( FT_Error )
FT_Set_Char_Size( FT_Face face,
@@ -2046,6 +2096,9 @@ FT_BEGIN_HEADER
/* which contain a single bitmap strike only (BDF, PCF, FNT) ignore */
/* `pixel_width'. */
/* */
/* For BDF and PCF formats, this function uses the sum of the */
/* `FONT_ASCENT' and `FONT_DESCENT' properties of the bitmap font. */
/* */
FT_EXPORT( FT_Error )
FT_Set_Pixel_Sizes( FT_Face face,
FT_UInt pixel_width,
@@ -2223,9 +2276,11 @@ FT_BEGIN_HEADER
*
* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
* Indicates that the glyph loader should ignore the global advance
* width defined in the font. As far as we know, this is only used by
* the X-TrueType font server, in order to deal correctly with the
* incorrect metrics contained in DynaLab's TrueType CJK fonts.
* width defined in the font. For historical reasons (to support
* buggy CJK fonts), FreeType uses the value of the `advanceWidthMax'
* field in the `htmx' table for all glyphs if the font is monospaced.
* Activating this flags makes FreeType use the metric values given in
* the `htmx' table.
*
* FT_LOAD_NO_RECURSE ::
* This flag is only used internally. It merely indicates that the
@@ -2315,8 +2370,8 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* A function used to set the transformation that is applied to glyph */
/* images just before they are converted to bitmaps in a glyph slot */
/* when @FT_Render_Glyph is called. */
/* images when they are loaded into a glyph slot through */
/* @FT_Load_Glyph. */
/* */
/* <InOut> */
/* face :: A handle to the source face object. */
@@ -2530,9 +2585,9 @@ FT_BEGIN_HEADER
/* kerning vector. */
/* */
/* <Output> */
/* akerning :: The kerning vector. This is in font units for */
/* scalable formats, and in pixels for fixed-sizes */
/* formats. */
/* akerning :: The kerning vector. This is either in font units */
/* or in pixels (26.6 format) for scalable formats, */
/* and in pixels for fixed-sizes formats. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@@ -2601,13 +2656,13 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* Retrieves the ASCII Postscript name of a given face, if available. */
/* This should only work with Postscript and TrueType fonts. */
/* This only works with Postscript and TrueType fonts. */
/* */
/* <Input> */
/* face :: A handle to the source face object. */
/* */
/* <Return> */
/* A pointer to the face's Postscript name. NULL if un-available. */
/* A pointer to the face's Postscript name. NULL if unavailable. */
/* */
/* <Note> */
/* The returned pointer is owned by the face and will be destroyed */
@@ -2672,6 +2727,25 @@ FT_BEGIN_HEADER
FT_CharMap charmap );
/*************************************************************************/
/* */
/* @function: */
/* FT_Get_Charmap_Index */
/* */
/* @description: */
/* Retrieve index of a given charmap. */
/* */
/* @input: */
/* charmap :: A handle to a charmap. */
/* */
/* @return: */
/* The index into the array of character maps within the face to */
/* which `charmap' belongs. */
/* */
FT_EXPORT( FT_Int )
FT_Get_Charmap_Index( FT_CharMap charmap );
/*************************************************************************/
/* */
/* <Function> */
@@ -2815,7 +2889,7 @@ FT_BEGIN_HEADER
/* Computations */
/* */
/* <Abstract> */
/* Crunching fixed numbers and vectors */
/* Crunching fixed numbers and vectors. */
/* */
/* <Description> */
/* This section contains various functions used to perform */
@@ -3001,7 +3075,7 @@ FT_BEGIN_HEADER
/* */
FT_EXPORT( void )
FT_Vector_Transform( FT_Vector* vec,
FT_Matrix* matrix );
const FT_Matrix* matrix );
/* */
+4 -4
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing BDF-specific strings (specification). */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -38,13 +38,13 @@ FT_BEGIN_HEADER
/* bdf_fonts */
/* */
/* <Title> */
/* BDF Fonts */
/* BDF Files */
/* */
/* <Abstract> */
/* BDF-specific APIs */
/* BDF specific API. */
/* */
/* <Description> */
/* This section contains the declaration of BDF-specific functions. */
/* This section contains the declaration of BDF specific functions. */
/* */
/*************************************************************************/
+206
View File
@@ -0,0 +1,206 @@
/***************************************************************************/
/* */
/* ftbitmap.h */
/* */
/* FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */
/* bitmaps into 8bpp format (specification). */
/* */
/* Copyright 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __FTBITMAP_H__
#define __FTBITMAP_H__
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Section> */
/* bitmap_handling */
/* */
/* <Title> */
/* Bitmap Handling */
/* */
/* <Abstract> */
/* Handling FT_Bitmap objects. */
/* */
/* <Description> */
/* This section contains functions for converting FT_Bitmap objects. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* FT_Bitmap_New */
/* */
/* <Description> */
/* Initialize a pointer to an FT_Bitmap structure. */
/* */
/* <InOut> */
/* abitmap :: A pointer to the bitmap structure. */
/* */
FT_EXPORT( void )
FT_Bitmap_New( FT_Bitmap *abitmap );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Bitmap_Copy */
/* */
/* <Description> */
/* Copies an bitmap into another one. */
/* */
/* <Input> */
/* library :: A handle to a library object. */
/* */
/* source :: A handle to the source bitmap. */
/* */
/* <Output> */
/* target :: A handle to the target bitmap. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Copy( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target);
/*************************************************************************/
/* */
/* <Function> */
/* FT_Bitmap_Embolden */
/* */
/* <Description> */
/* Embolden a bitmap. The new bitmap will be about `xStrength' */
/* pixels wider and `yStrength' pixels higher. The left and bottom */
/* borders are kept unchanged. */
/* */
/* <Input> */
/* library :: A handle to a library object. */
/* */
/* xStrength :: How strong the glyph is emboldened horizontally. */
/* Expressed in 26.6 pixel format. */
/* */
/* yStrength :: How strong the glyph is emboldened vertically. */
/* Expressed in 26.6 pixel format. */
/* */
/* <InOut> */
/* bitmap :: A handle to the target bitmap. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The current implementation restricts `xStrength' to be less than */
/* or equal to 8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */
/* */
/* Don't embolden the bitmap owned by a @FT_GlyphSlot directly! Call */
/* @FT_Bitmap_Copy to get a copy and work on the copy instead. */
/* */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Embolden( FT_Library library,
FT_Bitmap* bitmap,
FT_Pos xStrength,
FT_Pos yStrength );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Bitmap_Convert */
/* */
/* <Description> */
/* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, or 8bpp to a */
/* bitmap object with depth 8bpp, making the number of used bytes per */
/* line (a.k.a. the `pitch') a multiple of `alignment'. */
/* */
/* <Input> */
/* library :: A handle to a library object. */
/* */
/* source :: The source bitmap. */
/* */
/* alignment :: The pitch of the bitmap is a multiple of this */
/* parameter. Common values are 1, 2, or 4. */
/* */
/* <Output> */
/* target :: The target bitmap. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* It is possible to call @FT_Bitmap_Convert multiple times without */
/* calling @FT_Bitmap_Done (the memory is simply reallocated). */
/* */
/* Use @FT_Bitmap_Done to finally remove the bitmap object. */
/* */
/* The `library' argument is taken to have access to FreeType's */
/* memory handling functions. */
/* */
FT_EXPORT( FT_Error )
FT_Bitmap_Convert( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target,
FT_Int alignment );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Bitmap_Done */
/* */
/* <Description> */
/* Destroy a bitmap object created with @FT_Bitmap_New. */
/* */
/* <Input> */
/* library :: A handle to a library object. */
/* */
/* bitmap :: The bitmap object to be freed. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The `library' argument is taken to have access to FreeType's */
/* memory handling functions. */
/* */
FT_EXPORT( FT_Error )
FT_Bitmap_Done( FT_Library library,
FT_Bitmap *bitmap );
/* */
FT_END_HEADER
#endif /* __FTBITMAP_H__ */
/* END */
+9 -16
View File
@@ -55,7 +55,7 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* This section describes the FreeType 2 cache sub-system which is */
/* stile in beta. */
/* still in beta. */
/* */
/* <Order> */
/* FTC_Manager */
@@ -63,11 +63,13 @@ FT_BEGIN_HEADER
/* FTC_Face_Requester */
/* */
/* FTC_Manager_New */
/* FTC_Manager_Reset */
/* FTC_Manager_Done */
/* FTC_Manager_LookupFace */
/* FTC_Manager_LookupSize */
/* FTC_Manager_RemoveFaceID */
/* */
/* FTC_Node */
/* FTC_Node_Ref */
/* FTC_Node_Unref */
/* */
/* FTC_Font */
@@ -80,13 +82,9 @@ FT_BEGIN_HEADER
/* FTC_SBitCache_New */
/* FTC_SBitCache_Lookup */
/* */
/* */
/* FTC_Image_Desc */
/* FTC_Image_Cache */
/* FTC_Image_Cache_Lookup */
/* */
/* FTC_SBit_Cache */
/* FTC_SBit_Cache_Lookup */
/* FTC_CMapCache */
/* FTC_CMapCache_New */
/* FTC_CMapCache_Lookup */
/* */
/*************************************************************************/
@@ -502,11 +500,6 @@ FT_BEGIN_HEADER
FTC_CMapCache *acache );
/* retrieve the index of a given charmap */
FT_EXPORT( FT_Int )
FT_Get_CharMap_Index( FT_CharMap charmap );
/*************************************************************************/
/* */
/* @function: */
@@ -519,9 +512,9 @@ FT_BEGIN_HEADER
/* @input: */
/* cache :: A charmap cache handle. */
/* */
/* face_id :: source face id */
/* face_id :: The source face ID. */
/* */
/* cmap_index :: index of charmap in source face */
/* cmap_index :: The index of the charmap in the source face. */
/* */
/* char_code :: The character code (in the corresponding charmap). */
/* */
+14 -1
View File
@@ -1,3 +1,11 @@
/***************************************************************************/
/* */
/* This file defines the structure of the FreeType reference. */
/* It is used by the python script which generates the HTML files. */
/* */
/***************************************************************************/
/***************************************************************************/
/* */
/* <Chapter> */
@@ -31,6 +39,8 @@
/* sfnt_names */
/* bdf_fonts */
/* pfr_fonts */
/* winfnt_fonts */
/* ot_validation */
/* */
/***************************************************************************/
@@ -61,9 +71,12 @@
/* computations */
/* list_processing */
/* outline_processing */
/* bitmap_handling */
/* raster */
/* glyph_stroker */
/* system_interface */
/* module_management */
/* gzip */
/* lzw */
/* */
/***************************************************************************/
+14 -15
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType error code handling (specification). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,17 +25,12 @@
/* I - Error Formats */
/* ----------------- */
/* */
/* Since release 2.1, the error constants have changed. The lower */
/* byte of the error value gives the "generic" error code, while the */
/* higher byte indicates in which module the error occurred. */
/* */
/* You can use the macro FT_ERROR_BASE(x) macro to extract the generic */
/* error code from an FT_Error value. */
/* */
/* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */
/* undefined in ftoption.h in order to make the higher byte always */
/* zero, in case you need to be compatible with previous versions of */
/* FreeType 2. */
/* defined in ftoption.h in order to make the higher byte indicate */
/* the module where the error has happened (this is not compatible */
/* with standard builds of FreeType 2). You can then use the macro */
/* FT_ERROR_BASE macro to extract the generic error code from an */
/* FT_Error value. */
/* */
/* */
/* II - Error Message strings */
@@ -158,7 +153,7 @@
#define FT_ERRORDEF_( e, v, s ) \
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
/* this is only used for FT_Err_Ok, which must be 0! */
/* this is only used for <module>_Err_Ok, which must be 0! */
#define FT_NOERRORDEF_( e, v, s ) \
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
@@ -168,7 +163,7 @@
#endif
/* no include the error codes */
/* now include the error codes */
#include FT_ERROR_DEFINITIONS_H
@@ -197,9 +192,13 @@
#undef FT_NOERRORDEF_
#undef FT_NEED_EXTERN_C
#undef FT_ERR_PREFIX
#undef FT_ERR_BASE
#undef FT_ERR_CONCAT
#undef FT_ERR_BASE
/* FT_KEEP_ERR_PREFIX is needed for ftvalid.h */
#ifndef FT_KEEP_ERR_PREFIX
#undef FT_ERR_PREFIX
#endif
#endif /* __FTERRORS_H__ */
+2 -2
View File
@@ -4,7 +4,7 @@
/* */
/* Gzip-compressed stream support. */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
/* GZIP Streams */
/* */
/* <Abstract> */
/* Using gzip-compressed font files */
/* Using gzip-compressed font files. */
/* */
/* <Description> */
/* This section contains the declaration of Gzip-specific functions. */
+11 -17
View File
@@ -5,7 +5,7 @@
/* FreeType glyph image formats and default raster interface */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -264,25 +264,19 @@ FT_BEGIN_HEADER
/* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
/* See @FT_Pixel_Mode for possible values. */
/* */
/* palette_mode :: This field is only used with paletted pixel modes; */
/* it indicates how the palette is stored. */
/* palette_mode :: This field is intended for paletted pixel modes; */
/* it indicates how the palette is stored. Not */
/* used currently. */
/* */
/* palette :: A typeless pointer to the bitmap palette; only */
/* used for paletted pixel modes. */
/* palette :: A typeless pointer to the bitmap palette; this */
/* field is intended for paletted pixel modes. Not */
/* used currently. */
/* */
/* <Note> */
/* For now, the only pixel mode supported by FreeType are mono and */
/* For now, the only pixel modes supported by FreeType are mono and */
/* grays. However, drivers might be added in the future to support */
/* more `colorful' options. */
/* */
/* When using pixel modes pal2, pal4 and pal8 with a void `palette' */
/* field, a gray pixmap with respectively 4, 16, and 256 levels of */
/* gray is assumed. This, in order to be compatible with some */
/* embedded bitmap formats defined in the TrueType specification. */
/* */
/* Note that no font was found presenting such embedded bitmaps, so */
/* this is currently completely unhandled by the library. */
/* */
typedef struct FT_Bitmap_
{
int rows;
@@ -772,7 +766,7 @@ FT_BEGIN_HEADER
/* raster */
/* */
/* <Title> */
/* Scanline converter */
/* Scanline Converter */
/* */
/* <Abstract> */
/* How vectorial outlines are converted into bitmaps and pixmaps. */
@@ -1036,8 +1030,8 @@ FT_BEGIN_HEADER
/* */
typedef struct FT_Raster_Params_
{
FT_Bitmap* target;
void* source;
const FT_Bitmap* target;
const void* source;
int flags;
FT_SpanFunc gray_spans;
FT_SpanFunc black_spans;
+1 -1
View File
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
/* LZW Streams */
/* */
/* <Abstract> */
/* Using LZW-compressed font files */
/* Using LZW-compressed font files. */
/* */
/* <Description> */
/* This section contains the declaration of LZW-specific functions. */
+1 -1
View File
@@ -41,7 +41,7 @@ FT_BEGIN_HEADER
/* mac_specific */
/* */
/* <Title> */
/* Mac-Specific Interface */
/* Mac Specific Interface */
/* */
/* <Abstract> */
/* Only available on the Macintosh. */
+193 -3
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType Multiple Master font interface (specification). */
/* */
/* Copyright 1996-2001 by */
/* Copyright 1996-2001, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -43,6 +43,12 @@ FT_BEGIN_HEADER
/* Master fonts, i.e. the selection of specific design instances by */
/* setting design axis coordinates. */
/* */
/* George Williams has extended this interface to make it work with */
/* both Type 1 Multiple Masters fonts, and GX distortable (var) */
/* fonts. Some of these routines only work with MM fonts, others */
/* will work with both types. They are similar enough that a */
/* consistent interface makes sense. */
/* */
/*************************************************************************/
@@ -55,6 +61,8 @@ FT_BEGIN_HEADER
/* A simple structure used to model a given axis in design space for */
/* Multiple Masters fonts. */
/* */
/* This structure can't be used for GX var fonts. */
/* */
/* <Fields> */
/* name :: The axis's name. */
/* */
@@ -80,6 +88,8 @@ FT_BEGIN_HEADER
/* A structure used to model the axes and space of a Multiple Masters */
/* font. */
/* */
/* This structure can't be used for GX var fonts. */
/* */
/* <Fields> */
/* num_axis :: Number of axes. Cannot exceed 4. */
/* */
@@ -98,7 +108,118 @@ FT_BEGIN_HEADER
} FT_Multi_Master;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Var_Axis */
/* */
/* <Description> */
/* A simple structure used to model a given axis in design space for */
/* Multiple Masters and GX var fonts. */
/* */
/* <Fields> */
/* name :: The axis's name. */
/* Not always meaningful for GX. */
/* */
/* minimum :: The axis's minimum design coordinate. */
/* */
/* def :: The axis's default design coordinate. */
/* FreeType computes meaningful default values for MM; it */
/* is then an integer value, not in 16.16 format. */
/* */
/* maximum :: The axis's maximum design coordinate. */
/* */
/* tag :: The axis's tag (the GX equivalent to `name'). */
/* FreeType provides default values for MM if possible. */
/* */
/* strid :: The entry in `name' table (another GX version of */
/* `name'). */
/* Not meaningful for MM. */
/* */
typedef struct FT_Var_Axis_
{
FT_String* name;
FT_Fixed minimum;
FT_Fixed def;
FT_Fixed maximum;
FT_ULong tag;
FT_UInt strid;
} FT_Var_Axis;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_Var_Named_Style */
/* */
/* <Description> */
/* A simple structure used to model a named style in a GX var font. */
/* */
/* This structure can't be used for MM fonts. */
/* */
/* <Fields> */
/* coords :: The design coordinates for this style. */
/* This is an array with one entry for each axis. */
/* */
/* strid :: The entry in `name' table identifying this style. */
/* */
typedef struct FT_Var_Named_Style_
{
FT_Fixed* coords;
FT_UInt strid;
} FT_Var_Named_Style;
/*************************************************************************/
/* */
/* <Struct> */
/* FT_MM_Var */
/* */
/* <Description> */
/* A structure used to model the axes and space of a Multiple Masters */
/* or GX var distortable font. */
/* */
/* Some fields are specific to one format and not to the other. */
/* */
/* <Fields> */
/* num_axis :: The number of axes. The maximum value is 4 for */
/* MM; no limit in GX. */
/* */
/* num_designs :: The number of designs; should be normally */
/* 2^num_axis for MM fonts. Not meaningful for GX */
/* (where every glyph could have a different */
/* number of designs). */
/* */
/* num_namedstyles :: The number of named styles; only meaningful for */
/* GX which allows certain design coordinates to */
/* have a string ID (in the `name' table) */
/* associated with them. The font can tell the */
/* user that, for example, Weight=1.5 is `Bold'. */
/* */
/* axis :: A table of axis descriptors. */
/* GX fonts contain slightly more data than MM. */
/* */
/* namedstyles :: A table of named styles. */
/* Only meaningful with GX. */
/* */
typedef struct FT_MM_Var_
{
FT_UInt num_axis;
FT_UInt num_designs;
FT_UInt num_namedstyles;
FT_Var_Axis* axis;
FT_Var_Named_Style* namedstyle;
} FT_MM_Var;
/* */
/*************************************************************************/
/* */
@@ -108,6 +229,8 @@ FT_BEGIN_HEADER
/* <Description> */
/* Retrieves the Multiple Master descriptor of a given font. */
/* */
/* This function can't be used with GX fonts. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
@@ -122,6 +245,30 @@ FT_BEGIN_HEADER
FT_Multi_Master *amaster );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Get_MM_Var */
/* */
/* <Description> */
/* Retrieves the Multiple Master/GX var descriptor of a given font. */
/* */
/* <Input> */
/* face :: A handle to the source face. */
/* */
/* <Output> */
/* amaster :: The Multiple Masters descriptor. */
/* Allocates a data structure, which the user must free */
/* (a single call to FT_FREE will do it). */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT( FT_Error )
FT_Get_MM_Var( FT_Face face,
FT_MM_Var* *amaster );
/*************************************************************************/
/* */
/* <Function> */
@@ -131,6 +278,8 @@ FT_BEGIN_HEADER
/* For Multiple Masters fonts, choose an interpolated font design */
/* through design coordinates. */
/* */
/* This function can't be used with GX fonts. */
/* */
/* <InOut> */
/* face :: A handle to the source face. */
/* */
@@ -149,14 +298,41 @@ FT_BEGIN_HEADER
FT_Long* coords );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Set_Var_Design_Coordinates */
/* */
/* <Description> */
/* For Multiple Master or GX Var fonts, choose an interpolated font */
/* design through design coordinates. */
/* */
/* <InOut> */
/* face :: A handle to the source face. */
/* */
/* <Input> */
/* num_coords :: The number of design coordinates (must be equal to */
/* the number of axes in the font). */
/* */
/* coords :: An array of design coordinates. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT( FT_Error )
FT_Set_Var_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Set_MM_Blend_Coordinates */
/* */
/* <Description> */
/* For Multiple Masters fonts, choose an interpolated font design */
/* through normalized blend coordinates. */
/* For Multiple Masters and GX var fonts, choose an interpolated font */
/* design through normalized blend coordinates. */
/* */
/* <InOut> */
/* face :: A handle to the source face. */
@@ -177,6 +353,20 @@ FT_BEGIN_HEADER
FT_Fixed* coords );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Set_Var_Blend_Coordinates */
/* */
/* <Description> */
/* This is another name of @FT_Set_MM_Blend_Coordinates. */
/* */
FT_EXPORT( FT_Error )
FT_Set_Var_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
/* */
+17 -16
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType module error offsets (specification). */
/* */
/* Copyright 2001, 2002, 2003, 2004 by */
/* Copyright 2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -23,8 +23,8 @@
/* The lower byte gives the error code, the higher byte gives the */
/* module. The base module has error offset 0. For example, the error */
/* `FT_Err_Invalid_File_Format' has value 0x003, the error */
/* `TT_Err_Invalid_File_Format' has value 0x1003, the error */
/* `T1_Err_Invalid_File_Format' has value 0x1103, etc. */
/* `TT_Err_Invalid_File_Format' has value 0x1103, the error */
/* `T1_Err_Invalid_File_Format' has value 0x1203, etc. */
/* */
/* Undefine the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in ftoption.h */
/* to make the higher byte always zero (disabling the module error */
@@ -103,25 +103,26 @@
FT_MODERRDEF( Base, 0x000, "base module" )
FT_MODERRDEF( Autohint, 0x100, "autohinter module" )
FT_MODERRDEF( Autofit, 0x100, "autofitter module" )
FT_MODERRDEF( BDF, 0x200, "BDF module" )
FT_MODERRDEF( Cache, 0x300, "cache module" )
FT_MODERRDEF( CFF, 0x400, "CFF module" )
FT_MODERRDEF( CID, 0x500, "CID module" )
FT_MODERRDEF( Gzip, 0x600, "Gzip module" )
FT_MODERRDEF( LZW, 0x700, "LZW module" )
FT_MODERRDEF( PCF, 0x800, "PCF module" )
FT_MODERRDEF( PFR, 0x900, "PFR module" )
FT_MODERRDEF( PSaux, 0xA00, "PS auxiliary module" )
FT_MODERRDEF( PShinter, 0xB00, "PS hinter module" )
FT_MODERRDEF( PSnames, 0xC00, "PS names module" )
FT_MODERRDEF( Raster, 0xD00, "raster module" )
FT_MODERRDEF( SFNT, 0xE00, "SFNT module" )
FT_MODERRDEF( Smooth, 0xF00, "smooth raster module" )
FT_MODERRDEF( TrueType, 0x1000, "TrueType module" )
FT_MODERRDEF( Type1, 0x1100, "Type 1 module" )
FT_MODERRDEF( Type42, 0x1200, "Type 42 module" )
FT_MODERRDEF( Winfonts, 0x1300, "Windows FON/FNT module" )
FT_MODERRDEF( OTvalid, 0x800, "OpenType validation module" )
FT_MODERRDEF( PCF, 0x900, "PCF module" )
FT_MODERRDEF( PFR, 0xA00, "PFR module" )
FT_MODERRDEF( PSaux, 0xB00, "PS auxiliary module" )
FT_MODERRDEF( PShinter, 0xC00, "PS hinter module" )
FT_MODERRDEF( PSnames, 0xD00, "PS names module" )
FT_MODERRDEF( Raster, 0xE00, "raster module" )
FT_MODERRDEF( SFNT, 0xF00, "SFNT module" )
FT_MODERRDEF( Smooth, 0x1000, "smooth raster module" )
FT_MODERRDEF( TrueType, 0x1100, "TrueType module" )
FT_MODERRDEF( Type1, 0x1200, "Type 1 module" )
FT_MODERRDEF( Type42, 0x1300, "Type 42 module" )
FT_MODERRDEF( Winfonts, 0x1400, "Windows FON/FNT module" )
#ifdef FT_MODERR_END_LIST
+170
View File
@@ -0,0 +1,170 @@
/***************************************************************************/
/* */
/* ftotval.h */
/* */
/* FreeType API for validating OpenType tables (specification). */
/* */
/* Copyright 2004, 2005 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. */
/* */
/***************************************************************************/
/***************************************************************************/
/* */
/* */
/* Warning: This module might be moved to a different library in the */
/* future to avoid a tight dependency between FreeType and the */
/* OpenType specification. */
/* */
/* */
/***************************************************************************/
#ifndef __FTOTVAL_H__
#define __FTOTVAL_H__
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Section> */
/* ot_validation */
/* */
/* <Title> */
/* OpenType Validation */
/* */
/* <Abstract> */
/* An API to validate OpenType tables. */
/* */
/* <Description> */
/* This section contains the declaration of functions to validate */
/* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF). */
/* */
/*************************************************************************/
/**********************************************************************
*
* @enum:
* FT_VALIDATE_XXX
*
* @description:
* A list of bit-field constants used with @FT_OpenType_Validate to
* indicate which OpenType tables should be validated.
*
* @values:
* FT_VALIDATE_BASE ::
* Validate BASE table.
*
* FT_VALIDATE_GDEF ::
* Validate GDEF table.
*
* FT_VALIDATE_GPOS ::
* Validate GPOS table.
*
* FT_VALIDATE_GSUB ::
* Validate GSUB table.
*
* FT_VALIDATE_JSTF ::
* Validate JSTF table.
*
* FT_VALIDATE_OT ::
* Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF).
*
*/
#define FT_VALIDATE_BASE 0x0100
#define FT_VALIDATE_GDEF 0x0200
#define FT_VALIDATE_GPOS 0x0400
#define FT_VALIDATE_GSUB 0x0800
#define FT_VALIDATE_JSTF 0x1000
#define FT_VALIDATE_OT FT_VALIDATE_BASE | \
FT_VALIDATE_GDEF | \
FT_VALIDATE_GPOS | \
FT_VALIDATE_GSUB | \
FT_VALIDATE_JSTF
/* */
/**********************************************************************
*
* @function:
* FT_OpenType_Validate
*
* @description:
* Validate various OpenType tables to assure that all offsets and
* indices are valid. The idea is that a higher-level library which
* actually does the text layout can access those tables without
* error checking (which can be quite time consuming).
*
* @input:
* face ::
* A handle to the input face.
*
* validation_flags ::
* A bit field which specifies the tables to be validated. See
* @FT_VALIDATE_XXX for possible values.
*
* @output:
* BASE_table ::
* A pointer to the BASE table.
*
* GDEF_table ::
* A pointer to the GDEF table.
*
* GPOS_table ::
* A pointer to the GPOS table.
*
* GSUB_table ::
* A pointer to the GSUB table.
*
* JSTF_table ::
* A pointer to the JSTF table.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* This function only works with OpenType fonts, returning an error
* otherwise.
*
* After use, the application should deallocate the five tables with
* `free'. A NULL value indicates that the table either doesn't exist
* in the font, or the application hasn't asked for validation.
*/
FT_EXPORT( FT_Error )
FT_OpenType_Validate( FT_Face face,
FT_UInt validation_flags,
FT_Bytes *BASE_table,
FT_Bytes *GDEF_table,
FT_Bytes *GPOS_table,
FT_Bytes *GSUB_table,
FT_Bytes *JSTF_table );
/* */
FT_END_HEADER
#endif /* __FTOTVAL_H__ */
/* END */
+33 -7
View File
@@ -5,7 +5,7 @@
/* Support for the FT_Outline type used to store glyph shapes of */
/* most scalable font formats (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003 by */
/* Copyright 1996-2001, 2002, 2003, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -58,6 +58,7 @@ FT_BEGIN_HEADER
/* FT_Outline_Copy */
/* FT_Outline_Translate */
/* FT_Outline_Transform */
/* FT_Outline_Embolden */
/* FT_Outline_Reverse */
/* FT_Outline_Check */
/* */
@@ -229,7 +230,7 @@ FT_BEGIN_HEADER
/* acbox :: The outline's control box. */
/* */
FT_EXPORT( void )
FT_Outline_Get_CBox( FT_Outline* outline,
FT_Outline_Get_CBox( const FT_Outline* outline,
FT_BBox *acbox );
@@ -250,7 +251,7 @@ FT_BEGIN_HEADER
/* yOffset :: The vertical offset. */
/* */
FT_EXPORT( void )
FT_Outline_Translate( FT_Outline* outline,
FT_Outline_Translate( const FT_Outline* outline,
FT_Pos xOffset,
FT_Pos yOffset );
@@ -275,7 +276,7 @@ FT_BEGIN_HEADER
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT( FT_Error )
FT_Outline_Copy( FT_Outline* source,
FT_Outline_Copy( const FT_Outline* source,
FT_Outline *target );
@@ -299,8 +300,33 @@ FT_BEGIN_HEADER
/* outline's points. */
/* */
FT_EXPORT( void )
FT_Outline_Transform( FT_Outline* outline,
FT_Matrix* matrix );
FT_Outline_Transform( const FT_Outline* outline,
const FT_Matrix* matrix );
/*************************************************************************/
/* */
/* <Function> */
/* FT_Outline_Embolden */
/* */
/* <Description> */
/* Emboldens an outline. The new outline will be at most 4 times */
/* `strength' pixels wider and higher. You may think of the left and */
/* bottom borders as unchanged. */
/* */
/* <InOut> */
/* outline :: A handle to the target outline. */
/* */
/* <Input> */
/* strength :: How strong the glyph is emboldened. Expressed in */
/* 26.6 pixel format. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Embolden( FT_Outline* outline,
FT_Pos strength );
/*************************************************************************/
@@ -355,7 +381,7 @@ FT_BEGIN_HEADER
FT_EXPORT( FT_Error )
FT_Outline_Get_Bitmap( FT_Library library,
FT_Outline* outline,
FT_Bitmap *abitmap );
const FT_Bitmap *abitmap );
/*************************************************************************/
+3 -3
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing PFR-specific data (specification only). */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -41,7 +41,7 @@ FT_BEGIN_HEADER
/* PFR Fonts */
/* */
/* <Abstract> */
/* PFR/TrueDoc specific APIs */
/* PFR/TrueDoc specific API. */
/* */
/* <Description> */
/* This section contains the declaration of PFR-specific functions. */
@@ -166,7 +166,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __FTBDF_H__ */
#endif /* __FTPFR_H__ */
/* END */
+1 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType renderer modules public interface (specification). */
/* */
/* Copyright 1996-2001 by */
/* Copyright 1996-2001, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
+3 -3
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType size objects management (specification). */
/* */
/* Copyright 1996-2001, 2003 by */
/* Copyright 1996-2001, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -48,10 +48,10 @@ FT_BEGIN_HEADER
/* sizes_management */
/* */
/* <Title> */
/* Size management */
/* Size Management */
/* */
/* <Abstract> */
/* Managing multiple sizes per face */
/* Managing multiple sizes per face. */
/* */
/* <Description> */
/* When creating a new face object (e.g. with @FT_New_Face), an */
+27 -3
View File
@@ -23,9 +23,33 @@
#include FT_OUTLINE_H
#include FT_GLYPH_H
FT_BEGIN_HEADER
/*@*************************************************************
/************************************************************************
*
* <Section>
* glyph_stroker
*
* <Title>
* Glyph Stroker
*
* <Abstract>
* Generating bordered and stroked glyphs.
*
* <Description>
* This component generates stroked outlines of a given vectorial
* glyph. It also allows you to retrieve the `outside' and/or the
* `inside' borders of the stroke.
*
* This can be useful to generate `bordered' glyph, i.e., glyphs
* displayed with a coloured (and anti-aliased) border around their
* shape.
*/
/**************************************************************
*
* @type:
* FT_Stroker
@@ -36,7 +60,7 @@ FT_BEGIN_HEADER
typedef struct FT_StrokerRec_* FT_Stroker;
/*@*************************************************************
/**************************************************************
*
* @enum:
* FT_Stroker_LineJoin
@@ -69,7 +93,7 @@ FT_BEGIN_HEADER
} FT_Stroker_LineJoin;
/*@*************************************************************
/**************************************************************
*
* @enum:
* FT_Stroker_LineCap
+27 -3
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType simple types definitions (specification only). */
/* */
/* Copyright 1996-2001 by */
/* Copyright 1996-2001, 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -49,6 +49,7 @@ FT_BEGIN_HEADER
/* */
/* <Order> */
/* FT_Byte */
/* FT_Bytes */
/* FT_Char */
/* FT_Int */
/* FT_UInt */
@@ -60,6 +61,7 @@ FT_BEGIN_HEADER
/* FT_Offset */
/* FT_PtrDist */
/* FT_String */
/* FT_Tag */
/* FT_Error */
/* FT_Fixed */
/* FT_Pointer */
@@ -143,6 +145,28 @@ FT_BEGIN_HEADER
typedef unsigned char FT_Byte;
/*************************************************************************/
/* */
/* <Type> */
/* FT_Bytes */
/* */
/* <Description> */
/* A typedef for constant memory areas. */
/* */
typedef const FT_Byte* FT_Bytes;
/*************************************************************************/
/* */
/* <Type> */
/* FT_Tag */
/* */
/* <Description> */
/* A typedef for 32bit tags (as used in the SFNT format). */
/* */
typedef FT_UInt32 FT_Tag;
/*************************************************************************/
/* */
/* <Type> */
@@ -184,7 +208,7 @@ FT_BEGIN_HEADER
/* <Description> */
/* A typedef for the int type. */
/* */
typedef int FT_Int;
typedef signed int FT_Int;
/*************************************************************************/
@@ -301,7 +325,7 @@ FT_BEGIN_HEADER
/* largest _signed_ integer type used to express the distance */
/* between two pointers. */
/* */
typedef size_t FT_PtrDist;
typedef ft_ptrdiff_t FT_PtrDist;
/*************************************************************************/
+3 -3
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing Windows fnt-specific data. */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -38,10 +38,10 @@ FT_BEGIN_HEADER
/* winfnt_fonts */
/* */
/* <Title> */
/* Window FNT Fonts */
/* Window FNT Files */
/* */
/* <Abstract> */
/* Windows FNT specific APIs */
/* Windows FNT specific API. */
/* */
/* <Description> */
/* This section contains the declaration of Windows FNT specific */
@@ -4,7 +4,7 @@
/* */
/* Arithmetic computations (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003 by */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,6 +27,23 @@
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Function> */
/* FT_FixedSqrt */
/* */
/* <Description> */
/* Computes the square root of a 16.16 fixed point value. */
/* */
/* <Input> */
/* x :: The value to compute the root for. */
/* */
/* <Return> */
/* The result of `sqrt(x)'. */
/* */
/* <Note> */
/* This function is not very fast. */
/* */
FT_EXPORT( FT_Int32 )
FT_SqrtFixed( FT_Int32 x );
@@ -4,7 +4,7 @@
/* */
/* The FreeType memory management macros (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004 by */
/* Copyright 1996-2001, 2002, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -43,6 +43,7 @@ FT_BEGIN_HEADER
( ( error = (expression) ) != 0 )
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -64,6 +65,13 @@ FT_BEGIN_HEADER
const char* file_name,
FT_Long line_no );
FT_BASE( FT_Error )
FT_QAlloc_Debug( FT_Memory memory,
FT_Long size,
void* *P,
const char* file_name,
FT_Long line_no );
FT_BASE( FT_Error )
FT_Realloc_Debug( FT_Memory memory,
FT_Long current,
@@ -72,6 +80,14 @@ FT_BEGIN_HEADER
const char* file_name,
FT_Long line_no );
FT_BASE( FT_Error )
FT_QRealloc_Debug( FT_Memory memory,
FT_Long current,
FT_Long size,
void* *P,
const char* file_name,
FT_Long line_no );
FT_BASE( void )
FT_Free_Debug( FT_Memory memory,
FT_Pointer block,
@@ -109,6 +125,34 @@ FT_BEGIN_HEADER
void* *P );
/*************************************************************************/
/* */
/* <Function> */
/* FT_QAlloc */
/* */
/* <Description> */
/* Allocates a new block of memory. The returned area is *not* */
/* zero-filled, making allocation quicker. */
/* */
/* <Input> */
/* memory :: A handle to a given `memory object' which handles */
/* allocation. */
/* */
/* size :: The size in bytes of the block to allocate. */
/* */
/* <Output> */
/* P :: A pointer to the fresh new block. It should be set to */
/* NULL if `size' is 0, or in case of error. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
FT_BASE( FT_Error )
FT_QAlloc( FT_Memory memory,
FT_Long size,
void* *p );
/*************************************************************************/
/* */
/* <Function> */
@@ -116,7 +160,8 @@ FT_BEGIN_HEADER
/* */
/* <Description> */
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */
/* from the heap, possibly changing `*P'. */
/* from the heap, possibly changing `*P'. The returned area is */
/* zero-filled. */
/* */
/* <Input> */
/* memory :: A handle to a given `memory object' which handles */
@@ -144,6 +189,42 @@ FT_BEGIN_HEADER
void* *P );
/*************************************************************************/
/* */
/* <Function> */
/* FT_QRealloc */
/* */
/* <Description> */
/* Reallocates a block of memory pointed to by `*P' to `Size' bytes */
/* from the heap, possibly changing `*P'. The returned area is *not* */
/* zero-filled, making reallocation quicker. */
/* */
/* <Input> */
/* memory :: A handle to a given `memory object' which handles */
/* reallocation. */
/* */
/* current :: The current block size in bytes. */
/* */
/* size :: The new block size in bytes. */
/* */
/* <InOut> */
/* P :: A pointer to the fresh new block. It should be set to */
/* NULL if `size' is 0, or in case of error. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* All callers of FT_Realloc() _must_ provide the current block size */
/* as well as the new one. */
/* */
FT_BASE( FT_Error )
FT_QRealloc( FT_Memory memory,
FT_Long current,
FT_Long size,
void* *p );
/*************************************************************************/
/* */
/* <Function> */
@@ -180,11 +261,24 @@ FT_BEGIN_HEADER
#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
#define FT_ARRAY_ZERO( dest, count ) \
FT_MEM_ZERO( dest, (count) * sizeof ( *(dest) ) )
#define FT_ARRAY_COPY( dest, source, count ) \
FT_MEM_COPY( dest, source, (count) * sizeof( *(dest) ) )
FT_MEM_COPY( dest, source, (count) * sizeof ( *(dest) ) )
#define FT_ARRAY_MOVE( dest, source, count ) \
FT_MEM_MOVE( dest, source, (count) * sizeof( *(dest) ) )
FT_MEM_MOVE( dest, source, (count) * sizeof ( *(dest) ) )
/*
* Return the maximum number of adressable elements in an array.
* We limit ourselves to INT_MAX, rather than UINT_MAX, to avoid
* any problems.
*/
#define FT_ARRAY_MAX( ptr ) ( FT_INT_MAX / sizeof ( *(ptr) ) )
#define FT_ARRAY_CHECK( ptr, count ) ( (count) <= FT_ARRAY_MAX( ptr ) )
/*************************************************************************/
@@ -198,28 +292,51 @@ FT_BEGIN_HEADER
#define FT_MEM_ALLOC( _pointer_, _size_ ) \
FT_Alloc_Debug( memory, _size_, \
(void**)&(_pointer_), __FILE__, __LINE__ )
(void**)(void*)&(_pointer_), \
__FILE__, __LINE__ )
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \
FT_Realloc_Debug( memory, _current_, _size_, \
(void**)&(_pointer_), __FILE__, __LINE__ )
(void**)(void*)&(_pointer_), \
__FILE__, __LINE__ )
#define FT_MEM_QALLOC( _pointer_, _size_ ) \
FT_QAlloc_Debug( memory, _size_, \
(void**)(void*)&(_pointer_), \
__FILE__, __LINE__ )
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \
FT_QRealloc_Debug( memory, _current_, _size_, \
(void**)(void*)&(_pointer_), \
__FILE__, __LINE__ )
#define FT_MEM_FREE( _pointer_ ) \
FT_Free_Debug( memory, (void**)&(_pointer_), __FILE__, __LINE__ )
FT_Free_Debug( memory, (void**)(void*)&(_pointer_), \
__FILE__, __LINE__ )
#else /* !FT_DEBUG_MEMORY */
#define FT_MEM_ALLOC( _pointer_, _size_ ) \
FT_Alloc( memory, _size_, (void**)&(_pointer_) )
FT_Alloc( memory, _size_, \
(void**)(void*)&(_pointer_) )
#define FT_MEM_FREE( _pointer_ ) \
FT_Free( memory, (void**)&(_pointer_) )
FT_Free( memory, \
(void**)(void*)&(_pointer_) )
#define FT_MEM_REALLOC( _pointer_, _current_, _size_ ) \
FT_Realloc( memory, _current_, _size_, (void**)&(_pointer_) )
FT_Realloc( memory, _current_, _size_, \
(void**)(void*)&(_pointer_) )
#define FT_MEM_QALLOC( _pointer_, _size_ ) \
FT_QAlloc( memory, _size_, \
(void**)(void*)&(_pointer_) )
#define FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) \
FT_QRealloc( memory, _current_, _size_, \
(void**)(void*)&(_pointer_) )
#endif /* !FT_DEBUG_MEMORY */
@@ -240,6 +357,16 @@ FT_BEGIN_HEADER
FT_MEM_REALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \
(_new_) * sizeof ( *(_pointer_) ) )
#define FT_MEM_QNEW( _pointer_ ) \
FT_MEM_QALLOC( _pointer_, sizeof ( *(_pointer_) ) )
#define FT_MEM_QNEW_ARRAY( _pointer_, _count_ ) \
FT_MEM_QALLOC( _pointer_, (_count_) * sizeof ( *(_pointer_) ) )
#define FT_MEM_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_MEM_QREALLOC( _pointer_, (_old_) * sizeof ( *(_pointer_) ), \
(_new_) * sizeof ( *(_pointer_) ) )
/*************************************************************************/
/* */
@@ -267,26 +394,45 @@ FT_BEGIN_HEADER
#define FT_REALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, _current_, _size_ ) )
#define FT_QALLOC( _pointer_, _size_ ) \
FT_SET_ERROR( FT_MEM_QALLOC( _pointer_, _size_ ) )
#define FT_QREALLOC( _pointer_, _current_, _size_ ) \
FT_SET_ERROR( FT_MEM_QREALLOC( _pointer_, _current_, _size_ ) )
#define FT_FREE( _pointer_ ) \
FT_MEM_FREE( _pointer_ )
#define FT_NEW( _pointer_ ) \
FT_SET_ERROR( FT_MEM_NEW( _pointer_ ) )
FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) )
#define FT_NEW_ARRAY( _pointer_, _count_ ) \
FT_SET_ERROR( FT_MEM_NEW_ARRAY( _pointer_, _count_ ) )
FT_ALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) )
#define FT_RENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_SET_ERROR( FT_MEM_RENEW_ARRAY( _pointer_, _old_, _new_ ) )
FT_REALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \
sizeof ( *(_pointer_) ) * (_new_) )
#define FT_QNEW( _pointer_ ) \
FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) )
#define FT_QNEW_ARRAY( _pointer_, _count_ ) \
FT_QALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_count_) )
#define FT_QRENEW_ARRAY( _pointer_, _old_, _new_ ) \
FT_QREALLOC( _pointer_, sizeof ( *(_pointer_) ) * (_old_), \
sizeof ( *(_pointer_) ) * (_new_) )
#define FT_ALLOC_ARRAY( _pointer_, _count_, _type_ ) \
FT_SET_ERROR( FT_MEM_ALLOC( _pointer_, \
(_count_) * sizeof ( _type_ ) ) )
FT_ALLOC( _pointer_, (_count_) * sizeof ( _type_ ) )
#define FT_REALLOC_ARRAY( _pointer_, _old_, _new_, _type_ ) \
FT_SET_ERROR( FT_MEM_REALLOC( _pointer_, \
(_old_) * sizeof ( _type_ ), \
(_new_) * sizeof ( _type_ ) ) )
FT_REALLOC( _pointer, (_old_) * sizeof ( _type_ ), \
(_new_) * sizeof ( _type_ ) )
/* */
@@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,7 +27,6 @@
#define __FTOBJS_H__
#include <ft2build.h>
#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */
#include FT_RENDER_H
#include FT_SIZES_H
#include FT_INTERNAL_MEMORY_H
@@ -81,109 +80,12 @@ FT_BEGIN_HEADER
#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** V A L I D A T I O N ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* handle to a validation object */
typedef struct FT_ValidatorRec_* FT_Validator;
/*************************************************************************/
/* */
/* There are three distinct validation levels defined here: */
/* */
/* FT_VALIDATE_DEFAULT :: */
/* A table that passes this validation level can be used reliably by */
/* FreeType. It generally means that all offsets have been checked to */
/* prevent out-of-bound reads, array counts are correct, etc. */
/* */
/* FT_VALIDATE_TIGHT :: */
/* A table that passes this validation level can be used reliably and */
/* doesn't contain invalid data. For example, a charmap table that */
/* returns invalid glyph indices will not pass, even though it can */
/* be used with FreeType in default mode (the library will simply */
/* return an error later when trying to load the glyph). */
/* */
/* It also check that fields that must be a multiple of 2, 4, or 8 */
/* don't have incorrect values, etc. */
/* */
/* FT_VALIDATE_PARANOID :: */
/* Only for font debugging. Checks that a table follows the */
/* specification by 100%. Very few fonts will be able to pass this */
/* level anyway but it can be useful for certain tools like font */
/* editors/converters. */
/* */
typedef enum FT_ValidationLevel_
{
FT_VALIDATE_DEFAULT = 0,
FT_VALIDATE_TIGHT,
FT_VALIDATE_PARANOID
} FT_ValidationLevel;
/* validator structure */
typedef struct FT_ValidatorRec_
{
const FT_Byte* base; /* address of table in memory */
const FT_Byte* limit; /* `base' + sizeof(table) in memory */
FT_ValidationLevel level; /* validation level */
FT_Error error; /* error returned. 0 means success */
ft_jmp_buf jump_buffer; /* used for exception handling */
} FT_ValidatorRec;
#define FT_VALIDATOR( x ) ((FT_Validator)( x ))
FT_BASE( void )
ft_validator_init( FT_Validator valid,
const FT_Byte* base,
const FT_Byte* limit,
FT_ValidationLevel level );
FT_BASE( FT_Int )
ft_validator_run( FT_Validator valid );
/* Sets the error field in a validator, then calls `longjmp' to return */
/* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
/* error checks within the validation routines. */
/* */
FT_BASE( void )
ft_validator_error( FT_Validator valid,
FT_Error error );
/* Calls ft_validate_error. Assumes that the `valid' local variable */
/* holds a pointer to the current validator object. */
/* */
#define FT_INVALID( _error ) ft_validator_error( valid, _error )
/* called when a broken table is detected */
#define FT_INVALID_TOO_SHORT FT_INVALID( FT_Err_Invalid_Table )
/* called when an invalid offset is detected */
#define FT_INVALID_OFFSET FT_INVALID( FT_Err_Invalid_Offset )
/* called when an invalid format/value is detected */
#define FT_INVALID_FORMAT FT_INVALID( FT_Err_Invalid_Table )
/* called when an invalid glyph index is detected */
#define FT_INVALID_GLYPH_ID FT_INVALID( FT_Err_Invalid_Glyph_Index )
/* called when an invalid field value is detected */
#define FT_INVALID_DATA FT_INVALID( FT_Err_Invalid_Table )
/*
* Return the highest power of 2 that is <= value; this correspond to
* the highest bit in a given 32-bit value.
*/
FT_BASE( FT_UInt32 )
ft_highpow2( FT_UInt32 value );
/*************************************************************************/
@@ -257,7 +159,7 @@ FT_BEGIN_HEADER
FT_CharMap charmap,
FT_CMap *acmap );
/* destroy a charmap (don't remove it from face's list though) */
/* destroy a charmap and remove it from face's list */
FT_BASE( void )
FT_CMap_Done( FT_CMap cmap );
@@ -4,7 +4,7 @@
/* */
/* The FreeType services (specification only). */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -34,6 +34,13 @@
FT_BEGIN_HEADER
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* we disable the warning `conditional expression is constant' here */
/* in order to compile cleanly with the maximum level of warnings */
#pragma warning( disable : 4127 )
#endif /* _MSC_VER */
/*
* @macro:
@@ -57,18 +64,33 @@ FT_BEGIN_HEADER
* A variable that receives the service pointer. Will be NULL
* if not found.
*/
#ifdef __cplusplus
#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \
/* the strange cast is to allow C++ compilation */ \
FT_Pointer* Pptr = (FT_Pointer*) &(ptr); \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_ = NULL; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
*Pptr = NULL; \
if ( module->clazz->get_interface ) \
*Pptr = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
_tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_ = NULL; \
\
if ( module->clazz->get_interface ) \
_tmp_ = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
/*
* @macro:
@@ -92,16 +114,33 @@ FT_BEGIN_HEADER
* A variable that receives the service pointer. Will be NULL
* if not found.
*/
#ifdef __cplusplus
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \
/* the strange cast is to allow C++ compilation */ \
FT_Pointer* Pptr = (FT_Pointer*) &(ptr); \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
FT_Pointer* _pptr_ = (FT_Pointer*)&(ptr); \
\
\
*Pptr = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
*_pptr_ = _tmp_; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_FIND_GLOBAL_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Module module = FT_MODULE( FT_FACE( face )->driver ); \
FT_Pointer _tmp_; \
\
\
_tmp_ = ft_module_get_service( module, FT_SERVICE_ID_ ## id ); \
ptr = _tmp_; \
FT_END_STMNT
#endif /* !C++ */
/*************************************************************************/
/*************************************************************************/
@@ -199,27 +238,50 @@ FT_BEGIN_HEADER
* ptr ::
* A variable receiving the service data. NULL if not available.
*/
#ifdef __cplusplus
#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
/* the strange cast is to allow C++ compilation */ \
FT_Pointer* pptr = (FT_Pointer*)&(ptr); \
FT_Pointer svc; \
FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \
\
\
svc = FT_FACE(face)->internal->services. service_ ## id ; \
svc = FT_FACE( face )->internal->services. service_ ## id; \
if ( svc == FT_SERVICE_UNAVAILABLE ) \
svc = NULL; \
else if ( svc == NULL ) \
{ \
FT_FACE_FIND_SERVICE( face, svc, id ); \
\
FT_FACE(face)->internal->services. service_ ## id = \
FT_FACE( face )->internal->services. service_ ## id = \
(FT_Pointer)( svc != NULL ? svc \
: FT_SERVICE_UNAVAILABLE ); \
} \
*pptr = svc; \
*Pptr = svc; \
FT_END_STMNT
#else /* !C++ */
#define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \
FT_BEGIN_STMNT \
FT_Pointer svc; \
\
\
svc = FT_FACE( face )->internal->services. service_ ## id; \
if ( svc == FT_SERVICE_UNAVAILABLE ) \
svc = NULL; \
else if ( svc == NULL ) \
{ \
FT_FACE_FIND_SERVICE( face, svc, id ); \
\
FT_FACE( face )->internal->services. service_ ## id = \
(FT_Pointer)( svc != NULL ? svc \
: FT_SERVICE_UNAVAILABLE ); \
} \
ptr = svc; \
FT_END_STMNT
#endif /* !C++ */
/*
* A macro used to define new service structure types.
@@ -238,17 +300,18 @@ FT_BEGIN_HEADER
* The header files containing the services.
*/
#define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h>
#define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/svgldict.h>
#define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/svmm.h>
#define FT_SERVICE_POSTSCRIPT_NAME_H <freetype/internal/services/svpostnm.h>
#define FT_SERVICE_OPENTYPE_VALIDATE_H <freetype/internal/services/svotval.h>
#define FT_SERVICE_PFR_H <freetype/internal/services/svpfr.h>
#define FT_SERVICE_POSTSCRIPT_CMAPS_H <freetype/internal/services/svpscmap.h>
#define FT_SERVICE_POSTSCRIPT_INFO_H <freetype/internal/services/svpsinfo.h>
#define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/svgldict.h>
#define FT_SERVICE_BDF_H <freetype/internal/services/svbdf.h>
#define FT_SERVICE_XFREE86_NAME_H <freetype/internal/services/svxf86nm.h>
#define FT_SERVICE_POSTSCRIPT_NAME_H <freetype/internal/services/svpostnm.h>
#define FT_SERVICE_SFNT_H <freetype/internal/services/svsfnt.h>
#define FT_SERVICE_PFR_H <freetype/internal/services/svpfr.h>
#define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h>
#define FT_SERVICE_TT_CMAP_H <freetype/internal/services/svttcmap.h>
#define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h>
#define FT_SERVICE_XFREE86_NAME_H <freetype/internal/services/svxf86nm.h>
/* */
@@ -4,7 +4,7 @@
/* */
/* Stream handling (specification). */
/* */
/* Copyright 1996-2001, 2002, 2004 by */
/* Copyright 1996-2001, 2002, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -269,6 +269,25 @@ FT_BEGIN_HEADER
/* */
/* Each GET_xxxx() macro uses an implicit `stream' variable. */
/* */
#if 0
#define FT_GET_MACRO( type ) FT_NEXT_ ## type ( stream->cursor )
#define FT_GET_CHAR() FT_GET_MACRO( CHAR )
#define FT_GET_BYTE() FT_GET_MACRO( BYTE )
#define FT_GET_SHORT() FT_GET_MACRO( SHORT )
#define FT_GET_USHORT() FT_GET_MACRO( USHORT )
#define FT_GET_OFF3() FT_GET_MACRO( OFF3 )
#define FT_GET_UOFF3() FT_GET_MACRO( UOFF3 )
#define FT_GET_LONG() FT_GET_MACRO( LONG )
#define FT_GET_ULONG() FT_GET_MACRO( ULONG )
#define FT_GET_TAG4() FT_GET_MACRO( ULONG )
#define FT_GET_SHORT_LE() FT_GET_MACRO( SHORT_LE )
#define FT_GET_USHORT_LE() FT_GET_MACRO( USHORT_LE )
#define FT_GET_LONG_LE() FT_GET_MACRO( LONG_LE )
#define FT_GET_ULONG_LE() FT_GET_MACRO( ULONG_LE )
#else
#define FT_GET_MACRO( func, type ) ( (type)func( stream ) )
#define FT_GET_CHAR() FT_GET_MACRO( FT_Stream_GetChar, FT_Char )
@@ -285,6 +304,7 @@ FT_BEGIN_HEADER
#define FT_GET_USHORT_LE() FT_GET_MACRO( FT_Stream_GetShortLE, FT_UShort )
#define FT_GET_LONG_LE() FT_GET_MACRO( FT_Stream_GetLongLE, FT_Long )
#define FT_GET_ULONG_LE() FT_GET_MACRO( FT_Stream_GetLongLE, FT_ULong )
#endif
#define FT_READ_MACRO( func, type, var ) \
( var = (type)func( stream, &error ), \
@@ -365,6 +385,13 @@ FT_BEGIN_HEADER
FT_Byte* buffer,
FT_ULong count );
/* try to read bytes at the end of a stream; return number of bytes */
/* really available */
FT_BASE( FT_ULong )
FT_Stream_TryRead( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count );
/* Enter a frame of `count' consecutive bytes in a stream. Returns an */
/* error if the frame could not be read/accessed. The caller can use */
/* the FT_Stream_Get_XXX functions to retrieve frame data without */
@@ -4,7 +4,7 @@
/* */
/* Tracing handling (specification only). */
/* */
/* Copyright 2002, 2004 by */
/* Copyright 2002, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -37,24 +37,26 @@ FT_TRACE_DEF( smooth ) /* anti-aliasing raster (ftgrays.c) */
FT_TRACE_DEF( mm ) /* MM interface (ftmm.c) */
FT_TRACE_DEF( raccess ) /* resource fork accessor (ftrfork.c) */
/* Cache sub-system */
/* Cache sub-system */
FT_TRACE_DEF( cache ) /* cache sub-system (ftcache.c, etc.) */
/* SFNT driver components */
/* SFNT driver components */
FT_TRACE_DEF( sfobjs ) /* SFNT object handler (sfobjs.c) */
FT_TRACE_DEF( ttcmap ) /* charmap handler (ttcmap.c) */
FT_TRACE_DEF( ttkern ) /* kerning handler (ttkern.c) */
FT_TRACE_DEF( ttload ) /* basic TrueType tables (ttload.c) */
FT_TRACE_DEF( ttpost ) /* PS table processing (ttpost.c) */
FT_TRACE_DEF( ttsbit ) /* TrueType sbit handling (ttsbit.c) */
/* TrueType driver components */
/* TrueType driver components */
FT_TRACE_DEF( ttdriver ) /* TT font driver (ttdriver.c) */
FT_TRACE_DEF( ttgload ) /* TT glyph loader (ttgload.c) */
FT_TRACE_DEF( ttinterp ) /* bytecode interpreter (ttinterp.c) */
FT_TRACE_DEF( ttobjs ) /* TT objects manager (ttobjs.c) */
FT_TRACE_DEF( ttpload ) /* TT data/program loader (ttpload.c) */
FT_TRACE_DEF( ttgxvar ) /* TrueType GX var handler (ttgxvar.c) */
/* Type 1 driver components */
/* Type 1 driver components */
FT_TRACE_DEF( t1driver )
FT_TRACE_DEF( t1gload )
FT_TRACE_DEF( t1hint )
@@ -62,26 +64,26 @@ FT_TRACE_DEF( t1load )
FT_TRACE_DEF( t1objs )
FT_TRACE_DEF( t1parse )
/* PostScript helper module `psaux' */
/* PostScript helper module `psaux' */
FT_TRACE_DEF( t1decode )
FT_TRACE_DEF( psobjs )
/* PostScript hinting module `pshinter' */
/* PostScript hinting module `pshinter' */
FT_TRACE_DEF( pshrec )
FT_TRACE_DEF( pshalgo1 )
FT_TRACE_DEF( pshalgo2 )
/* Type 2 driver components */
/* Type 2 driver components */
FT_TRACE_DEF( cffdriver )
FT_TRACE_DEF( cffgload )
FT_TRACE_DEF( cffload )
FT_TRACE_DEF( cffobjs )
FT_TRACE_DEF( cffparse )
/* Type 42 driver component */
/* Type 42 driver component */
FT_TRACE_DEF( t42 )
/* CID driver components */
/* CID driver components */
FT_TRACE_DEF( cidafm )
FT_TRACE_DEF( ciddriver )
FT_TRACE_DEF( cidgload )
@@ -89,19 +91,28 @@ FT_TRACE_DEF( cidload )
FT_TRACE_DEF( cidobjs )
FT_TRACE_DEF( cidparse )
/* Windows fonts component */
/* Windows font component */
FT_TRACE_DEF( winfnt )
/* PCF fonts components */
/* PCF font components */
FT_TRACE_DEF( pcfdriver )
FT_TRACE_DEF( pcfread )
/* BDF fonts component */
/* BDF font components */
FT_TRACE_DEF( bdfdriver )
FT_TRACE_DEF( bdflib )
/* PFR fonts component */
/* PFR font component */
FT_TRACE_DEF( pfr )
/* OpenType validation components */
FT_TRACE_DEF( otvmodule )
FT_TRACE_DEF( otvcommon )
FT_TRACE_DEF( otvbase )
FT_TRACE_DEF( otvgdef )
FT_TRACE_DEF( otvgpos )
FT_TRACE_DEF( otvgsub )
FT_TRACE_DEF( otvjstf )
/* END */
@@ -0,0 +1,148 @@
/***************************************************************************/
/* */
/* ftvalid.h */
/* */
/* FreeType validation support (specification). */
/* */
/* Copyright 2004 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. */
/* */
/***************************************************************************/
#ifndef __FTVALID_H__
#define __FTVALID_H__
#include <ft2build.h>
#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */
FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/**** ****/
/**** ****/
/**** V A L I D A T I O N ****/
/**** ****/
/**** ****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* handle to a validation object */
typedef struct FT_ValidatorRec_* FT_Validator;
/*************************************************************************/
/* */
/* There are three distinct validation levels defined here: */
/* */
/* FT_VALIDATE_DEFAULT :: */
/* A table that passes this validation level can be used reliably by */
/* FreeType. It generally means that all offsets have been checked to */
/* prevent out-of-bound reads, that array counts are correct, etc. */
/* */
/* FT_VALIDATE_TIGHT :: */
/* A table that passes this validation level can be used reliably and */
/* doesn't contain invalid data. For example, a charmap table that */
/* returns invalid glyph indices will not pass, even though it can */
/* be used with FreeType in default mode (the library will simply */
/* return an error later when trying to load the glyph). */
/* */
/* It also checks that fields which must be a multiple of 2, 4, or 8, */
/* don't have incorrect values, etc. */
/* */
/* FT_VALIDATE_PARANOID :: */
/* Only for font debugging. Checks that a table follows the */
/* specification by 100%. Very few fonts will be able to pass this */
/* level anyway but it can be useful for certain tools like font */
/* editors/converters. */
/* */
typedef enum FT_ValidationLevel_
{
FT_VALIDATE_DEFAULT = 0,
FT_VALIDATE_TIGHT,
FT_VALIDATE_PARANOID
} FT_ValidationLevel;
/* validator structure */
typedef struct FT_ValidatorRec_
{
const FT_Byte* base; /* address of table in memory */
const FT_Byte* limit; /* `base' + sizeof(table) in memory */
FT_ValidationLevel level; /* validation level */
FT_Error error; /* error returned. 0 means success */
ft_jmp_buf jump_buffer; /* used for exception handling */
} FT_ValidatorRec;
#define FT_VALIDATOR( x ) ((FT_Validator)( x ))
FT_BASE( void )
ft_validator_init( FT_Validator valid,
const FT_Byte* base,
const FT_Byte* limit,
FT_ValidationLevel level );
FT_BASE( FT_Int )
ft_validator_run( FT_Validator valid );
/* Sets the error field in a validator, then calls `longjmp' to return */
/* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
/* error checks within the validation routines. */
/* */
FT_BASE( void )
ft_validator_error( FT_Validator valid,
FT_Error error );
/* Calls ft_validate_error. Assumes that the `valid' local variable */
/* holds a pointer to the current validator object. */
/* */
/* Use preprocessor prescan to pass FT_ERR_PREFIX. */
/* */
#define FT_INVALID( _prefix, _error ) FT_INVALID_( _prefix, _error )
#define FT_INVALID_( _prefix, _error ) \
ft_validator_error( valid, _prefix ## _error )
/* called when a broken table is detected */
#define FT_INVALID_TOO_SHORT \
FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
/* called when an invalid offset is detected */
#define FT_INVALID_OFFSET \
FT_INVALID( FT_ERR_PREFIX, Invalid_Offset )
/* called when an invalid format/value is detected */
#define FT_INVALID_FORMAT \
FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
/* called when an invalid glyph index is detected */
#define FT_INVALID_GLYPH_ID \
FT_INVALID( FT_ERR_PREFIX, Invalid_Glyph_Index )
/* called when an invalid field value is detected */
#define FT_INVALID_DATA \
FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
FT_END_HEADER
#endif /* __FTVALID_H__ */
/* END */
@@ -35,6 +35,7 @@
#define FT_INTERNAL_SFNT_H <freetype/internal/sfnt.h>
#define FT_INTERNAL_SERVICE_H <freetype/internal/ftserv.h>
#define FT_INTERNAL_RFORK_H <freetype/internal/ftrfork.h>
#define FT_INTERNAL_VALIDATE_H <freetype/internal/ftvalid.h>
#define FT_INTERNAL_TRUETYPE_TYPES_H <freetype/internal/tttypes.h>
#define FT_INTERNAL_TYPE1_TYPES_H <freetype/internal/t1types.h>
@@ -5,7 +5,7 @@
/* Auxiliary functions and data structures related to PostScript fonts */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003 by */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -478,6 +478,17 @@ FT_BEGIN_HEADER
} T1_Builder_FuncsRec;
/* an enumeration type to handle charstring parsing states */
typedef enum T1_ParseState_
{
T1_Parse_Start,
T1_Parse_Have_Width,
T1_Parse_Have_Moveto,
T1_Parse_Have_Path
} T1_ParseState;
/*************************************************************************/
/* */
/* <Structure> */
@@ -519,15 +530,13 @@ FT_BEGIN_HEADER
/* */
/* bbox :: Unused. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* parse_state :: An enumeration which controls the charstring */
/* parsing state. */
/* */
/* load_points :: If this flag is not set, no points are loaded. */
/* */
/* no_recurse :: Set but not used. */
/* */
/* error :: An error code that is only used to report memory */
/* allocation problems. */
/* */
/* metrics_only :: A boolean indicating that we only want to compute */
/* the metrics of a given glyph, not load all of its */
/* points. */
@@ -555,12 +564,11 @@ FT_BEGIN_HEADER
FT_Vector advance;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
T1_ParseState parse_state;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool shift;
FT_Error error; /* only used for memory errors */
FT_Bool metrics_only;
void* hints_funcs; /* hinter-specific */
@@ -2,9 +2,9 @@
/* */
/* svmm.h */
/* */
/* The FreeType Multiple Masters services (specification). */
/* The FreeType Multiple Masters and GX var services (specification). */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -39,11 +39,20 @@ FT_BEGIN_HEADER
(*FT_Get_MM_Func)( FT_Face face,
FT_Multi_Master* master );
typedef FT_Error
(*FT_Get_MM_Var_Func)( FT_Face face,
FT_MM_Var* *master );
typedef FT_Error
(*FT_Set_MM_Design_Func)( FT_Face face,
FT_UInt num_coords,
FT_Long* coords );
typedef FT_Error
(*FT_Set_Var_Design_Func)( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords );
typedef FT_Error
(*FT_Set_MM_Blend_Func)( FT_Face face,
FT_UInt num_coords,
@@ -55,6 +64,8 @@ FT_BEGIN_HEADER
FT_Get_MM_Func get_mm;
FT_Set_MM_Design_Func set_mm_design;
FT_Set_MM_Blend_Func set_mm_blend;
FT_Get_MM_Var_Func get_mm_var;
FT_Set_Var_Design_Func set_var_design;
};
/* */
@@ -0,0 +1,53 @@
/***************************************************************************/
/* */
/* svotval.h */
/* */
/* The FreeType OpenType validation service (specification). */
/* */
/* Copyright 2004 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. */
/* */
/***************************************************************************/
#ifndef __SVOTVAL_H__
#define __SVOTVAL_H__
FT_BEGIN_HEADER
#define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate"
typedef FT_Error
(*otv_validate_func)( FT_Face face,
FT_UInt ot_flags,
FT_Bytes *base,
FT_Bytes *gdef,
FT_Bytes *gpos,
FT_Bytes *gsub,
FT_Bytes *jstf );
FT_DEFINE_SERVICE( OTvalidate )
{
otv_validate_func validate;
};
/* */
FT_END_HEADER
#endif /* __SVOTVAL_H__ */
/* END */
@@ -4,7 +4,7 @@
/* */
/* The FreeType PostScript info service (specification). */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -36,11 +36,16 @@ FT_BEGIN_HEADER
typedef FT_Int
(*PS_HasGlyphNamesFunc)( FT_Face face );
typedef FT_Error
(*PS_GetFontPrivateFunc)( FT_Face face,
PS_PrivateRec* afont_private );
FT_DEFINE_SERVICE( PsInfo )
{
PS_GetFontInfoFunc ps_get_font_info;
PS_HasGlyphNamesFunc ps_has_glyph_names;
PS_GetFontPrivateFunc ps_get_font_private;
};
/* */
@@ -2,9 +2,9 @@
/* */
/* svsfnt.h */
/* */
/* The FreeType PostScript name services (specification). */
/* The FreeType SFNT table loading service (specification). */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -51,10 +51,21 @@ FT_BEGIN_HEADER
FT_Sfnt_Tag tag );
/*
* Used to implement FT_Sfnt_Table_Info().
*/
typedef FT_Error
(*FT_SFNT_TableInfoFunc)( FT_Face face,
FT_UInt idx,
FT_ULong *tag,
FT_ULong *length );
FT_DEFINE_SERVICE( SFNT_Table )
{
FT_SFNT_TableLoadFunc load_table;
FT_SFNT_TableGetFunc get_table;
FT_SFNT_TableInfoFunc table_info;
};
/* */
@@ -4,7 +4,7 @@
/* */
/* High-level `sfnt' driver interface (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -478,6 +478,27 @@ FT_BEGIN_HEADER
(*TT_Free_Table_Func)( TT_Face face );
/*
* @functype:
* TT_Face_GetKerningFunc
*
* @description:
* Return the horizontal kerning value between two glyphs.
*
* @input:
* face :: A handle to the source face object.
* left_glyph :: The left glyph index.
* right_glyph :: The right glyph index.
*
* @return:
* The kerning value in font units.
*/
typedef FT_Int
(*TT_Face_GetKerningFunc)( TT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph );
/*************************************************************************/
/* */
/* <Struct> */
@@ -534,6 +555,9 @@ FT_BEGIN_HEADER
TT_Load_SBit_Image_Func load_sbit_image;
TT_Free_Table_Func free_sbits;
/* see `ttkern.h' */
TT_Face_GetKerningFunc get_kerning;
/* see `ttpost.h' */
TT_Get_PS_Name_Func get_psname;
TT_Free_Table_Func free_psnames;
@@ -5,7 +5,7 @@
/* Basic SFNT/TrueType type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,6 +25,10 @@
#include FT_TRUETYPE_TABLES_H
#include FT_INTERNAL_OBJECTS_H
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_MULTIPLE_MASTERS_H
#endif
FT_BEGIN_HEADER
@@ -307,6 +311,8 @@ FT_BEGIN_HEADER
} TT_GaspRec;
#ifndef FT_OPTIMIZE_MEMORY
/*************************************************************************/
/* */
/* <Struct> */
@@ -383,6 +389,8 @@ FT_BEGIN_HEADER
} TT_Kern0_PairRec, *TT_Kern0_Pair;
#endif /* !OPTIMIZE_MEMORY */
/*************************************************************************/
/*************************************************************************/
@@ -818,6 +826,24 @@ FT_BEGIN_HEADER
} TT_Post_NamesRec, *TT_Post_Names;
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** GX VARIATION TABLE SUPPORT ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
typedef struct GX_BlendRec_ *GX_Blend;
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -1110,6 +1136,9 @@ FT_BEGIN_HEADER
/* glyph data within the `glyf' table. */
/* Ignored for Type 2 font faces. */
/* */
/* glyf_len :: The length of the `glyf' table. Needed */
/* for malformed `loca' tables. */
/* */
/* font_program_size :: Size in bytecodes of the face's font */
/* program. 0 if none defined. Ignored for */
/* Type 2 fonts. */
@@ -1152,8 +1181,18 @@ FT_BEGIN_HEADER
/* unpatented_hinting :: If true, use only unpatented methods in */
/* the bytecode interpreter. */
/* */
/* doblend :: A boolean which is set if the font should */
/* be blended (this is for GX var). */
/* */
/* blend :: Contains the data needed to control GX */
/* variation tables (rather like Multiple */
/* Master data). */
/* */
/* extra :: Reserved for third-party font drivers. */
/* */
/* postscript_name :: The PS name of the font. Used by the */
/* postscript name service. */
/* */
typedef struct TT_FaceRec_
{
FT_FaceRec root;
@@ -1166,12 +1205,20 @@ FT_BEGIN_HEADER
TT_Header header; /* TrueType header table */
TT_HoriHeader horizontal; /* TrueType horizontal header */
#ifdef FT_OPTIMIZE_MEMORY
FT_Byte* horz_metrics;
FT_ULong horz_metrics_size;
#endif
TT_MaxProfile max_profile;
FT_ULong max_components;
FT_Bool vertical_info;
TT_VertHeader vertical; /* TT Vertical header, if present */
#ifdef FT_OPTIMIZE_MEMORY
FT_Byte* vert_metrics;
FT_ULong vert_metrics_size;
#endif
FT_UShort num_names; /* number of name records */
TT_NameTableRec name_table; /* name table */
@@ -1206,7 +1253,15 @@ FT_BEGIN_HEADER
/***********************************************************************/
/* horizontal device metrics */
#ifdef FT_OPTIMIZE_MEMORY
FT_Byte* hdmx_table;
FT_ULong hdmx_table_size;
FT_UInt hdmx_record_count;
FT_ULong hdmx_record_size;
FT_Byte* hdmx_record_sizes;
#else
TT_HdmxRec hdmx;
#endif
/* grid-fitting and scaling table */
TT_GaspRec gasp; /* the `gasp' table */
@@ -1215,8 +1270,14 @@ FT_BEGIN_HEADER
TT_PCLT pclt;
/* embedded bitmaps support */
#ifdef FT_OPTIMIZE_MEMORY
FT_Byte* sbit_table;
FT_ULong sbit_table_size;
FT_UInt sbit_num_strikes;
#else
FT_ULong num_sbit_strikes;
TT_SBit_Strike sbit_strikes;
#endif
FT_ULong num_sbit_scales;
TT_SBit_Scale sbit_scales;
@@ -1232,8 +1293,15 @@ FT_BEGIN_HEADER
/***********************************************************************/
/* the glyph locations */
#ifdef FT_OPTIMIZE_MEMORY
FT_UInt num_locations;
FT_Byte* glyph_locations;
#else
FT_UShort num_locations;
FT_Long* glyph_locations;
#endif
FT_ULong glyf_len;
/* the font program, if any */
FT_ULong font_program_size;
@@ -1247,10 +1315,18 @@ FT_BEGIN_HEADER
FT_ULong cvt_size;
FT_Short* cvt;
#ifdef FT_OPTIMIZE_MEMORY
FT_Byte* kern_table;
FT_ULong kern_table_size;
FT_UInt num_kern_tables;
FT_UInt32 kern_avail_bits;
FT_UInt32 kern_order_bits;
#else
/* the format 0 kerning table, if any */
FT_Int num_kern_pairs;
FT_Int kern_table_index;
TT_Kern0_Pair kern_pairs;
#endif
/* A pointer to the bytecode interpreter to use. This is also */
/* used to hook the debugger for the `ttdebug' utility. */
@@ -1261,6 +1337,11 @@ FT_BEGIN_HEADER
FT_Bool unpatented_hinting;
#endif
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_Bool doblend;
GX_Blend blend;
#endif
/***********************************************************************/
/* */
/* Other tables or fields. This is used by derivative formats like */
+33 -1
View File
@@ -226,7 +226,7 @@ FT_BEGIN_HEADER
typedef struct PS_DesignMap_
{
FT_Byte num_points;
FT_Fixed* design_points;
FT_Long* design_points;
FT_Fixed* blend_points;
} PS_DesignMapRec, *PS_DesignMap;
@@ -387,6 +387,38 @@ FT_BEGIN_HEADER
FT_Get_PS_Font_Info( FT_Face face,
PS_FontInfoRec *afont_info );
/************************************************************************
*
* @function:
* FT_Get_PS_Font_Private
*
* @description:
* Retrieve the @PS_PrivateRec structure corresponding to a given
* Postscript font.
*
* @input:
* face ::
* Postscript face handle.
*
* @output:
* afont_private ::
* Output private dictionary structure pointer.
*
* @return:
* FreeType error code. 0 means success.
*
* @note:
* The string pointers within the font info structure are owned by
* the face and don't need to be freed by the caller.
*
* If the font's format is not Postscript-based, this function will
* return the FT_Err_Invalid_Argument error code.
*/
FT_EXPORT( FT_Error )
FT_Get_PS_Font_Private( FT_Face face,
PS_PrivateRec *afont_private );
/* */
+128 -85
View File
@@ -4,7 +4,7 @@
/* */
/* TrueType name ID definitions (specification only). */
/* */
/* Copyright 1996-2002, 2003 by */
/* Copyright 1996-2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -443,15 +443,23 @@ FT_BEGIN_HEADER
/* of the TTF `name' table if the `platform' identifier code is */
/* TT_PLATFORM_MICROSOFT. */
/* */
/* The canonical source for the MS assigned LCID's used to be at */
/* The canonical source for the MS assigned LCID's (seems to) be at */
/* */
/* http://www.microsoft.com/globaldev/reference/lcid-all.mspx */
/* */
/* It used to be at various places, among them */
/* */
/* http://www.microsoft.com/typography/OTSPEC/lcid-cp.txt */
/* */
/* Now (2002-11-15), the Microsoft site directs to */
/* */
/* http://www.microsoft.com/globaldev/reference/loclanghome.asp */
/* http://support.microsoft.com/support/kb/articles/Q224/8/04.ASP */
/* http://msdn.microsoft.com/library/en-us/passport25/ */
/* NET_Passport_VBScript_Documentation/Single_Sign_In/ */
/* Advanced_Single_Sign_In/Localization_and_LCIDs.asp */
/* */
/* Hopefully, it seems now that the Globaldev site prevails... */
/* (updated by Antoine, 2004-02-17) */
#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401
#define TT_MS_LANGID_ARABIC_IRAQ 0x0801
#define TT_MS_LANGID_ARABIC_EGYPT 0x0c01
@@ -470,18 +478,23 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_ARABIC_QATAR 0x4001
#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402
#define TT_MS_LANGID_CATALAN_SPAIN 0x0403
#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404
#define TT_MS_LANGID_CHINESE_PRC 0x0804
#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0c04
#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004
#if 1 /* this used to be this value (and it still is in many places) */
#if 1 /* this looks like the correct value */
#define TT_MS_LANGID_CHINESE_MACAU 0x1404
#else /* but beware, Microsoft may change its mind...
the most recent Word reference has the following: */
#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG
#endif
#if 0 /* used only with .NET "cultures"; commented out */
#define TT_MS_LANGID_CHINESE_TRADITIONAL 0x7C04
#endif
#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
#define TT_MS_LANGID_DANISH_DENMARK 0x0406
#define TT_MS_LANGID_GERMAN_GERMANY 0x0407
@@ -490,6 +503,13 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007
#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407
#define TT_MS_LANGID_GREEK_GREECE 0x0408
/* don't ask what this one means... It is commented out currently. */
#if 0
#define TT_MS_LANGID_GREEK_GREECE2 0x2008
#endif
#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809
#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0c09
@@ -503,6 +523,11 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2c09
#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009
#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409
#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809
#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3c09
#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809
#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040a
#define TT_MS_LANGID_SPANISH_MEXICO 0x080a
#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0c0a
@@ -523,6 +548,10 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_SPANISH_HONDURAS 0x480a
#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4c0a
#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500a
#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540a
/* The following ID blatantly violate MS specs by using a */
/* sublanguage > 0x1F. */
#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40aU
#define TT_MS_LANGID_FINNISH_FINLAND 0x040b
#define TT_MS_LANGID_FRENCH_FRANCE 0x040c
#define TT_MS_LANGID_FRENCH_BELGIUM 0x080c
@@ -530,6 +559,19 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100c
#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140c
#define TT_MS_LANGID_FRENCH_MONACO 0x180c
#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1c0c
#define TT_MS_LANGID_FRENCH_REUNION 0x200c
#define TT_MS_LANGID_FRENCH_CONGO 0x240c
/* which was formerly: */
#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO
#define TT_MS_LANGID_FRENCH_SENEGAL 0x280c
#define TT_MS_LANGID_FRENCH_CAMEROON 0x2c0c
#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300c
#define TT_MS_LANGID_FRENCH_MALI 0x340c
#define TT_MS_LANGID_FRENCH_MOROCCO 0x380c
#define TT_MS_LANGID_FRENCH_HAITI 0x3c0c
/* and another violation of the spec (see 0xE40aU) */
#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40cU
#define TT_MS_LANGID_HEBREW_ISRAEL 0x040d
#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040e
#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040f
@@ -553,6 +595,18 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_CROATIAN_CROATIA 0x041a
#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081a
#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0c1a
#if 0 /* this used to be this value, but it looks like we were wrong */
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x101a
#else /* current sources say */
#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101a
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141a
/* and XPsp2 Platform SDK added (2004-07-26) */
/* Names are shortened to be signifiant within 40 chars. */
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181a
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x181a
#endif
#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041b
#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041c
#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041d
@@ -560,6 +614,7 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_THAI_THAILAND 0x041e
#define TT_MS_LANGID_TURKISH_TURKEY 0x041f
#define TT_MS_LANGID_URDU_PAKISTAN 0x0420
#define TT_MS_LANGID_URDU_INDIA 0x0820
#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421
#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422
#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423
@@ -568,11 +623,7 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426
#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427
#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827
#if 0 /* this seems to be an error that have been dropped */
#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0428
#endif
#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
#define TT_MS_LANGID_FARSI_IRAN 0x0429
#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042a
#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042b
@@ -592,6 +643,17 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438
#define TT_MS_LANGID_HINDI_INDIA 0x0439
#define TT_MS_LANGID_MALTESE_MALTA 0x043a
/* Added by XPsp2 Platform SDK (2004-07-26) */
#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043b
#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083b
#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3b
#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103b
#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143b
#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183b
#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3b
#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203b
#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243b
/* ... and we also keep our old identifier... */
#define TT_MS_LANGID_SAAMI_LAPONIA 0x043b
#if 0 /* this seems to be a previous invertion */
@@ -602,15 +664,24 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043c
#endif
#define TT_MS_LANGID_YIDDISH_GERMANY 0x043d
#define TT_MS_LANGID_MALAY_MALAYSIA 0x043e
#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083e
#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043f
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN /* Cyrillic*/ 0x0440
/* alias declared in Windows 2000 */
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN
#define TT_MS_LANGID_SWAHILI_KENYA 0x0441
#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843
#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444
#define TT_MS_LANGID_BENGALI_INDIA 0x0445
#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
#define TT_MS_LANGID_PUNJABI_INDIA 0x0446
#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
#define TT_MS_LANGID_GUJARATI_INDIA 0x0447
#define TT_MS_LANGID_ORIYA_INDIA 0x0448
#define TT_MS_LANGID_TAMIL_INDIA 0x0449
@@ -620,107 +691,72 @@ FT_BEGIN_HEADER
#define TT_MS_LANGID_ASSAMESE_INDIA 0x044d
#define TT_MS_LANGID_MARATHI_INDIA 0x044e
#define TT_MS_LANGID_SANSKRIT_INDIA 0x044f
#define TT_MS_LANGID_KONKANI_INDIA 0x0457
/* new as of 2001-01-01 */
#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1c0c
#define TT_MS_LANGID_FRENCH_REUNION 0x200c
#define TT_MS_LANGID_FRENCH_CONGO 0x240c
/* which was formerly: */
#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO
#define TT_MS_LANGID_FRENCH_SENEGAL 0x280c
#define TT_MS_LANGID_FRENCH_CAMEROON 0x2c0c
#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300c
#define TT_MS_LANGID_FRENCH_MALI 0x340c
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x101a
#define TT_MS_LANGID_URDU_INDIA 0x0820
#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
#define TT_MS_LANGID_YIDDISH_GERMANY 0x043d
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN 0x0440
/* alias declared in Windows 2000 */
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN
#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
/* the following seems to be inconsistent;
here is the current "official" way: */
#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451
/* and here is what is used by Passport SDK */
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850
#define TT_MS_LANGID_TIBETAN_CHINA 0x0451
#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
/* end of inconsistency */
#if 0
/* the following used to be defined */
#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451
/* ... but it was changed; */
#else
/* So we will continue to #define it, but with the correct value */
#define TT_MS_LANGID_TIBETAN_BHUTAN TT_MS_LANGID_DZONGHKA_BHUTAN
#endif
#define TT_MS_LANGID_WELSH_WALES 0x0452
#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453
#define TT_MS_LANGID_LAO_LAOS 0x0454
#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455
#define TT_MS_LANGID_GALICIAN_SPAIN 0x0456
#define TT_MS_LANGID_MANIPURI_INDIA 0x0458
#define TT_MS_LANGID_SINDHI_INDIA 0x0459
/* the following one is only encountered in Microsoft RTF specification */
#define TT_MS_LANGID_KASHMIRI_PAKISTAN 0x0460
/* the following one is not in the Passport list, looks like an omission */
#define TT_MS_LANGID_KASHMIRI_INDIA 0x0860
#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
#define TT_MS_LANGID_NEPALI_INDIA 0x0861
#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
/* new as of 2001-03-01 (from Office Xp) */
#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3c09
#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809
#define TT_MS_LANGID_KONKANI_INDIA 0x0457
#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458
#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459
#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859
/* Missing a LCID for Sindhi in Devanagari script */
#define TT_MS_LANGID_SYRIAC_SYRIA 0x045a
#define TT_MS_LANGID_SINHALESE_SRI_LANKA 0x045b
#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045c
#define TT_MS_LANGID_INUKTITUT_CANADA 0x045d
#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045e
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO 0x045f
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045f
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN 0x085f
/* Missing a LCID for Tifinagh script */
#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460
/* Spelled this way by XPsp2 Platform SDK (2004-07-26) */
/* script is yet unclear... might be Arabic, Nagari or Sharada */
#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860
/* ... and aliased (by MS) for compatibility reasons. */
#define TT_MS_LANGID_KASHMIRI_INDIA TT_MS_LANGID_KASHMIRI_SASIA
#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
#define TT_MS_LANGID_NEPALI_INDIA 0x0861
#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463
#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464
#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465
/* alias declared in Windows 2000 */
#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES
/* for language codes from 0x0466 to 0x0471 see below */
#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
/* also spelled in the `Passport SDK' list as: */
#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA
/* New additions from Windows Xp/Passport SDK 2001-11-10. */
/* don't ask what this one means... It is commented out currently. */
#if 0
#define TT_MS_LANGID_GREEK_GREECE2 0x2008
#endif
#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540a
/* The following two IDs blatantly violate MS specs by using a */
/* sublanguage > 0x1F. */
#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40aU
#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40cU
#define TT_MS_LANGID_FRENCH_MOROCCO 0x380c
#define TT_MS_LANGID_FRENCH_HAITI 0x3c0c
#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850
#define TT_MS_LANGID_EDO_NIGERIA 0x0466
#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
#define TT_MS_LANGID_YORUBA_NIGERIA 0x046a
/* language codes from 0x046b to 0x046f are (still) unknown. */
#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046b
#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086b
#define TT_MS_LANGID_QUECHUA_PERU 0x0c6b
#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA 0x046c
/* Also spelled by XPsp2 Platform SDK (2004-07-26) */
#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \
TT_MS_LANGID_SEPEDI_SOUTH_AFRICA
/* language codes 0x046d, 0x046e and 0x046f are (still) unknown. */
#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
/* also spelled in the `Passport SDK' list as: */
#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA
#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
#define TT_MS_LANGID_LATIN 0x0476
@@ -730,6 +766,13 @@ FT_BEGIN_HEADER
/* studying). */
#define TT_MS_LANGID_YI_CHINA 0x0478
#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
/* language codes from 0x047a to 0x047f are (still) unknown. */
#define TT_MS_LANGID_UIGHUR_CHINA 0x0480
#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481
#if 0 /* not deemed useful for fonts */
#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE 0x04ff
#endif
/*************************************************************************/
+44 -8
View File
@@ -5,7 +5,7 @@
/* Basic SFNT/TrueType tables definitions and interface */
/* (specification only). */
/* */
/* Copyright 1996-2001, 2002, 2003 by */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,7 +42,7 @@ FT_BEGIN_HEADER
/* TrueType Tables */
/* */
/* <Abstract> */
/* TrueType-specific table types and functions. */
/* TrueType specific table types and functions. */
/* */
/* <Description> */
/* This section contains the definition of TrueType-specific tables */
@@ -516,12 +516,11 @@ FT_BEGIN_HEADER
/* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
/* used for glyph hinting. */
/* */
/* maxComponentElements :: An obscure value related to composite */
/* glyphs definitions. */
/* maxComponentElements :: The maximum number of simple (i.e., non- */
/* composite) glyphs in a composite glyph. */
/* */
/* maxComponentDepth :: An obscure value related to composite */
/* glyphs definitions. Probably the maximum */
/* number of simple glyphs in a composite. */
/* maxComponentDepth :: The maximum nesting depth of composite */
/* glyphs. */
/* */
/* <Note> */
/* This structure is only used during font loading. */
@@ -652,7 +651,7 @@ FT_BEGIN_HEADER
* buffer = malloc( length );
* if ( buffer == NULL ) { ... not enough memory ... }
*
* error = FT_Load_Sfnt_Table( face,tag, 0, buffer, &length );
* error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
* if ( error ) { ... could not load table ... }
* }
*/
@@ -664,6 +663,43 @@ FT_BEGIN_HEADER
FT_ULong* length );
/**************************************************************************
*
* <Function>
* FT_Sfnt_Table_Info
*
* <Description>
* Returns information on an SFNT table.
*
* <Input>
* face ::
* A handle to the source face.
*
* table_index ::
* The index of an SFNT table. The function returns
* FT_Err_Table_Missing for an invalid value.
*
* <Output>
* tag ::
* The name tag of the SFNT table.
*
* length ::
* The length of the SFNT table.
*
* <Return>
* FreeType error code. 0 means success.
*
* <Note>
* SFNT tables with length zero are treated as missing by Windows.
*
*/
FT_EXPORT( FT_Error )
FT_Sfnt_Table_Info( FT_Face face,
FT_UInt table_index,
FT_ULong *tag,
FT_ULong *length );
/*************************************************************************/
/* */
/* <Function> */
+15 -8
View File
@@ -2,9 +2,9 @@
/* */
/* tttags.h */
/* */
/* Tags for TrueType tables (specification only). */
/* Tags for TrueType and OpenType tables (specification only). */
/* */
/* Copyright 1996-2001 by */
/* Copyright 1996-2001, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -33,31 +33,38 @@
FT_BEGIN_HEADER
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' )
#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' )
#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' )
#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
+1 -1
View File
@@ -10,7 +10,7 @@ UseFreeTypeHeaders ;
if $(FT2_MULTI)
{
_sources = autofit afmodule afloader aflatin afhints afglobal afdummy afangles ;
_sources = afangles afglobal afhints aflatin afloader afmodule afdummy ;
}
else
{
+121 -10
View File
@@ -1,8 +1,76 @@
/***************************************************************************/
/* */
/* afangles.c */
/* */
/* Routines used to compute vector angles with limited accuracy */
/* and very high speed. It also contains sorting routines (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#include "aftypes.h"
/*
* a python script used to generate the following table
*
import sys, math
units = 256
scale = units/math.pi
comma = ""
print ""
print "table of arctan( 1/2^n ) for PI = " + repr( units / 65536.0 ) + " units"
r = [-1] + range( 32 )
for n in r:
if n >= 0:
x = 1.0 / ( 2.0 ** n ) # tangent value
else:
x = 2.0 ** ( -n )
angle = math.atan( x ) # arctangent
angle2 = angle * scale # arctangent in FT_Angle units
# determine which integer value for angle gives the best tangent
lo = int( angle2 )
hi = lo + 1
tlo = math.tan( lo / scale )
thi = math.tan( hi / scale )
errlo = abs( tlo - x )
errhi = abs( thi - x )
angle2 = hi
if errlo < errhi:
angle2 = lo
if angle2 <= 0:
break
sys.stdout.write( comma + repr( int( angle2 ) ) )
comma = ", "
*
* end of python script
*/
/* this table was generated for AF_ANGLE_PI = 256 */
#define AF_ANGLE_MAX_ITERS 8
#define AF_TRIG_MAX_ITERS 9
#define AF_TRIG_MAX_ITERS 8
static const FT_Fixed
af_angle_arctan_table[9] =
@@ -69,11 +137,11 @@
{
x = -x;
y = -y;
theta = 2 * AF_ANGLE_PI2;
theta = AF_ANGLE_PI;
}
if ( y > 0 )
theta = - theta;
theta = -theta;
arctanptr = af_angle_arctan_table;
@@ -115,18 +183,20 @@
}
} while ( ++i < AF_TRIG_MAX_ITERS );
#if 0
/* round theta */
if ( theta >= 0 )
theta = FT_PAD_ROUND( theta, 4 );
theta = FT_PAD_ROUND( theta, 2 );
else
theta = - FT_PAD_ROUND( theta, 4 );
theta = -FT_PAD_ROUND( -theta, 2 );
#endif
vec->x = x;
vec->y = theta;
}
/* documentation is in fttrigon.h */
/* cf. documentation in fttrigon.h */
FT_LOCAL_DEF( AF_Angle )
af_angle_atan( FT_Fixed dx,
@@ -147,13 +217,13 @@
}
FT_LOCAL_DEF( AF_Angle )
af_angle_diff( AF_Angle angle1,
AF_Angle angle2 )
{
AF_Angle delta = angle2 - angle1;
delta %= AF_ANGLE_2PI;
if ( delta < 0 )
delta += AF_ANGLE_2PI;
@@ -165,9 +235,6 @@
}
/* well, this needs to be somewhere, right :-)
*/
FT_LOCAL_DEF( void )
af_sort_pos( FT_UInt count,
FT_Pos* table )
@@ -212,3 +279,47 @@
}
}
}
#ifdef TEST
#include <stdio.h>
#include <math.h>
int main( void )
{
int angle;
int dist;
for ( dist = 100; dist < 1000; dist++ )
{
for ( angle = AF_ANGLE_PI; angle < AF_ANGLE_2PI * 4; angle++ )
{
double a = ( angle * 3.1415926535 ) / ( 1.0 * AF_ANGLE_PI );
int dx, dy, angle1, angle2, delta;
dx = dist * cos( a );
dy = dist * sin( a );
angle1 = ( ( atan2( dy, dx ) * AF_ANGLE_PI ) / 3.1415926535 );
angle2 = af_angle_atan( dx, dy );
delta = ( angle2 - angle1 ) % AF_ANGLE_2PI;
if ( delta < 0 )
delta = -delta;
if ( delta >= 2 )
{
printf( "dist:%4d angle:%4d => (%4d,%4d) angle1:%4d angle2:%4d\n",
dist, angle, dx, dy, angle1, angle2 );
}
}
}
return 0;
}
#endif /* TEST */
/* END */
+7
View File
@@ -0,0 +1,7 @@
/*
* afangles.h
*
* This is a dummy file, used to please the build system. It is never
* included by the auto-fitter sources.
*
*/
+35 -8
View File
@@ -1,35 +1,62 @@
/***************************************************************************/
/* */
/* afdummy.c */
/* */
/* Auto-fitter dummy routines to be used if no hinting should be */
/* performed (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#include "afdummy.h"
#include "afhints.h"
static FT_Error
af_dummy_hints_init( AF_GlyphHints hints,
FT_Outline* outline,
AF_ScriptMetrics metrics )
{
return af_glyph_hints_reset( hints,
&metrics->scaler,
metrics,
outline );
af_glyph_hints_rescale( hints,
metrics );
return 0;
}
static FT_Error
af_dummy_hints_apply( AF_GlyphHints hints,
FT_Outline* outline )
{
af_glyph_hints_save( hints, outline );
FT_UNUSED( hints );
FT_UNUSED( outline );
return 0;
}
FT_LOCAL_DEF( const AF_ScriptClassRec ) af_dummy_script_class =
FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec
af_dummy_script_class =
{
AF_SCRIPT_NONE,
NULL,
sizeof( AF_ScriptMetricsRec ),
(AF_Script_InitMetricsFunc) NULL,
(AF_Script_ScaleMetricsFunc) NULL,
(AF_Script_ScaleMetricsFunc)NULL,
(AF_Script_DoneMetricsFunc) NULL,
(AF_Script_InitHintsFunc) af_dummy_hints_init,
(AF_Script_ApplyHintsFunc) af_dummy_hints_apply
};
/* END */
+28 -3
View File
@@ -1,18 +1,43 @@
/***************************************************************************/
/* */
/* afdummy.h */
/* */
/* Auto-fitter dummy routines to be used if no hinting should be */
/* performed (specification). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __AFDUMMY_H__
#define __AFDUMMY_H__
#include "aftypes.h"
FT_BEGIN_HEADER
/* a dummy script metrics class used when no hinting should
* be performed. This is the default for non-latin glyphs !
/* A dummy script metrics class used when no hinting should
* be performed. This is the default for non-latin glyphs!
*/
FT_LOCAL( const AF_ScriptClassRec ) af_dummy_script_class;
FT_CALLBACK_TABLE const AF_ScriptClassRec
af_dummy_script_class;
/* */
FT_END_HEADER
#endif /* __AFDUMMY_H__ */
/* END */
+40
View File
@@ -0,0 +1,40 @@
/***************************************************************************/
/* */
/* aferrors.h */
/* */
/* Autofitter error codes (specification only). */
/* */
/* Copyright 2005 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* This file is used to define the Autofitter error enumeration */
/* constants. */
/* */
/*************************************************************************/
#ifndef __AFERRORS_H__
#define __AFERRORS_H__
#include FT_MODULE_ERRORS_H
#undef __FTERRORS_H__
#define FT_ERR_PREFIX AF_Err_
#define FT_ERR_BASE FT_Mod_Err_Autofit
#include FT_ERRORS_H
#endif /* __AFERRORS_H__ */
/* END */
+78 -45
View File
@@ -1,23 +1,45 @@
/***************************************************************************/
/* */
/* afglobal.c */
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#include "afglobal.h"
#include "afdummy.h"
#include "aflatin.h"
#include "aferrors.h"
/* populate this list when you add new scripts
*/
/* populate this list when you add new scripts */
static AF_ScriptClass const af_script_classes[] =
{
& af_dummy_script_class,
& af_latin_script_class,
&af_dummy_script_class,
&af_latin_script_class,
NULL /* do not remove */
};
#define AF_SCRIPT_LIST_DEFAULT 0 /* index of default script in 'af_script_classes' */
#define AF_SCRIPT_LIST_NONE 255 /* indicates an uncovered glyph */
/* index of default script in `af_script_classes' */
#define AF_SCRIPT_LIST_DEFAULT 1
/* indicates an uncovered glyph */
#define AF_SCRIPT_LIST_NONE 255
/*
* note that glyph_scripts[] is used to map each glyph into
* an index into the 'af_script_classes' array.
* Note that glyph_scripts[] is used to map each glyph into
* an index into the `af_script_classes' array.
*
*/
typedef struct AF_FaceGlobalsRec_
@@ -26,27 +48,24 @@
FT_UInt glyph_count; /* same as face->num_glyphs */
FT_Byte* glyph_scripts;
AF_ScriptMetrics metrics[ AF_SCRIPT_MAX ];
AF_ScriptMetrics metrics[AF_SCRIPT_MAX];
} AF_FaceGlobalsRec;
/* Compute the script index of each glyph within a given face. */
/* this function is used to compute the script index of each glyph
* within a given face
*/
static FT_Error
af_face_globals_compute_script_coverage( AF_FaceGlobals globals )
{
FT_Error error = 0;
FT_Error error = AF_Err_Ok;
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts;
FT_UInt ss;
/* the value 255 means "uncovered glyph"
*/
/* the value 255 means `uncovered glyph' */
FT_MEM_SET( globals->glyph_scripts,
AF_SCRIPT_LIST_NONE,
globals->glyph_count );
@@ -54,39 +73,43 @@
error = FT_Select_Charmap( face, FT_ENCODING_UNICODE );
if ( error )
{
/* ignore this error, we'll simply use Latin as the standard
* script. XXX: Shouldn't we rather disable hinting ??
/*
* Ignore this error; we simply use Latin as the standard
* script. XXX: Shouldn't we rather disable hinting?
*/
error = 0;
error = AF_Err_Ok;
goto Exit;
}
/* scan each script in a Unicode charmap
*/
/* scan each script in a Unicode charmap */
for ( ss = 0; af_script_classes[ss]; ss++ )
{
AF_ScriptClass clazz = af_script_classes[ss];
AF_Script_UniRange range;
if ( clazz->script_uni_ranges == NULL )
continue;
/* scan all unicode points in the range, and set the corresponding
* glyph script index
/*
* Scan all unicode points in the range and set the corresponding
* glyph script index.
*/
for ( range = clazz->script_uni_ranges; range->first != 0; range++ )
{
FT_ULong charcode = range->first;
FT_UInt gindex;
gindex = FT_Get_Char_Index( face, charcode );
if ( gindex != 0 &&
gindex < globals->glyph_count &&
gscripts[ gindex ] == AF_SCRIPT_LIST_NONE )
gscripts[gindex] == AF_SCRIPT_LIST_NONE )
{
gscripts[ gindex ] = (FT_Byte) ss;
gscripts[gindex] = (FT_Byte)ss;
}
for (;;)
{
charcode = FT_Get_Next_Char( face, charcode, &gindex );
@@ -95,25 +118,27 @@
break;
if ( gindex < globals->glyph_count &&
gscripts[ gindex ] == AF_SCRIPT_LIST_NONE )
gscripts[gindex] == AF_SCRIPT_LIST_NONE )
{
gscripts[ gindex ] = (FT_Byte) ss;
gscripts[gindex] = (FT_Byte)ss;
}
}
}
}
Exit:
/* by default, all uncovered glyphs are set to the latin script
* XXX: shouldnt' we disable hinting or do something similar ?
/*
* By default, all uncovered glyphs are set to the latin script.
* XXX: Shouldnt' we disable hinting or do something similar?
*/
{
FT_UInt nn;
for ( nn = 0; nn < globals->glyph_count; nn++ )
{
if ( gscripts[ nn ] == AF_SCRIPT_LIST_NONE )
gscripts[ nn ] = AF_SCRIPT_LIST_DEFAULT;
if ( gscripts[nn] == AF_SCRIPT_LIST_NONE )
gscripts[nn] = AF_SCRIPT_LIST_DEFAULT;
}
}
@@ -122,7 +147,6 @@
}
FT_LOCAL_DEF( FT_Error )
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals )
@@ -131,14 +155,15 @@
FT_Memory memory;
AF_FaceGlobals globals;
memory = face->memory;
if ( !FT_ALLOC( globals, sizeof(*globals) +
face->num_glyphs*sizeof(FT_Byte) ) )
if ( !FT_ALLOC( globals, sizeof ( *globals ) +
face->num_glyphs * sizeof ( FT_Byte ) ) )
{
globals->face = face;
globals->glyph_count = face->num_glyphs;
globals->glyph_scripts = (FT_Byte*)( globals+1 );
globals->glyph_scripts = (FT_Byte*)( globals + 1 );
error = af_face_globals_compute_script_coverage( globals );
if ( error )
@@ -161,12 +186,14 @@
FT_Memory memory = globals->face->memory;
FT_UInt nn;
for ( nn = 0; nn < AF_SCRIPT_MAX; nn++ )
{
if ( globals->metrics[nn] )
{
AF_ScriptClass clazz = af_script_classes[nn];
FT_ASSERT( globals->metrics[nn]->clazz == clazz );
if ( clazz->script_metrics_done )
@@ -177,8 +204,9 @@
}
globals->glyph_count = 0;
globals->glyph_scripts = NULL; /* no need to free this one !! */
globals->glyph_scripts = NULL; /* no need to free this one! */
globals->face = NULL;
FT_FREE( globals );
}
}
@@ -190,25 +218,26 @@
AF_ScriptMetrics *ametrics )
{
AF_ScriptMetrics metrics = NULL;
FT_UInt index;
FT_UInt gidx;
AF_ScriptClass clazz;
FT_Error error = 0;
FT_Error error = AF_Err_Ok;
if ( gindex >= globals->glyph_count )
{
error = FT_Err_Invalid_Argument;
error = AF_Err_Invalid_Argument;
goto Exit;
}
index = globals->glyph_scripts[ gindex ];
clazz = af_script_classes[ index ];
metrics = globals->metrics[ clazz->script ];
gidx = globals->glyph_scripts[gindex];
clazz = af_script_classes[gidx];
metrics = globals->metrics[clazz->script];
if ( metrics == NULL )
{
/* create the global metrics object when needed
*/
/* create the global metrics object when needed */
FT_Memory memory = globals->face->memory;
if ( FT_ALLOC( metrics, clazz->script_metrics_size ) )
goto Exit;
@@ -227,10 +256,14 @@
}
}
globals->metrics[ clazz->script ] = metrics;
globals->metrics[clazz->script] = metrics;
}
Exit:
*ametrics = metrics;
return error;
}
/* END */
+32 -7
View File
@@ -1,23 +1,44 @@
/***************************************************************************/
/* */
/* afglobal.h */
/* */
/* Auto-fitter routines to compute global hinting values */
/* (specification). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __AF_GLOBAL_H__
#define __AF_GLOBAL_H__
#include "aftypes.h"
FT_BEGIN_HEADER
/**************************************************************************/
/**************************************************************************/
/************************************************************************/
/************************************************************************/
/***** *****/
/***** F A C E G L O B A L S *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/************************************************************************/
/************************************************************************/
/*
* models the global hints data for a given face, decomposed into
* script-specific items..
*
* model the global hints data for a given face, decomposed into
* script-specific items
*/
typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals;
@@ -36,6 +57,10 @@ FT_BEGIN_HEADER
/* */
FT_END_HEADER
#endif /* __AF_GLOBALS_H__ */
/* END */
+226 -122
View File
@@ -1,25 +1,154 @@
/***************************************************************************/
/* */
/* afhints.c */
/* */
/* Auto-fitter hinting routines (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#include "afhints.h"
#include "aferrors.h"
FT_LOCAL_DEF( FT_Error )
af_axis_hints_new_segment( AF_AxisHints axis,
FT_Memory memory,
AF_Segment *asegment )
{
FT_Error error = AF_Err_Ok;
AF_Segment segment = NULL;
if ( axis->num_segments >= axis->max_segments )
{
FT_Int old_max = axis->max_segments;
FT_Int new_max = old_max;
FT_Int big_max = FT_INT_MAX / sizeof ( *segment );
if ( old_max >= big_max )
{
error = AF_Err_Out_Of_Memory;
goto Exit;
}
new_max += ( new_max >> 2 ) + 4;
if ( new_max < old_max || new_max > big_max )
new_max = big_max;
if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
goto Exit;
axis->max_segments = new_max;
}
segment = axis->segments + axis->num_segments++;
FT_ZERO( segment );
Exit:
*asegment = segment;
return error;
}
FT_LOCAL( FT_Error )
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
FT_Memory memory,
AF_Edge *aedge )
{
FT_Error error = AF_Err_Ok;
AF_Edge edge = NULL;
AF_Edge edges;
if ( axis->num_edges >= axis->max_edges )
{
FT_Int old_max = axis->max_edges;
FT_Int new_max = old_max;
FT_Int big_max = FT_INT_MAX / sizeof ( *edge );
if ( old_max >= big_max )
{
error = AF_Err_Out_Of_Memory;
goto Exit;
}
new_max += ( new_max >> 2 ) + 4;
if ( new_max < old_max || new_max > big_max )
new_max = big_max;
if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
goto Exit;
axis->max_edges = new_max;
}
edges = axis->edges;
edge = edges + axis->num_edges;
while ( edge > edges && edge[-1].fpos > fpos )
{
edge[0] = edge[-1];
edge--;
}
axis->num_edges++;
FT_ZERO( edge );
edge->fpos = (FT_Short)fpos;
Exit:
*aedge = edge;
return error;
}
#ifdef AF_DEBUG
#include <stdio.h>
static const char* af_dir_str( AF_Direction dir )
static const char*
af_dir_str( AF_Direction dir )
{
const char* result;
switch (dir)
switch ( dir )
{
case AF_DIR_UP: result = "up"; break;
case AF_DIR_DOWN: result = "down"; break;
case AF_DIR_LEFT: result = "left"; break;
case AF_DIR_RIGHT: result = "right"; break;
default: result = "none";
case AF_DIR_UP:
result = "up";
break;
case AF_DIR_DOWN:
result = "down";
break;
case AF_DIR_LEFT:
result = "left";
break;
case AF_DIR_RIGHT:
result = "right";
break;
default:
result = "none";
}
return result;
}
#define AF_INDEX_NUM(ptr,base) ( (ptr) ? ((ptr)-(base)) : -1 )
#define AF_INDEX_NUM( ptr, base ) ( (ptr) ? ( (ptr) - (base) ) : -1 )
void
af_glyph_hints_dump_points( AF_GlyphHints hints )
@@ -28,11 +157,15 @@
AF_Point limit = points + hints->num_points;
AF_Point point;
printf( "Table of points:\n" );
printf( " [ index | xorg | yorg | xscale | yscale | xfit | yfit | flags ]\n" );
printf( " [ index | xorg | yorg | xscale | yscale "
"| xfit | yfit | flags ]\n" );
for ( point = points; point < limit; point++ )
{
printf( " [ %5d | %5d | %5d | %-5.2f | %-5.2f | %-5.2f | %-5.2f | %c%c%c%c%c%c ]\n",
printf( " [ %5d | %5d | %5d | %-5.2f | %-5.2f "
"| %-5.2f | %-5.2f | %c%c%c%c%c%c ]\n",
point - points,
point->fx,
point->fy,
@@ -40,25 +173,25 @@
point->oy/64.0,
point->x/64.0,
point->y/64.0,
(point->flags & AF_FLAG_WEAK_INTERPOLATION) ? 'w' : ' ',
(point->flags & AF_FLAG_INFLECTION) ? 'i' : ' ',
(point->flags & AF_FLAG_EXTREMA_X) ? '<' : ' ',
(point->flags & AF_FLAG_EXTREMA_Y) ? 'v' : ' ',
(point->flags & AF_FLAG_ROUND_X) ? '(' : ' ',
(point->flags & AF_FLAG_ROUND_Y) ? 'u' : ' '
);
( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ',
( point->flags & AF_FLAG_INFLECTION ) ? 'i' : ' ',
( point->flags & AF_FLAG_EXTREMA_X ) ? '<' : ' ',
( point->flags & AF_FLAG_EXTREMA_Y ) ? 'v' : ' ',
( point->flags & AF_FLAG_ROUND_X ) ? '(' : ' ',
( point->flags & AF_FLAG_ROUND_Y ) ? 'u' : ' ');
}
printf( "\n" );
}
/* A function used to dump the array of linked segments */
/* A function to dump the array of linked segments. */
void
af_glyph_hints_dump_segments( AF_GlyphHints hints )
{
AF_Point points = hints->points;
FT_Int dimension;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AF_AxisHints axis = &hints->axis[dimension];
@@ -94,15 +227,18 @@
{
FT_Int dimension;
for ( dimension = 1; dimension >= 0; dimension-- )
{
AF_AxisHints axis = &hints->axis[ dimension ];
AF_AxisHints axis = &hints->axis[dimension];
AF_Edge edges = axis->edges;
AF_Edge limit = edges + axis->num_edges;
AF_Edge edge;
/* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have constant X coordinate
/*
* note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
* since they have constant a X coordinate.
*/
printf ( "Table of %s edges:\n",
dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
@@ -111,7 +247,8 @@
for ( edge = edges; edge < limit; edge++ )
{
printf ( " [ %5d | %4d | %5s | %4d | %5d | %c | %5.2f | %5.2f ]\n",
printf ( " [ %5d | %4d | %5s | %4d |"
" %5d | %c | %5.2f | %5.2f ]\n",
edge - edges,
(int)edge->fpos,
af_dir_str( edge->dir ),
@@ -121,13 +258,10 @@
edge->opos / 64.0,
edge->pos / 64.0 );
}
printf( "\n" );
}
}
#endif /* AF_DEBUG */
@@ -268,7 +402,6 @@
}
FT_LOCAL_DEF( void )
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory )
@@ -278,26 +411,31 @@
}
FT_LOCAL_DEF( void )
af_glyph_hints_done( AF_GlyphHints hints )
{
if ( hints && hints->memory )
{
FT_Memory memory = hints->memory;
AF_Dimension dim;
int dim;
/* note that we don't need to free the segment and edge
* buffers, since they're really within the hints->points array
/*
* note that we don't need to free the segment and edge
* buffers, since they are really within the hints->points array
*/
for ( dim = 0; dim < 2; dim++ )
for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
{
AF_AxisHints axis = &hints->axis[ dim ];
AF_AxisHints axis = &hints->axis[dim];
axis->num_segments = 0;
axis->max_segments = 0;
FT_FREE( axis->segments );
axis->num_edges = 0;
axis->segments = NULL;
axis->edges = NULL;
axis->max_edges = 0;
FT_FREE( axis->edges );
}
FT_FREE( hints->contours );
@@ -313,27 +451,30 @@
}
FT_LOCAL_DEF( void )
af_glyph_hints_rescale( AF_GlyphHints hints,
AF_ScriptMetrics metrics )
{
hints->metrics = metrics;
}
FT_LOCAL_DEF( FT_Error )
af_glyph_hints_reset( AF_GlyphHints hints,
AF_Scaler scaler,
AF_ScriptMetrics metrics,
af_glyph_hints_reload( AF_GlyphHints hints,
FT_Outline* outline )
{
FT_Error error = FT_Err_Ok;
FT_Error error = AF_Err_Ok;
AF_Point points;
FT_UInt old_max, new_max;
FT_Fixed x_scale = scaler->x_scale;
FT_Fixed y_scale = scaler->y_scale;
FT_Pos x_delta = scaler->x_delta;
FT_Pos y_delta = scaler->y_delta;
AF_Scaler scaler = &hints->metrics->scaler;
FT_Fixed x_scale = hints->x_scale;
FT_Fixed y_scale = hints->y_scale;
FT_Pos x_delta = hints->x_delta;
FT_Pos y_delta = hints->y_delta;
FT_Memory memory = hints->memory;
hints->metrics = metrics;
hints->scaler_flags = scaler->flags;
hints->other_flags = 0;
hints->num_points = 0;
hints->num_contours = 0;
@@ -342,13 +483,12 @@
hints->axis[1].num_segments = 0;
hints->axis[1].num_edges = 0;
/* first of all, reallocate the contours array when necessary
*/
new_max = (FT_UInt) outline->n_contours;
/* first of all, reallocate the contours array when necessary */
new_max = (FT_UInt)outline->n_contours;
old_max = hints->max_contours;
if ( new_max > old_max )
{
new_max = (new_max + 3) & ~3;
new_max = ( new_max + 3 ) & ~3;
if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
goto Exit;
@@ -356,78 +496,37 @@
hints->max_contours = new_max;
}
/* then, reallocate the points, segments & edges arrays if needed --
* note that we reserved two additional point positions, used to
/*
* then reallocate the points arrays if necessary --
* note that we reserve two additional point positions, used to
* hint metrics appropriately
*/
new_max = (FT_UInt)( outline->n_points + 2 );
old_max = hints->max_points;
if ( new_max > old_max )
{
FT_Byte* items;
FT_ULong off1, off2, off3;
/* we store in a single buffer the following arrays:
*
* - an array of N AF_PointRec items
* - an array of 2*N AF_SegmentRec items
* - an array of 2*N AF_EdgeRec items
*
*/
new_max = ( new_max + 2 + 7 ) & ~7;
#define OFF_PAD2(x,y) (((x)+(y)-1) & ~((y)-1))
#define OFF_PADX(x,y) ((((x)+(y)-1)/(y))*(y))
#define OFF_PAD(x,y) ( ((y) & ((y)-1)) ? OFF_PADX(x,y) : OFF_PAD2(x,y) )
#undef OFF_INCREMENT
#define OFF_INCREMENT( _off, _type, _count ) \
( OFF_PAD( _off, sizeof(_type) ) + (_count)*sizeof(_type))
off1 = OFF_INCREMENT( 0, AF_PointRec, new_max );
off2 = OFF_INCREMENT( off1, AF_SegmentRec, new_max*2 );
off3 = OFF_INCREMENT( off2, AF_EdgeRec, new_max*2 );
FT_FREE( hints->points );
if ( FT_ALLOC( items, off3 ) )
{
hints->max_points = 0;
hints->axis[0].segments = NULL;
hints->axis[0].edges = NULL;
hints->axis[1].segments = NULL;
hints->axis[1].edges = NULL;
if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
goto Exit;
}
/* readjust some pointers
*/
hints->max_points = new_max;
hints->points = (AF_Point) items;
hints->axis[0].segments = (AF_Segment)( items + off1 );
hints->axis[1].segments = hints->axis[0].segments + new_max;
hints->axis[0].edges = (AF_Edge) ( items + off2 );
hints->axis[1].edges = hints->axis[0].edges + new_max;
}
hints->num_points = outline->n_points;
hints->num_contours = outline->n_contours;
/* We can't rely on the value of `FT_Outline.flags' to know the fill */
/* direction used for a glyph, given that some fonts are broken (e.g. */
/* direction used for a glyph, given that some fonts are broken (e.g., */
/* the Arphic ones). We thus recompute it each time we need to. */
/* */
hints->axis[ AF_DIMENSION_HORZ ].major_dir = AF_DIR_UP;
hints->axis[ AF_DIMENSION_VERT ].major_dir = AF_DIR_LEFT;
hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_UP;
hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_LEFT;
if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_POSTSCRIPT )
{
hints->axis[ AF_DIMENSION_HORZ ].major_dir = AF_DIR_DOWN;
hints->axis[ AF_DIMENSION_VERT ].major_dir = AF_DIR_RIGHT;
hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_DOWN;
hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_RIGHT;
}
hints->x_scale = x_scale;
@@ -444,7 +543,7 @@
AF_Point point_limit = points + hints->num_points;
/* compute coordinates & bezier flags */
/* compute coordinates & Bezier flags */
{
FT_Vector* vec = outline->points;
char* tag = outline->tags;
@@ -452,8 +551,8 @@
for ( point = points; point < point_limit; point++, vec++, tag++ )
{
point->fx = vec->x;
point->fy = vec->y;
point->fx = (FT_Short)vec->x;
point->fy = (FT_Short)vec->y;
point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
point->oy = point->y = FT_MulFix( vec->y, y_scale ) + y_delta;
@@ -467,7 +566,6 @@
break;
default:
point->flags = 0;
;
}
}
}
@@ -536,13 +634,13 @@
in_x = point->fx - prev->fx;
in_y = point->fy - prev->fy;
point->in_dir = af_direction_compute( in_x, in_y );
point->in_dir = (FT_Char)af_direction_compute( in_x, in_y );
next = point->next;
out_x = next->fx - point->fx;
out_y = next->fy - point->fy;
point->out_dir = af_direction_compute( out_x, out_y );
point->out_dir = (FT_Char)af_direction_compute( out_x, out_y );
if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
{
@@ -570,8 +668,7 @@
}
}
/* compute inflection points
*/
/* compute inflection points */
af_glyph_hints_compute_inflections( hints );
Exit:
@@ -588,10 +685,11 @@
FT_Vector* vec = outline->points;
char* tag = outline->tags;
for ( ; point < limit; point++, vec++, tag++ )
{
vec->x = (FT_Pos) point->x;
vec->y = (FT_Pos) point->y;
vec->x = point->x;
vec->y = point->y;
if ( point->flags & AF_FLAG_CONIC )
tag[0] = FT_CURVE_TAG_CONIC;
@@ -603,22 +701,23 @@
}
/*
/****************************************************************
*
* E D G E P O I N T G R I D - F I T T I N G
* EDGE POINT GRID-FITTING
*
*/
****************************************************************/
FT_LOCAL_DEF( void )
af_glyph_hints_align_edge_points( AF_GlyphHints hints,
AF_Dimension dim )
{
AF_AxisHints axis = & hints->axis[ dim ];
AF_AxisHints axis = & hints->axis[dim];
AF_Edge edges = axis->edges;
AF_Edge edge_limit = edges + axis->num_edges;
AF_Edge edge;
for ( edge = edges; edge < edge_limit; edge++ )
{
/* move the points of each segment */
@@ -657,15 +756,16 @@
}
/*
/****************************************************************
*
* S T R O N G P O I N T I N T E R P O L A T I O N
* STRONG POINT INTERPOLATION
*
*/
****************************************************************/
/* hint the strong points -- this is equivalent to the TrueType `IP' */
/* hinting instruction */
FT_LOCAL_DEF( void )
af_glyph_hints_align_strong_points( AF_GlyphHints hints,
AF_Dimension dim )
@@ -688,6 +788,7 @@
AF_Point point;
AF_Edge edge;
for ( point = points; point < point_limit; point++ )
{
FT_Pos u, ou, fu; /* point position */
@@ -697,8 +798,9 @@
if ( point->flags & touch_flag )
continue;
/* if this point is candidate to weak interpolation, we will */
/* if this point is candidate to weak interpolation, we */
/* interpolate it after all strong points have been processed */
if ( ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) &&
!( point->flags & AF_FLAG_INFLECTION ) )
continue;
@@ -776,9 +878,7 @@
}
}
Store_Point:
/* save the point position */
if ( dim == AF_DIMENSION_HORZ )
point->x = u;
@@ -791,11 +891,12 @@
}
/*
/****************************************************************
*
* W E A K P O I N T I N T E R P O L A T I O N
* WEAK POINT INTERPOLATION
*
*/
****************************************************************/
static void
af_iup_shift( AF_Point p1,
@@ -984,3 +1085,6 @@
point->y = point->u;
}
}
/* END */
+87 -47
View File
@@ -1,20 +1,40 @@
/***************************************************************************/
/* */
/* afhints.h */
/* */
/* Auto-fitter hinting routines (specification). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __AFHINTS_H__
#define __AFHINTS_H__
#include "aftypes.h"
FT_BEGIN_HEADER
/*
* The definition of outline glyph hints. These are shared by all
* script analysis routines (until now)
*
* script analysis routines (until now).
*/
typedef enum
{
AF_DIMENSION_HORZ = 0, /* x coordinates, i.e. vertical segments & edges */
AF_DIMENSION_VERT = 1, /* y coordinates, i.e. horizontal segments & edges */
AF_DIMENSION_HORZ = 0, /* x coordinates, */
/* i.e., vertical segments & edges */
AF_DIMENSION_VERT = 1, /* y coordinates, */
/* i.e., horizontal segments & edges */
AF_DIMENSION_MAX /* do not remove */
@@ -22,7 +42,7 @@ FT_BEGIN_HEADER
/* hint directions -- the values are computed so that two vectors are */
/* in opposite directions iff `dir1+dir2 == 0' */
/* in opposite directions iff `dir1 + dir2 == 0' */
typedef enum
{
AF_DIR_NONE = 4,
@@ -40,27 +60,27 @@ FT_BEGIN_HEADER
AF_FLAG_NONE = 0,
/* point type flags */
AF_FLAG_CONIC = (1 << 0),
AF_FLAG_CUBIC = (1 << 1),
AF_FLAG_CONIC = 1 << 0,
AF_FLAG_CUBIC = 1 << 1,
AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC,
/* point extremum flags */
AF_FLAG_EXTREMA_X = (1 << 2),
AF_FLAG_EXTREMA_Y = (1 << 3),
AF_FLAG_EXTREMA_X = 1 << 2,
AF_FLAG_EXTREMA_Y = 1 << 3,
/* point roundness flags */
AF_FLAG_ROUND_X = (1 << 4),
AF_FLAG_ROUND_Y = (1 << 5),
AF_FLAG_ROUND_X = 1 << 4,
AF_FLAG_ROUND_Y = 1 << 5,
/* point touch flags */
AF_FLAG_TOUCH_X = (1 << 6),
AF_FLAG_TOUCH_Y = (1 << 7),
AF_FLAG_TOUCH_X = 1 << 6,
AF_FLAG_TOUCH_Y = 1 << 7,
/* candidates for weak interpolation have this flag set */
AF_FLAG_WEAK_INTERPOLATION = (1 << 8),
AF_FLAG_WEAK_INTERPOLATION = 1 << 8,
/* all inflection points in the outline have this flag set */
AF_FLAG_INFLECTION = (1 << 9)
AF_FLAG_INFLECTION = 1 << 9
} AF_Flags;
@@ -69,14 +89,13 @@ FT_BEGIN_HEADER
typedef enum
{
AF_EDGE_NORMAL = 0,
AF_EDGE_ROUND = (1 << 0),
AF_EDGE_SERIF = (1 << 1),
AF_EDGE_DONE = (1 << 2)
AF_EDGE_ROUND = 1 << 0,
AF_EDGE_SERIF = 1 << 1,
AF_EDGE_DONE = 1 << 2
} AF_Edge_Flags;
typedef struct AF_PointRec_* AF_Point;
typedef struct AF_SegmentRec_* AF_Segment;
typedef struct AF_EdgeRec_* AF_Edge;
@@ -84,15 +103,15 @@ FT_BEGIN_HEADER
typedef struct AF_PointRec_
{
AF_Flags flags; /* point flags used by hinter */
FT_UShort flags; /* point flags used by hinter */
FT_Char in_dir; /* direction of inwards vector */
FT_Char out_dir; /* direction of outwards vector */
FT_Pos ox, oy; /* original, scaled position */
FT_Pos fx, fy; /* original, unscaled position (font units) */
FT_Short fx, fy; /* original, unscaled position (font units) */
FT_Pos x, y; /* current position */
FT_Pos u, v; /* current (x,y) or (y,x) depending on context */
AF_Direction in_dir; /* direction of inwards vector */
AF_Direction out_dir; /* direction of outwards vector */
AF_Point next; /* next point in contour */
AF_Point prev; /* previous point in contour */
@@ -101,11 +120,11 @@ FT_BEGIN_HEADER
typedef struct AF_SegmentRec_
{
AF_Edge_Flags flags; /* edge/segment flags for this segment */
AF_Direction dir; /* segment direction */
FT_Pos pos; /* position of segment */
FT_Pos min_coord; /* minimum coordinate of segment */
FT_Pos max_coord; /* maximum coordinate of segment */
FT_Byte flags; /* edge/segment flags for this segment */
FT_Char dir; /* segment direction */
FT_Short pos; /* position of segment */
FT_Short min_coord; /* minimum coordinate of segment */
FT_Short max_coord; /* maximum coordinate of segment */
AF_Edge edge; /* the segment's parent edge */
AF_Segment edge_next; /* link to next segment in parent edge */
@@ -124,18 +143,18 @@ FT_BEGIN_HEADER
typedef struct AF_EdgeRec_
{
FT_Pos fpos; /* original, unscaled position (font units) */
FT_Short fpos; /* original, unscaled position (font units) */
FT_Pos opos; /* original, scaled position */
FT_Pos pos; /* current position */
AF_Edge_Flags flags; /* edge flags */
AF_Direction dir; /* edge direction */
FT_Byte flags; /* edge flags */
FT_Char dir; /* edge direction */
FT_Fixed scale; /* used to speed up interpolation between edges */
AF_Width blue_edge; /* non-NULL if this is a blue edge */
AF_Edge link;
AF_Edge serif;
FT_Int num_linked;
FT_Short num_linked;
FT_Int score;
@@ -148,9 +167,11 @@ FT_BEGIN_HEADER
typedef struct AF_AxisHintsRec_
{
FT_Int num_segments;
FT_Int max_segments;
AF_Segment segments;
FT_Int num_edges;
FT_Int max_edges;
AF_Edge edges;
AF_Direction major_dir;
@@ -178,26 +199,27 @@ FT_BEGIN_HEADER
FT_Int num_contours;
AF_Point* contours;
AF_AxisHintsRec axis[ AF_DIMENSION_MAX ];
AF_AxisHintsRec axis[AF_DIMENSION_MAX];
FT_UInt32 scaler_flags; /* copy of scaler flags */
FT_UInt32 other_flags; /* free for script-specific implementations */
FT_UInt32 other_flags; /* free for script-specific */
/* implementations */
AF_ScriptMetrics metrics;
} AF_GlyphHintsRec;
#define AF_HINTS_TEST_SCALER(h,f) ( (h)->scaler_flags & (f) )
#define AF_HINTS_TEST_OTHER(h,f) ( (h)->other_flags & (f) )
#define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) )
#define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) )
#define AF_HINTS_DO_HORIZONTAL(h) \
!AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_HORIZONTAL)
#define AF_HINTS_DO_HORIZONTAL( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL )
#define AF_HINTS_DO_VERTICAL(h) \
!AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_VERTICAL)
#define AF_HINTS_DO_VERTICAL( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL )
#define AF_HINTS_DO_ADVANCE(h) \
!AF_HINTS_TEST_SCALER(h,AF_SCALER_FLAG_NO_ADVANCE)
#define AF_HINTS_DO_ADVANCE( h ) \
!AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
FT_LOCAL( AF_Direction )
@@ -205,19 +227,33 @@ FT_BEGIN_HEADER
FT_Pos dy );
FT_LOCAL( FT_Error )
af_axis_hints_new_segment( AF_AxisHints axis,
FT_Memory memory,
AF_Segment *asegment );
FT_LOCAL( FT_Error)
af_axis_hints_new_edge( AF_AxisHints axis,
FT_Int fpos,
FT_Memory memory,
AF_Edge *edge );
FT_LOCAL( void )
af_glyph_hints_init( AF_GlyphHints hints,
FT_Memory memory );
/* recomputes all AF_Point in a AF_GlyphHints from the definitions
/*
* recompute all AF_Point in a AF_GlyphHints from the definitions
* in a source outline
*/
FT_LOCAL( void )
af_glyph_hints_rescale( AF_GlyphHints hints,
AF_ScriptMetrics metrics );
FT_LOCAL( FT_Error )
af_glyph_hints_reset( AF_GlyphHints hints,
AF_Scaler scaler,
AF_ScriptMetrics metrics,
af_glyph_hints_reload( AF_GlyphHints hints,
FT_Outline* outline );
FT_LOCAL( void )
@@ -241,6 +277,10 @@ FT_BEGIN_HEADER
/* */
FT_END_HEADER
#endif /* __AFHINTS_H__ */
/* END */
File diff suppressed because it is too large Load Diff
+78 -48
View File
@@ -1,34 +1,53 @@
/***************************************************************************/
/* */
/* aflatin.h */
/* */
/* Auto-fitter hinting routines for latin script (specification). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __AFLATIN_H__
#define __AFLATIN_H__
#include "afhints.h"
FT_BEGIN_HEADER
/*
* the latin-specific script class
*
*/
FT_LOCAL( const AF_ScriptClassRec ) af_latin_script_class;
/***************************************************************************/
/***************************************************************************/
/* the latin-specific script class */
FT_CALLBACK_TABLE const AF_ScriptClassRec
af_latin_script_class;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L O B A L M E T R I C S *****/
/***** *****/
/***************************************************************************/
/***************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*
* the following declarations could be embedded in the file "aflatin.c"
* they've been made semi-public to allow alternate script hinters to
* re-use some of them
* The following declarations could be embedded in the file `aflatin.c';
* they have been made semi-public to allow alternate script hinters to
* re-use some of them.
*/
/*
* Latin (global) metrics management
*
*/
/* Latin (global) metrics management */
enum
{
@@ -42,6 +61,7 @@ FT_BEGIN_HEADER
AF_LATIN_BLUE_MAX
};
#define AF_LATIN_IS_TOP_BLUE( b ) ( (b) == AF_LATIN_BLUE_CAPITAL_TOP || \
(b) == AF_LATIN_BLUE_SMALL_F_TOP || \
(b) == AF_LATIN_BLUE_SMALL_TOP )
@@ -49,11 +69,13 @@ FT_BEGIN_HEADER
#define AF_LATIN_MAX_WIDTHS 16
#define AF_LATIN_MAX_BLUES AF_LATIN_BLUE_MAX
enum
{
AF_LATIN_BLUE_ACTIVE = (1 << 0),
AF_LATIN_BLUE_TOP = (1 << 1),
AF_LATIN_BLUE_ACTIVE = 1 << 0,
AF_LATIN_BLUE_TOP = 1 << 1,
AF_LATIN_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */
/* optimization */
AF_LATIN_BLUE_FLAG_MAX
};
@@ -73,13 +95,13 @@ FT_BEGIN_HEADER
FT_Pos delta;
FT_UInt width_count;
AF_WidthRec widths[ AF_LATIN_MAX_WIDTHS ];
AF_WidthRec widths[AF_LATIN_MAX_WIDTHS];
FT_Pos edge_distance_threshold;
/* ignored for horizontal metrics */
FT_Bool control_overshoot;
FT_UInt blue_count;
AF_LatinBlueRec blues[ AF_LATIN_BLUE_MAX ];
AF_LatinBlueRec blues[AF_LATIN_BLUE_MAX];
FT_Fixed org_scale;
FT_Pos org_delta;
@@ -91,12 +113,11 @@ FT_BEGIN_HEADER
{
AF_ScriptMetricsRec root;
FT_UInt units_per_em;
AF_LatinAxisRec axis[ AF_DIMENSION_MAX ];
AF_LatinAxisRec axis[AF_DIMENSION_MAX];
} AF_LatinMetricsRec, *AF_LatinMetrics;
FT_LOCAL( FT_Error )
af_latin_metrics_init( AF_LatinMetrics metrics,
FT_Face face );
@@ -107,57 +128,63 @@ FT_BEGIN_HEADER
/***************************************************************************/
/***************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** L A T I N G L Y P H A N A L Y S I S *****/
/***** *****/
/***************************************************************************/
/***************************************************************************/
/*************************************************************************/
/*************************************************************************/
enum
{
AF_LATIN_HINTS_HORZ_SNAP = (1 << 0), /* enable stem width snapping */
AF_LATIN_HINTS_VERT_SNAP = (1 << 1), /* enable stem height snapping */
AF_LATIN_HINTS_STEM_ADJUST = (1 << 2), /* enable stem width/height adjustment */
AF_LATIN_HINTS_MONO = (1 << 3) /* indicate monochrome rendering */
AF_LATIN_HINTS_HORZ_SNAP = 1 << 0, /* enable stem width snapping */
AF_LATIN_HINTS_VERT_SNAP = 1 << 1, /* enable stem height snapping */
AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height */
/* adjustment */
AF_LATIN_HINTS_MONO = 1 << 3 /* indicate monochrome */
/* rendering */
};
#define AF_LATIN_HINTS_DO_HORZ_SNAP(h) \
AF_HINTS_TEST_OTHER(h,AF_LATIN_HINTS_HORZ_SNAP)
#define AF_LATIN_HINTS_DO_VERT_SNAP(h) \
AF_HINTS_TEST_OTHER(h,AF_LATIN_HINTS_VERT_SNAP)
#define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP )
#define AF_LATIN_HINTS_DO_STEM_ADJUST(h) \
AF_HINTS_TEST_OTHER(h,AF_LATIN_HINTS_STEM_ADJUST)
#define AF_LATIN_HINTS_DO_VERT_SNAP( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP )
#define AF_LATIN_HINTS_DO_MONO(h) \
AF_HINTS_TEST_OTHER(h,AF_LATIN_HINTS_MONO)
#define AF_LATIN_HINTS_DO_STEM_ADJUST( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST )
#define AF_LATIN_HINTS_DO_MONO( h ) \
AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO )
/* this shouldn't normally be exported. However, other scripts might
* like to use this function as-is
/*
* This shouldn't normally be exported. However, other scripts might
* like to use this function as-is.
*/
FT_LOCAL( void )
FT_LOCAL( FT_Error )
af_latin_hints_compute_segments( AF_GlyphHints hints,
AF_Dimension dim );
/* this shouldn't normally be exported. However, other scripts might
* want to use this function as-is
/*
* This shouldn't normally be exported. However, other scripts might
* want to use this function as-is.
*/
FT_LOCAL( void )
af_latin_hints_link_segments( AF_GlyphHints hints,
AF_Dimension dim );
/* this shouldn't normally be exported. However, other scripts might
* want to use this function as-is
/*
* This shouldn't normally be exported. However, other scripts might
* want to use this function as-is.
*/
FT_LOCAL( void )
FT_LOCAL( FT_Error )
af_latin_hints_compute_edges( AF_GlyphHints hints,
AF_Dimension dim );
FT_LOCAL( void )
FT_LOCAL( FT_Error )
af_latin_hints_detect_features( AF_GlyphHints hints,
AF_Dimension dim );
@@ -166,3 +193,6 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __AFLATIN_H__ */
/* END */
+95 -39
View File
@@ -1,7 +1,27 @@
/***************************************************************************/
/* */
/* afloader.c */
/* */
/* Auto-fitter glyph loading routines (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#include "afloader.h"
#include "afhints.h"
#include "afglobal.h"
#include "aflatin.h"
#include "aferrors.h"
FT_LOCAL_DEF( FT_Error )
af_loader_init( AF_Loader loader,
@@ -9,6 +29,7 @@
{
FT_Error error;
FT_ZERO( loader );
af_glyph_hints_init( &loader->hints, memory );
@@ -31,10 +52,11 @@
af_loader_reset( AF_Loader loader,
FT_Face face )
{
FT_Error error = 0;
FT_Error error = AF_Err_Ok;
loader->face = face;
loader->globals = (AF_FaceGlobals) face->autohint.data;
loader->globals = (AF_FaceGlobals)face->autohint.data;
FT_GlyphLoader_Rewind( loader->gloader );
@@ -43,10 +65,13 @@
error = af_face_globals_new( face, &loader->globals );
if ( !error )
{
face->autohint.data = (FT_Pointer) loader->globals;
face->autohint.finalizer = (FT_Generic_Finalizer) af_face_globals_free;
face->autohint.data =
(FT_Pointer)loader->globals;
face->autohint.finalizer =
(FT_Generic_Finalizer)af_face_globals_free;
}
}
return error;
}
@@ -54,6 +79,8 @@
FT_LOCAL_DEF( void )
af_loader_done( AF_Loader loader )
{
af_glyph_hints_done( &loader->hints );
loader->face = NULL;
loader->globals = NULL;
@@ -69,7 +96,7 @@
FT_Int32 load_flags,
FT_UInt depth )
{
FT_Error error = 0;
FT_Error error;
FT_Face face = loader->face;
FT_GlyphLoader gloader = loader->gloader;
AF_ScriptMetrics metrics = loader->metrics;
@@ -77,6 +104,7 @@
FT_GlyphSlot slot = face->glyph;
FT_Slot_Internal internal = slot->internal;
error = FT_Load_Glyph( face, glyph_index, load_flags );
if ( error )
goto Exit;
@@ -86,6 +114,7 @@
{
FT_Matrix inverse;
loader->trans_matrix = internal->glyph_matrix;
loader->trans_delta = internal->glyph_delta;
@@ -101,20 +130,11 @@
switch ( slot->format )
{
case FT_GLYPH_FORMAT_OUTLINE:
/* translate the loaded glyph when an internal transform
* is needed
*/
/* translate the loaded glyph when an internal transform is needed */
if ( loader->transformed )
{
FT_Vector* point = slot->outline.points;
FT_Vector* limit = point + slot->outline.n_points;
for ( ; point < limit; point++ )
{
point->x += loader->trans_delta.x;
point->y += loader->trans_delta.y;
}
}
FT_Outline_Translate( &slot->outline,
loader->trans_delta.x,
loader->trans_delta.y );
/* copy the outline points in the loader's current */
/* extra points which is used to keep original glyph coordinates */
@@ -157,38 +177,61 @@
/* now load the slot image into the auto-outline and run the */
/* automatic hinting process */
error = metrics->clazz->script_hints_init( hints,
&gloader->current.outline,
metrics );
if ( error )
goto Exit;
/* apply the hints */
metrics->clazz->script_hints_apply( hints,
&gloader->current.outline,
metrics );
/* we now need to hint the metrics according to the change in */
/* width/positioning that occured during the hinting process */
{
FT_Pos old_advance, old_rsb, old_lsb, new_lsb;
AF_AxisHints axis = &hints->axis[ AF_DIMENSION_HORZ ];
FT_Pos pp1x_uh, pp2x_uh;
AF_AxisHints axis = &hints->axis[AF_DIMENSION_HORZ];
AF_Edge edge1 = axis->edges; /* leftmost edge */
AF_Edge edge2 = edge1 + axis->num_edges - 1; /* rightmost edge */
AF_Edge edge2 = edge1 +
axis->num_edges - 1; /* rightmost edge */
if ( axis->num_edges > 1 )
{
old_advance = loader->pp2.x;
old_rsb = old_advance - edge2->opos;
old_lsb = edge1->opos;
new_lsb = edge1->pos;
loader->pp1.x = FT_PIX_ROUND( new_lsb - old_lsb );
loader->pp2.x = FT_PIX_ROUND( edge2->pos + old_rsb );
/* remember unhinted values to later account */
/* for rounding errors */
pp1x_uh = new_lsb - old_lsb;
pp2x_uh = edge2->pos + old_rsb;
/* prefer too much space over too little space */
/* for very small sizes */
if ( old_lsb < 24 )
pp1x_uh -= 5;
if ( old_rsb < 24 )
pp2x_uh += 5;
loader->pp1.x = FT_PIX_ROUND( pp1x_uh );
loader->pp2.x = FT_PIX_ROUND( pp2x_uh );
slot->lsb_delta = loader->pp1.x - pp1x_uh;
slot->rsb_delta = loader->pp2.x - pp2x_uh;
#if 0
/* try to fix certain bad advance computations */
if ( loader->pp2.x + loader->pp1.x == edge2->pos && old_rsb > 4 )
loader->pp2.x += 64;
#endif
}
else
{
loader->pp1.x = FT_PIX_ROUND( loader->pp1.x );
loader->pp2.x = FT_PIX_ROUND( loader->pp2.x );
}
}
/* good, we simply add the glyph to our loader's base */
@@ -289,7 +332,7 @@
if ( start_point + k >= num_base_points ||
l >= (FT_UInt)num_new_points )
{
error = FT_Err_Invalid_Composite;
error = AF_Err_Invalid_Composite;
goto Exit;
}
@@ -308,8 +351,8 @@
x = FT_MulFix( subglyph->arg1, hints->x_scale ) + hints->x_delta;
y = FT_MulFix( subglyph->arg2, hints->y_scale ) + hints->y_delta;
x = FT_PIX_ROUND(x);
y = FT_PIX_ROUND(y);
x = FT_PIX_ROUND( x );
y = FT_PIX_ROUND( y );
}
{
@@ -327,7 +370,7 @@
default:
/* we don't support other formats (yet?) */
error = FT_Err_Unimplemented_Feature;
error = AF_Err_Unimplemented_Feature;
}
Hint_Metrics:
@@ -366,7 +409,11 @@
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
x_scale );
#else
if ( !FT_IS_FIXED_WIDTH( slot->face ) )
slot->metrics.horiAdvance = loader->pp2.x - loader->pp1.x;
else
slot->metrics.horiAdvance = FT_MulFix( slot->metrics.horiAdvance,
metrics->scaler.x_scale );
#endif
slot->metrics.horiAdvance = FT_PIX_ROUND( slot->metrics.horiAdvance );
@@ -390,8 +437,6 @@
}
FT_LOCAL_DEF( FT_Error )
af_loader_load_glyph( AF_Loader loader,
FT_Face face,
@@ -402,8 +447,9 @@
FT_Size size = face->size;
AF_ScalerRec scaler;
if ( !size )
return FT_Err_Invalid_Argument;
return AF_Err_Invalid_Argument;
FT_ZERO( &scaler );
@@ -421,21 +467,31 @@
{
AF_ScriptMetrics metrics;
error = af_face_globals_get_metrics( loader->globals, gindex, &metrics );
error = af_face_globals_get_metrics( loader->globals, gindex,
&metrics );
if ( !error )
{
loader->metrics = metrics;
metrics->scaler = scaler;
if ( metrics->clazz->script_metrics_scale )
metrics->clazz->script_metrics_scale( metrics, &scaler );
else
metrics->scaler = scaler;
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM;
load_flags &= ~FT_LOAD_RENDER;
error = metrics->clazz->script_hints_init( &loader->hints, metrics );
if ( error )
goto Exit;
error = af_loader_load_g( loader, &scaler, gindex, load_flags, 0 );
}
}
Exit:
return error;
}
/* END */
+23
View File
@@ -1,9 +1,28 @@
/***************************************************************************/
/* */
/* afloader.h */
/* */
/* Auto-fitter glyph loading routines (specification). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __AF_LOADER_H__
#define __AF_LOADER_H__
#include "afhints.h"
#include "afglobal.h"
FT_BEGIN_HEADER
typedef struct AF_LoaderRec_
@@ -45,6 +64,10 @@ FT_BEGIN_HEADER
/* */
FT_END_HEADER
#endif /* __AF_LOADER_H__ */
/* END */
+25 -6
View File
@@ -1,7 +1,27 @@
/***************************************************************************/
/* */
/* afmodule.c */
/* */
/* Auto-fitter module implementation (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#include "afmodule.h"
#include "afloader.h"
#include FT_INTERNAL_OBJECTS_H
typedef struct FT_AutofitterRec_
{
FT_ModuleRec root;
@@ -31,21 +51,20 @@
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_UNUSED(size);
FT_UNUSED( size );
return af_loader_load_glyph( module->loader, slot->face,
glyph_index, load_flags );
}
FT_CALLBACK_TABLE_DEF
const FT_AutoHinter_ServiceRec af_autofitter_service =
{
NULL,
NULL,
NULL,
(FT_AutoHinter_GlyphLoadFunc) af_autofitter_load_glyph
(FT_AutoHinter_GlyphLoadFunc)af_autofitter_load_glyph
};
@@ -59,11 +78,11 @@
0x10000L, /* version 1.0 of the autofitter */
0x20000L, /* requires FreeType 2.0 or above */
(const void*) &af_autofitter_service,
(const void*)&af_autofitter_service,
(FT_Module_Constructor) af_autofitter_init,
(FT_Module_Constructor)af_autofitter_init,
(FT_Module_Destructor) af_autofitter_done,
(FT_Module_Requester) 0
(FT_Module_Requester) NULL
};
+21
View File
@@ -1,3 +1,21 @@
/***************************************************************************/
/* */
/* afmodule.h */
/* */
/* Auto-fitter module implementation (specification). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#ifndef __AFMODULE_H__
#define __AFMODULE_H__
@@ -14,3 +32,6 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __AFMODULE_H__ */
/* END */
+120 -69
View File
@@ -1,42 +1,80 @@
/***************************************************************************/
/* */
/* aftypes.h */
/* */
/* Auto-fitter types (specification only). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
/***************************************************************************
*
* The auto-fitter is a complete rewrite of the old auto-hinter.
* Its main feature is the ability to differentiate between different
* scripts in order to apply language-specific rules.
*
* The code has also been compartimentized into several entities that
* should make algorithmic experimentation easier than with the old
* code.
*
* Finally, we get rid of the Catharon license, since this code is
* released under the FreeType one.
*
***************************************************************************/
#ifndef __AFTYPES_H__
#define __AFTYPES_H__
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
FT_BEGIN_HEADER
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** D E B U G G I N G *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
#define xxAF_DEBUG
#ifdef AF_DEBUG
# include <stdio.h>
# define AF_LOG( x ) printf x
#include <stdio.h>
#define AF_LOG( x ) printf x
#else
# define AF_LOG( x ) do ; while ( 0 ) /* nothing */
#define AF_LOG( x ) do ; while ( 0 ) /* nothing */
#endif /* AF_DEBUG */
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** U T I L I T Y *****/
/***** U T I L I T Y S T U F F *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
typedef struct AF_WidthRec_
{
@@ -56,31 +94,31 @@ FT_BEGIN_HEADER
AF_Width widths );
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** A N G L E T Y P E S *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*
* Angle type. The auto-fitter doesn't need a very high angular accuracy,
* and this allows us to speed up some computations considerably with a
* light Cordic algorithm (see afangles.c)
*
* The auto-fitter doesn't need a very high angular accuracy;
* this allows us to speed up some computations considerably with a
* light Cordic algorithm (see afangles.c).
*/
typedef FT_Int AF_Angle;
#define AF_ANGLE_PI 128
#define AF_ANGLE_2PI (AF_ANGLE_PI*2)
#define AF_ANGLE_PI2 (AF_ANGLE_PI/2)
#define AF_ANGLE_PI4 (AF_ANGLE_PI/4)
#define AF_ANGLE_PI 256
#define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 )
#define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 )
#define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 )
/*
* compute the angle of a given 2-D vector
*
*/
FT_LOCAL( AF_Angle )
af_angle_atan( FT_Pos dx,
@@ -88,31 +126,30 @@ FT_BEGIN_HEADER
/*
* computes "angle2 - angle1", the result is always within
* the range [ -AF_ANGLE_PI .. AF_ANGLE_PI-1 ]
*
* compute `angle2 - angle1'; the result is always within
* the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1]
*/
FT_LOCAL( AF_Angle )
af_angle_diff( AF_Angle angle1,
AF_Angle angle2 );
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** O U T L I N E S *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* opaque handle to glyph-specific hints. see "afhints.h" for more
/* opaque handle to glyph-specific hints -- see `afhints.h' for more
* details
*/
typedef struct AF_GlyphHintsRec_* AF_GlyphHints;
/* this structure is used to model an input glyph outline to
* the auto-hinter. The latter will set the "hints" field
* depending on the glyph's script
/* This structure is used to model an input glyph outline to
* the auto-hinter. The latter will set the `hints' field
* depending on the glyph's script.
*/
typedef struct AF_OutlineRec_
{
@@ -128,18 +165,17 @@ FT_BEGIN_HEADER
} AF_OutlineRec;
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S C A L E R S *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*
* A scaler models the target pixel device that will receive the
* auto-hinted glyph image
*
* auto-hinted glyph image.
*/
typedef enum
@@ -158,53 +194,60 @@ FT_BEGIN_HEADER
FT_Fixed y_scale; /* from font units to 1/64th device pixels */
FT_Pos x_delta; /* in 1/64th device pixels */
FT_Pos y_delta; /* in 1/64th device pixels */
FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc.. */
FT_UInt32 flags; /* additionnal control flags, see above */
FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */
FT_UInt32 flags; /* additional control flags, see above */
} AF_ScalerRec, *AF_Scaler;
#define AF_SCALER_EQUAL_SCALES( a, b ) \
( (a)->x_scale == (b)->x_scale && \
(a)->y_scale == (b)->y_scale && \
(a)->x_delta == (b)->x_delta && \
(a)->y_delta == (b)->y_delta )
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** S C R I P T S *****/
/***** *****/
/**************************************************************************/
/**************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*
* the list of know scripts. Each different script correspond to the
* The list of know scripts. Each different script corresponds to the
* following information:
*
* - a set of Unicode ranges to test weither the face supports the
* script
* - A set of Unicode ranges to test whether the face supports the
* script.
*
* - a specific global analyzer that will compute global metrics
* - A specific global analyzer that will compute global metrics
* specific to the script.
*
* - a specific glyph analyzer that will compute segments and
* edges for each glyph covered by the script
* - A specific glyph analyzer that will compute segments and
* edges for each glyph covered by the script.
*
* - a specific grid-fitting algorithm that will distort the
* - A specific grid-fitting algorithm that will distort the
* scaled glyph outline according to the results of the glyph
* analyzer
* analyzer.
*
* note that a given analyzer and/or grid-fitting algorithm can be
* used by more than one script
* Note that a given analyzer and/or grid-fitting algorithm can be
* used by more than one script.
*/
typedef enum
{
AF_SCRIPT_NONE = 0,
AF_SCRIPT_LATIN = 1,
/* add new scripts here. don't forget to update the list in "afglobal.c" */
/* add new scripts here. Don't forget to update the list in */
/* `afglobal.c'. */
AF_SCRIPT_MAX /* do not remove */
} AF_Script;
typedef struct AF_ScriptClassRec_ const* AF_ScriptClass;
typedef struct AF_ScriptMetricsRec_
@@ -215,23 +258,27 @@ FT_BEGIN_HEADER
} AF_ScriptMetricsRec, *AF_ScriptMetrics;
/* this function parses a FT_Face to compute global metrics for
* a specific script
/* This function parses an FT_Face to compute global metrics for
* a specific script.
*/
typedef FT_Error (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
typedef FT_Error
(*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics,
FT_Face face );
typedef void (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
typedef void
(*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics,
AF_Scaler scaler );
typedef void (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
typedef void
(*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics );
typedef FT_Error (*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
FT_Outline* outline,
typedef FT_Error
(*AF_Script_InitHintsFunc)( AF_GlyphHints hints,
AF_ScriptMetrics metrics );
typedef void (*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
typedef void
(*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints,
FT_Outline* outline,
AF_ScriptMetrics metrics );
@@ -243,7 +290,8 @@ FT_BEGIN_HEADER
} AF_Script_UniRangeRec;
typedef const AF_Script_UniRangeRec * AF_Script_UniRange;
typedef const AF_Script_UniRangeRec *AF_Script_UniRange;
typedef struct AF_ScriptClassRec_
{
@@ -266,3 +314,6 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __AFTYPES_H__ */
/* END */
+21
View File
@@ -1,3 +1,21 @@
/***************************************************************************/
/* */
/* autofit.c */
/* */
/* Auto-fitter module (body). */
/* */
/* Copyright 2003, 2004, 2005 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. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
#include "afangles.c"
@@ -7,3 +25,6 @@
#include "aflatin.c"
#include "afloader.c"
#include "afmodule.c"
/* END */
+22
View File
@@ -0,0 +1,22 @@
#
# FreeType 2 auto-fitter module definition
#
# Copyright 2003, 2004, 2005 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.
make_module_list: add_autofit_module
add_autofit_module:
$(OPEN_DRIVER)autofit_module_class$(CLOSE_DRIVER)
$(ECHO_DRIVER)autofit $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE)
# EOF
+75
View File
@@ -0,0 +1,75 @@
#
# FreeType 2 auto-fitter module configuration rules
#
# Copyright 2003, 2004, 2005 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.
# AUTOF driver directory
#
AUTOF_DIR := $(SRC_DIR)/autofit
# compilation flags for the driver
#
AUTOF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(AUTOF_DIR))
# AUTOF driver sources (i.e., C files)
#
AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
$(AUTOF_DIR)/afdummy.c \
$(AUTOF_DIR)/afglobal.c \
$(AUTOF_DIR)/afhints.c \
$(AUTOF_DIR)/aflatin.c \
$(AUTOF_DIR)/afloader.c \
$(AUTOF_DIR)/afmodule.c
# AUTOF driver headers
#
AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \
$(AUTOF_DIR)/aftypes.h \
$(AUTOF_DIR)/aferrors.h
# AUTOF driver object(s)
#
# AUTOF_DRV_OBJ_M is used during `multi' builds.
# AUTOF_DRV_OBJ_S is used during `single' builds.
#
AUTOF_DRV_OBJ_M := $(AUTOF_DRV_SRC:$(AUTOF_DIR)/%.c=$(OBJ_DIR)/%.$O)
AUTOF_DRV_OBJ_S := $(OBJ_DIR)/autofit.$O
# AUTOF driver source file for single build
#
AUTOF_DRV_SRC_S := $(AUTOF_DIR)/autofit.c
# AUTOF driver - single object
#
$(AUTOF_DRV_OBJ_S): $(AUTOF_DRV_SRC_S) $(AUTOF_DRV_SRC) \
$(FREETYPE_H) $(AUTOF_DRV_H)
$(AUTOF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(AUTOF_DRV_SRC_S))
# AUTOF driver - multiple objects
#
$(OBJ_DIR)/%.$O: $(AUTOF_DIR)/%.c $(FREETYPE_H) $(AUTOF_DRV_H)
$(AUTOF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<)
# update main driver object lists
#
DRV_OBJS_S += $(AUTOF_DRV_OBJ_S)
DRV_OBJS_M += $(AUTOF_DRV_OBJ_M)
# EOF
+1 -1
View File
@@ -25,7 +25,7 @@ UseFreeTypeHeaders ;
#
FT2_Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c
ftbbox.c ftdebug.c ftxf86.c fttype1.c ftpfr.c
ftstroke.c ftwinfnt.c ;
ftstroke.c ftwinfnt.c ftotval.c ftbitmap.c ;
# Add Macintosh-specific file to the library when necessary.
#
+71 -65
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
@@ -48,7 +48,7 @@
/* This function is used as a `move_to' and `line_to' emitter during */
/* FT_Outline_Decompose(). It simply records the destination point */
/* in `user->last'; no further computations are necessary since we */
/* the cbox as the starting bbox which must be refined. */
/* use the cbox as the starting bbox which must be refined. */
/* */
/* <Input> */
/* to :: A pointer to the destination vector. */
@@ -88,11 +88,14 @@
/* */
/* <Input> */
/* y1 :: The start coordinate. */
/* */
/* y2 :: The coordinate of the control point. */
/* */
/* y3 :: The end coordinate. */
/* */
/* <InOut> */
/* min :: The address of the current minimum. */
/* */
/* max :: The address of the current maximum. */
/* */
static void
@@ -102,19 +105,17 @@
FT_Pos* min,
FT_Pos* max )
{
if ( y1 <= y3 )
{
if ( y2 == y1 ) /* Flat arc */
if ( y1 <= y3 && y2 == y1 ) /* flat arc */
goto Suite;
}
else if ( y1 < y3 )
if ( y1 < y3 )
{
if ( y2 >= y1 && y2 <= y3 ) /* Ascending arc */
if ( y2 >= y1 && y2 <= y3 ) /* ascending arc */
goto Suite;
}
else
{
if ( y2 >= y3 && y2 <= y1 ) /* Descending arc */
if ( y2 >= y3 && y2 <= y1 ) /* descending arc */
{
y2 = y1;
y1 = y3;
@@ -144,6 +145,7 @@
/* */
/* <Input> */
/* control :: A pointer to a control point. */
/* */
/* to :: A pointer to the destination vector. */
/* */
/* <InOut> */
@@ -165,7 +167,6 @@
/* within the bbox */
if ( CHECK_X( control, user->bbox ) )
BBox_Conic_Check( user->last.x,
control->x,
to->x,
@@ -173,7 +174,6 @@
&user->bbox.xMax );
if ( CHECK_Y( control, user->bbox ) )
BBox_Conic_Check( user->last.y,
control->y,
to->y,
@@ -194,19 +194,25 @@
/* <Description> */
/* Finds the extrema of a 1-dimensional cubic Bezier curve and */
/* updates a bounding range. This version uses splitting because we */
/* don't want to use square roots and extra accuracies. */
/* don't want to use square roots and extra accuracy. */
/* */
/* <Input> */
/* p1 :: The start coordinate. */
/* */
/* p2 :: The coordinate of the first control point. */
/* */
/* p3 :: The coordinate of the second control point. */
/* */
/* p4 :: The end coordinate. */
/* */
/* <InOut> */
/* min :: The address of the current minimum. */
/* */
/* max :: The address of the current maximum. */
/* */
#if 0
static void
BBox_Cubic_Check( FT_Pos p1,
FT_Pos p2,
@@ -235,17 +241,17 @@
if ( y1 == y4 )
{
if ( y1 == y2 && y1 == y3 ) /* Flat */
if ( y1 == y2 && y1 == y3 ) /* flat */
goto Test;
}
else if ( y1 < y4 )
{
if ( y2 >= y1 && y2 <= y4 && y3 >= y1 && y3 <= y4 ) /* Ascending */
if ( y2 >= y1 && y2 <= y4 && y3 >= y1 && y3 <= y4 ) /* ascending */
goto Test;
}
else
{
if ( y2 >= y4 && y2 <= y1 && y3 >= y4 && y3 <= y1 ) /* Descending */
if ( y2 >= y4 && y2 <= y1 && y3 >= y4 && y3 <= y1 ) /* descending */
{
y2 = y1;
y1 = y4;
@@ -254,7 +260,7 @@
}
}
/* Unknown direction -- split the arc in two */
/* unknown direction -- split the arc in two */
arc[6] = y4;
arc[1] = y1 = ( y1 + y2 ) / 2;
arc[5] = y4 = ( y4 + y3 ) / 2;
@@ -275,6 +281,7 @@
;
} while ( arc >= stack );
}
#else
static void
@@ -298,15 +305,17 @@
/* The polynom is */
/* */
/* a*x^3 + 3b*x^2 + 3c*x + d . */
/* P(x) = a*x^3 + 3b*x^2 + 3c*x + d , */
/* */
/* dP/dx = 3a*x^2 + 6b*x + 3c . */
/* */
/* However, we also have */
/* */
/* dP/dx(u) = 0 , */
/* */
/* which implies that */
/* which implies by subtraction that */
/* */
/* P(u) = b*u^2 + 2c*u + d */
/* P(u) = b*u^2 + 2c*u + d . */
if ( u > 0 && u < 0x10000L )
{
@@ -357,72 +366,67 @@
FT_Fixed t;
/* We need to solve "ax^2+2bx+c" here, without floating points! */
/* We need to solve `ax^2+2bx+c' here, without floating points! */
/* The trick is to normalize to a different representation in order */
/* to use our 16.16 fixed point routines. */
/* */
/* We compute FT_MulFix(b,b) and FT_MulFix(a,c) after the */
/* the normalization. These values must fit into a single 16.16 */
/* value. */
/* */
/* We normalize a, b, and c to "8.16" fixed float values to ensure */
/* that their product is held in a "16.16" value. */
/* We compute FT_MulFix(b,b) and FT_MulFix(a,c) after normalization. */
/* These values must fit into a single 16.16 value. */
/* */
/* We normalize a, b, and c to `8.16' fixed float values to ensure */
/* that its product is held in a `16.16' value. */
{
FT_ULong t1, t2;
int shift = 0;
/* Technical explanation of what's happening there. */
/* */
/* The following computation is based on the fact that for */
/* any value "y", if "n" is the position of the most */
/* significant bit of "abs(y)" (starting from 0 for the */
/* least significant bit), then y is in the range */
/* any value `y', if `n' is the position of the most */
/* significant bit of `abs(y)' (starting from 0 for the */
/* least significant bit), then `y' is in the range */
/* */
/* "-2^n..2^n-1" */
/* -2^n..2^n-1 */
/* */
/* We want to shift "a", "b" and "c" concurrently in order */
/* We want to shift `a', `b', and `c' concurrently in order */
/* to ensure that they all fit in 8.16 values, which maps */
/* to the integer range "-2^23..2^23-1". */
/* to the integer range `-2^23..2^23-1'. */
/* */
/* Necessarily, we need to shift "a", "b" and "c" so that */
/* the most significant bit of their absolute values is at */
/* Necessarily, we need to shift `a', `b', and `c' so that */
/* the most significant bit of its absolute values is at */
/* _most_ at position 23. */
/* */
/* We begin by computing "t1" as the bitwise "or" of the */
/* absolute values of "a", "b", "c". */
/* */
t1 = (FT_ULong)((a >= 0) ? a : -a );
t2 = (FT_ULong)((b >= 0) ? b : -b );
/* We begin by computing `t1' as the bitwise `OR' of the */
/* absolute values of `a', `b', `c'. */
t1 = (FT_ULong)( ( a >= 0 ) ? a : -a );
t2 = (FT_ULong)( ( b >= 0 ) ? b : -b );
t1 |= t2;
t2 = (FT_ULong)((c >= 0) ? c : -c );
t2 = (FT_ULong)( ( c >= 0 ) ? c : -c );
t1 |= t2;
/* Now, the most significant bit of "t1" is sure to be the */
/* msb of one of "a", "b", "c", depending on which one is */
/* expressed in the greatest integer range. */
/* Now we can be sure that the most significant bit of `t1' */
/* is the most significant bit of either `a', `b', or `c', */
/* depending on the greatest integer range of the particular */
/* variable. */
/* */
/* We now compute the "shift", by shifting "t1" as many */
/* times as necessary to move its msb to position 23. */
/* */
/* This corresponds to a value of t1 that is in the range */
/* Next, we compute the `shift', by shifting `t1' as many */
/* times as necessary to move its MSB to position 23. This */
/* corresponds to a value of `t1' that is in the range */
/* 0x40_0000..0x7F_FFFF. */
/* */
/* Finally, we shift "a", "b" and "c" by the same amount. */
/* Finally, we shift `a', `b', and `c' by the same amount. */
/* This ensures that all values are now in the range */
/* -2^23..2^23, i.e. that they are now expressed as 8.16 */
/* fixed float numbers. */
/* -2^23..2^23, i.e., they are now expressed as 8.16 */
/* fixed-float numbers. This also means that we are using */
/* 24 bits of precision to compute the zeros, independently */
/* of the range of the original polynomial coefficients. */
/* */
/* This also means that we are using 24 bits of precision */
/* to compute the zeros, independently of the range of */
/* the original polynom coefficients. */
/* */
/* This should ensure reasonably accurate values for the */
/* zeros. Note that the latter are only expressed with */
/* This algorithm should ensure reasonably accurate values */
/* for the zeros. Note that they are only expressed with */
/* 16 bits when computing the extrema (the zeros need to */
/* be in 0..1 exclusive to be considered part of the arc). */
/* */
if ( t1 == 0 ) /* all coefficients are 0! */
return;
@@ -432,10 +436,11 @@
{
shift++;
t1 >>= 1;
} while ( t1 > 0x7FFFFFUL );
/* losing some bits of precision, but we use 24 of them */
/* for the computation anyway. */
/* this loses some bits of precision, but we use 24 of them */
/* for the computation anyway */
a >>= shift;
b >>= shift;
c >>= shift;
@@ -446,6 +451,7 @@
{
shift++;
t1 <<= 1;
} while ( t1 < 0x400000UL );
a <<= shift;
@@ -478,7 +484,7 @@
}
else
{
/* there are two solutions; we need to filter them though */
/* there are two solutions; we need to filter them */
d = FT_SqrtFixed( (FT_Int32)d );
t = - FT_DivFix( b - d, a );
test_cubic_extrema( y1, y2, y3, y4, t, min, max );
@@ -506,7 +512,9 @@
/* */
/* <Input> */
/* control1 :: A pointer to the first control point. */
/* */
/* control2 :: A pointer to the second control point. */
/* */
/* to :: A pointer to the destination vector. */
/* */
/* <InOut> */
@@ -517,7 +525,7 @@
/* */
/* <Note> */
/* In the case of a non-monotonous arc, we don't compute directly */
/* extremum coordinates, we subdivise instead. */
/* extremum coordinates, we subdivide instead. */
/* */
static int
BBox_Cubic_To( FT_Vector* control1,
@@ -530,7 +538,6 @@
if ( CHECK_X( control1, user->bbox ) ||
CHECK_X( control2, user->bbox ) )
BBox_Cubic_Check( user->last.x,
control1->x,
control2->x,
@@ -540,7 +547,6 @@
if ( CHECK_Y( control1, user->bbox ) ||
CHECK_Y( control2, user->bbox ) )
BBox_Cubic_Check( user->last.y,
control1->y,
control2->y,
+5 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing BDF-specific strings (body). */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,8 @@
#include FT_SERVICE_BDF_H
/* documentation is in ftbdf.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_BDF_Charset_ID( FT_Face face,
const char* *acharset_encoding,
@@ -54,6 +56,8 @@
}
/* documentation is in ftbdf.h */
FT_EXPORT( FT_Error )
FT_Get_BDF_Property( FT_Face face,
const char* prop_name,
+616
View File
@@ -0,0 +1,616 @@
/***************************************************************************/
/* */
/* ftbitmap.c */
/* */
/* FreeType utility functions for converting 1bpp, 2bpp, 4bpp, and 8bpp */
/* bitmaps into 8bpp format (body). */
/* */
/* Copyright 2004, 2005 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H
static
const FT_Bitmap null_bitmap = { 0, 0, 0, 0, 0, 0, 0, 0 };
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( void )
FT_Bitmap_New( FT_Bitmap *abitmap )
{
*abitmap = null_bitmap;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Copy( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target)
{
FT_Memory memory = library->memory;
FT_Error error = FT_Err_Ok;
FT_Int pitch = source->pitch;
FT_ULong size;
if ( source == target )
return FT_Err_Ok;
if ( source->buffer == NULL )
{
*target = *source;
return FT_Err_Ok;
}
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)( pitch * source->rows );
if ( target->buffer )
{
FT_Int target_pitch = target->pitch;
FT_ULong target_size;
if ( target_pitch < 0 )
target_pitch = -target_pitch;
target_size = (FT_ULong)( target_pitch * target->rows );
if ( target_size != size )
FT_QREALLOC( target->buffer, target_size, size );
}
else
FT_QALLOC( target->buffer, size );
if ( !error )
{
unsigned char *p;
p = target->buffer;
*target = *source;
target->buffer = p;
FT_MEM_COPY( target->buffer, source->buffer, size );
}
return error;
}
static FT_Error
ft_bitmap_assure_buffer( FT_Memory memory,
FT_Bitmap* bitmap,
FT_UInt xpixels,
FT_UInt ypixels )
{
FT_Error error;
int pitch;
int new_pitch;
FT_UInt ppb;
FT_Int i;
unsigned char* buffer;
pitch = bitmap->pitch;
if ( pitch < 0 )
pitch = -pitch;
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
ppb = 8;
break;
case FT_PIXEL_MODE_GRAY2:
ppb = 4;
break;
case FT_PIXEL_MODE_GRAY4:
ppb = 2;
break;
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_LCD:
case FT_PIXEL_MODE_LCD_V:
ppb = 1;
break;
default:
return FT_Err_Invalid_Glyph_Format;
}
/* if no need to allocate memory */
if ( ypixels == 0 && pitch * ppb >= bitmap->width + xpixels )
{
/* zero the padding */
for ( i = 0; i < bitmap->rows; i++ )
{
unsigned char* last_byte;
int bits = xpixels * ( 8 / ppb );
int mask = 0;
last_byte = bitmap->buffer + i * pitch + ( bitmap->width - 1 ) / ppb;
if ( bits >= 8 )
{
FT_MEM_ZERO( last_byte + 1, bits / 8 );
bits %= 8;
}
if ( bits > 0 )
{
while ( bits-- > 0 )
mask |= 1 << bits;
*last_byte &= ~mask;
}
}
return FT_Err_Ok;
}
new_pitch = ( bitmap->width + xpixels + ppb - 1 ) / ppb;
if ( FT_ALLOC( buffer, new_pitch * ( bitmap->rows + ypixels ) ) )
return error;
if ( bitmap->pitch > 0 )
{
for ( i = 0; i < bitmap->rows; i++ )
FT_MEM_COPY( buffer + new_pitch * ( ypixels + i ),
bitmap->buffer + pitch * i, pitch );
}
else
{
for ( i = 0; i < bitmap->rows; i++ )
FT_MEM_COPY( buffer + new_pitch * i,
bitmap->buffer + pitch * i, pitch );
}
FT_FREE( bitmap->buffer );
bitmap->buffer = buffer;
if ( bitmap->pitch < 0 )
new_pitch = -new_pitch;
/* set pitch only */
bitmap->pitch = new_pitch;
return FT_Err_Ok;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Embolden( FT_Library library,
FT_Bitmap* bitmap,
FT_Pos xStrength,
FT_Pos yStrength )
{
FT_Error error;
unsigned char* p;
FT_Int i, x, y, pitch;
FT_Int xstr, ystr;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !bitmap || !bitmap->buffer )
return FT_Err_Invalid_Argument;
xstr = FT_PIX_ROUND( xStrength ) >> 6;
ystr = FT_PIX_ROUND( yStrength ) >> 6;
if ( xstr == 0 && ystr == 0 )
return FT_Err_Ok;
else if ( xstr < 0 || ystr < 0 )
return FT_Err_Invalid_Argument;
switch ( bitmap->pixel_mode )
{
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
{
FT_Bitmap tmp;
FT_Int align;
if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY2 )
align = ( bitmap->width + xstr + 3 ) / 4;
else
align = ( bitmap->width + xstr + 1 ) / 2;
FT_Bitmap_New( &tmp );
error = FT_Bitmap_Convert( library, bitmap, &tmp, align );
if ( error )
return error;
FT_Bitmap_Done( library, bitmap );
*bitmap = tmp;
}
break;
case FT_PIXEL_MODE_MONO:
if ( xstr > 8 )
xstr = 8;
break;
case FT_PIXEL_MODE_LCD:
xstr *= 3;
break;
case FT_PIXEL_MODE_LCD_V:
ystr *= 3;
break;
}
error = ft_bitmap_assure_buffer( library->memory, bitmap, xstr, ystr );
if ( error )
return error;
pitch = bitmap->pitch;
if ( pitch > 0 )
p = bitmap->buffer + pitch * ystr;
else
{
pitch = -pitch;
p = bitmap->buffer + pitch * ( bitmap->rows - 1 );
}
/* for each row */
for ( y = 0; y < bitmap->rows ; y++ )
{
/*
* Horizontally:
*
* From the last pixel on, make each pixel or'ed with the
* `xstr' pixels before it.
*/
for ( x = pitch - 1; x >= 0; x-- )
{
unsigned char tmp;
tmp = p[x];
for ( i = 1; i <= xstr; i++ )
{
if ( bitmap->pixel_mode == FT_PIXEL_MODE_MONO )
{
p[x] |= tmp >> i;
/* the maximum value of 8 for `xstr' comes from here */
if ( x > 0 )
p[x] |= p[x - 1] << ( 8 - i );
#if 0
if ( p[x] == 0xff )
break;
#endif
}
else
{
if ( x - i >= 0 )
{
if ( p[x] + p[x - i] > bitmap->num_grays - 1 )
{
p[x] = bitmap->num_grays - 1;
break;
}
else
{
p[x] += p[x - i];
if ( p[x] == bitmap->num_grays - 1 )
break;
}
}
else
break;
}
}
}
/*
* Vertically:
*
* Make the above `ystr' rows or'ed with it.
*/
for ( x = 1; x <= ystr; x++ )
{
unsigned char* q;
q = p - bitmap->pitch * x;
for ( i = 0; i < pitch; i++ )
q[i] |= p[i];
}
p += bitmap->pitch;
}
bitmap->width += xstr;
bitmap->rows += ystr;
return FT_Err_Ok;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Convert( FT_Library library,
const FT_Bitmap *source,
FT_Bitmap *target,
FT_Int alignment )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory;
if ( !library )
return FT_Err_Invalid_Library_Handle;
memory = library->memory;
switch ( source->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
case FT_PIXEL_MODE_GRAY:
case FT_PIXEL_MODE_GRAY2:
case FT_PIXEL_MODE_GRAY4:
{
FT_Int pad;
FT_Long old_size;
old_size = target->rows * target->pitch;
if ( old_size < 0 )
old_size = -old_size;
target->pixel_mode = FT_PIXEL_MODE_GRAY;
target->rows = source->rows;
target->width = source->width;
pad = 0;
if ( alignment > 0 )
{
pad = source->width % alignment;
if ( pad != 0 )
pad = alignment - pad;
}
target->pitch = source->width + pad;
if ( target->rows * target->pitch > old_size &&
FT_QREALLOC( target->buffer,
old_size, target->rows * target->pitch ) )
return error;
}
break;
default:
error = FT_Err_Invalid_Argument;
}
switch ( source->pixel_mode )
{
case FT_PIXEL_MODE_MONO:
{
FT_Byte* s = source->buffer;
FT_Byte* t = target->buffer;
FT_Int i;
target->num_grays = 2;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_Int j;
/* get the full bytes */
for ( j = source->width >> 3; j > 0; j-- )
{
FT_Int val = ss[0]; /* avoid a byte->int cast on each line */
tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7 );
tt[1] = (FT_Byte)( ( val & 0x40 ) >> 6 );
tt[2] = (FT_Byte)( ( val & 0x20 ) >> 5 );
tt[3] = (FT_Byte)( ( val & 0x10 ) >> 4 );
tt[4] = (FT_Byte)( ( val & 0x08 ) >> 3 );
tt[5] = (FT_Byte)( ( val & 0x04 ) >> 2 );
tt[6] = (FT_Byte)( ( val & 0x02 ) >> 1 );
tt[7] = (FT_Byte)( val & 0x01 );
tt += 8;
ss += 1;
}
/* get remaining pixels (if any) */
j = source->width & 7;
if ( j > 0 )
{
FT_Int val = *ss;
for ( ; j > 0; j-- )
{
tt[0] = (FT_Byte)( ( val & 0x80 ) >> 7);
val <<= 1;
tt += 1;
}
}
s += source->pitch;
t += target->pitch;
}
}
break;
case FT_PIXEL_MODE_GRAY:
{
FT_Int width = source->width;
FT_Byte* s = source->buffer;
FT_Byte* t = target->buffer;
FT_Int s_pitch = source->pitch;
FT_Int t_pitch = target->pitch;
FT_Int i;
target->num_grays = 256;
for ( i = source->rows; i > 0; i-- )
{
FT_ARRAY_COPY( t, s, width );
s += s_pitch;
t += t_pitch;
}
}
break;
case FT_PIXEL_MODE_GRAY2:
{
FT_Byte* s = source->buffer;
FT_Byte* t = target->buffer;
FT_Int i;
target->num_grays = 4;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_Int j;
/* get the full bytes */
for ( j = source->width >> 2; j > 0; j-- )
{
FT_Int val = ss[0];
tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 );
tt[1] = (FT_Byte)( ( val & 0x30 ) >> 4 );
tt[2] = (FT_Byte)( ( val & 0x0C ) >> 2 );
tt[3] = (FT_Byte)( ( val & 0x03 ) );
ss += 1;
tt += 4;
}
j = source->width & 3;
if ( j > 0 )
{
FT_Int val = ss[0];
for ( ; j > 0; j-- )
{
tt[0] = (FT_Byte)( ( val & 0xC0 ) >> 6 );
val <<= 2;
tt += 1;
}
}
s += source->pitch;
t += target->pitch;
}
}
break;
case FT_PIXEL_MODE_GRAY4:
{
FT_Byte* s = source->buffer;
FT_Byte* t = target->buffer;
FT_Int i;
target->num_grays = 16;
for ( i = source->rows; i > 0; i-- )
{
FT_Byte* ss = s;
FT_Byte* tt = t;
FT_Int j;
/* get the full bytes */
for ( j = source->width >> 1; j > 0; j-- )
{
FT_Int val = ss[0];
tt[0] = (FT_Byte)( ( val & 0xF0 ) >> 4 );
tt[1] = (FT_Byte)( ( val & 0x0F ) );
ss += 1;
tt += 2;
}
if ( source->width & 1 )
tt[0] = (FT_Byte)( ( ss[0] & 0xF0 ) >> 4 );
s += source->pitch;
t += target->pitch;
}
}
break;
default:
;
}
return error;
}
/* documentation is in ftbitmap.h */
FT_EXPORT_DEF( FT_Error )
FT_Bitmap_Done( FT_Library library,
FT_Bitmap *bitmap )
{
FT_Memory memory;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !bitmap )
return FT_Err_Invalid_Argument;
memory = library->memory;
FT_FREE( bitmap->buffer );
*bitmap = null_bitmap;
return FT_Err_Ok;
}
/* END */
+1 -1
View File
@@ -586,7 +586,7 @@
#endif /* FT_LONG64 */
/* a not-so-fast but working 16.16 fixed point square root function */
/* documentation is in ftcalc.h */
FT_EXPORT_DEF( FT_Int32 )
FT_SqrtFixed( FT_Int32 x )
+364 -47
View File
@@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
/* Copyright 2001, 2002, 2003, 2004 by */
/* Copyright 2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -27,26 +27,67 @@
#ifdef FT_DEBUG_MEMORY
#define KEEPALIVE /* `Keep alive' means that freed blocks aren't released
* to the heap. This is useful to detect double-frees
* or weird heap corruption, but it uses large amounts of
* memory, however.
*/
#include <stdio.h>
#include <stdlib.h>
extern void
FT_DumpMemory( FT_Memory memory );
typedef struct FT_MemSourceRec_* FT_MemSource;
typedef struct FT_MemNodeRec_* FT_MemNode;
typedef struct FT_MemTableRec_* FT_MemTable;
#define FT_MEM_VAL( addr ) ((FT_ULong)(FT_Pointer)( addr ))
typedef struct FT_MemSourceRec_
{
const char* file_name;
long line_no;
FT_Long cur_blocks; /* current number of allocated blocks */
FT_Long max_blocks; /* max. number of allocated blocks */
FT_Long all_blocks; /* total number of blocks allocated */
FT_Long cur_size; /* current cumulative allocated size */
FT_Long max_size; /* maximum cumulative allocated size */
FT_Long all_size; /* total cumulative allocated size */
FT_Long cur_max; /* current maximum allocated size */
FT_UInt32 hash;
FT_MemSource link;
} FT_MemSourceRec;
/*
* We don't need a resizable array for the memory sources, because
* their number is pretty limited within FreeType.
*/
#define FT_MEM_SOURCE_BUCKETS 128
typedef struct FT_MemNodeRec_
{
FT_Byte* address;
FT_Long size; /* < 0 if the block was freed */
const char* alloc_file_name;
FT_Long alloc_line_no;
FT_MemSource source;
#ifdef KEEPALIVE
const char* free_file_name;
FT_Long free_line_no;
#endif
FT_MemNode link;
@@ -70,9 +111,13 @@
FT_Bool bound_count;
FT_ULong alloc_count_max;
FT_MemSource sources[FT_MEM_SOURCE_BUCKETS];
const char* file_name;
FT_Long line_no;
FT_Bool keep_alive;
FT_Memory memory;
FT_Pointer memory_user;
FT_Alloc_Func alloc;
@@ -88,6 +133,10 @@
#define FT_FILENAME( x ) ((x) ? (x) : "unknown file")
/*
* Prime numbers are ugly to handle. It would be better to implement
* L-Hashing, which is 10% faster and doesn't require divisions.
*/
static const FT_UInt ft_mem_primes[] =
{
7,
@@ -128,24 +177,6 @@
};
extern void
ft_mem_debug_panic( const char* fmt, ... )
{
va_list ap;
printf( "FreeType.Debug: " );
va_start( ap, fmt );
vprintf( fmt, ap );
va_end( ap );
printf( "\n" );
exit( EXIT_FAILURE );
}
static FT_ULong
ft_mem_closest_prime( FT_ULong num )
{
@@ -161,6 +192,24 @@
}
extern void
ft_mem_debug_panic( const char* fmt,
... )
{
va_list ap;
printf( "FreeType.Debug: " );
va_start( ap, fmt );
vprintf( fmt, ap );
va_end( ap );
printf( "\n" );
exit( EXIT_FAILURE );
}
static FT_Pointer
ft_mem_table_alloc( FT_MemTable table,
FT_Long size )
@@ -199,7 +248,7 @@
new_size = ft_mem_closest_prime( table->nodes );
if ( new_size != table->size )
{
FT_MemNode* new_buckets ;
FT_MemNode* new_buckets;
FT_ULong i;
@@ -209,7 +258,7 @@
if ( new_buckets == NULL )
return;
FT_MEM_ZERO( new_buckets, sizeof ( FT_MemNode ) * new_size );
FT_ARRAY_ZERO( new_buckets, new_size );
for ( i = 0; i < table->size; i++ )
{
@@ -250,7 +299,7 @@
if ( table == NULL )
goto Exit;
FT_MEM_ZERO( table, sizeof ( *table ) );
FT_ZERO( table );
table->size = FT_MEM_SIZE_MIN;
table->nodes = 0;
@@ -267,7 +316,7 @@
memory->alloc( memory,
table->size * sizeof ( FT_MemNode ) );
if ( table->buckets )
FT_MEM_ZERO( table->buckets, sizeof ( FT_MemNode ) * table->size );
FT_ARRAY_ZERO( table->buckets, table->size );
else
{
memory->free( memory, table );
@@ -285,12 +334,14 @@
FT_ULong i;
FT_DumpMemory( table->memory );
if ( table )
{
FT_Long leak_count = 0;
FT_ULong leaks = 0;
/* remove all blocks from the table, revealing leaked ones */
for ( i = 0; i < table->size; i++ )
{
FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
@@ -306,8 +357,8 @@
printf(
"leaked memory block at address %p, size %8ld in (%s:%ld)\n",
node->address, node->size,
FT_FILENAME( node->alloc_file_name ),
node->alloc_line_no );
FT_FILENAME( node->source->file_name ),
node->source->line_no );
leak_count++;
leaks += node->size;
@@ -318,28 +369,45 @@
node->address = NULL;
node->size = 0;
free( node );
ft_mem_table_free( table, node );
node = next;
}
table->buckets[i] = 0;
}
ft_mem_table_free( table, table->buckets );
table->buckets = NULL;
table->size = 0;
table->nodes = 0;
/* remove all sources */
for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
{
FT_MemSource source, next;
for ( source = table->sources[i]; source != NULL; source = next )
{
next = source->link;
ft_mem_table_free( table, source );
}
table->sources[i] = NULL;
}
printf(
"FreeType: total memory allocations = %ld\n", table->alloc_total );
printf(
"FreeType: maximum memory footprint = %ld\n", table->alloc_max );
free( table );
ft_mem_table_free( table, table );
if ( leak_count > 0 )
ft_mem_debug_panic(
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
leaks, leak_count );
printf( "FreeType: No memory leaks detected!\n" );
}
}
@@ -371,6 +439,57 @@
}
static FT_MemSource
ft_mem_table_get_source( FT_MemTable table )
{
FT_UInt32 hash;
FT_MemSource node, *pnode;
hash = (FT_UInt32)(void*)table->file_name +
(FT_UInt32)( 5 * table->line_no );
pnode = &table->sources[hash % FT_MEM_SOURCE_BUCKETS];
for ( ;; )
{
node = *pnode;
if ( node == NULL )
break;
if ( node->file_name == table->file_name &&
node->line_no == table->line_no )
goto Exit;
pnode = &node->link;
}
node = (FT_MemSource)ft_mem_table_alloc( table, sizeof ( *node ) );
if ( node == NULL )
ft_mem_debug_panic(
"not enough memory to perform memory debugging\n" );
node->file_name = table->file_name;
node->line_no = table->line_no;
node->cur_blocks = 0;
node->max_blocks = 0;
node->all_blocks = 0;
node->cur_size = 0;
node->max_size = 0;
node->all_size = 0;
node->cur_max = 0;
node->link = NULL;
node->hash = hash;
*pnode = node;
Exit:
return node;
}
static void
ft_mem_table_set( FT_MemTable table,
FT_Byte* address,
@@ -381,23 +500,32 @@
if ( table )
{
FT_MemSource source;
pnode = ft_mem_table_get_nodep( table, address );
node = *pnode;
if ( node )
{
if ( node->size < 0 )
{
/* this block was already freed. This means that our memory is */
/* now completely corrupted! */
/* This block was already freed. Our memory is now completely */
/* corrupted! */
/* This can only happen in keep-alive mode. */
ft_mem_debug_panic(
"memory heap corrupted (allocating freed block)" );
}
else
{
/* this block was already allocated. This means that our memory */
/* This block was already allocated. This means that our memory */
/* is also corrupted! */
ft_mem_debug_panic(
"memory heap corrupted (re-allocating allocated block)" );
"memory heap corrupted (re-allocating allocated block at"
" %p, of size %ld)\n"
"org=%s:%d new=%s:%d\n",
node->address, node->size,
FT_FILENAME( node->source->file_name ), node->source->line_no,
FT_FILENAME( table->file_name ), table->line_no );
}
}
@@ -409,8 +537,20 @@
node->address = address;
node->size = size;
node->alloc_file_name = table->file_name;
node->alloc_line_no = table->line_no;
node->source = source = ft_mem_table_get_source( table );
source->all_blocks++;
source->cur_blocks++;
if ( source->cur_blocks > source->max_blocks )
source->max_blocks = source->cur_blocks;
if ( size > (FT_ULong)source->cur_max )
source->cur_max = size;
source->all_size += size;
source->cur_size += size;
if ( source->cur_size > source->max_size )
source->max_size = source->cur_size;
node->free_file_name = NULL;
node->free_line_no = 0;
@@ -445,24 +585,51 @@
node = *pnode;
if ( node )
{
FT_MemSource source;
if ( node->size < 0 )
ft_mem_debug_panic(
"freeing memory block at %p more than once at (%s:%ld)\n"
"block allocated at (%s:%ld) and released at (%s:%ld)",
address,
FT_FILENAME( table->file_name ), table->line_no,
FT_FILENAME( node->alloc_file_name ), node->alloc_line_no,
FT_FILENAME( node->source->file_name ), node->source->line_no,
FT_FILENAME( node->free_file_name ), node->free_line_no );
/* we simply invert the node's size to indicate that the node */
/* was freed. We also change its contents. */
/* scramble the node's content for additional safety */
FT_MEM_SET( address, 0xF3, node->size );
table->alloc_current -= node->size;
source = node->source;
source->cur_blocks--;
source->cur_size -= node->size;
if ( table->keep_alive )
{
/* we simply invert the node's size to indicate that the node */
/* was freed. */
node->size = -node->size;
node->free_file_name = table->file_name;
node->free_line_no = table->line_no;
}
else
{
table->nodes--;
*pnode = node->link;
node->size = 0;
node->source = NULL;
ft_mem_table_free( table, node );
if ( table->nodes * 3 < table->size ||
table->size * 3 < table->nodes )
ft_mem_table_resize( table );
}
}
else
ft_mem_debug_panic(
"trying to free unknown block at %p in (%s:%ld)\n",
@@ -502,7 +669,7 @@
table->file_name = NULL;
table->line_no = 0;
return (FT_Pointer) block;
return (FT_Pointer)block;
}
@@ -520,7 +687,11 @@
ft_mem_table_remove( table, (FT_Byte*)block );
/* we never really free the block */
if ( !table->keep_alive )
ft_mem_table_free( table, block );
table->alloc_count--;
table->file_name = NULL;
table->line_no = 0;
}
@@ -540,16 +711,21 @@
FT_Long line_no = table->line_no;
/* the following is valid according to ANSI C */
#if 0
if ( block == NULL || cur_size == 0 )
ft_mem_debug_panic( "trying to reallocate NULL in (%s:%ld)",
file_name, line_no );
#endif
/* while the following is allowed in ANSI C also, we abort since */
/* such case should be handled by FreeType. */
if ( new_size <= 0 )
ft_mem_debug_panic(
"trying to reallocate %p to size 0 (current is %ld) in (%s:%ld)",
block, cur_size, file_name, line_no );
/* check 'cur_size' value */
/* check `cur_size' value */
pnode = ft_mem_table_get_nodep( table, (FT_Byte*)block );
node = *pnode;
if ( !node )
@@ -596,6 +772,7 @@
{
const char* p;
memory->user = table;
memory->alloc = ft_mem_debug_alloc;
memory->realloc = ft_mem_debug_realloc;
@@ -604,27 +781,39 @@
p = getenv( "FT2_ALLOC_TOTAL_MAX" );
if ( p != NULL )
{
FT_Long total_max = ft_atol(p);
FT_Long total_max = ft_atol( p );
if ( total_max > 0 )
{
table->bound_total = 1;
table->alloc_total_max = (FT_ULong) total_max;
table->alloc_total_max = (FT_ULong)total_max;
}
}
p = getenv( "FT2_ALLOC_COUNT_MAX" );
if ( p != NULL )
{
FT_Long total_count = ft_atol(p);
FT_Long total_count = ft_atol( p );
if ( total_count > 0 )
{
table->bound_count = 1;
table->alloc_count_max = (FT_ULong) total_count;
table->alloc_count_max = (FT_ULong)total_count;
}
}
p = getenv( "FT2_KEEP_ALIVE" );
if ( p != NULL )
{
FT_Long keep_alive = ft_atol( p );
if ( keep_alive > 0 )
table->keep_alive = 1;
}
result = 1;
}
}
@@ -665,6 +854,7 @@
table->file_name = file_name;
table->line_no = line_no;
}
return FT_Alloc( memory, size, P );
}
@@ -685,10 +875,52 @@
table->file_name = file_name;
table->line_no = line_no;
}
return FT_Realloc( memory, current, size, P );
}
FT_BASE_DEF( FT_Error )
FT_QAlloc_Debug( FT_Memory memory,
FT_Long size,
void* *P,
const char* file_name,
FT_Long line_no )
{
FT_MemTable table = (FT_MemTable)memory->user;
if ( table )
{
table->file_name = file_name;
table->line_no = line_no;
}
return FT_QAlloc( memory, size, P );
}
FT_BASE_DEF( FT_Error )
FT_QRealloc_Debug( FT_Memory memory,
FT_Long current,
FT_Long size,
void* *P,
const char* file_name,
FT_Long line_no )
{
FT_MemTable table = (FT_MemTable)memory->user;
if ( table )
{
table->file_name = file_name;
table->line_no = line_no;
}
return FT_QRealloc( memory, current, size, P );
}
FT_BASE_DEF( void )
FT_Free_Debug( FT_Memory memory,
FT_Pointer block,
@@ -703,10 +935,95 @@
table->file_name = file_name;
table->line_no = line_no;
}
FT_Free( memory, (void **)block );
}
static int
ft_mem_source_compare( const void* p1,
const void* p2 )
{
FT_MemSource s1 = *(FT_MemSource*)p1;
FT_MemSource s2 = *(FT_MemSource*)p2;
if ( s2->max_size > s1->max_size )
return 1;
else if ( s2->max_size < s1->max_size )
return -1;
else
return 0;
}
extern void
FT_DumpMemory( FT_Memory memory )
{
FT_MemTable table = (FT_MemTable)memory->user;
if ( table )
{
FT_MemSource* bucket = table->sources;
FT_MemSource* limit = bucket + FT_MEM_SOURCE_BUCKETS;
FT_MemSource* sources;
FT_UInt nn, count;
const char* fmt;
count = 0;
for ( ; bucket < limit; bucket++ )
{
FT_MemSource source = *bucket;
for ( ; source; source = source->link )
count++;
}
sources = (FT_MemSource*)ft_mem_table_alloc(
table, sizeof ( *sources ) * count );
count = 0;
for ( bucket = table->sources; bucket < limit; bucket++ )
{
FT_MemSource source = *bucket;
for ( ; source; source = source->link )
sources[count++] = source;
}
ft_qsort( sources, count, sizeof ( *sources ), ft_mem_source_compare );
printf( "FreeType Memory Dump: "
"current=%ld max=%ld total=%ld count=%ld\n",
table->alloc_current, table->alloc_max,
table->alloc_total, table->alloc_count );
printf( " block block sizes sizes sizes source\n" );
printf( " count high sum highsum max location\n" );
printf( "-------------------------------------------------\n" );
fmt = "%6ld %6ld %8ld %8ld %8ld %s:%d\n";
for ( nn = 0; nn < count; nn++ )
{
FT_MemSource source = sources[nn];
printf( fmt,
source->cur_blocks, source->max_blocks,
source->cur_size, source->max_size, source->cur_max,
FT_FILENAME( source->file_name ),
source->line_no );
}
printf( "------------------------------------------------\n" );
ft_mem_table_free( table, sources );
}
}
#else /* !FT_DEBUG_MEMORY */
/* ANSI C doesn't like empty source files */
+9 -5
View File
@@ -48,6 +48,8 @@
#if defined( FT_DEBUG_LEVEL_ERROR )
/* documentation is in ftdebug.h */
FT_EXPORT_DEF( void )
FT_Message( const char* fmt, ... )
{
@@ -60,6 +62,8 @@
}
/* documentation is in ftdebug.h */
FT_EXPORT_DEF( void )
FT_Panic( const char* fmt, ... )
{
@@ -125,17 +129,17 @@
/* value of the `FT2_DEBUG' environment variable. It must be a list of */
/* toggles, separated by spaces, `;', or `,'. Example: */
/* */
/* export FT2_DEBUG="any:3 memory:6 stream:5" */
/* export FT2_DEBUG="any:3 memory:7 stream:5" */
/* */
/* This requests that all levels be set to 3, except the trace level for */
/* the memory and stream components which are set to 6 and 5, */
/* the memory and stream components which are set to 7 and 5, */
/* respectively. */
/* */
/* See the file <include/freetype/internal/fttrace.h> for details of the */
/* available toggle names. */
/* */
/* The level must be between 0 and 6; 0 means quiet (except for serious */
/* runtime errors), and 6 means _very_ verbose. */
/* The level must be between 0 and 7; 0 means quiet (except for serious */
/* runtime errors), and 7 means _very_ verbose. */
/* */
FT_BASE_DEF( void )
ft_debug_init( void )
@@ -189,7 +193,7 @@
if ( *p )
{
level = *p++ - '0';
if ( level < 0 || level > 6 )
if ( level < 0 || level > 7 )
level = -1;
}
+3 -3
View File
@@ -182,9 +182,9 @@
}
/* Ensure that we can add `n_points' and `n_contours' to our glyph. this */
/* function reallocates its outline tables if necessary. Note that it */
/* DOESN'T change the number of points within the loader! */
/* Ensure that we can add `n_points' and `n_contours' to our glyph. */
/* This function reallocates its outline tables if necessary. Note that */
/* it DOESN'T change the number of points within the loader! */
/* */
FT_BASE_DEF( FT_Error )
FT_GlyphLoader_CheckPoints( FT_GlyphLoader loader,
+77 -85
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType convenience functions to handle glyphs (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -31,6 +31,7 @@
#include <ft2build.h>
#include FT_GLYPH_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
#include FT_INTERNAL_OBJECTS_H
@@ -114,37 +115,13 @@
/*************************************************************************/
/*************************************************************************/
static FT_Error
ft_bitmap_copy( FT_Memory memory,
FT_Bitmap* source,
FT_Bitmap* target )
{
FT_Error error;
FT_Int pitch = source->pitch;
FT_ULong size;
*target = *source;
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)( pitch * source->rows );
if ( !FT_ALLOC( target->buffer, size ) )
FT_MEM_COPY( target->buffer, source->buffer, size );
return error;
}
static FT_Error
ft_bitmap_glyph_init( FT_BitmapGlyph glyph,
FT_CALLBACK_DEF( FT_Error )
ft_bitmap_glyph_init( FT_Glyph bitmap_glyph,
FT_GlyphSlot slot )
{
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Error error = FT_Err_Ok;
FT_Library library = FT_GLYPH(glyph)->library;
FT_Memory memory = library->memory;
FT_Library library = FT_GLYPH( glyph )->library;
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
@@ -153,17 +130,19 @@
goto Exit;
}
/* grab the bitmap in the slot - do lazy copying whenever possible */
glyph->bitmap = slot->bitmap;
glyph->left = slot->bitmap_left;
glyph->top = slot->bitmap_top;
/* do lazy copying whenever possible */
if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
{
glyph->bitmap = slot->bitmap;
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
else
{
/* copy the bitmap into a new buffer */
error = ft_bitmap_copy( memory, &slot->bitmap, &glyph->bitmap );
FT_Bitmap_New( &glyph->bitmap );
error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap );
}
Exit:
@@ -171,34 +150,40 @@
}
static FT_Error
ft_bitmap_glyph_copy( FT_BitmapGlyph source,
FT_BitmapGlyph target )
FT_CALLBACK_DEF( FT_Error )
ft_bitmap_glyph_copy( FT_Glyph bitmap_source,
FT_Glyph bitmap_target )
{
FT_Memory memory = source->root.library->memory;
FT_Library library = bitmap_source->library;
FT_BitmapGlyph source = (FT_BitmapGlyph)bitmap_source;
FT_BitmapGlyph target = (FT_BitmapGlyph)bitmap_target;
target->left = source->left;
target->top = source->top;
return ft_bitmap_copy( memory, &source->bitmap, &target->bitmap );
return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap );
}
static void
ft_bitmap_glyph_done( FT_BitmapGlyph glyph )
FT_CALLBACK_DEF( void )
ft_bitmap_glyph_done( FT_Glyph bitmap_glyph )
{
FT_Memory memory = FT_GLYPH(glyph)->library->memory;
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
FT_Library library = FT_GLYPH( glyph )->library;
FT_FREE( glyph->bitmap.buffer );
FT_Bitmap_Done( library, &glyph->bitmap );
}
static void
ft_bitmap_glyph_bbox( FT_BitmapGlyph glyph,
FT_CALLBACK_DEF( void )
ft_bitmap_glyph_bbox( FT_Glyph bitmap_glyph,
FT_BBox* cbox )
{
FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph;
cbox->xMin = glyph->left << 6;
cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 );
cbox->yMax = glyph->top << 6;
@@ -209,15 +194,15 @@
FT_CALLBACK_TABLE_DEF
const FT_Glyph_Class ft_bitmap_glyph_class =
{
sizeof( FT_BitmapGlyphRec ),
sizeof ( FT_BitmapGlyphRec ),
FT_GLYPH_FORMAT_BITMAP,
(FT_Glyph_InitFunc) ft_bitmap_glyph_init,
(FT_Glyph_DoneFunc) ft_bitmap_glyph_done,
(FT_Glyph_CopyFunc) ft_bitmap_glyph_copy,
(FT_Glyph_TransformFunc)0,
(FT_Glyph_GetBBoxFunc) ft_bitmap_glyph_bbox,
(FT_Glyph_PrepareFunc) 0
ft_bitmap_glyph_init,
ft_bitmap_glyph_done,
ft_bitmap_glyph_copy,
0, /* FT_Glyph_TransformFunc */
ft_bitmap_glyph_bbox,
0 /* FT_Glyph_PrepareFunc */
};
@@ -230,12 +215,13 @@
/*************************************************************************/
static FT_Error
ft_outline_glyph_init( FT_OutlineGlyph glyph,
FT_CALLBACK_DEF( FT_Error )
ft_outline_glyph_init( FT_Glyph outline_glyph,
FT_GlyphSlot slot )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
FT_Error error = FT_Err_Ok;
FT_Library library = FT_GLYPH(glyph)->library;
FT_Library library = FT_GLYPH( glyph )->library;
FT_Outline* source = &slot->outline;
FT_Outline* target = &glyph->outline;
@@ -253,32 +239,29 @@
if ( error )
goto Exit;
/* copy it */
FT_ARRAY_COPY( target->points, source->points, source->n_points );
FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
target->flags = source->flags | FT_OUTLINE_OWNER;
FT_Outline_Copy( source, target );
Exit:
return error;
}
static void
ft_outline_glyph_done( FT_OutlineGlyph glyph )
FT_CALLBACK_DEF( void )
ft_outline_glyph_done( FT_Glyph outline_glyph )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline );
}
static FT_Error
ft_outline_glyph_copy( FT_OutlineGlyph source,
FT_OutlineGlyph target )
FT_CALLBACK_DEF( FT_Error )
ft_outline_glyph_copy( FT_Glyph outline_source,
FT_Glyph outline_target )
{
FT_OutlineGlyph source = (FT_OutlineGlyph)outline_source;
FT_OutlineGlyph target = (FT_OutlineGlyph)outline_target;
FT_Error error;
FT_Library library = FT_GLYPH( source )->library;
@@ -292,11 +275,14 @@
}
static void
ft_outline_glyph_transform( FT_OutlineGlyph glyph,
FT_Matrix* matrix,
FT_Vector* delta )
FT_CALLBACK_DEF( void )
ft_outline_glyph_transform( FT_Glyph outline_glyph,
const FT_Matrix* matrix,
const FT_Vector* delta )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
if ( matrix )
FT_Outline_Transform( &glyph->outline, matrix );
@@ -305,18 +291,24 @@
}
static void
ft_outline_glyph_bbox( FT_OutlineGlyph glyph,
FT_CALLBACK_DEF( void )
ft_outline_glyph_bbox( FT_Glyph outline_glyph,
FT_BBox* bbox )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
FT_Outline_Get_CBox( &glyph->outline, bbox );
}
static FT_Error
ft_outline_glyph_prepare( FT_OutlineGlyph glyph,
FT_CALLBACK_DEF( FT_Error )
ft_outline_glyph_prepare( FT_Glyph outline_glyph,
FT_GlyphSlot slot )
{
FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph;
slot->format = FT_GLYPH_FORMAT_OUTLINE;
slot->outline = glyph->outline;
slot->outline.flags &= ~FT_OUTLINE_OWNER;
@@ -328,15 +320,15 @@
FT_CALLBACK_TABLE_DEF
const FT_Glyph_Class ft_outline_glyph_class =
{
sizeof( FT_OutlineGlyphRec ),
sizeof ( FT_OutlineGlyphRec ),
FT_GLYPH_FORMAT_OUTLINE,
(FT_Glyph_InitFunc) ft_outline_glyph_init,
(FT_Glyph_DoneFunc) ft_outline_glyph_done,
(FT_Glyph_CopyFunc) ft_outline_glyph_copy,
(FT_Glyph_TransformFunc)ft_outline_glyph_transform,
(FT_Glyph_GetBBoxFunc) ft_outline_glyph_bbox,
(FT_Glyph_PrepareFunc) ft_outline_glyph_prepare
ft_outline_glyph_init,
ft_outline_glyph_done,
ft_outline_glyph_copy,
ft_outline_glyph_transform,
ft_outline_glyph_bbox,
ft_outline_glyph_prepare
};
@@ -611,7 +603,7 @@
/* create result bitmap glyph */
error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class,
(FT_Glyph*)&bitmap );
(FT_Glyph*)(void*)&bitmap );
if ( error )
goto Exit;
@@ -644,7 +636,7 @@
goto Exit;
/* in case of success, copy the bitmap to the glyph bitmap */
error = ft_bitmap_glyph_init( bitmap, &dummy );
error = ft_bitmap_glyph_init( (FT_Glyph)bitmap, &dummy );
if ( error )
goto Exit;
+4 -4
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType initialization layer (body). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -55,9 +55,9 @@
#undef FT_USE_MODULE
#ifdef __cplusplus
#define FT_USE_MODULE( x ) extern "C" const FT_Module_Class* x;
#define FT_USE_MODULE( x ) extern "C" const FT_Module_Class x;
#else
#define FT_USE_MODULE( x ) extern const FT_Module_Class* x;
#define FT_USE_MODULE( x ) extern const FT_Module_Class x;
#endif
@@ -65,7 +65,7 @@
#undef FT_USE_MODULE
#define FT_USE_MODULE( x ) (const FT_Module_Class*)&x,
#define FT_USE_MODULE( x ) (const FT_Module_Class*)&(x),
static
const FT_Module_Class* const ft_default_modules[] =
+4 -6
View File
@@ -63,17 +63,13 @@
#include FT_FREETYPE_H
#include FT_INTERNAL_STREAM_H
#ifdef __GNUC__
#include "../truetype/ttobjs.h"
#include "../type1/t1objs.h"
#if defined( __GNUC__ ) || defined( __IBMC__ )
/* This is for Mac OS X. Without redefinition, OS_INLINE */
/* expands to `static inline' which doesn't survive the */
/* -ansi compilation flag of GCC. */
#define OS_INLINE static __inline__
#include <Carbon/Carbon.h>
#else
#include "truetype/ttobjs.h"
#include "type1/t1objs.h"
#include <Resources.h>
#include <Fonts.h>
#include <Errors.h>
@@ -1012,11 +1008,13 @@
FT_Long face_index,
FT_Face *aface )
{
#if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO
FT_Open_Args args;
FT_Error error;
FT_Stream stream;
FILE* file;
FT_Memory memory;
#endif
FT_Error error;
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
+72 -1
View File
@@ -4,7 +4,7 @@
/* */
/* Multiple Master font support (body). */
/* */
/* Copyright 1996-2001, 2003 by */
/* Copyright 1996-2001, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -82,6 +82,28 @@
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_MM_Var( FT_Face face,
FT_MM_Var* *amaster )
{
FT_Error error;
FT_Service_MultiMasters service;
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_Err_Invalid_Argument;
if ( service->get_mm_var )
error = service->get_mm_var( face, amaster );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
@@ -105,6 +127,29 @@
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
FT_Set_Var_Design_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_Err_Invalid_Argument;
if ( service->set_var_design )
error = service->set_var_design( face, num_coords, coords );
}
return error;
}
/* documentation is in ftmm.h */
FT_EXPORT_DEF( FT_Error )
@@ -128,4 +173,30 @@
}
/* documentation is in ftmm.h */
/* This is exactly the same as the previous function. It exists for */
/* orthogonality. */
FT_EXPORT_DEF( FT_Error )
FT_Set_Var_Blend_Coordinates( FT_Face face,
FT_UInt num_coords,
FT_Fixed* coords )
{
FT_Error error;
FT_Service_MultiMasters service;
error = ft_face_get_mm_service( face, &service );
if ( !error )
{
error = FT_Err_Invalid_Argument;
if ( service->set_mm_blend )
error = service->set_mm_blend( face, num_coords, coords );
}
return error;
}
/* END */
+143 -30
View File
@@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,6 +19,7 @@
#include <ft2build.h>
#include FT_LIST_H
#include FT_OUTLINE_H
#include FT_INTERNAL_VALIDATE_H
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_RFORK_H
@@ -67,7 +68,7 @@
valid->base = base;
valid->limit = limit;
valid->level = level;
valid->error = 0;
valid->error = FT_Err_Ok;
}
@@ -291,7 +292,7 @@
slot->bitmap.rows = 0;
slot->bitmap.pitch = 0;
slot->bitmap.pixel_mode = 0;
/* don't touch 'slot->bitmap.buffer'! */
/* `slot->bitmap.buffer' has been handled by ft_glyphslot_free_bitmap */
slot->bitmap_left = 0;
slot->bitmap_top = 0;
@@ -304,6 +305,8 @@
slot->linearHoriAdvance = 0;
slot->linearVertAdvance = 0;
slot->lsb_delta = 0;
slot->rsb_delta = 0;
}
@@ -345,11 +348,9 @@
FT_GlyphSlot slot;
if ( !face || !aslot || !face->driver )
if ( !face || !face->driver )
return FT_Err_Invalid_Argument;
*aslot = 0;
driver = face->driver;
clazz = driver->clazz;
memory = driver->root.memory;
@@ -367,8 +368,15 @@
goto Exit;
}
slot->next = face->glyph;
face->glyph = slot;
if ( aslot )
*aslot = slot;
}
else if ( aslot )
*aslot = 0;
Exit:
FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error ));
@@ -385,23 +393,28 @@
{
FT_Driver driver = slot->face->driver;
FT_Memory memory = driver->root.memory;
FT_GlyphSlot* parent;
FT_GlyphSlot prev;
FT_GlyphSlot cur;
/* Remove slot from its parent face's list */
parent = &slot->face->glyph;
cur = *parent;
prev = NULL;
cur = slot->face->glyph;
while ( cur )
{
if ( cur == slot )
{
*parent = cur->next;
if ( !prev )
slot->face->glyph = cur->next;
else
prev->next = cur->next;
ft_glyphslot_done( slot );
FT_FREE( slot );
break;
}
prev = cur;
cur = cur->next;
}
}
@@ -673,6 +686,10 @@
}
static void
ft_cmap_done_internal( FT_CMap cmap );
static void
destroy_charmaps( FT_Face face,
FT_Memory memory )
@@ -685,7 +702,7 @@
FT_CMap cmap = FT_CMAP( face->charmaps[n] );
FT_CMap_Done( cmap );
ft_cmap_done_internal( cmap );
face->charmaps[n] = NULL;
}
@@ -814,7 +831,7 @@
* when found. Otherwise, a 16-bit one is returned when found.
*/
/* since the `interesting' table, with id's 3,10, is normally the */
/* Since the `interesting' table, with IDs (3,10), is normally the */
/* last one, we loop backwards. This looses with type1 fonts with */
/* non-BMP characters (<.0001%), this wins with .ttf with non-BMP */
/* chars (.01% ?), and this is the same about 99.99% of the time! */
@@ -1547,11 +1564,9 @@
/* test for valid `library' delayed to */
/* FT_Stream_New() */
if ( !aface || !args )
if ( ( !aface && face_index >= 0 ) || !args )
return FT_Err_Invalid_Argument;
*aface = 0;
external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream );
@@ -1676,19 +1691,12 @@
FT_List_Add( &face->driver->faces_list, node );
/* now allocate a glyph slot object for the face */
{
FT_GlyphSlot slot;
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
error = FT_New_GlyphSlot( face, &slot );
error = FT_New_GlyphSlot( face, NULL );
if ( error )
goto Fail;
face->glyph = slot;
}
/* finally, allocate a size object for the face */
{
FT_Size size;
@@ -1717,6 +1725,7 @@
internal->transform_delta.y = 0;
}
if ( aface )
*aface = face;
goto Exit;
@@ -1744,6 +1753,7 @@
if ( !filepathname )
return FT_Err_Invalid_Argument;
open.stream = NULL;
open.flags = FT_OPEN_PATHNAME;
open.pathname = (char*)filepathname;
@@ -1999,7 +2009,7 @@
if ( char_height < 1 * 64 )
char_height = 1 * 64;
/* Compute pixel sizes in 26.6 units with rounding */
/* Compute pixel sizes in 26.6 units */
dim_x = ( char_width * horz_resolution + 36 ) / 72;
dim_y = ( char_height * vert_resolution + 36 ) / 72;
@@ -2008,8 +2018,14 @@
FT_UShort y_ppem = (FT_UShort)( ( dim_y + 32 ) >> 6 );
/* Don't take, say, 12.5x12.5 equal to 13x13. If working with */
/* fractional font sizes this would hide slightly different */
/* font metrics. Consequently, the next two lines are */
/* disabled. */
#if 0
if ( x_ppem == metrics->x_ppem && y_ppem == metrics->y_ppem )
return FT_Err_Ok;
#endif
metrics->x_ppem = x_ppem;
metrics->y_ppem = y_ppem;
@@ -2134,6 +2150,16 @@
if ( kern_mode != FT_KERNING_UNFITTED )
{
/* we scale down kerning values for small ppem values */
/* to avoid that rounding makes them too big. */
/* `25' has been determined heuristically. */
if ( face->size->metrics.x_ppem < 25 )
akerning->x = FT_MulDiv( akerning->x,
face->size->metrics.x_ppem, 25 );
if ( face->size->metrics.y_ppem < 25 )
akerning->y = FT_MulDiv( akerning->y,
face->size->metrics.y_ppem, 25 );
akerning->x = FT_PIX_ROUND( akerning->x );
akerning->y = FT_PIX_ROUND( akerning->y );
}
@@ -2215,10 +2241,26 @@
}
FT_BASE_DEF( void )
FT_CMap_Done( FT_CMap cmap )
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Int )
FT_Get_Charmap_Index( FT_CharMap charmap )
{
if ( cmap )
FT_Int i;
for ( i = 0; i < charmap->face->num_charmaps; i++ )
if ( charmap->face->charmaps[i] == charmap )
break;
FT_ASSERT( i < charmap->face->num_charmaps );
return i;
}
static void
ft_cmap_done_internal( FT_CMap cmap )
{
FT_CMap_Class clazz = cmap->clazz;
FT_Face face = cmap->charmap.face;
@@ -2230,6 +2272,51 @@
FT_FREE( cmap );
}
FT_BASE_DEF( void )
FT_CMap_Done( FT_CMap cmap )
{
if ( cmap )
{
FT_Face face = cmap->charmap.face;
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Error error;
FT_Int i, j;
for ( i = 0; i < face->num_charmaps; i++ )
{
if ( (FT_CMap)face->charmaps[i] == cmap )
{
FT_CharMap last_charmap = face->charmaps[face->num_charmaps - 1];
if ( FT_RENEW_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps - 1 ) )
return;
/* remove it from our list of charmaps */
for ( j = i + 1; j < face->num_charmaps; j++ )
{
if ( j == face->num_charmaps - 1 )
face->charmaps[j - 1] = last_charmap;
else
face->charmaps[j - 1] = face->charmaps[j];
}
face->num_charmaps--;
if ( (FT_CMap)face->charmap == cmap )
face->charmap = NULL;
ft_cmap_done_internal( cmap );
break;
}
}
}
}
@@ -2239,7 +2326,7 @@
FT_CharMap charmap,
FT_CMap *acmap )
{
FT_Error error = 0;
FT_Error error = FT_Err_Ok;
FT_Face face;
FT_Memory memory;
FT_CMap cmap;
@@ -2266,7 +2353,7 @@
/* add it to our list of charmaps */
if ( FT_RENEW_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps+1 ) )
face->num_charmaps + 1 ) )
goto Fail;
face->charmaps[face->num_charmaps++] = (FT_CharMap)cmap;
@@ -2279,7 +2366,7 @@
return error;
Fail:
FT_CMap_Done( cmap );
ft_cmap_done_internal( cmap );
cmap = NULL;
goto Exit;
}
@@ -2490,6 +2577,30 @@
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( FT_Error )
FT_Sfnt_Table_Info( FT_Face face,
FT_UInt table_index,
FT_ULong *tag,
FT_ULong *length )
{
FT_Service_SFNT_Table service;
if ( !face || !FT_IS_SFNT( face ) )
return FT_Err_Invalid_Face_Handle;
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
return FT_Err_Unimplemented_Feature;
return service->table_info( face, table_index, tag, length );
}
/* documentation is in tttables.h */
FT_EXPORT_DEF( FT_ULong )
FT_Get_CMap_Language_ID( FT_CharMap charmap )
{
@@ -2512,6 +2623,8 @@
}
/* documentation is in ftsizes.h */
FT_EXPORT_DEF( FT_Error )
FT_Activate_Size( FT_Size size )
{
+72
View File
@@ -0,0 +1,72 @@
/***************************************************************************/
/* */
/* ftotval.c */
/* */
/* FreeType API for validating OpenType tables (body). */
/* */
/* Copyright 2004 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. */
/* */
/***************************************************************************/
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_OPENTYPE_VALIDATE_H
/* documentation is in ftotval.h */
FT_EXPORT_DEF( FT_Error )
FT_OpenType_Validate( FT_Face face,
FT_UInt validation_flags,
FT_Bytes *BASE_table,
FT_Bytes *GDEF_table,
FT_Bytes *GPOS_table,
FT_Bytes *GSUB_table,
FT_Bytes *JSTF_table )
{
FT_Service_OTvalidate service;
FT_Error error;
if ( !face )
{
error = FT_Err_Invalid_Face_Handle;
goto Exit;
}
if ( !( BASE_table &&
GDEF_table &&
GPOS_table &&
GSUB_table &&
JSTF_table ) )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
FT_FACE_FIND_GLOBAL_SERVICE( face, service, OPENTYPE_VALIDATE );
if ( service )
error = service->validate( face,
validation_flags,
BASE_table,
GDEF_table,
GPOS_table,
GSUB_table,
JSTF_table );
else
error = FT_Err_Invalid_Argument;
Exit:
return error;
}
/* END */
+135 -115
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType outline management (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -347,7 +347,7 @@
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Copy( FT_Outline* source,
FT_Outline_Copy( const FT_Outline* source,
FT_Outline *target )
{
FT_Int is_owner;
@@ -358,6 +358,9 @@
source->n_contours != target->n_contours )
return FT_Err_Invalid_Argument;
if ( source == target )
return FT_Err_Ok;
FT_ARRAY_COPY( target->points, source->points, source->n_points );
FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
@@ -379,7 +382,7 @@
FT_Outline_Done_Internal( FT_Memory memory,
FT_Outline* outline )
{
if ( outline )
if ( memory && outline )
{
if ( outline->flags & FT_OUTLINE_OWNER )
{
@@ -414,7 +417,7 @@
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Get_CBox( FT_Outline* outline,
FT_Outline_Get_CBox( const FT_Outline* outline,
FT_BBox *acbox )
{
FT_Pos xMin, yMin, xMax, yMax;
@@ -464,7 +467,7 @@
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Translate( FT_Outline* outline,
FT_Outline_Translate( const FT_Outline* outline,
FT_Pos xOffset,
FT_Pos yOffset )
{
@@ -472,6 +475,9 @@
FT_Vector* vec = outline->points;
if ( !outline )
return;
for ( n = 0; n < outline->n_points; n++ )
{
vec->x += xOffset;
@@ -490,6 +496,9 @@
FT_Int first, last;
if ( !outline )
return;
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
@@ -553,7 +562,7 @@
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !params )
if ( !outline || !params )
return FT_Err_Invalid_Argument;
renderer = library->cur_renderer;
@@ -593,7 +602,7 @@
FT_EXPORT_DEF( FT_Error )
FT_Outline_Get_Bitmap( FT_Library library,
FT_Outline* outline,
FT_Bitmap *abitmap )
const FT_Bitmap *abitmap )
{
FT_Raster_Params params;
@@ -619,7 +628,7 @@
FT_EXPORT_DEF( void )
FT_Vector_Transform( FT_Vector* vector,
FT_Matrix* matrix )
const FT_Matrix* matrix )
{
FT_Pos xz, yz;
@@ -641,154 +650,165 @@
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( void )
FT_Outline_Transform( FT_Outline* outline,
FT_Matrix* matrix )
FT_Outline_Transform( const FT_Outline* outline,
const FT_Matrix* matrix )
{
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
FT_Vector* vec;
FT_Vector* limit;
if ( !outline || !matrix )
return;
vec = outline->points;
limit = vec + outline->n_points;
for ( ; vec < limit; vec++ )
FT_Vector_Transform( vec, matrix );
}
typedef struct FT_OrientationExtremumRec_
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Error )
FT_Outline_Embolden( FT_Outline* outline,
FT_Pos strength )
{
FT_Int index;
FT_Long pos;
FT_Int first;
FT_Int last;
} FT_OrientationExtremumRec;
FT_Vector* points;
FT_Vector v_prev, v_first, v_next, v_cur;
FT_Angle rotate, angle_in, angle_out;
FT_Int c, n, first;
static FT_Orientation
ft_orientation_extremum_compute( FT_OrientationExtremumRec* extremum,
FT_Outline* outline )
if ( !outline )
return FT_Err_Invalid_Argument;
if ( strength == 0 )
return FT_Err_Ok;
if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_TRUETYPE )
rotate = -FT_ANGLE_PI2;
else
rotate = FT_ANGLE_PI2;
points = outline->points;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
{
FT_Vector *point, *first, *last, *prev, *next;
FT_Vector* points = outline->points;
FT_Angle angle_in, angle_out;
int last = outline->contours[c];
/* compute the previous and next points in the same contour */
point = points + extremum->index;
first = points + extremum->first;
last = points + extremum->last;
v_first = points[first];
v_prev = points[last];
v_cur = v_first;
prev = point;
next = point;
do
for ( n = first; n <= last; n++ )
{
prev = ( prev == first ) ? last : prev - 1;
if ( prev == point )
return FT_ORIENTATION_TRUETYPE; /* degenerate case */
FT_Vector in, out;
FT_Angle angle_diff;
FT_Pos d;
FT_Fixed scale;
} while ( prev->x != point->x || prev->y != point->y );
do
if ( n < last )
v_next = points[n + 1];
else
v_next = v_first;
/* compute the in and out vectors */
in.x = v_cur.x - v_prev.x;
in.y = v_cur.y - v_prev.y;
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
angle_in = FT_Atan2( in.x, in.y );
angle_out = FT_Atan2( out.x, out.y );
angle_diff = FT_Angle_Diff( angle_in, angle_out );
scale = FT_Cos( angle_diff / 2 );
if ( scale < 0x4000L && scale > -0x4000L )
in.x = in.y = 0;
else
{
next = ( next == last ) ? first : next + 1;
if ( next == point )
return FT_ORIENTATION_TRUETYPE; /* shouldn't happen */
d = FT_DivFix( strength, scale );
} while ( next->x != point->x || next->y != point->y );
/* now compute the orientation of the `out' vector relative */
/* to the `in' vector. */
angle_in = FT_Atan2( point->x - prev->x, point->y - prev->y );
angle_out = FT_Atan2( next->x - point->x, next->y - point->y );
return ( FT_Angle_Diff( angle_in, angle_out ) >= 0 )
? FT_ORIENTATION_TRUETYPE
: FT_ORIENTATION_POSTSCRIPT;
FT_Vector_From_Polar( &in, d, angle_in + angle_diff / 2 - rotate );
}
outline->points[n].x = v_cur.x + strength + in.x;
outline->points[n].y = v_cur.y + strength + in.y;
v_prev = v_cur;
v_cur = v_next;
}
first = last + 1;
}
return FT_Err_Ok;
}
/* documentation is in ftoutln.h */
FT_EXPORT_DEF( FT_Orientation )
FT_Outline_Get_Orientation( FT_Outline* outline )
{
FT_Orientation result = FT_ORIENTATION_TRUETYPE;
FT_Pos xmin = 32768L;
FT_Vector* xmin_point = NULL;
FT_Vector* xmin_first = NULL;
FT_Vector* xmin_last = NULL;
short* contour;
FT_Vector* first;
FT_Vector* last;
FT_Vector* prev;
FT_Vector* next;
if ( outline && outline->n_points > 0 )
if ( !outline || outline->n_points <= 0 )
return FT_ORIENTATION_TRUETYPE;
first = outline->points;
for ( contour = outline->contours;
contour < outline->contours + outline->n_contours;
contour++, first = last + 1 )
{
FT_OrientationExtremumRec xmin, ymin, xmax, ymax;
FT_Int n;
FT_Int first, last;
FT_Vector* points = outline->points;
FT_Vector* point;
xmin.pos = ymin.pos = +32768L;
xmax.pos = ymax.pos = -32768L;
last = outline->points + *contour;
xmin.index = ymin.index = xmax.index = ymax.index = -1;
/* skip degenerate contours */
if ( last < first + 2 )
continue;
first = 0;
for ( n = 0; n < outline->n_contours; n++, first = last + 1 )
for ( point = first; point <= last; point++ )
{
last = outline->contours[n];
/* skip single-point contours; these are degenerated cases */
if ( last > first + 1 )
if ( point->x < xmin )
{
FT_Int i;
for ( i = first; i < last; i++ )
{
FT_Pos x = points[i].x;
FT_Pos y = points[i].y;
if ( x < xmin.pos )
{
xmin.pos = x;
xmin.index = i;
xmin.first = first;
xmin.last = last;
}
if ( x > xmax.pos )
{
xmax.pos = x;
xmax.index = i;
xmax.first = first;
xmax.last = last;
}
if ( y < ymin.pos )
{
ymin.pos = y;
ymin.index = i;
ymin.first = first;
ymin.last = last;
}
if ( y > ymax.pos )
{
ymax.pos = y;
ymax.index = i;
ymax.first = first;
ymax.last = last;
xmin = point->x;
xmin_point = point;
xmin_first = first;
xmin_last = last;
}
}
}
if ( xmin.index >= 0 )
result = ft_orientation_extremum_compute( &xmin, outline );
if ( !xmin_point )
return FT_ORIENTATION_TRUETYPE;
else if ( xmax.index >= 0 )
result = ft_orientation_extremum_compute( &xmax, outline );
prev = ( xmin_point == xmin_first ) ? xmin_last : xmin_point - 1;
next = ( xmin_point == xmin_last ) ? xmin_first : xmin_point + 1;
else if ( ymin.index >= 0 )
result = ft_orientation_extremum_compute( &ymin, outline );
else if ( ymax.index >= 0 )
result = ft_orientation_extremum_compute( &ymax, outline );
}
}
return result;
if ( FT_Atan2( prev->x - xmin_point->x, prev->y - xmin_point->y ) >
FT_Atan2( next->x - xmin_point->x, next->y - xmin_point->y ) )
return FT_ORIENTATION_POSTSCRIPT;
else
return FT_ORIENTATION_TRUETYPE;
}
+7 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing PFR-specific data (body). */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -33,6 +33,8 @@
}
/* documentation is in ftpfr.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Metrics( FT_Face face,
FT_UInt *aoutline_resolution,
@@ -78,6 +80,8 @@
}
/* documentation is in ftpfr.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Kerning( FT_Face face,
FT_UInt left,
@@ -101,6 +105,8 @@
}
/* documentation is in ftpfr.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PFR_Advance( FT_Face face,
FT_UInt gindex,
+14 -8
View File
@@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (body). */
/* */
/* Copyright 2004 by */
/* Copyright 2004, 2005 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
@@ -569,19 +569,21 @@
{
FT_Int32 magic_from_stream;
FT_Error error;
FT_Int32 version_number;
FT_Int32 version_number = 0;
FT_UShort n_of_entries;
int i;
FT_UInt32 entry_id, entry_offset, entry_length;
FT_UInt32 entry_id, entry_offset, entry_length = 0;
const FT_UInt32 resource_fork_entry_id = 0x2;
FT_UNUSED( library );
FT_UNUSED( base_file_name );
FT_UNUSED( version_number );
FT_UNUSED( entry_length );
if ( FT_READ_LONG ( magic_from_stream ) )
if ( FT_READ_LONG( magic_from_stream ) )
return error;
if ( magic_from_stream != magic )
return FT_Err_Unknown_File_Format;
@@ -625,15 +627,12 @@
char * file_name,
FT_Long *result_offset )
{
FT_Memory memory;
FT_Open_Args args2;
FT_Stream stream2;
char * nouse = NULL;
FT_Error error;
memory = library->memory;
args2.flags = FT_OPEN_PATHNAME;
args2.pathname = file_name;
error = FT_Stream_New( library, &args2, &stream2 );
@@ -658,7 +657,10 @@
char* tmp;
const char* slash;
unsigned new_length;
FT_ULong error;
FT_ULong error = FT_Err_Ok;
FT_UNUSED( error );
new_length = ft_strlen( original_name ) + ft_strlen( insertion );
if ( FT_ALLOC( new_name, new_length + 1 ) )
@@ -701,6 +703,10 @@
{
int i;
FT_UNUSED( library );
FT_UNUSED( stream );
FT_UNUSED( base_name );
for ( i = 0; i < FT_RACCESS_N_RULES; i++ )
{
+31 -5
View File
@@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
/* Copyright 2000-2001, 2002, 2004 by */
/* Copyright 2000-2001, 2002, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -49,10 +49,7 @@
FT_Stream_Close( FT_Stream stream )
{
if ( stream && stream->close )
{
stream->close( stream );
stream->close = NULL;
}
}
@@ -156,6 +153,35 @@
}
FT_BASE_DEF( FT_ULong )
FT_Stream_TryRead( FT_Stream stream,
FT_Byte* buffer,
FT_ULong count )
{
FT_ULong read_bytes = 0;
if ( stream->pos >= stream->size )
goto Exit;
if ( stream->read )
read_bytes = stream->read( stream, stream->pos, buffer, count );
else
{
read_bytes = stream->size - stream->pos;
if ( read_bytes > count )
read_bytes = count;
FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes );
}
stream->pos += read_bytes;
Exit:
return read_bytes;
}
FT_BASE_DEF( FT_Error )
FT_Stream_ExtractFrame( FT_Stream stream,
FT_ULong count,
@@ -210,7 +236,7 @@
FT_Memory memory = stream->memory;
if ( FT_ALLOC( stream->base, count ) )
if ( FT_QALLOC( stream->base, count ) )
goto Exit;
/* read it */
+117 -19
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
/* Copyright 2002, 2003, 2004 by */
/* Copyright 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -24,6 +24,9 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_OBJECTS_H
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_StrokerBorder )
FT_Outline_GetInsideBorder( FT_Outline* outline )
{
@@ -35,6 +38,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_StrokerBorder )
FT_Outline_GetOutsideBorder( FT_Outline* outline )
{
@@ -234,6 +239,7 @@
} FT_StrokeTags;
#define FT_STROKE_TAG_BEGIN_END (FT_STROKE_TAG_BEGIN|FT_STROKE_TAG_END)
typedef struct FT_StrokeBorderRec_
{
@@ -279,15 +285,64 @@
static void
ft_stroke_border_close( FT_StrokeBorder border )
ft_stroke_border_close( FT_StrokeBorder border,
FT_Bool reverse )
{
FT_UInt start = border->start;
FT_UInt count = border->num_points;
FT_ASSERT( border->start >= 0 );
/* don't record empty paths! */
if ( border->num_points > (FT_UInt)border->start )
if ( count <= start + 1U )
border->num_points = start;
else
{
border->tags[border->start ] |= FT_STROKE_TAG_BEGIN;
border->tags[border->num_points - 1] |= FT_STROKE_TAG_END;
/* copy the last point to the start of this sub-path, since */
/* it contains the `adjusted' starting coordinates */
border->num_points = --count;
border->points[start] = border->points[count];
if ( reverse )
{
/* reverse the points */
{
FT_Vector* vec1 = border->points + start + 1;
FT_Vector* vec2 = border->points + count - 1;
for ( ; vec1 < vec2; vec1++, vec2-- )
{
FT_Vector tmp;
tmp = *vec1;
*vec1 = *vec2;
*vec2 = tmp;
}
}
/* then the tags */
{
FT_Byte* tag1 = border->tags + start + 1;
FT_Byte* tag2 = border->tags + count - 1;
for ( ; tag1 < tag2; tag1++, tag2-- )
{
FT_Byte tmp;
tmp = *tag1;
*tag1 = *tag2;
*tag2 = tmp;
}
}
}
border->tags[start ] |= FT_STROKE_TAG_BEGIN;
border->tags[count - 1] |= FT_STROKE_TAG_END;
}
border->start = -1;
@@ -472,7 +527,7 @@
{
/* close current open path if any ? */
if ( border->start >= 0 )
ft_stroke_border_close( border );
ft_stroke_border_close( border, 0 );
border->start = border->num_points;
border->movable = 0;
@@ -658,6 +713,8 @@
} FT_StrokerRec;
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_New( FT_Memory memory,
FT_Stroker *astroker )
@@ -678,6 +735,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Set( FT_Stroker stroker,
FT_Fixed radius,
@@ -694,6 +753,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Rewind( FT_Stroker stroker )
{
@@ -705,6 +766,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Done( FT_Stroker stroker )
{
@@ -824,6 +887,7 @@
thcos = FT_Cos( theta );
sigma = FT_MulFix( stroker->miter_limit, thcos );
/* TODO: find better criterion to switch off the optimization */
if ( sigma < 0x10000L )
{
FT_Vector_From_Polar( &delta, stroker->radius,
@@ -1036,6 +1100,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_LineTo( FT_Stroker stroker,
FT_Vector* to )
@@ -1097,6 +1163,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_ConicTo( FT_Stroker stroker,
FT_Vector* control,
@@ -1193,6 +1261,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_CubicTo( FT_Stroker stroker,
FT_Vector* control1,
@@ -1301,6 +1371,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_BeginSubPath( FT_Stroker stroker,
FT_Vector* to,
@@ -1351,12 +1423,17 @@
*dst_tag = *src_tag;
if ( open )
dst_tag[0] &= ~( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END );
dst_tag[0] &= ~FT_STROKE_TAG_BEGIN_END;
else
{
/* switch begin/end tags if necessary.. */
if ( dst_tag[0] & ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END ) )
dst_tag[0] ^= ( FT_STROKE_TAG_BEGIN | FT_STROKE_TAG_END );
FT_Byte ttag = (FT_Byte)( dst_tag[0] & FT_STROKE_TAG_BEGIN_END );
/* switch begin/end tags if necessary */
if ( ttag == FT_STROKE_TAG_BEGIN ||
ttag == FT_STROKE_TAG_END )
dst_tag[0] ^= FT_STROKE_TAG_BEGIN_END;
}
src_point--;
@@ -1378,6 +1455,8 @@
}
/* documentation is in ftstroke.h */
/* there's a lot of magic in this function! */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_EndSubPath( FT_Stroker stroker )
@@ -1409,7 +1488,7 @@
/* Now end the right subpath accordingly. The left one is */
/* rewind and doesn't need further processing. */
ft_stroke_border_close( right );
ft_stroke_border_close( right, 0 );
}
else
{
@@ -1440,11 +1519,9 @@
if ( turn < 0 )
inside_side = 1;
/* IMPORTANT: WE DO NOT PROCESS THE INSIDE BORDER HERE! */
/* process the inside side */
/* error = ft_stroker_inside( stroker, inside_side ); */
/* if ( error ) */
/* goto Exit; */
error = ft_stroker_inside( stroker, inside_side );
if ( error )
goto Exit;
/* process the outside side */
error = ft_stroker_outside( stroker, 1 - inside_side );
@@ -1453,8 +1530,8 @@
}
/* then end our two subpaths */
ft_stroke_border_close( stroker->borders + 0 );
ft_stroke_border_close( stroker->borders + 1 );
ft_stroke_border_close( stroker->borders + 0, 1 );
ft_stroke_border_close( stroker->borders + 1, 0 );
}
Exit:
@@ -1462,6 +1539,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_GetBorderCounts( FT_Stroker stroker,
FT_StrokerBorder border,
@@ -1491,6 +1570,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Stroker_GetCounts( FT_Stroker stroker,
FT_UInt *anum_points,
@@ -1521,6 +1602,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_ExportBorder( FT_Stroker stroker,
FT_StrokerBorder border,
@@ -1538,6 +1621,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( void )
FT_Stroker_Export( FT_Stroker stroker,
FT_Outline* outline )
@@ -1547,6 +1632,8 @@
}
/* documentation is in ftstroke.h */
/*
* The following is very similar to FT_Outline_Decompose, except
* that we do support opened paths, and do not scale the outline.
@@ -1580,12 +1667,19 @@
for ( n = 0; n < outline->n_contours; n++ )
{
FT_Int last; /* index of last point in contour */
FT_UInt last; /* index of last point in contour */
last = outline->contours[n];
limit = outline->points + last;
/* skip empty points; we don't stroke these */
if ( last <= first )
{
first = last + 1;
continue;
}
v_start = outline->points[first];
v_last = outline->points[last];
@@ -1749,6 +1843,8 @@
extern const FT_Glyph_Class ft_outline_glyph_class;
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_Stroke( FT_Glyph *pglyph,
FT_Stroker stroker,
@@ -1819,6 +1915,8 @@
}
/* documentation is in ftstroke.h */
FT_EXPORT_DEF( FT_Error )
FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
FT_Stroker stroker,
+60 -205
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
/* Copyright 2000-2001, 2002, 2003 by */
/* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -17,14 +17,10 @@
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CALC_H
#include FT_OUTLINE_H
#include FT_TRIGONOMETRY_H
#include FT_SYNTHESIS_H
#define FT_BOLD_THRESHOLD 0x0100
#include FT_INTERNAL_OBJECTS_H
#include FT_OUTLINE_H
#include FT_BITMAP_H
/*************************************************************************/
@@ -35,6 +31,8 @@
/*************************************************************************/
/*************************************************************************/
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
{
@@ -70,217 +68,74 @@
/*************************************************************************/
static int
ft_test_extrema( FT_Outline* outline,
int n )
{
FT_Vector *prev, *cur, *next;
FT_Pos product;
FT_Int c, first, last;
/* we need to compute the `previous' and `next' point */
/* for these extrema. */
cur = outline->points + n;
prev = cur - 1;
next = cur + 1;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
{
last = outline->contours[c];
if ( n == first )
prev = outline->points + last;
if ( n == last )
next = outline->points + first;
first = last + 1;
}
product = FT_MulDiv( cur->x - prev->x, /* in.x */
next->y - cur->y, /* out.y */
0x40 )
-
FT_MulDiv( cur->y - prev->y, /* in.y */
next->x - cur->x, /* out.x */
0x40 );
if ( product )
product = product > 0 ? 1 : -1;
return product;
}
/* Compute the orientation of path filling. It differs between TrueType */
/* and Type1 formats. We could use the `FT_OUTLINE_REVERSE_FILL' flag, */
/* but it is better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs currently). */
/* */
/* We do this by computing bounding box points, and computing their */
/* curvature. */
/* */
/* The function returns either 1 or -1. */
/* */
static int
ft_get_orientation( FT_Outline* outline )
{
FT_BBox box;
FT_BBox indices;
int n, last;
indices.xMin = -1;
indices.yMin = -1;
indices.xMax = -1;
indices.yMax = -1;
box.xMin = box.yMin = 32767;
box.xMax = box.yMax = -32768;
/* is it empty ? */
if ( outline->n_contours < 1 )
return 1;
last = outline->contours[outline->n_contours - 1];
for ( n = 0; n <= last; n++ )
{
FT_Pos x, y;
x = outline->points[n].x;
if ( x < box.xMin )
{
box.xMin = x;
indices.xMin = n;
}
if ( x > box.xMax )
{
box.xMax = x;
indices.xMax = n;
}
y = outline->points[n].y;
if ( y < box.yMin )
{
box.yMin = y;
indices.yMin = n;
}
if ( y > box.yMax )
{
box.yMax = y;
indices.yMax = n;
}
}
/* test orientation of the xmin */
n = ft_test_extrema( outline, indices.xMin );
if ( n )
goto Exit;
n = ft_test_extrema( outline, indices.yMin );
if ( n )
goto Exit;
n = ft_test_extrema( outline, indices.xMax );
if ( n )
goto Exit;
n = ft_test_extrema( outline, indices.yMax );
if ( !n )
n = 1;
Exit:
return n;
}
/* documentation is in ftsynth.h */
FT_EXPORT_DEF( void )
FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
{
FT_Vector* points;
FT_Vector v_prev, v_first, v_next, v_cur;
FT_Pos distance;
FT_Outline* outline = &slot->outline;
FT_Library library = slot->library;
FT_Face face = FT_SLOT_FACE( slot );
FT_Angle rotate, angle_in, angle_out;
FT_Int c, n, first, orientation;
FT_Error error = FT_Err_Ok;
FT_Pos xstr, ystr;
/* only embolden outline glyph images */
if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
return;
/* some reasonable strength */
xstr = FT_MulFix( face->units_per_EM,
face->size->metrics.y_scale ) / 42;
ystr = xstr;
/* compute control distance */
distance = FT_MulFix( face->units_per_EM / 60,
face->size->metrics.y_scale );
orientation = ft_get_orientation( outline );
rotate = FT_ANGLE_PI2*orientation;
points = outline->points;
first = 0;
for ( c = 0; c < outline->n_contours; c++ )
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
int last = outline->contours[c];
v_first = points[first];
v_prev = points[last];
v_cur = v_first;
for ( n = first; n <= last; n++ )
error = FT_Outline_Embolden( &slot->outline, xstr );
xstr = xstr * 4; /* according to the documentation */
ystr = xstr;
}
else if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
{
FT_Pos d;
FT_Vector in, out;
FT_Fixed scale;
FT_Angle angle_diff;
xstr = FT_PIX_FLOOR( xstr );
if ( xstr == 0 )
xstr = 1 << 6;
ystr = FT_PIX_FLOOR( ystr );
if ( n < last ) v_next = points[n + 1];
else v_next = v_first;
/* compute the in and out vectors */
in.x = v_cur.x - v_prev.x;
in.y = v_cur.y - v_prev.y;
out.x = v_next.x - v_cur.x;
out.y = v_next.y - v_cur.y;
angle_in = FT_Atan2( in.x, in.y );
angle_out = FT_Atan2( out.x, out.y );
angle_diff = FT_Angle_Diff( angle_in, angle_out );
scale = FT_Cos( angle_diff/2 );
if ( scale < 0x400L && scale > -0x400L )
/* slot must be bitmap-owner */
if ( !( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) )
{
if ( scale >= 0 )
scale = 0x400L;
FT_Bitmap bitmap;
FT_Bitmap_New( &bitmap );
error = FT_Bitmap_Copy( library, &slot->bitmap, &bitmap );
if ( !error )
{
slot->bitmap = bitmap;
slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
}
}
if ( !error )
error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
}
else
scale = -0x400L;
error = FT_Err_Invalid_Argument;
/* modify the metrics accordingly */
if ( !error )
{
slot->advance.x += xstr;
slot->advance.y += ystr;
slot->metrics.width += xstr;
slot->metrics.height += ystr;
slot->metrics.horiBearingY += ystr;
slot->metrics.horiAdvance += xstr;
slot->metrics.vertBearingX -= xstr / 2;
slot->metrics.vertBearingY += ystr;
slot->metrics.vertAdvance += ystr;
if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
slot->bitmap_top += ystr >> 6;
}
d = FT_DivFix( distance, scale );
FT_Vector_From_Polar( &in, d, angle_in + angle_diff/2 - rotate );
outline->points[n].x = v_cur.x + distance + in.x;
outline->points[n].y = v_cur.y + distance + in.y;
v_prev = v_cur;
v_cur = v_next;
}
first = last + 1;
}
slot->metrics.horiAdvance =
( slot->metrics.horiAdvance + distance*4 ) & ~63;
}
+3 -2
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType trigonometric functions (body). */
/* */
/* Copyright 2001, 2002, 2003 by */
/* Copyright 2001, 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -274,7 +274,7 @@
if ( theta >= 0 )
theta = FT_PAD_ROUND( theta, 32 );
else
theta = - FT_PAD_ROUND( -theta, 32 );
theta = -FT_PAD_ROUND( -theta, 32 );
vec->x = x;
vec->y = theta;
@@ -485,6 +485,7 @@
{
FT_Angle delta = angle2 - angle1;
delta %= FT_ANGLE_2PI;
if ( delta < 0 )
delta += FT_ANGLE_2PI;
+25 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for PS names support (body). */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -67,4 +67,28 @@
}
/* documentation is in t1tables.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_PS_Font_Private( FT_Face face,
PS_PrivateRec* afont_private )
{
FT_Error error = FT_Err_Invalid_Argument;
if ( face )
{
FT_Service_PsInfo service = NULL;
FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO );
if ( service && service->ps_get_font_private )
error = service->ps_get_font_private( face, afont_private );
}
return error;
}
/* END */
+95 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
/* Copyright 2002 by */
/* Copyright 2002, 2004, 2005 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -19,6 +19,7 @@
#include <ft2build.h>
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_MEMORY_H
#include FT_INTERNAL_OBJECTS_H
#include FT_LIST_H
@@ -77,6 +78,38 @@
}
/* documentation is in ftmemory.h */
FT_BASE_DEF( FT_Error )
FT_QAlloc( FT_Memory memory,
FT_Long size,
void* *P )
{
FT_ASSERT( P != 0 );
if ( size > 0 )
{
*P = memory->alloc( memory, size );
if ( !*P )
{
FT_ERROR(( "FT_QAlloc:" ));
FT_ERROR(( " Out of memory? (%ld requested)\n",
size ));
return FT_Err_Out_Of_Memory;
}
}
else
*P = NULL;
FT_TRACE7(( "FT_QAlloc:" ));
FT_TRACE7(( " size = %ld, block = 0x%08p, ref = 0x%08p\n",
size, *P, P ));
return FT_Err_Ok;
}
/* documentation is in ftmemory.h */
FT_BASE_DEF( FT_Error )
@@ -119,6 +152,45 @@
}
/* documentation is in ftmemory.h */
FT_BASE_DEF( FT_Error )
FT_QRealloc( FT_Memory memory,
FT_Long current,
FT_Long size,
void** P )
{
void* Q;
FT_ASSERT( P != 0 );
/* if the original pointer is NULL, call FT_QAlloc() */
if ( !*P )
return FT_QAlloc( memory, size, P );
/* if the new block if zero-sized, clear the current one */
if ( size <= 0 )
{
FT_Free( memory, P );
return FT_Err_Ok;
}
Q = memory->realloc( memory, current, size, *P );
if ( !Q )
goto Fail;
*P = Q;
return FT_Err_Ok;
Fail:
FT_ERROR(( "FT_QRealloc:" ));
FT_ERROR(( " Failed (current %ld, requested %ld)\n",
current, size ));
return FT_Err_Out_Of_Memory;
}
/* documentation is in ftmemory.h */
FT_BASE_DEF( void )
@@ -327,4 +399,26 @@
}
FT_BASE( FT_UInt32 )
ft_highpow2( FT_UInt32 value )
{
FT_UInt32 value2;
/*
* We simply clear the lowest bit in each iteration. When
* we reach 0, we know that the previous value was our result.
*/
for ( ;; )
{
value2 = value & (value - 1); /* clear lowest bit */
if ( value2 == 0 )
break;
value = value2;
}
return value;
}
/* END */
+3 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing Windows FNT specific info (body). */
/* */
/* Copyright 2003 by */
/* Copyright 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -22,6 +22,8 @@
#include FT_SERVICE_WINFNT_H
/* documentation is in ftwinfnt.h */
FT_EXPORT_DEF( FT_Error )
FT_Get_WinFNT_Header( FT_Face face,
FT_WinFNT_HeaderRec *header )
+4 -1
View File
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for X11 support (body). */
/* */
/* Copyright 2002, 2003 by */
/* Copyright 2002, 2003, 2004 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,6 +21,9 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_SERVICE_XFREE86_NAME_H
/* documentation is in ftxf86.h */
FT_EXPORT_DEF( const char* )
FT_Get_X11_Font_Format( FT_Face face )
{
+5 -2
View File
@@ -3,7 +3,7 @@
#
# Copyright 1996-2000, 2002, 2003, 2004 by
# Copyright 1996-2000, 2002, 2003, 2004, 2005 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -50,12 +50,15 @@ BASE_SRC := $(BASE_DIR)/ftapi.c \
# object. It will then be linked to the final executable only if one of its
# symbols is used by the application.
#
BASE_EXT_SRC := $(BASE_DIR)/ftbbox.c \
BASE_EXT_SRC := $(BASE_DIR)/ftbitmap.c \
$(BASE_DIR)/ftbbox.c \
$(BASE_DIR)/ftbdf.c \
$(BASE_DIR)/ftglyph.c \
$(BASE_DIR)/ftmm.c \
$(BASE_DIR)/ftotval.c \
$(BASE_DIR)/ftpfr.c \
$(BASE_DIR)/ftstroke.c \
$(BASE_DIR)/ftsynth.c \
$(BASE_DIR)/fttype1.c \
$(BASE_DIR)/ftwinfnt.c \
$(BASE_DIR)/ftxf86.c
+1
View File
@@ -21,3 +21,4 @@ UseFreeTypeHeaders ;
}
# end of src/bdf Jamfile
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
* Copyright 2001, 2002, 2003 Francesco Zappa Nardelli
* Copyright 2001, 2002, 2003, 2004 Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -202,7 +202,7 @@ FT_BEGIN_HEADER
unsigned short monowidth; /* Logical width for monowidth font. */
long default_glyph; /* Encoding of the default glyph. */
long default_char; /* Encoding of the default glyph. */
long font_ascent; /* Font ascent. */
long font_descent; /* Font descent. */
+118 -145
View File
@@ -2,7 +2,7 @@
FreeType font driver for bdf files
Copyright (C) 2001, 2002, 2003, 2004 by
Copyright (C) 2001, 2002, 2003, 2004, 2005 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -60,9 +60,12 @@ THE SOFTWARE.
FT_CALLBACK_DEF( FT_Error )
bdf_cmap_init( BDF_CMap cmap )
bdf_cmap_init( FT_CMap bdfcmap,
FT_Pointer init_data )
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_Face face = (BDF_Face)FT_CMAP_FACE( cmap );
FT_UNUSED( init_data );
cmap->num_encodings = face->bdffont->glyphs_used;
@@ -73,17 +76,21 @@ THE SOFTWARE.
FT_CALLBACK_DEF( void )
bdf_cmap_done( BDF_CMap cmap )
bdf_cmap_done( FT_CMap bdfcmap )
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
cmap->encodings = NULL;
cmap->num_encodings = 0;
}
FT_CALLBACK_DEF( FT_UInt )
bdf_cmap_char_index( BDF_CMap cmap,
bdf_cmap_char_index( FT_CMap bdfcmap,
FT_UInt32 charcode )
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings;
FT_UInt min, max, mid;
FT_UInt result = 0;
@@ -102,6 +109,8 @@ THE SOFTWARE.
if ( charcode == code )
{
/* increase glyph index by 1 -- */
/* we reserve slot 0 for the undefined glyph */
result = encodings[mid].glyph + 1;
break;
}
@@ -117,9 +126,10 @@ THE SOFTWARE.
FT_CALLBACK_DEF( FT_UInt )
bdf_cmap_char_next( BDF_CMap cmap,
bdf_cmap_char_next( FT_CMap bdfcmap,
FT_UInt32 *acharcode )
{
BDF_CMap cmap = (BDF_CMap)bdfcmap;
BDF_encoding_el* encodings = cmap->encodings;
FT_UInt min, max, mid;
FT_UInt32 charcode = *acharcode + 1;
@@ -139,6 +149,8 @@ THE SOFTWARE.
if ( charcode == code )
{
/* increase glyph index by 1 -- */
/* we reserve slot 0 for the undefined glyph */
result = encodings[mid].glyph + 1;
goto Exit;
}
@@ -162,13 +174,14 @@ THE SOFTWARE.
}
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec bdf_cmap_class =
FT_CALLBACK_TABLE_DEF
const FT_CMap_ClassRec bdf_cmap_class =
{
sizeof( BDF_CMapRec ),
(FT_CMap_InitFunc) bdf_cmap_init,
(FT_CMap_DoneFunc) bdf_cmap_done,
(FT_CMap_CharIndexFunc)bdf_cmap_char_index,
(FT_CMap_CharNextFunc) bdf_cmap_char_next
sizeof ( BDF_CMapRec ),
bdf_cmap_init,
bdf_cmap_done,
bdf_cmap_char_index,
bdf_cmap_char_next
};
@@ -284,9 +297,10 @@ THE SOFTWARE.
}
FT_CALLBACK_DEF( FT_Error )
BDF_Face_Done( BDF_Face face )
FT_CALLBACK_DEF( void )
BDF_Face_Done( FT_Face bdfface ) /* BDF_Face */
{
BDF_Face face = (BDF_Face)bdfface;
FT_Memory memory = FT_FACE_MEMORY( face );
@@ -296,26 +310,25 @@ THE SOFTWARE.
FT_FREE( face->charset_encoding );
FT_FREE( face->charset_registry );
FT_FREE( face->root.family_name );
FT_FREE( bdfface->family_name );
FT_FREE( face->root.available_sizes );
FT_FREE( bdfface->available_sizes );
FT_FREE( face->bdffont );
FT_TRACE4(( "BDF_Face_Done: done face\n" ));
return BDF_Err_Ok;
}
FT_CALLBACK_DEF( FT_Error )
BDF_Face_Init( FT_Stream stream,
BDF_Face face,
FT_Face bdfface, /* BDF_Face */
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error = BDF_Err_Ok;
BDF_Face face = (BDF_Face)bdfface;
FT_Memory memory = FT_FACE_MEMORY( face );
bdf_font_t* font;
@@ -346,7 +359,6 @@ THE SOFTWARE.
/* we have a bdf font: let's construct the face object */
face->bdffont = font;
{
FT_Face root = FT_FACE( face );
bdf_property_t* prop = NULL;
@@ -357,9 +369,9 @@ THE SOFTWARE.
font->unencoded_size,
font->unencoded_used ));
root->num_faces = 1;
root->face_index = 0;
root->face_flags = FT_FACE_FLAG_FIXED_SIZES |
bdfface->num_faces = 1;
bdfface->face_index = 0;
bdfface->face_flags = FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL |
FT_FACE_FLAG_FAST_GLYPHS;
@@ -368,7 +380,7 @@ THE SOFTWARE.
prop->value.atom &&
( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' ||
*(prop->value.atom) == 'C' || *(prop->value.atom) == 'c' ) )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
bdfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL */
/* FZ XXX: I need a font to implement this */
@@ -379,36 +391,38 @@ THE SOFTWARE.
int l = ft_strlen( prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( root->family_name, l ) )
if ( FT_NEW_ARRAY( bdfface->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
ft_strcpy( bdfface->family_name, prop->value.atom );
}
else
root->family_name = 0;
bdfface->family_name = 0;
if ( ( error = bdf_interpret_style( face ) ) != 0 )
goto Exit;
root->num_glyphs = font->glyphs_size; /* unencoded included */
/* the number of glyphs (with one slot for the undefined glyph */
/* at position 0 and all unencoded glyphs) */
bdfface->num_glyphs = font->glyphs_size + 1;
root->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( root->available_sizes, 1 ) )
bdfface->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
goto Exit;
{
FT_Bitmap_Size* bsize = root->available_sizes;
FT_Bitmap_Size* bsize = bdfface->available_sizes;
FT_Short resolution_x = 0, resolution_y = 0;
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
bsize->height = font->font_ascent + font->font_descent;
bsize->height = (FT_Short)( font->font_ascent + font->font_descent );
prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
if ( prop )
bsize->width = (FT_Short)( ( prop->value.int32 + 5 ) / 10 );
else
bsize->width = bsize->height * 2/3;
bsize->width = (FT_Short)( bsize->height * 2/3 );
prop = bdf_get_font_property( font, "POINT_SIZE" );
if ( prop )
@@ -449,11 +463,15 @@ THE SOFTWARE.
if ( FT_NEW_ARRAY( face->en_table, font->glyphs_size ) )
goto Exit;
face->default_glyph = 0;
for ( n = 0; n < font->glyphs_size; n++ )
{
(face->en_table[n]).enc = cur[n].encoding;
FT_TRACE4(( "idx %d, val 0x%lX\n", n, cur[n].encoding ));
(face->en_table[n]).glyph = (FT_Short)n;
if ( cur[n].encoding == font->default_char )
face->default_glyph = n;
}
}
@@ -521,8 +539,8 @@ THE SOFTWARE.
#if 0
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
if ( bdfface->num_charmaps )
bdfface->charmap = bdfface->charmaps[0];
#endif
}
@@ -544,8 +562,8 @@ THE SOFTWARE.
error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
if ( bdfface->num_charmaps )
bdfface->charmap = bdfface->charmaps[0];
}
}
}
@@ -554,17 +572,52 @@ THE SOFTWARE.
return error;
Fail:
BDF_Face_Done( face );
BDF_Face_Done( bdfface );
return BDF_Err_Unknown_File_Format;
}
static FT_Error
BDF_Set_Pixel_Size( FT_Size size )
FT_CALLBACK_DEF( FT_Error )
BDF_Set_Pixel_Size( FT_Size size,
FT_UInt char_width,
FT_UInt char_height )
{
BDF_Face face = (BDF_Face)FT_SIZE_FACE( size );
FT_Face root = FT_FACE( face );
FT_UNUSED( char_width );
if ( char_height == (FT_UInt)root->available_sizes->height )
{
size->metrics.ascender = face->bdffont->font_ascent << 6;
size->metrics.descender = -face->bdffont->font_descent << 6;
size->metrics.height = ( face->bdffont->font_ascent +
face->bdffont->font_descent ) << 6;
size->metrics.max_advance = face->bdffont->bbx.width << 6;
return BDF_Err_Ok;
}
else
return BDF_Err_Invalid_Pixel_Size;
}
FT_CALLBACK_DEF( FT_Error )
BDF_Set_Point_Size( FT_Size size,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
BDF_Face face = (BDF_Face)FT_SIZE_FACE( size );
FT_Face root = FT_FACE( face );
FT_UNUSED( char_width );
FT_UNUSED( char_height );
FT_UNUSED( horz_resolution );
FT_UNUSED( vert_resolution );
FT_TRACE4(( "rec %d - pres %d\n",
size->metrics.y_ppem, root->available_sizes->y_ppem ));
@@ -584,7 +637,7 @@ THE SOFTWARE.
}
static FT_Error
FT_CALLBACK_DEF( FT_Error )
BDF_Glyph_Load( FT_GlyphSlot slot,
FT_Size size,
FT_UInt glyph_index,
@@ -595,8 +648,6 @@ THE SOFTWARE.
FT_Bitmap* bitmap = &slot->bitmap;
bdf_glyph_t glyph;
int bpp = face->bdffont->bpp;
int i, j, count;
unsigned char *p, *pp;
FT_UNUSED( load_flags );
@@ -607,7 +658,10 @@ THE SOFTWARE.
goto Exit;
}
if ( glyph_index > 0 )
/* index 0 is the undefined glyph */
if ( glyph_index == 0 )
glyph_index = face->default_glyph;
else
glyph_index--;
/* slot, bitmap => freetype, glyph => bdflib */
@@ -615,110 +669,28 @@ THE SOFTWARE.
bitmap->rows = glyph.bbx.height;
bitmap->width = glyph.bbx.width;
if ( bpp == 1 )
{
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
bitmap->pitch = glyph.bpr;
/* note: we don't allocate a new array to hold the bitmap, we */
/* can simply point to it */
/* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */
ft_glyphslot_set_bitmap( slot, glyph.bitmap );
}
else
{
/* blow up pixmap to have 8 bits per pixel */
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->pitch = bitmap->width;
error = ft_glyphslot_alloc_bitmap( slot, bitmap->rows * bitmap->pitch );
if ( error )
goto Exit;
switch ( bpp )
{
case 2:
bitmap->num_grays = 4;
count = 0;
p = glyph.bitmap;
for ( i = 0; i < bitmap->rows; i++ )
{
pp = p;
/* get the full bytes */
for ( j = 0; j < ( bitmap->width >> 2 ); j++ )
{
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xC0 ) >> 6 );
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x30 ) >> 4 );
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x0C ) >> 2 );
bitmap->buffer[count++] = (FT_Byte)( *pp & 0x03 );
pp++;
}
/* get remaining pixels (if any) */
switch ( bitmap->width & 3 )
{
case 3:
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xC0 ) >> 6 );
/* fall through */
case 2:
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x30 ) >> 4 );
/* fall through */
case 1:
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0x0C ) >> 2 );
/* fall through */
case 0:
bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
break;
}
p += glyph.bpr;
}
case 2:
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY2;
break;
case 4:
bitmap->num_grays = 16;
count = 0;
p = glyph.bitmap;
for ( i = 0; i < bitmap->rows; i++ )
{
pp = p;
/* get the full bytes */
for ( j = 0; j < ( bitmap->width >> 1 ); j++ )
{
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xF0 ) >> 4 );
bitmap->buffer[count++] = (FT_Byte)( *pp & 0x0F );
pp++;
}
/* get remaining pixel (if any) */
switch ( bitmap->width & 1 )
{
case 1:
bitmap->buffer[count++] = (FT_Byte)( ( *pp & 0xF0 ) >> 4 );
/* fall through */
case 0:
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY4;
break;
}
p += glyph.bpr;
}
break;
case 8:
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->num_grays = 256;
FT_MEM_COPY( bitmap->buffer, glyph.bitmap,
bitmap->rows * bitmap->pitch );
break;
}
}
slot->bitmap_left = glyph.bbx.x_offset;
slot->bitmap_top = glyph.bbx.ascent;
@@ -784,6 +756,7 @@ THE SOFTWARE.
return BDF_Err_Invalid_Argument;
}
static FT_Error
bdf_get_charset_id( BDF_Face face,
const char* *acharset_encoding,
@@ -817,7 +790,7 @@ THE SOFTWARE.
};
static FT_Module_Interface
FT_CALLBACK_DEF( FT_Module_Interface )
bdf_driver_requester( FT_Module module,
const char* name )
{
@@ -851,21 +824,21 @@ THE SOFTWARE.
sizeof ( FT_SizeRec ),
sizeof ( FT_GlyphSlotRec ),
(FT_Face_InitFunc) BDF_Face_Init,
(FT_Face_DoneFunc) BDF_Face_Done,
(FT_Size_InitFunc) 0,
(FT_Size_DoneFunc) 0,
(FT_Slot_InitFunc) 0,
(FT_Slot_DoneFunc) 0,
BDF_Face_Init,
BDF_Face_Done,
0, /* FT_Size_InitFunc */
0, /* FT_Size_DoneFunc */
0, /* FT_Slot_InitFunc */
0, /* FT_Slot_DoneFunc */
(FT_Size_ResetPointsFunc) BDF_Set_Pixel_Size,
(FT_Size_ResetPixelsFunc) BDF_Set_Pixel_Size,
BDF_Set_Point_Size,
BDF_Set_Pixel_Size,
(FT_Slot_LoadFunc) BDF_Glyph_Load,
BDF_Glyph_Load,
(FT_Face_GetKerningFunc) 0,
(FT_Face_AttachFunc) 0,
(FT_Face_GetAdvancesFunc) 0
0, /* FT_Face_GetKerningFunc */
0, /* FT_Face_AttachFunc */
0, /* FT_Face_GetAdvancesFunc */
};
+3 -1
View File
@@ -2,7 +2,7 @@
FreeType font driver for bdf fonts
Copyright (C) 2001, 2002, 2003 by
Copyright (C) 2001, 2002, 2003, 2004 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -59,6 +59,8 @@ FT_BEGIN_HEADER
FT_CharMap charmap_handle;
FT_CharMapRec charmap; /* a single charmap per face */
FT_UInt default_glyph;
} BDF_FaceRec, *BDF_Face;
+258 -275
View File
@@ -1,6 +1,6 @@
/*
* Copyright 2000 Computing Research Labs, New Mexico State University
* Copyright 2001, 2002, 2003, 2004 Francesco Zappa Nardelli
* Copyright 2001, 2002, 2003, 2004, 2005 Francesco Zappa Nardelli
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -224,7 +224,6 @@
if ( FT_NEW_ARRAY( ht->table, ht->size ) )
goto Exit;
FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * ht->size );
for ( i = 0, bp = obp; i < sz; i++, bp++ )
{
@@ -255,7 +254,6 @@
if ( FT_NEW_ARRAY( ht->table, sz ) )
goto Exit;
FT_MEM_ZERO( ht->table, sizeof ( hashnode ) * sz );
Exit:
return error;
@@ -351,6 +349,7 @@
char** field;
unsigned long size;
unsigned long used;
FT_Memory memory;
} _bdf_list_t;
@@ -389,20 +388,126 @@
#define sbitset( m, cc ) ( m[(cc) >> 3] & ( 1 << ( (cc) & 7 ) ) )
static void
_bdf_list_init( _bdf_list_t* list,
FT_Memory memory )
{
FT_ZERO( list );
list->memory = memory;
}
static void
_bdf_list_done( _bdf_list_t* list )
{
FT_Memory memory = list->memory;
if ( memory )
{
FT_FREE( list->field );
FT_ZERO( list );
}
}
static FT_Error
_bdf_list_ensure( _bdf_list_t* list,
int num_items )
{
FT_Error error = BDF_Err_Ok;
if ( num_items > (int)list->size )
{
int oldsize = list->size;
int newsize = oldsize + ( oldsize >> 1 ) + 4;
int bigsize = FT_INT_MAX / sizeof ( char* );
FT_Memory memory = list->memory;
if ( oldsize == bigsize )
{
error = BDF_Err_Out_Of_Memory;
goto Exit;
}
else if ( newsize < oldsize || newsize > bigsize )
newsize = bigsize;
if ( FT_RENEW_ARRAY( list->field, oldsize, newsize ) )
goto Exit;
list->size = newsize;
}
Exit:
return error;
}
static void
_bdf_list_shift( _bdf_list_t* list,
unsigned long n )
{
unsigned long i, u;
if ( list == 0 || list->used == 0 || n == 0 )
return;
if ( n >= list->used )
{
list->used = 0;
return;
}
for ( u = n, i = 0; u < list->used; i++, u++ )
list->field[i] = list->field[u];
list->used -= n;
}
static char *
_bdf_list_join( _bdf_list_t* list,
int c,
unsigned long *alen )
{
unsigned long i, j;
char *fp, *dp;
*alen = 0;
if ( list == 0 || list->used == 0 )
return 0;
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
fp = list->field[i];
while ( *fp )
dp[j++] = *fp++;
if ( i + 1 < list->used )
dp[j++] = (char)c;
}
dp[j] = 0;
*alen = j;
return dp;
}
/* An empty string for empty fields. */
static const char empty[1] = { 0 }; /* XXX eliminate this */
/* Assume the line is NULL-terminated and that the `list' parameter */
/* was initialized the first time it was used. */
static FT_Error
_bdf_split( char* separators,
_bdf_list_split( _bdf_list_t* list,
char* separators,
char* line,
unsigned long linelen,
_bdf_list_t* list,
FT_Memory memory )
unsigned long linelen )
{
int mult, final_empty;
char *sp, *ep, *end;
@@ -451,21 +556,10 @@
/* Resize the list if necessary. */
if ( list->used == list->size )
{
if ( list->size == 0 )
{
if ( FT_NEW_ARRAY( list->field, 5 ) )
error = _bdf_list_ensure( list, list->used + 1 );
if ( error )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY ( list->field ,
list->size,
list->size + 5 ) )
goto Exit;
}
list->size += 5;
}
/* Assign the field appropriately. */
list->field[list->used++] = ( ep > sp ) ? sp : (char*)empty;
@@ -489,48 +583,16 @@
}
/* Finally, NULL-terminate the list. */
if ( list->used + final_empty + 1 >= list->size )
if ( list->used + final_empty >= list->size )
{
if ( list->used == list->size )
{
if ( list->size == 0 )
{
if ( FT_NEW_ARRAY( list->field, 5 ) )
error = _bdf_list_ensure( list, list->used + final_empty + 1 );
if ( error )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( list->field,
list->size,
list->size + 5 ) )
goto Exit;
}
list->size += 5;
}
}
if ( final_empty )
list->field[list->used++] = (char*)empty;
if ( list->used == list->size )
{
if ( list->size == 0 )
{
if ( FT_NEW_ARRAY( list->field, 5 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( list->field,
list->size,
list->size + 5 ) )
goto Exit;
}
list->size += 5;
}
list->field[list->used] = 0;
Exit:
@@ -538,99 +600,7 @@
}
static void
_bdf_shift( unsigned long n,
_bdf_list_t* list )
{
unsigned long i, u;
if ( list == 0 || list->used == 0 || n == 0 )
return;
if ( n >= list->used )
{
list->used = 0;
return;
}
for ( u = n, i = 0; u < list->used; i++, u++ )
list->field[i] = list->field[u];
list->used -= n;
}
static char *
_bdf_join( int c,
unsigned long* len,
_bdf_list_t* list )
{
unsigned long i, j;
char *fp, *dp;
if ( list == 0 || list->used == 0 )
return 0;
*len = 0;
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
fp = list->field[i];
while ( *fp )
dp[j++] = *fp++;
if ( i + 1 < list->used )
dp[j++] = (char)c;
}
dp[j] = 0;
*len = j;
return dp;
}
/* High speed file reader that passes each line to a callback. */
static FT_Error
bdf_internal_readstream( FT_Stream stream,
char* buffer,
int count,
int *read_bytes )
{
int rbytes;
unsigned long pos = stream->pos;
FT_Error error = BDF_Err_Ok;
if ( pos > stream->size )
{
FT_ERROR(( "bdf_internal_readstream:" ));
FT_ERROR(( " invalid i/o; pos = 0x%lx, size = 0x%lx\n",
pos, stream->size ));
error = BDF_Err_Invalid_Stream_Operation;
goto Exit;
}
if ( stream->read )
rbytes = stream->read( stream, pos,
(unsigned char *)buffer, count );
else
{
rbytes = stream->size - pos;
if ( rbytes > count )
rbytes = count;
FT_MEM_COPY( buffer, stream->base + pos, rbytes );
}
stream->pos = pos + rbytes;
*read_bytes = rbytes;
Exit:
return error;
}
#define NO_SKIP 256 /* this value cannot be stored in a 'char' */
static FT_Error
@@ -640,10 +610,10 @@
unsigned long *lno )
{
_bdf_line_func_t cb;
unsigned long lineno;
int n, done, refill, bytes, hold;
char *ls, *le, *pp, *pe, *hp;
char *buf = 0;
unsigned long lineno, buf_size;
int refill, bytes, hold, to_skip;
int start, end, cursor, avail;
char* buf = 0;
FT_Memory memory = stream->memory;
FT_Error error = BDF_Err_Ok;
@@ -654,82 +624,112 @@
goto Exit;
}
if ( FT_NEW_ARRAY( buf, 65536L ) )
/* initial size and allocation of the input buffer */
buf_size = 1024;
if ( FT_NEW_ARRAY( buf, buf_size ) )
goto Exit;
cb = callback;
lineno = 1;
buf[0] = 0;
start = 0;
end = 0;
avail = 0;
cursor = 0;
refill = 1;
to_skip = NO_SKIP;
bytes = 0; /* make compiler happy */
done = 0;
pp = ls = le = buf;
bytes = 65536L;
while ( !done )
for (;;)
{
error = bdf_internal_readstream( stream, pp, bytes, &n );
if ( error )
if ( refill )
{
bytes = (int)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor,
(FT_ULong)(buf_size - cursor) );
avail = cursor + bytes;
cursor = 0;
refill = 0;
}
end = start;
/* should we skip an optional character like \n or \r? */
if ( start < avail && buf[start] == to_skip )
{
start += 1;
to_skip = NO_SKIP;
continue;
}
/* try to find the end of the line */
while ( end < avail && buf[end] != '\n' && buf[end] != '\r' )
end++;
/* if we hit the end of the buffer, try shifting its content */
/* or even resizing it */
if ( end >= avail )
{
if ( bytes == 0 ) /* last line in file doesn't end in \r or \n */
break; /* ignore it then exit */
if ( start == 0 )
{
/* this line is definitely too long; try resizing the input */
/* buffer a bit to handle it. */
FT_ULong new_size;
if ( buf_size >= 65536UL ) /* limit ourselves to 64KByte */
{
error = BDF_Err_Invalid_Argument;
goto Exit;
}
new_size = buf_size * 2;
if ( FT_RENEW_ARRAY( buf, buf_size, new_size ) )
goto Exit;
if ( n == 0 )
break;
/* Determine the new end of the buffer pages. */
pe = pp + n;
for ( refill = 0; done == 0 && refill == 0; )
{
while ( le < pe && *le != '\n' && *le != '\r' )
le++;
if ( le == pe )
{
/* Hit the end of the last page in the buffer. Need to find */
/* out how many pages to shift and how many pages need to be */
/* read in. Adjust the line start and end pointers down to */
/* point to the right places in the pages. */
pp = buf + ( ( ( ls - buf ) >> 13 ) << 13 );
n = pp - buf;
ls -= n;
le -= n;
n = pe - pp;
FT_MEM_MOVE( buf, pp, n );
pp = buf + n;
bytes = 65536L - n;
refill = 1;
cursor = buf_size;
buf_size = new_size;
}
else
{
/* Temporarily NULL-terminate the line. */
hp = le;
hold = *le;
*le = 0;
bytes = avail - start;
FT_MEM_COPY( buf, buf + start, bytes );
cursor = bytes;
avail -= bytes;
start = 0;
}
refill = 1;
continue;
}
/* Temporarily NUL-terminate the line. */
hold = buf[end];
buf[end] = 0;
/* XXX: Use encoding independent value for 0x1a */
if ( *ls != '#' && *ls != 0x1a &&
le > ls &&
( error = (*cb)( ls, le - ls, lineno, (void *)&cb,
client_data ) ) != BDF_Err_Ok )
done = 1;
else
if ( buf[start] != '#' && buf[start] != 0x1a && end > start )
{
ls = ++le;
/* Handle the case of DOS crlf sequences. */
if ( le < pe && hold == '\n' && *le =='\r' )
ls = ++le;
error = (*cb)( buf + start, end - start, lineno,
(void*)&cb, client_data );
if ( error )
break;
}
/* Increment the line number. */
lineno++;
lineno += 1;
buf[end] = (char)hold;
start = end + 1;
/* Restore the character at the end of the line. */
*hp = (char)hold;
}
}
if ( hold == '\n' )
to_skip = '\r';
else if ( hold == '\r' )
to_skip = '\n';
else
to_skip = NO_SKIP;
}
*lno = lineno;
@@ -955,7 +955,8 @@
if ( c1->encoding < c2->encoding )
return -1;
else if ( c1->encoding > c2->encoding )
if ( c1->encoding > c2->encoding )
return 1;
return 0;
@@ -979,23 +980,16 @@
if ( hash_lookup( name, &(font->proptbl) ) )
goto Exit;
if ( font->nuser_props == 0 )
{
if ( FT_NEW_ARRAY( font->user_props, 1 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->user_props,
font->nuser_props,
font->nuser_props + 1 ) )
goto Exit;
}
p = font->user_props + font->nuser_props;
FT_MEM_ZERO( p, sizeof ( bdf_property_t ) );
FT_ZERO( p );
n = (unsigned long)( ft_strlen( name ) + 1 );
if ( FT_NEW_ARRAY( p->name, n ) )
goto Exit;
@@ -1110,23 +1104,16 @@
FT_Error error = BDF_Err_Ok;
if ( font->comments_len == 0 )
{
if ( FT_NEW_ARRAY( font->comments, len + 1 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->comments,
font->comments_len,
font->comments_len + len + 1 ) )
goto Exit;
}
cp = font->comments + font->comments_len;
FT_MEM_COPY( cp, comment, len );
cp += len;
*cp++ = '\n';
cp[len] = '\n';
font->comments_len += len + 1;
Exit:
@@ -1155,16 +1142,16 @@
memory = font->memory;
_bdf_list_init( &list, memory );
font->spacing = opts->font_spacing;
len = (unsigned long)( ft_strlen( font->name ) + 1 );
FT_MEM_COPY( name, font->name, len );
list.size = list.used = 0;
error = _bdf_split( (char *)"-", name, len, &list, memory );
error = _bdf_list_split( &list, (char *)"-", name, len );
if ( error )
goto Exit;
goto Fail;
if ( list.used == 15 )
{
@@ -1185,7 +1172,8 @@
}
}
FT_FREE( list.field );
Fail:
_bdf_list_done( &list );
Exit:
return error;
@@ -1404,7 +1392,7 @@
/* present, and the SPACING property should override the default */
/* spacing. */
if ( ft_memcmp( name, "DEFAULT_CHAR", 12 ) == 0 )
font->default_glyph = fp->value.int32;
font->default_char = fp->value.int32;
else if ( ft_memcmp( name, "FONT_ASCENT", 11 ) == 0 )
font->font_ascent = fp->value.int32;
else if ( ft_memcmp( name, "FONT_DESCENT", 12 ) == 0 )
@@ -1484,7 +1472,7 @@
goto Exit;
}
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
p->cnt = font->glyphs_size = _bdf_atoul( p->list.field[1], 0, 10 );
@@ -1538,15 +1526,17 @@
/* encoding can be checked for an unencoded character. */
FT_FREE( p->glyph_name );
error = _bdf_split( (char *)" +", line, linelen, &p->list,memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
_bdf_shift( 1, &p->list );
s = _bdf_join( ' ', &slen, &p->list );
_bdf_list_shift( &p->list, 1 );
s = _bdf_list_join( &p->list, ' ', &slen );
if ( FT_NEW_ARRAY( p->glyph_name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->glyph_name, s, slen + 1 );
p->flags |= _BDF_GLYPH;
@@ -1565,9 +1555,10 @@
goto Exit;
}
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
p->glyph_enc = _bdf_atol( p->list.field[1], 0, 10 );
/* Check to see whether this encoding has already been encountered. */
@@ -1598,8 +1589,7 @@
font->glyphs_size,
font->glyphs_size + 64 ) )
goto Exit;
FT_MEM_ZERO( font->glyphs + font->glyphs_size,
sizeof ( bdf_glyph_t ) * 64 ); /* FZ inutile */
font->glyphs_size += 64;
}
@@ -1618,19 +1608,12 @@
{
/* Allocate the next unencoded glyph. */
if ( font->unencoded_used == font->unencoded_size )
{
if ( font->unencoded_size == 0 )
{
if ( FT_NEW_ARRAY( font->unencoded, 4 ) )
goto Exit;
}
else
{
if ( FT_RENEW_ARRAY( font->unencoded ,
font->unencoded_size,
font->unencoded_size + 4 ) )
goto Exit;
}
font->unencoded_size += 4;
}
@@ -1719,9 +1702,10 @@
goto Exit;
}
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
glyph->swidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 );
p->flags |= _BDF_SWIDTH;
@@ -1731,9 +1715,10 @@
/* Expect the DWIDTH (scalable width) field next. */
if ( ft_memcmp( line, "DWIDTH", 6 ) == 0 )
{
error = _bdf_split( (char *)" +", line, linelen, &p->list,memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
glyph->dwidth = (unsigned short)_bdf_atoul( p->list.field[1], 0, 10 );
if ( !( p->flags & _BDF_SWIDTH ) )
@@ -1755,7 +1740,7 @@
/* Expect the BBX field next. */
if ( ft_memcmp( line, "BBX", 3 ) == 0 )
{
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -1862,7 +1847,6 @@
char* name;
char* value;
char nbuf[128];
FT_Memory memory;
FT_Error error = BDF_Err_Ok;
FT_UNUSED( lineno );
@@ -1871,8 +1855,6 @@
next = (_bdf_line_func_t *)call_data;
p = (_bdf_parse_t *) client_data;
memory = p->font->memory;
/* Check for the end of the properties. */
if ( ft_memcmp( line, "ENDPROPERTIES", 13 ) == 0 )
{
@@ -1936,13 +1918,13 @@
}
else
{
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
name = p->list.field[0];
_bdf_shift( 1, &p->list );
value = _bdf_join( ' ', &vlen, &p->list );
_bdf_list_shift( &p->list, 1 );
value = _bdf_list_join( &p->list, ' ', &vlen );
error = _bdf_add_property( p->font, name, value );
if ( error )
@@ -2049,7 +2031,7 @@
if ( error )
goto Exit;
p->font->spacing = p->opts->font_spacing;
p->font->default_glyph = -1;
p->font->default_char = -1;
goto Exit;
}
@@ -2057,7 +2039,7 @@
/* Check for the start of the properties. */
if ( ft_memcmp( line, "STARTPROPERTIES", 15 ) == 0 )
{
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
p->cnt = p->font->props_size = _bdf_atoul( p->list.field[1], 0, 10 );
@@ -2082,7 +2064,7 @@
goto Exit;
}
error = _bdf_split( (char *)" +", line, linelen, &p->list , memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -2105,12 +2087,12 @@
/* The next thing to check for is the FONT field. */
if ( ft_memcmp( line, "FONT", 4 ) == 0 )
{
error = _bdf_split( (char *)" +", line, linelen, &p->list , memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
_bdf_shift( 1, &p->list );
_bdf_list_shift( &p->list, 1 );
s = _bdf_join( ' ', &slen, &p->list );
s = _bdf_list_join( &p->list, ' ', &slen );
if ( FT_NEW_ARRAY( p->font->name, slen + 1 ) )
goto Exit;
FT_MEM_COPY( p->font->name, s, slen + 1 );
@@ -2137,7 +2119,7 @@
goto Exit;
}
error = _bdf_split( (char *)" +", line, linelen, &p->list, memory );
error = _bdf_list_split( &p->list, (char *)" +", line, linelen );
if ( error )
goto Exit;
@@ -2207,7 +2189,7 @@
FT_Error error = BDF_Err_Ok;
if ( FT_ALLOC( p, sizeof ( _bdf_parse_t ) ) )
if ( FT_NEW( p ) )
goto Exit;
memory = NULL;
@@ -2215,6 +2197,8 @@
p->minlb = 32767;
p->memory = extmemory; /* only during font creation */
_bdf_list_init( &p->list, extmemory );
error = _bdf_readstream( stream, _bdf_parse_start,
(void *)p, &lineno );
if ( error )
@@ -2301,10 +2285,6 @@
}
}
/* Free up the list used during the parsing. */
if ( memory != NULL )
FT_FREE( p->list.field );
if ( p->font != 0 )
{
/* Make sure the comments are NULL terminated if they exist. */
@@ -2327,7 +2307,10 @@
Exit:
if ( p )
{
_bdf_list_done( &p->list );
memory = extmemory;
FT_FREE( p );
}
+1
View File
@@ -27,3 +27,4 @@ UseFreeTypeHeaders ;
}
# end of src/cache Jamfile

Some files were not shown because too many files have changed in this diff Show More