diff --git a/ChangeLog b/ChangeLog index d9d72fd84..00d71cadb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,61 @@ +2003-06-21 Werner Lemberg + + * src/winfonts/winfnt.c (FNT_Load_Glyph): Use first_char in + computation of glyph_index. + (FNT_Size_Set_Pixels): To find a strike, first check pixel_height + only, then try to find a better hit by comparing pixel_width also. + Without this fix it isn't possible to access all strikes. + Also compute metrics.max_advance to be in sync with other bitmap + drivers. + + * src/base/ftobjs.c (FT_Set_Char_Size): Remove redundant code. + (FT_Set_Pixel_Size): Assign value to `metrics' after validation of + arguments. + +2003-06-20 Werner Lemberg + + Synchronize computation of height and width for bitmap strikes. The + `width' field in the FT_Bitmap_Size structure is now only useful to + enumerate different strikes. The `max_advance' field of the + FT_Size_Metrics structure should be used to get the (maximum) width + of a strike. + + * src/bdf/bdfdrivr.c (BDF_Face_Init): Don't use AVERAGE_WIDTH for + computing `available_sizes->width' but make it always equal to + `available_sizes->height'. + + * src/pcf/pcfread.c (pcf_load_font): Don't use RESOLUTION_X for + computing `available_sizes->width' but make it always equal to + `available_sizes->height'. + + * src/truetype/ttdriver.c (Set_Pixel_Sizes): Pass only single + argument to function. + + * src/psnames/psmodule.c (ps_unicode_value): Handle `.' after + `uniXXXX' and `uXXXX[X[X]]'. + +2003-06-19 Werner Lemberg + + * src/bdf/bdfdrivr.c: s/FT_Err_/BDF_Err/. + * src/cache/ftccache.c, src/cache/ftcsbits.c, src/cache/ftlru.c: + s/FT_Err_/FTC_Err_/. + * src/cff/cffcmap.c: s/FT_Err_/CFF_Err_/. + * src/pcf/pcfdrivr.c: s/FT_Err_/PCF_Err_/. + * src/psaux/t1cmap.c: Include psauxerr.h. + s/FT_Err_/PSaux_Err_/. + * src/pshinter/pshnterr.h: New file. + * src/pshinter/rules.mk: Updated. + * src/pshinter/pshalgo.c, src/pshinter/pshrec.c: Include pshnterr.h. + s/FT_Err_/PSH_Err_/. + * src/pfr/pfrdrivr.c, src/pfr/pfrobjs.c, src/pfr/pfrsbit.c: + s/FT_Err_/PFR_Err_/. + * src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, src/sfnt/ttcmap0.c, + src/sfnt/ttload.c: s/FT_Err_/SFNT_Err_/. + * src/truetype/ttgload.c: s/FT_Err_/TT_Err_/. + * src/gzip/ftgzip.c: Load FT_MODULE_ERRORS_H and define + FT_ERR_PREFIX and FT_ERR_BASE. + s/FT_Err_/Gzip_Err_/. + 2003-06-19 Dirck Blaskey * src/cff/cffload (cff_encoding_load): `nleft' must be FT_UInt, @@ -376,7 +434,7 @@ 2003-05-30 Werner Lemberg Avoid overwriting of numeric font dictionary entries for synthetic - fonts. Additionally, some entries were handled as `integer' instead + fonts. Additionally, some entries were handled as `integer' instead of `number'. * include/freetype/internal/psaux.h (T1_FieldType): Add @@ -443,7 +501,7 @@ s/ps3/ps/. * src/pshinter/pshrec.c, src/pshinter/pshinter.c: Updated. - * src/pshinter/rules.mk, src/pshinter/Jamfile: Updated + * src/pshinter/rules.mk, src/pshinter/Jamfile: Updated. * src/pshinter/pshglob.[ch] (psh_dimension_snap_width): Commented out. diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index eb1a7130d..241298f0a 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -218,7 +218,12 @@ FT_BEGIN_HEADER /* */ /* height :: The character height in pixels. */ /* */ - /* width :: The character width in pixels. */ + /* width :: The character width in pixels. For drivers which */ + /* contain a single bitmap strike only (BDF, PCF) this */ + /* field is always equal to `height'. To get the */ + /* (maximum) width of a bitmap strike use */ + /* `face->size->metrics.max_advance' after a call to */ + /* @FT_Set_Pixel_Sizes. */ /* */ typedef struct FT_Bitmap_Size_ { @@ -697,8 +702,8 @@ FT_BEGIN_HEADER /* */ /* num_fixed_sizes :: The number of fixed sizes available in this */ /* face. This should be set to 0 for scalable */ - /* fonts, unless its face includes a complete */ - /* set of glyphs (called a `strike') for the */ + /* fonts, unless its face includes a set of */ + /* glyphs (called a `strike') for the */ /* specified sizes. */ /* */ /* available_sizes :: An array of sizes specifying the available */ @@ -907,7 +912,7 @@ FT_BEGIN_HEADER /* */ /* FT_FACE_FLAG_GLYPH_NAMES :: */ /* Indicates that the font contains glyph names that can be */ - /* retrieved through @FT_Get_Glyph_Names. Note that some TrueType */ + /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */ /* fonts contain broken glyph name tables. Use the function */ /* @FT_Has_PS_Glyph_Name when needed. */ /* */ @@ -1056,7 +1061,7 @@ FT_BEGIN_HEADER /* */ /* @description: */ /* A macro that returns true whenever a face object contains some */ - /* glyph names that can be accessed through @FT_Get_Glyph_Names. */ + /* glyph names that can be accessed through @FT_Get_Glyph_Name. */ /* */ #define FT_HAS_GLYPH_NAMES( face ) \ ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) @@ -1136,10 +1141,12 @@ FT_BEGIN_HEADER /* units to fractional (26.6) pixel coordinates. */ /* */ /* ascender :: The ascender, expressed in 26.6 fixed point */ - /* pixels. Always positive. */ + /* pixels. Positive for ascenders above the */ + /* baseline. */ /* */ /* descender :: The descender, expressed in 26.6 fixed point */ - /* pixels. Always negative. */ + /* pixels. Negative for descenders below the */ + /* baseline. */ /* */ /* height :: The text height, expressed in 26.6 fixed point */ /* pixels. Always positive. */ @@ -1167,7 +1174,7 @@ FT_BEGIN_HEADER FT_UShort y_ppem; /* vertical pixels per EM */ FT_Fixed x_scale; /* two scales used to convert font units */ - FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates.. */ + FT_Fixed y_scale; /* to 26.6 frac. pixel coordinates */ FT_Pos ascender; /* ascender in 26.6 frac. pixels */ FT_Pos descender; /* descender in 26.6 frac. pixels */ @@ -1871,7 +1878,7 @@ FT_BEGIN_HEADER /* */ /* */ /* When dealing with fixed-size faces (i.e., non-scalable formats), */ - /* use the function @FT_Set_Pixel_Sizes. */ + /* @FT_Set_Pixel_Sizes provides a more convenient interface. */ /* */ FT_EXPORT( FT_Error ) FT_Set_Char_Size( FT_Face face, @@ -1920,6 +1927,10 @@ FT_BEGIN_HEADER /* guarantee in any way that you will get glyph bitmaps that all fit */ /* within an 8x8 cell (sometimes even far from it). */ /* */ + /* For bitmap fonts, `pixel_height' usually is a reliable value for */ + /* the height of the bitmap cell. Drivers for bitmap font formats */ + /* which contain a single bitmap strike only (BDF, PCF) ignore */ + /* `pixel_width'. */ FT_EXPORT( FT_Error ) FT_Set_Pixel_Sizes( FT_Face face, FT_UInt pixel_width, diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index feac5ee83..59169d4ef 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1994,6 +1994,7 @@ driver = face->driver; metrics = &face->size->metrics; + clazz = driver->clazz; if ( !char_width ) char_width = char_height; @@ -2007,17 +2008,13 @@ if ( !vert_resolution ) vert_resolution = 72; - driver = face->driver; - clazz = driver->clazz; - /* default processing -- this can be overridden by the driver */ if ( char_width < 1 * 64 ) char_width = 1 * 64; if ( char_height < 1 * 64 ) char_height = 1 * 64; - /* Compute pixel sizes in 26.6 units. we use rounding - */ + /* Compute pixel sizes in 26.6 units with rounding */ dim_x = ( ( char_width * horz_resolution + (36+32*72) ) / 72 ) & -64; dim_y = ( ( char_height * vert_resolution + (36+32*72) ) / 72 ) & -64; @@ -2055,14 +2052,15 @@ FT_Error error = FT_Err_Ok; FT_Driver driver; FT_Driver_Class clazz; - FT_Size_Metrics* metrics = &face->size->metrics; + FT_Size_Metrics* metrics; if ( !face || !face->size || !face->driver ) return FT_Err_Invalid_Face_Handle; - driver = face->driver; - clazz = driver->clazz; + driver = face->driver; + metrics = &face->size->metrics; + clazz = driver->clazz; /* default processing -- this can be overridden by the driver */ if ( pixel_width == 0 ) diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c index 369039971..0bd479ce2 100644 --- a/src/bdf/bdfdrivr.c +++ b/src/bdf/bdfdrivr.c @@ -65,7 +65,7 @@ THE SOFTWARE. cmap->num_encodings = face->bdffont->glyphs_used; cmap->encodings = face->en_table; - return FT_Err_Ok; + return BDF_Err_Ok; } @@ -305,15 +305,9 @@ THE SOFTWARE. if ( FT_NEW_ARRAY( root->available_sizes, 1 ) ) goto Exit; - prop = bdf_get_font_property( font, "AVERAGE_WIDTH" ); - if ( ( prop != NULL ) && ( prop->value.int32 >= 10 ) ) - root->available_sizes->width = (short)( prop->value.int32 / 10 ); - prop = bdf_get_font_property( font, "PIXEL_SIZE" ); - if ( prop != NULL ) { - root->available_sizes->height = - root->available_sizes->width = (short) prop->value.int32; - } + if ( prop != NULL ) + root->available_sizes->height = (short) prop->value.int32; else { prop = bdf_get_font_property( font, "POINT_SIZE" ); @@ -333,19 +327,17 @@ THE SOFTWARE. } } - if ( root->available_sizes->width == 0 ) - { - if ( root->available_sizes->height == 0 ) - { - /* some fonts have broken SIZE declaration (jiskan24.bdf) */ - FT_ERROR(( "BDF_Face_Init: reading size\n" )); - root->available_sizes->width = (FT_Short)font->point_size; - } - else - root->available_sizes->width = root->available_sizes->height; - } if ( root->available_sizes->height == 0 ) - root->available_sizes->height = root->available_sizes->width; + { + /* some fonts have broken SIZE declaration (jiskan24.bdf) */ + FT_ERROR(( "BDF_Face_Init: reading size\n" )); + root->available_sizes->height = (FT_Short)font->point_size; + } + + /* `width' is just an enumeration value for different bitmap strikes */ + /* in a single font. Since a BDF font has a single strike only, */ + /* make this value the same as the height. */ + root->available_sizes->width = root->available_sizes->height; /* encoding table */ { @@ -682,7 +674,7 @@ THE SOFTWARE. } Fail: - return FT_Err_Invalid_Argument; + return BDF_Err_Invalid_Argument; } diff --git a/src/cache/ftccache.c b/src/cache/ftccache.c index d4d83f437..cc01c3978 100644 --- a/src/cache/ftccache.c +++ b/src/cache/ftccache.c @@ -173,7 +173,7 @@ if ( *pnode == NULL ) { FT_ERROR(( "ftc_node_hash_unlink: unknown node!\n" )); - return FT_Err_Ok; + return FTC_Err_Ok; } if ( *pnode == node ) @@ -551,7 +551,7 @@ FTC_Query query, FTC_Node *anode ) { - FT_Error error = FT_Err_Ok; + FT_Error error = FTC_Err_Ok; FTC_Manager manager; FT_LruNode lru; FT_UInt free_count = 0; @@ -743,7 +743,7 @@ } Fail: - if ( error != FT_Err_Out_Of_Memory ) + if ( error != FTC_Err_Out_Of_Memory ) goto Exit; /* There is not enough memory; try to release some unused nodes diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c index 5e37f2c2f..7578ef8c2 100644 --- a/src/cache/ftcsbits.c +++ b/src/cache/ftcsbits.c @@ -216,7 +216,7 @@ /* we mark unloaded glyphs with `sbit.buffer == 0' */ /* and 'width == 255', 'height == 0' */ /* */ - if ( error && error != FT_Err_Out_Of_Memory ) + if ( error && error != FTC_Err_Out_Of_Memory ) { sbit->width = 255; error = 0; diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c index 95c12924f..b25d7419d 100644 --- a/src/cache/ftlru.c +++ b/src/cache/ftlru.c @@ -198,7 +198,7 @@ * This loop will only exit when: * * - a new node was successfully created, or an old node flushed - * - an error other than FT_Err_Out_Of_Memory is detected + * - an error other than FTC_Err_Out_Of_Memory is detected * - the list of nodes is empty, and it isn't possible to create * new nodes * @@ -228,7 +228,7 @@ if ( node == NULL ) { FT_ASSERT( list->num_nodes == 0 ); - error = FT_Err_Out_Of_Memory; + error = FTC_Err_Out_Of_Memory; goto Exit; } @@ -298,7 +298,7 @@ goto Exit; Fail: - if ( error != FT_Err_Out_Of_Memory ) + if ( error != FTC_Err_Out_Of_Memory ) goto Exit; drop_last = 1; diff --git a/src/cff/cffcmap.c b/src/cff/cffcmap.c index 34af47ea6..5ed9d5dcf 100644 --- a/src/cff/cffcmap.c +++ b/src/cff/cffcmap.c @@ -189,7 +189,7 @@ { /* there are no unicode characters in here! */ FT_FREE( cmap->pairs ); - error = FT_Err_Invalid_Argument; + error = CFF_Err_Invalid_Argument; } else { diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index f58bec05e..3bcee6286 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -275,7 +275,6 @@ } - /*************************************************************************/ /* */ /* */ diff --git a/src/gzip/ftgzip.c b/src/gzip/ftgzip.c index ca734f301..0787d8095 100644 --- a/src/gzip/ftgzip.c +++ b/src/gzip/ftgzip.c @@ -26,6 +26,17 @@ #include FT_INTERNAL_DEBUG_H #include + +#include FT_MODULE_ERRORS_H + +#undef __FTERRORS_H__ + +#define FT_ERR_PREFIX Gzip_Err_ +#define FT_ERR_BASE FT_Mod_Err_Gzip + +#include FT_ERRORS_H + + #ifdef FT_CONFIG_OPTION_USE_ZLIB #ifdef FT_CONFIG_OPTION_SYSTEM_ZLIB @@ -181,7 +192,7 @@ head[2] != Z_DEFLATED || (head[3] & FT_GZIP_RESERVED) ) { - error = FT_Err_Invalid_File_Format; + error = Gzip_Err_Invalid_File_Format; goto Exit; } @@ -276,7 +287,7 @@ if ( inflateInit2( zstream, -MAX_WBITS ) != Z_OK || zstream->next_in == NULL ) { - error = FT_Err_Invalid_File_Format; + error = Gzip_Err_Invalid_File_Format; goto Exit; } @@ -347,7 +358,7 @@ size = stream->read( stream, stream->pos, zip->input, FT_GZIP_BUFFER_SIZE ); if ( size == 0 ) - return FT_Err_Invalid_Stream_Operation; + return Gzip_Err_Invalid_Stream_Operation; } else { @@ -356,7 +367,7 @@ size = FT_GZIP_BUFFER_SIZE; if ( size == 0 ) - return FT_Err_Invalid_Stream_Operation; + return Gzip_Err_Invalid_Stream_Operation; FT_MEM_COPY( zip->input, stream->base + stream->pos, size ); } @@ -398,12 +409,12 @@ { zip->limit = zstream->next_out; if ( zip->limit == zip->cursor ) - error = FT_Err_Invalid_Stream_Operation; + error = Gzip_Err_Invalid_Stream_Operation; break; } else if ( err != Z_OK ) { - error = FT_Err_Invalid_Stream_Operation; + error = Gzip_Err_Invalid_Stream_Operation; break; } } @@ -585,7 +596,7 @@ FT_UNUSED( stream ); FT_UNUSED( source ); - return FT_Err_Unimplemented_Feature; + return Gzip_Err_Unimplemented_Feature; } #endif /* !FT_CONFIG_OPTION_USE_ZLIB */ diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c index a1dae7d60..3681b1cbf 100644 --- a/src/pcf/pcfdrivr.c +++ b/src/pcf/pcfdrivr.c @@ -63,7 +63,7 @@ THE SOFTWARE. cmap->num_encodings = (FT_UInt)face->nencodings; cmap->encodings = face->encodings; - return FT_Err_Ok; + return PCF_Err_Ok; } @@ -245,7 +245,7 @@ THE SOFTWARE. /* this didn't work, try gzip support! */ error2 = FT_Stream_OpenGzip( &face->gzip_stream, stream ); - if ( error2 == FT_Err_Unimplemented_Feature ) + if ( error2 == PCF_Err_Unimplemented_Feature ) goto Fail; error = error2; @@ -454,9 +454,9 @@ THE SOFTWARE. slot->bitmap_left = metric->leftSideBearing; slot->bitmap_top = metric->ascent; - slot->metrics.horiAdvance = metric->characterWidth << 6 ; - slot->metrics.horiBearingX = metric->leftSideBearing << 6 ; - slot->metrics.horiBearingY = metric->ascent << 6 ; + slot->metrics.horiAdvance = metric->characterWidth << 6; + slot->metrics.horiBearingX = metric->leftSideBearing << 6; + slot->metrics.horiBearingY = metric->ascent << 6; slot->metrics.width = ( metric->rightSideBearing - metric->leftSideBearing ) << 6; slot->metrics.height = bitmap->rows << 6; @@ -499,7 +499,7 @@ THE SOFTWARE. return 0; } - return FT_Err_Invalid_Argument; + return PCF_Err_Invalid_Argument; } diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c index 5a5a16534..46002f9d8 100644 --- a/src/pcf/pcfread.c +++ b/src/pcf/pcfread.c @@ -919,7 +919,6 @@ THE SOFTWARE. { FT_Face root = FT_FACE( face ); PCF_Property prop; - int size_set = 0; root->num_faces = 1; @@ -986,45 +985,32 @@ THE SOFTWARE. prop = pcf_find_property( face, "PIXEL_SIZE" ); if ( prop != NULL ) - { - root->available_sizes->height = - root->available_sizes->width = (FT_Short)( prop->value.integer ); - - size_set = 1; - } + root->available_sizes->height = (FT_Short)( prop->value.integer ); else { prop = pcf_find_property( face, "POINT_SIZE" ); if ( prop != NULL ) { - PCF_Property xres, yres; + PCF_Property yres; - xres = pcf_find_property( face, "RESOLUTION_X" ); yres = pcf_find_property( face, "RESOLUTION_Y" ); - - if ( ( yres != NULL ) && ( xres != NULL ) ) - { + if ( yres != NULL ) root->available_sizes->height = (FT_Short)( prop->value.integer * yres->value.integer / 720 ); - - root->available_sizes->width = - (FT_Short)( prop->value.integer * - xres->value.integer / 720 ); - - size_set = 1; - } } } - if (size_set == 0 ) - { - root->available_sizes->width = 12; + if ( root->available_sizes->height == 0 ) root->available_sizes->height = 12; - } - /* set-up charset */ + /* `width' is just an enumeration value for different bitmap strikes */ + /* in a single font. Since a PCF font has a single strike only, */ + /* make this value the same as the height. */ + root->available_sizes->width = root->available_sizes->height; + + /* set up charset */ { PCF_Property charset_registry = 0, charset_encoding = 0; diff --git a/src/pfr/pfrdrivr.c b/src/pfr/pfrdrivr.c index 67989c577..3935e2e54 100644 --- a/src/pfr/pfrdrivr.c +++ b/src/pfr/pfrdrivr.c @@ -47,7 +47,7 @@ phys->metrics_resolution ); } - return FT_Err_Ok; + return PFR_Err_Ok; } @@ -56,7 +56,7 @@ FT_UInt gindex, FT_Pos *aadvance ) { - FT_Error error = FT_Err_Bad_Argument; + FT_Error error = PFR_Err_Bad_Argument; *aadvance = 0; diff --git a/src/pfr/pfrobjs.c b/src/pfr/pfrobjs.c index 3993eee3a..402db95d3 100644 --- a/src/pfr/pfrobjs.c +++ b/src/pfr/pfrobjs.c @@ -296,7 +296,7 @@ if ( load_flags & FT_LOAD_SBITS_ONLY ) { - error = FT_Err_Invalid_Argument; + error = PFR_Err_Invalid_Argument; goto Exit; } @@ -417,7 +417,7 @@ FT_UInt glyph2, FT_Vector* kerning ) { - FT_Error error = FT_Err_Ok; + FT_Error error = PFR_Err_Ok; PFR_PhyFont phy_font = &face->phy_font; PFR_KernItem item = phy_font->kern_items; FT_UInt32 idx = PFR_KERN_INDEX( glyph1, glyph2 ); diff --git a/src/pfr/pfrsbit.c b/src/pfr/pfrsbit.c index 5dabfe7be..84aeb7a04 100644 --- a/src/pfr/pfrsbit.c +++ b/src/pfr/pfrsbit.c @@ -508,7 +508,7 @@ default: FT_ERROR(( "pfr_read_bitmap_data: invalid image type\n" )); - error = FT_Err_Invalid_File_Format; + error = PFR_Err_Invalid_File_Format; } } @@ -560,7 +560,7 @@ } /* couldn't find it */ - return FT_Err_Invalid_Argument; + return PFR_Err_Invalid_Argument; } Found_Strike: @@ -593,7 +593,7 @@ if ( gps_size == 0 ) { /* Could not find a bitmap program string for this glyph */ - error = FT_Err_Invalid_Argument; + error = PFR_Err_Invalid_Argument; goto Exit; } } diff --git a/src/psaux/t1cmap.c b/src/psaux/t1cmap.c index 0ddd3f5da..3fdf2ee3c 100644 --- a/src/psaux/t1cmap.c +++ b/src/psaux/t1cmap.c @@ -20,6 +20,8 @@ #include FT_INTERNAL_DEBUG_H +#include "psauxerr.h" + /*************************************************************************/ /*************************************************************************/ @@ -320,7 +322,7 @@ { /* there are no unicode characters in here! */ FT_FREE( cmap->pairs ); - error = FT_Err_Invalid_Argument; + error = PSaux_Err_Invalid_Argument; } else { diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c index 21e82c3c8..3e76529ac 100644 --- a/src/pshinter/pshalgo.c +++ b/src/pshinter/pshalgo.c @@ -21,6 +21,8 @@ #include FT_INTERNAL_DEBUG_H #include "pshalgo.h" +#include "pshnterr.h" + #undef FT_COMPONENT #define FT_COMPONENT trace_pshalgo2 @@ -1900,7 +1902,7 @@ /* something to do? */ if ( outline->n_points == 0 || outline->n_contours == 0 ) - return FT_Err_Ok; + return PSH_Err_Ok; #ifdef DEBUG_HINTER diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c index a4b51fc28..dfcfee703 100644 --- a/src/pshinter/pshrec.c +++ b/src/pshinter/pshrec.c @@ -23,6 +23,8 @@ #include "pshrec.h" #include "pshalgo.h" +#include "pshnterr.h" + #undef FT_COMPONENT #define FT_COMPONENT trace_pshrec @@ -820,7 +822,7 @@ break; default: - hints->error = FT_Err_Invalid_Argument; + hints->error = PSH_Err_Invalid_Argument; hints->hint_type = hint_type; FT_ERROR(( "ps_hints_open: invalid charstring type!\n" )); @@ -934,7 +936,7 @@ else { FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type!\n" )); - error = FT_Err_Invalid_Argument; + error = PSH_Err_Invalid_Argument; goto Fail; } } @@ -975,7 +977,7 @@ else { /* invalid hint type */ - error = FT_Err_Invalid_Argument; + error = PSH_Err_Invalid_Argument; goto Fail; } } diff --git a/src/pshinter/rules.mk b/src/pshinter/rules.mk index be3257db4..57773394a 100644 --- a/src/pshinter/rules.mk +++ b/src/pshinter/rules.mk @@ -33,7 +33,8 @@ PSHINTER_DRV_SRC := $(PSHINTER_DIR)/pshrec.c \ # PSHINTER driver headers # -PSHINTER_DRV_H := $(PSHINTER_DRV_SRC:%c=%h) +PSHINTER_DRV_H := $(PSHINTER_DRV_SRC:%c=%h) \ + $(PSHINTER_DIR)/pshnterr.h # PSHINTER driver object(s) diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index f0be6e785..3b0c434c4 100644 --- a/src/psnames/psmodule.c +++ b/src/psnames/psmodule.c @@ -85,7 +85,7 @@ } /* there must be exactly four hex digits */ - if ( *p == '\0' && count == 0 ) + if ( ( *p == '\0' || *p == '.' ) && count == 0 ) return value; } @@ -120,7 +120,7 @@ value = ( value << 4 ) + d; } - if ( *p == '\0' && count <= 2 ) + if ( ( *p == '\0' || *p == '.' ) && count <= 2 ) return value; } diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 0e5f7e632..ea504bdd7 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -149,7 +149,7 @@ FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_win; FT_UInt len = name->stringLength / 2; - FT_Error error = FT_Err_Ok; + FT_Error error = SFNT_Err_Ok; FT_UNUSED( error ); @@ -191,7 +191,7 @@ FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_apple; FT_UInt len = name->stringLength; - FT_Error error = FT_Err_Ok; + FT_Error error = SFNT_Err_Ok; FT_UNUSED( error ); diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 4dac94ba6..86c125f80 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -258,7 +258,7 @@ { if ( rec->string == NULL ) { - FT_Error error = FT_Err_Ok; + FT_Error error = SFNT_Err_Ok; FT_Stream stream = face->name_table.stream; FT_UNUSED( error ); diff --git a/src/sfnt/ttcmap0.c b/src/sfnt/ttcmap0.c index 6c0e80eef..4c9dadfbb 100644 --- a/src/sfnt/ttcmap0.c +++ b/src/sfnt/ttcmap0.c @@ -1807,7 +1807,7 @@ if ( p + 4 > limit ) - return FT_Err_Invalid_Table; + return SFNT_Err_Invalid_Table; /* only recognize format 0 */ if ( TT_NEXT_USHORT( p ) != 0 ) @@ -1815,7 +1815,7 @@ p -= 2; FT_ERROR(( "tt_face_build_cmaps: unsupported `cmap' table format = %d\n", TT_PEEK_USHORT( p ) )); - return FT_Err_Invalid_Table; + return SFNT_Err_Invalid_Table; } num_cmaps = TT_NEXT_USHORT( p ); diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index f056bccbe..bea78d4f4 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -235,7 +235,7 @@ return error; Bad_Format: - error = FT_Err_Unknown_File_Format; + error = SFNT_Err_Unknown_File_Format; goto Exit; } diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index a269d0e83..638e406e8 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -242,11 +242,6 @@ /* A driver method used to reset a size's character sizes (horizontal */ /* and vertical) expressed in integer pixels. */ /* */ - /* */ - /* pixel_width :: The character width expressed in integer pixels. */ - /* */ - /* pixel_height :: The character height expressed in integer pixels. */ - /* */ /* */ /* size :: A handle to the target size object. */ /* */ @@ -254,13 +249,8 @@ /* FreeType error code. 0 means success. */ /* */ static FT_Error - Set_Pixel_Sizes( TT_Size size, - FT_UInt pixel_width, - FT_UInt pixel_height ) + Set_Pixel_Sizes( TT_Size size ) { - FT_UNUSED( pixel_width ); - FT_UNUSED( pixel_height ); - /* many things have been pre-computed by the base layer */ size->metrics = size->root.metrics; diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index deff1c05f..a8b82eee8 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -1681,7 +1681,7 @@ /* return immediately if we only want the embedded bitmaps */ if ( load_flags & FT_LOAD_SBITS_ONLY ) - return FT_Err_Invalid_Argument; + return TT_Err_Invalid_Argument; /* seek to the beginning of the glyph table. For Type 42 fonts */ /* the table might be accessed from a Postscript stream or something */ diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index 15848b300..44da0e5a6 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -554,7 +554,7 @@ T42_Face t42face = (T42_Face)face; - FT_Activate_Size(size->ttsize); + FT_Activate_Size( size->ttsize ); return FT_Set_Char_Size( t42face->ttf_face, char_width, @@ -573,7 +573,7 @@ T42_Face t42face = (T42_Face)face; - FT_Activate_Size(size->ttsize); + FT_Activate_Size( size->ttsize ); return FT_Set_Pixel_Sizes( t42face->ttf_face, pixel_width, diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index 5b754dd5d..70d097282 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -402,7 +402,6 @@ static FT_CMap_Class fnt_cmap_class = &fnt_cmap_class_rec; - static void FNT_Face_Done( FNT_Face face ) { @@ -495,6 +494,7 @@ { FT_CharMapRec charmap; + charmap.encoding = FT_ENCODING_UNICODE; charmap.platform_id = 3; charmap.encoding_id = 1; @@ -547,25 +547,41 @@ FNT_Face face = (FNT_Face)FT_SIZE_FACE( size ); FNT_Font cur = face->fonts; FNT_Font limit = cur + face->num_fonts; + FNT_Font hit; size->font = 0; + hit = 0; + for ( ; cur < limit; cur++ ) { - /* we only compare the character height, as fonts used some strange */ - /* values */ if ( cur->header.pixel_height == size->root.metrics.y_ppem ) { - size->font = cur; - - size->root.metrics.ascender = cur->header.ascent * 64; - size->root.metrics.descender = ( cur->header.pixel_height - - cur->header.ascent ) * 64; - size->root.metrics.height = cur->header.pixel_height * 64; + hit = cur; break; } } + /* try to find a better hit */ + for ( ; cur < limit; cur++ ) + { + if ( cur->header.pixel_height == size->root.metrics.y_ppem && + cur->header.pixel_width == size->root.metrics.x_ppem ) + { + hit = cur; + break; + } + } + + if ( hit ) { + size->font = hit; + size->root.metrics.ascender = hit->header.ascent * 64; + size->root.metrics.descender = ( hit->header.pixel_height - + hit->header.ascent ) * 64; + size->root.metrics.height = hit->header.pixel_height * 64; + size->root.metrics.max_advance = hit->header.max_width * 64; + } + return ( size->font ? FNT_Err_Ok : FNT_Err_Invalid_Pixel_Size ); } @@ -597,7 +613,8 @@ if ( glyph_index > 0 ) glyph_index--; else - glyph_index = font->header.default_char - font->header.first_char; + glyph_index = font->header.default_char; + glyph_index -= font->header.first_char; new_format = FT_BOOL( font->header.version == 0x300 ); len = new_format ? 6 : 4;