* src/pfr/pfrload.c (pfr_extra_item_load_font_id): Use FT_PtrDist
instead of FT_Uint for `len'. Cleanups.
This commit is contained in:
parent
004615e3d0
commit
2e57343f90
48
ChangeLog
48
ChangeLog
|
@ -1,3 +1,8 @@
|
|||
2003-04-23 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
* src/pfr/pfrload.c (pfr_extra_item_load_font_id): Use FT_PtrDist
|
||||
instead of FT_Uint for `len'.
|
||||
|
||||
2003-04-22 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
* src/gzip/ftgzip.c (zcalloc) [!FT_CONFIG_OPTION_SYSTEM_ZLIB]:
|
||||
|
@ -92,7 +97,10 @@
|
|||
Use `ft_glyphslot_*' functions.
|
||||
Don't set `FT_GLYPH_OWN_BITMAP'.
|
||||
|
||||
* src/pfr/pfrsbit.c, src/sfnt/ttsbit.c, src/type42/t42objs.c,
|
||||
* src/pfr/pfrsbit.c (pfr_slot_load_bitmap): Use
|
||||
`ft_glyphslot_alloc_bitmap'.
|
||||
|
||||
* src/sfnt/ttsbit.c, src/type42/t42objs.c,
|
||||
src/winfonts/winfnt.c:
|
||||
|
||||
* src/cache/ftlru.c (FT_LruList_Lookup): Fixed an invalid assertion
|
||||
|
@ -143,8 +151,8 @@
|
|||
* src/cache/ftlru.c: Include FT_INTERNAL_DEBUG_H.
|
||||
(FT_LruList_Lookup): Implement loop.
|
||||
|
||||
* src/pfr/pfrobjs.c, src/pfr/pfrsbits.c: Fixing compiler warnings
|
||||
and a small memory leak.
|
||||
* src/pfr/pfrobjs.c (pfr_face_done): Fix memory leak.
|
||||
(pfr_face_init): Fixing compiler warnings.
|
||||
|
||||
* src/psaux/psobjs.c (t1_reallocate_table): Fixed a bug (memory
|
||||
leak) that only happened when a try to resize an array would end in
|
||||
|
@ -178,8 +186,7 @@
|
|||
|
||||
touch 0123456789 ; gzip 0123456789 ; ftdump 0123456789.gz
|
||||
|
||||
* src/pfr/pfrobjs.c, src/pfr/pfrload.c, src/pfr/pfrtypes.h: Several
|
||||
fixes to the PFR font driver:
|
||||
Several fixes to the PFR font driver:
|
||||
|
||||
- The list of available embedded bitmaps was not correctly set in
|
||||
the root FT_FaceRec structure describing the face.
|
||||
|
@ -193,6 +200,20 @@
|
|||
|
||||
NOTE THAT THESE CHANGES THE FAMILY NAME OF MANY PFR FONTS!
|
||||
|
||||
* src/pfr/pfrload.c (pfr_aux_name_load): New function.
|
||||
(pfr_phy_font_done): Free `family_name' and `style_name' also.
|
||||
Remove unused variables.
|
||||
(pfr_phy_font_load): Extract useful information from the auxiliary
|
||||
bytes.
|
||||
|
||||
* src/pfr/pfrobjs.c (pfr_face_done): Set pointers to NULL.
|
||||
(pfr_face_init): Provide fallback values for `family_name' and
|
||||
`style_name'.
|
||||
Handle strikes.
|
||||
(pfr_slot_load): Handle FT_LOAD_SBITS_ONLY.
|
||||
* src/pfr/pfrtypes.h (PFR_PhyFontRec): Add fields `ascent',
|
||||
`descent', `leading', `family_name', and `style_name'.
|
||||
|
||||
* src/truetype/ttdriver.c (Set_Char_Sizes): Fixed a rounding bug
|
||||
when computing the scale factors for a given character size in
|
||||
points with resolution.
|
||||
|
@ -587,7 +608,7 @@
|
|||
* src/sfnt/ttcmap0.c (tt_face_build_cmaps): Removed compiler
|
||||
warnings in optimized mode relative to the "volatile" local
|
||||
variables. This was not a compiler bug after all, but the fact that
|
||||
a pointer to a volatile variable is not the same than a volatile
|
||||
a pointer to a volatile variable is not the same as a volatile
|
||||
pointer to a variable :-)
|
||||
|
||||
The fix was to change
|
||||
|
@ -595,8 +616,9 @@
|
|||
into
|
||||
`FT_Byte* volatile p'.
|
||||
|
||||
* src/pfr/pfrload.c, src/pfr/pfrdrivr.c, src/gzip/inftrees.c:
|
||||
Removed compiler warnings in optimized modes.
|
||||
* src/pfr/pfrload.c (pfr_phy_font_load), src/pfr/pfrdrivr.c
|
||||
(pfr_get_metrics), src/gzip/inftrees.c: Removed compiler warnings in
|
||||
optimized modes.
|
||||
|
||||
* src/gzip/*.[hc]: Modified our zlib copy in order to prevent
|
||||
exporting any zlib function names outside of the component. This
|
||||
|
@ -620,10 +642,16 @@
|
|||
* include/freetype/internal/internal.h (FT_INTERNAL_PFR_H): New
|
||||
macro for pfr.h.
|
||||
|
||||
src/base/ftpfr.c: New file.
|
||||
|
||||
* src/base/ftpfr.c: New file.
|
||||
* src/base/Jamfile, src/base/descrip.mms: Updated.
|
||||
|
||||
* src/pfr/pfrdrivr.c: Include FT_INTERNAL_PFR_H.
|
||||
(pfr_get_kerning, pfr_get_advance, pfr_get_metrics): New functions.
|
||||
(pfr_service_rec): New format interface.
|
||||
(pfr_driver_class): Use `pfr_service_rec'.
|
||||
Replace `pfr_face_get_kerning' with `pfr_get_kerning'.
|
||||
* src/pfr/pfrobjs.c: Remove dead code.
|
||||
|
||||
* src/base/ftobjs.c (ft_glyphslot_clear): Small internal fix to
|
||||
better support bitmap-based font formats.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType PFR driver interface (body). */
|
||||
/* */
|
||||
/* Copyright 2002 by */
|
||||
/* Copyright 2002, 2003 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -32,11 +32,13 @@
|
|||
{
|
||||
FT_Error error;
|
||||
|
||||
|
||||
error = pfr_face_get_kerning( face, left, right, avector );
|
||||
if ( !error )
|
||||
{
|
||||
PFR_PhyFont phys = &face->phy_font;
|
||||
|
||||
|
||||
/* convert from metrics to outline units when necessary */
|
||||
if ( phys->outline_resolution != phys->metrics_resolution )
|
||||
{
|
||||
|
@ -49,6 +51,7 @@
|
|||
phys->metrics_resolution );
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
@ -58,13 +61,15 @@
|
|||
FT_UInt gindex,
|
||||
FT_Pos *aadvance )
|
||||
{
|
||||
FT_Error error = FT_Err_Bad_Argument;
|
||||
FT_Error error = FT_Err_Bad_Argument;
|
||||
|
||||
|
||||
*aadvance = 0;
|
||||
if ( face )
|
||||
{
|
||||
PFR_PhyFont phys = &face->phy_font;
|
||||
|
||||
|
||||
if ( gindex < phys->num_chars )
|
||||
{
|
||||
*aadvance = phys->chars[ gindex ].advance;
|
||||
|
@ -87,6 +92,7 @@
|
|||
FT_Fixed x_scale, y_scale;
|
||||
FT_Size size = face->root.size;
|
||||
|
||||
|
||||
if ( aoutline_resolution )
|
||||
*aoutline_resolution = phys->outline_resolution;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType PFR loader (body). */
|
||||
/* */
|
||||
/* Copyright 2002 by */
|
||||
/* Copyright 2002, 2003 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -153,7 +153,7 @@
|
|||
pfr_header_load( PFR_Header header,
|
||||
FT_Stream stream )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_Error error;
|
||||
|
||||
|
||||
/* read header directly */
|
||||
|
@ -201,9 +201,9 @@
|
|||
FT_UInt32 section_offset,
|
||||
FT_UInt *acount )
|
||||
{
|
||||
FT_Error error;
|
||||
FT_UInt count;
|
||||
FT_UInt result = 0;
|
||||
FT_Error error;
|
||||
FT_UInt count;
|
||||
FT_UInt result = 0;
|
||||
|
||||
|
||||
if ( FT_STREAM_SEEK( section_offset ) || FT_READ_USHORT( count ) )
|
||||
|
@ -239,8 +239,8 @@
|
|||
return PFR_Err_Invalid_Argument;
|
||||
|
||||
if ( FT_STREAM_SKIP( idx * 5 ) ||
|
||||
FT_READ_USHORT( size ) ||
|
||||
FT_READ_UOFF3 ( offset ) )
|
||||
FT_READ_USHORT( size ) ||
|
||||
FT_READ_UOFF3 ( offset ) )
|
||||
goto Exit;
|
||||
|
||||
/* save logical font size and offset */
|
||||
|
@ -365,7 +365,8 @@
|
|||
/* re-allocate when needed */
|
||||
if ( phy_font->num_strikes + count > phy_font->max_strikes )
|
||||
{
|
||||
FT_UInt new_max = (phy_font->num_strikes + count + 3) & -4;
|
||||
FT_UInt new_max = ( phy_font->num_strikes + count + 3 ) & -4;
|
||||
|
||||
|
||||
if ( FT_RENEW_ARRAY( phy_font->strikes,
|
||||
phy_font->num_strikes,
|
||||
|
@ -432,30 +433,30 @@
|
|||
}
|
||||
|
||||
|
||||
/* load font ID, this is a so-called "unique" name that is rather
|
||||
* long and descriptive (like "Tiresias ScreenFont v7.51").
|
||||
*
|
||||
* note that a PFR font's family name is contained in an *undocumented*
|
||||
* string of the "auxiliary data" portion of a physical font record. this
|
||||
* may also contain the "real" style name !
|
||||
*
|
||||
* if no family name is present, the font id is used instead for the
|
||||
* family
|
||||
*/
|
||||
/* Load font ID. This is a so-called "unique" name that is rather
|
||||
* long and descriptive (like "Tiresias ScreenFont v7.51").
|
||||
*
|
||||
* Note that a PFR font's family name is contained in an *undocumented*
|
||||
* string of the "auxiliary data" portion of a physical font record. This
|
||||
* may also contain the "real" style name!
|
||||
*
|
||||
* If no family name is present, the font ID is used instead for the
|
||||
* family.
|
||||
*/
|
||||
FT_CALLBACK_DEF( FT_Error )
|
||||
pfr_extra_item_load_font_id( FT_Byte* p,
|
||||
FT_Byte* limit,
|
||||
PFR_PhyFont phy_font )
|
||||
{
|
||||
FT_Error error = 0;
|
||||
FT_Memory memory = phy_font->memory;
|
||||
FT_UInt len = (FT_UInt)( limit - p );
|
||||
FT_Error error = 0;
|
||||
FT_Memory memory = phy_font->memory;
|
||||
FT_PtrDist len = limit - p;
|
||||
|
||||
|
||||
if ( phy_font->font_id != NULL )
|
||||
goto Exit;
|
||||
|
||||
if ( FT_ALLOC( phy_font->font_id, len+1 ) )
|
||||
if ( FT_ALLOC( phy_font->font_id, len + 1 ) )
|
||||
goto Exit;
|
||||
|
||||
/* copy font ID name, and terminate it for safety */
|
||||
|
@ -702,9 +703,9 @@
|
|||
};
|
||||
|
||||
|
||||
/* loads a name from the auxiliary data. Since this extracts undocumented
|
||||
* strings from the font file, we need to be careful here
|
||||
*/
|
||||
/* Loads a name from the auxiliary data. Since this extracts undocumented
|
||||
* strings from the font file, we need to be careful here.
|
||||
*/
|
||||
static FT_Error
|
||||
pfr_aux_name_load( FT_Byte* p,
|
||||
FT_UInt len,
|
||||
|
@ -715,13 +716,14 @@
|
|||
FT_String* result = NULL;
|
||||
FT_UInt n, ok;
|
||||
|
||||
if ( len > 0 && p[len-1] == 0 )
|
||||
|
||||
if ( len > 0 && p[len - 1] == 0 )
|
||||
len--;
|
||||
|
||||
/* check that each character is ASCII, that's to be sure
|
||||
* to not load garbage..
|
||||
*/
|
||||
ok = (len > 0);
|
||||
/* check that each character is ASCII for making sure not to
|
||||
load garbage
|
||||
*/
|
||||
ok = ( len > 0 );
|
||||
for ( n = 0; n < len; n++ )
|
||||
if ( p[n] < 32 || p[n] > 127 )
|
||||
{
|
||||
|
@ -731,7 +733,7 @@
|
|||
|
||||
if ( ok )
|
||||
{
|
||||
if ( FT_ALLOC( result, len+1 ) )
|
||||
if ( FT_ALLOC( result, len + 1 ) )
|
||||
goto Exit;
|
||||
|
||||
FT_MEM_COPY( result, p, len );
|
||||
|
@ -787,7 +789,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
FT_LOCAL_DEF( FT_Error )
|
||||
pfr_phy_font_load( PFR_PhyFont phy_font,
|
||||
FT_Stream stream,
|
||||
|
@ -842,9 +843,9 @@
|
|||
goto Fail;
|
||||
}
|
||||
|
||||
/* in certain fonts, the auxiliary bytes contain interesting */
|
||||
/* In certain fonts, the auxiliary bytes contain interesting */
|
||||
/* information. These are not in the specification but can be */
|
||||
/* guessed by looking at the content of a few PFR0 fonts */
|
||||
/* guessed by looking at the content of a few PFR0 fonts. */
|
||||
PFR_CHECK( 3 );
|
||||
num_aux = PFR_NEXT_ULONG( p );
|
||||
|
||||
|
@ -853,6 +854,7 @@
|
|||
FT_Byte* q = p;
|
||||
FT_Byte* q2;
|
||||
|
||||
|
||||
PFR_CHECK( num_aux );
|
||||
p += num_aux;
|
||||
|
||||
|
@ -860,58 +862,54 @@
|
|||
{
|
||||
FT_UInt length, type;
|
||||
|
||||
|
||||
if ( q + 4 > p )
|
||||
break;
|
||||
|
||||
length = PFR_NEXT_USHORT(q);
|
||||
length = PFR_NEXT_USHORT( q );
|
||||
if ( length < 4 || length > num_aux )
|
||||
break;
|
||||
|
||||
q2 = q + length - 2;
|
||||
type = PFR_NEXT_USHORT(q);
|
||||
type = PFR_NEXT_USHORT( q );
|
||||
|
||||
switch ( type )
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
/* this seems to correspond to the font's family name,
|
||||
* padded to 16-bits with one zero when necessary
|
||||
*/
|
||||
error = pfr_aux_name_load( q, length-4U, memory,
|
||||
&phy_font->family_name );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
case 1:
|
||||
/* this seems to correspond to the font's family name,
|
||||
* padded to 16-bits with one zero when necessary
|
||||
*/
|
||||
error = pfr_aux_name_load( q, length - 4U, memory,
|
||||
&phy_font->family_name );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ( q + 32 > q2 )
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
if ( q + 32 > q2 )
|
||||
break;
|
||||
q += 10;
|
||||
phy_font->ascent = PFR_NEXT_SHORT( q );
|
||||
phy_font->descent = PFR_NEXT_SHORT( q );
|
||||
phy_font->leading = PFR_NEXT_SHORT( q );
|
||||
q += 16;
|
||||
break;
|
||||
|
||||
q += 10;
|
||||
phy_font->ascent = PFR_NEXT_SHORT(q);
|
||||
phy_font->descent = PFR_NEXT_SHORT(q);
|
||||
phy_font->leading = PFR_NEXT_SHORT(q);
|
||||
q += 16;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
/* this seems to correspond to the font's style name,
|
||||
* padded to 16-bits with one zero when necessary
|
||||
*/
|
||||
error = pfr_aux_name_load( q, length - 4U, memory,
|
||||
&phy_font->style_name );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
{
|
||||
/* this seems to correspond to the font's style name,
|
||||
* padded to 16-bits with one zero when necessary
|
||||
*/
|
||||
error = pfr_aux_name_load( q, length-4U, memory,
|
||||
&phy_font->style_name );
|
||||
if ( error )
|
||||
goto Exit;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
default:
|
||||
;
|
||||
}
|
||||
|
||||
q = q2;
|
||||
num_aux -= length;
|
||||
}
|
||||
|
@ -921,6 +919,7 @@
|
|||
{
|
||||
FT_UInt n, count;
|
||||
|
||||
|
||||
PFR_CHECK( 1 );
|
||||
phy_font->num_blue_values = count = PFR_NEXT_BYTE( p );
|
||||
|
||||
|
@ -1000,7 +999,8 @@
|
|||
}
|
||||
}
|
||||
|
||||
/* that's it !! */
|
||||
/* that's it! */
|
||||
|
||||
Fail:
|
||||
FT_FRAME_EXIT();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType PFR object methods (body). */
|
||||
/* */
|
||||
/* Copyright 2002 by */
|
||||
/* Copyright 2002, 2003 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -41,7 +41,8 @@
|
|||
FT_LOCAL_DEF( void )
|
||||
pfr_face_done( PFR_Face face )
|
||||
{
|
||||
FT_Memory memory = face->root.driver->root.memory;
|
||||
FT_Memory memory = face->root.driver->root.memory;
|
||||
|
||||
|
||||
/* we don't want dangling pointers */
|
||||
face->root.family_name = NULL;
|
||||
|
@ -143,18 +144,18 @@
|
|||
if ( phy_font->num_kern_pairs > 0 )
|
||||
root->face_flags |= FT_FACE_FLAG_KERNING;
|
||||
|
||||
/* if no family name was found in the "undocumented" auxiliary
|
||||
* data, use the font ID instead. This sucks but is better than
|
||||
* nothing
|
||||
*/
|
||||
/* If no family name was found in the "undocumented" auxiliary
|
||||
* data, use the font ID instead. This sucks but is better than
|
||||
* nothing.
|
||||
*/
|
||||
root->family_name = phy_font->family_name;
|
||||
if ( root->family_name == NULL )
|
||||
root->family_name = phy_font->font_id;
|
||||
|
||||
/* note that the style name can be NULL in certain PFR fonts,
|
||||
* probably meaning "Regular"
|
||||
*/
|
||||
root->style_name = phy_font->style_name;
|
||||
/* note that the style name can be NULL in certain PFR fonts,
|
||||
* probably meaning "Regular"
|
||||
*/
|
||||
root->style_name = phy_font->style_name;
|
||||
|
||||
root->num_fixed_sizes = 0;
|
||||
root->available_sizes = 0;
|
||||
|
@ -182,8 +183,8 @@
|
|||
strike = phy_font->strikes;
|
||||
for ( n = 0; n < count; n++, size++, strike++ )
|
||||
{
|
||||
size->height = (FT_UShort) strike->y_ppm;
|
||||
size->width = (FT_UShort) strike->x_ppm;
|
||||
size->height = (FT_UShort)strike->y_ppm;
|
||||
size->width = (FT_UShort)strike->x_ppm;
|
||||
}
|
||||
root->num_fixed_sizes = count;
|
||||
}
|
||||
|
@ -279,7 +280,8 @@
|
|||
FT_Outline* outline = &slot->root.outline;
|
||||
FT_ULong gps_offset;
|
||||
|
||||
if (gindex > 0)
|
||||
|
||||
if ( gindex > 0 )
|
||||
gindex--;
|
||||
|
||||
/* check that the glyph index is correct */
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType PFR bitmap loader (body). */
|
||||
/* */
|
||||
/* Copyright 2002 by */
|
||||
/* Copyright 2002, 2003 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
@ -115,7 +115,7 @@
|
|||
}
|
||||
|
||||
if ( mask != 0x80 )
|
||||
cur[0] = (FT_Byte) c;
|
||||
cur[0] = (FT_Byte)c;
|
||||
}
|
||||
|
||||
|
||||
|
@ -185,7 +185,7 @@
|
|||
}
|
||||
else if ( mask == 0 )
|
||||
{
|
||||
cur[0] = (FT_Byte) c;
|
||||
cur[0] = (FT_Byte)c;
|
||||
mask = 0x80;
|
||||
c = 0;
|
||||
cur ++;
|
||||
|
@ -249,7 +249,7 @@
|
|||
}
|
||||
else if ( mask == 0 )
|
||||
{
|
||||
cur[0] = (FT_Byte) c;
|
||||
cur[0] = (FT_Byte)c;
|
||||
c = 0;
|
||||
mask = 0x80;
|
||||
cur ++;
|
||||
|
@ -583,7 +583,7 @@
|
|||
pfr_lookup_bitmap_data( stream->cursor,
|
||||
stream->limit,
|
||||
strike->num_bitmaps,
|
||||
(FT_Byte) strike->flags,
|
||||
(FT_Byte)strike->flags,
|
||||
character->char_code,
|
||||
&gps_offset,
|
||||
&gps_size );
|
||||
|
@ -645,7 +645,8 @@
|
|||
|
||||
/* Allocate and read bitmap data */
|
||||
{
|
||||
FT_ULong len = glyph->root.bitmap.pitch * ysize;
|
||||
FT_ULong len = glyph->root.bitmap.pitch * ysize;
|
||||
|
||||
|
||||
error = ft_glyphslot_alloc_bitmap( &glyph->root, len );
|
||||
if ( !error )
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* FreeType PFR data structures (specification only). */
|
||||
/* */
|
||||
/* Copyright 2002 by */
|
||||
/* Copyright 2002, 2003 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
|
|
Loading…
Reference in New Issue