From 960ba59ad95d67c56df4bf22aa1881c48548b2ee Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Fri, 1 Dec 2006 08:20:47 +0000 Subject: [PATCH] * src/sfnt/sfobjs.c (tt_face_get_name): All Unicode strings are encoded in UTF-16BE. Patch from Rajeev Pahuja . (tt_name_entry_ascii_from_ucs4): Removed. * include/freetype/ftxf86.h: Fix and extend comment so that it appears in the documentation. * include/freetype/ftchapters.h: Add `font_format' section. * src/tools/docmaker/tohtml.py (HtmlFormatter::index_exit): Add link to TOC in index page. Formatting. --- ChangeLog | 59 +++++++++++++++++------ include/freetype/config/ftoption.h | 2 +- include/freetype/ftchapters.h | 1 + include/freetype/ftlcdfil.h | 4 +- include/freetype/ftxf86.h | 42 ++++++++++++----- src/autofit/afhints.c | 21 +++++---- src/autofit/afhints.h | 2 +- src/autofit/aflatin.c | 75 +++++++++++++++++------------- src/sfnt/sfobjs.c | 37 +-------------- src/smooth/ftgrays.c | 16 +++---- src/tools/docmaker/tohtml.py | 18 ++++++- 11 files changed, 162 insertions(+), 115 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cb6e1a87..463c3fb05 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,30 +1,61 @@ -2006-11-28 David Turner +2006-12-01 Werner Lemberg - * src/smooth/ftgrays.c (gray_raster_render): return 0 when we're - trying to rendering into a zero-width/height bitmap, instead of an - error code. + * src/sfnt/sfobjs.c (tt_face_get_name): All Unicode strings are + encoded in UTF-16BE. Patch from Rajeev Pahuja . + (tt_name_entry_ascii_from_ucs4): Removed. - * src/truetype/ttobjs.c (tt_face_init): Fix typo in previous patch - * src/smooth/ftgrays.c: remove hard-coded error values, use FreeType - ones instead + * include/freetype/ftxf86.h: Fix and extend comment so that it + appears in the documentation. - * src/autofit/afhints.c (af_glyph_hints_dump_segments): remove unused - variable + * include/freetype/ftchapters.h: Add `font_format' section. + + + * src/tools/docmaker/tohtml.py (HtmlFormatter::index_exit): Add link + to TOC in index page. + +2006-11-28 David Turner + + * src/smooth/ftgrays.c (gray_raster_render): Return 0 when we are + trying to render into a zero-width/height bitmap, not an error code. + + * src/truetype/ttobjs.c (tt_face_init): Fix typo in previous patch. + + * src/smooth/ftgrays.c: Remove hard-coded error values; use FreeType + ones instead. + + * src/autofit/afhints.c (af_glyph_hints_dump_segments): Remove unused + variable. 2006-11-26 Pierre Hanser * src/truetype/ttobjs.c (tt_face_init): Protect against NULL pointer. -2006-11-25 David Turner +2006-11-25 David Turner - * src/autofit/afhints.c: add stubs to link the "ftgrid" test program - when debugging is disabled in the auto-hinter + * src/autofit/afhints.c (af_glyph_hints_dump_points, + af_glyph_hints_dump_segments, af_glyph_hints_dumpedges) [!AF_DEBUG]: + Add stubs to link the `ftgrid' test program when debugging is + disabled in the auto-hinter. -2006-11-23 David Turner +2006-11-23 David Turner * src/autofit/afhints.c, src/autofit/afhints.h, src/autofit/aflatin.c, - src/autofit/aftypes.h: Misc. auto-hinter improvements + src/autofit/aftypes.h: Miscellaneous auto-hinter improvements. + + * src/autofit/afhints.c (af_glyph_hints_dump_segments) [AF_DEBUG]: + Emit more sensible information. + + * src/autofit/afhints.h (AF_SegmentRec): Add `height' member. + + * src/autofit/aflatin.c (af_latin_metrics_scale_dim): Improve + rounding of blue values. + (af_latin_hints_compute_segments): Hint segment heights. + (af_latin_hints_link_segments): Reduce `len_score' value. + (af_latin_hints_compute_edges): Increase `segment_length_threshold' + value and use `height' member for comparisons. + (af_latin_hint_edges): Extend logging message. + Improve handling of remaining edges. 2006-11-22 Werner Lemberg diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index c6caa1b71..c590ddc83 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -77,7 +77,7 @@ FT_BEGIN_HEADER /*************************************************************************/ /* */ - /* Uncomment the line below if you want to active sub-pixel rendering */ + /* Uncomment the line below if you want to activate sub-pixel rendering */ /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */ /* */ /* Note that this feature is covered by several Microsoft patents */ diff --git a/include/freetype/ftchapters.h b/include/freetype/ftchapters.h index 477daa5b9..f950cee80 100644 --- a/include/freetype/ftchapters.h +++ b/include/freetype/ftchapters.h @@ -56,6 +56,7 @@ /* bdf_fonts */ /* pfr_fonts */ /* winfnt_fonts */ +/* font_formats */ /* */ /***************************************************************************/ diff --git a/include/freetype/ftlcdfil.h b/include/freetype/ftlcdfil.h index 3a311d413..a6559da7a 100644 --- a/include/freetype/ftlcdfil.h +++ b/include/freetype/ftlcdfil.h @@ -102,13 +102,13 @@ FT_BEGIN_HEADER * @FT_LCD_FILTER_NONE in order to enable it. * * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning @FT_Err_Unimplemented_Feature if the + * do anything except returning `FT_Err_Unimplemented_Feature' if the * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not * defined in your build of the library, which should correspond to all * default builds of the library. * * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, - * @FT_Glyph_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char. + * @FT_Outline_Get_Bitmap, @FT_Load_Glyph, and @FT_Load_Char. * * It does _not_ affect the output of @FT_Outline_Render and * @FT_Outline_Get_Bitmap. diff --git a/include/freetype/ftxf86.h b/include/freetype/ftxf86.h index 3362883cb..bf1c6938c 100644 --- a/include/freetype/ftxf86.h +++ b/include/freetype/ftxf86.h @@ -4,7 +4,7 @@ /* */ /* Support functions for X11. */ /* */ -/* Copyright 2002, 2003, 2004 by */ +/* Copyright 2002, 2003, 2004, 2006 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -31,24 +31,44 @@ FT_BEGIN_HEADER - /* this comment is intentionally disabled for now, to prevent this */ - /* function from appearing in the API Reference. */ - /*@***********************************************************************/ + /*************************************************************************/ /* */ - /* */ - /* FT_Get_X11_Font_Format */ + /*
*/ + /* font_formats */ + /* */ + /* */ + /* Font Formats */ + /* */ + /* <Abstract> */ + /* Getting the font format. */ /* */ /* <Description> */ - /* Return a string describing the format of a given face as an X11 */ - /* FONT_PROPERTY. It should only be used by the FreeType 2 font */ - /* backend of the XFree86 font server. */ + /* The single function in this section can be used to get the font */ + /* format. Note that this information is not needed normally; */ + /* however, there are special cases (like in PDF devices) where it is */ + /* important to differentiate, inspite of FreeType's uniform API. */ + /* */ + /*************************************************************************/ + + + /*************************************************************************/ + /* */ + /* <Function> */ + /* FT_Get_X11_Font_Format */ + /* */ + /* <Description> */ + /* Return a string describing the format of a given face, using values */ + /* which can be used as an X11 FONT_PROPERTY. Possible values are */ + /* `TrueType', `Type 1', `BDF', `PCF', `Type 42', `CID Type 1', `CFF', */ + /* `PFR', and `Windows FNT'. */ /* */ /* <Input> */ - /* face :: Input face handle. */ + /* face :: */ + /* Input face handle. */ /* */ /* <Return> */ - /* Font format string. NULL in case of error. */ + /* Font format string. NULL in case of error. */ /* */ FT_EXPORT( const char* ) FT_Get_X11_Font_Format( FT_Face face ); diff --git a/src/autofit/afhints.c b/src/autofit/afhints.c index 264a70b24..d682ddbd4 100644 --- a/src/autofit/afhints.c +++ b/src/autofit/afhints.c @@ -216,7 +216,7 @@ AF_INDEX_NUM( seg->link, segments ), AF_INDEX_NUM( seg->serif, segments ), seg->height, - seg->height - (seg->max_coord - seg->min_coord) ); + seg->height - ( seg->max_coord - seg->min_coord ) ); } printf( "\n" ); } @@ -263,29 +263,32 @@ } } -#else - /* these empty stubs are only used to link the "ftgrid" test program - * when debugging is disabled - */ +#else /* !AF_DEBUG */ + + /* these empty stubs are only used to link the `ftgrid' test program */ + /* when debugging is disabled */ + void af_glyph_hints_dump_points( AF_GlyphHints hints ) { - FT_UNUSED(hints); + FT_UNUSED( hints ); } + void af_glyph_hints_dump_segments( AF_GlyphHints hints ) { - FT_UNUSED(hints); + FT_UNUSED( hints ); } + void af_glyph_hints_dump_edges( AF_GlyphHints hints ) { - FT_UNUSED(hints); + FT_UNUSED( hints ); } -#endif /* AF_DEBUG */ +#endif /* !AF_DEBUG */ /* compute the direction value of a given vector */ diff --git a/src/autofit/afhints.h b/src/autofit/afhints.h index 3bde12fc9..c889aad76 100644 --- a/src/autofit/afhints.h +++ b/src/autofit/afhints.h @@ -125,7 +125,7 @@ FT_BEGIN_HEADER FT_Short pos; /* position of segment */ FT_Short min_coord; /* minimum coordinate of segment */ FT_Short max_coord; /* maximum coordinate of segment */ - FT_Short height; + FT_Short height; /* the hinted segment height */ AF_Edge edge; /* the segment's parent edge */ AF_Segment edge_next; /* link to next segment in parent edge */ diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c index 91391fc6b..c97fc620e 100644 --- a/src/autofit/aflatin.c +++ b/src/autofit/aflatin.c @@ -471,7 +471,7 @@ if ( blue ) { FT_Pos scaled = FT_MulFix( blue->shoot.org, scaler->y_scale ); - FT_Pos fitted = (scaled + 40) & ~63; + FT_Pos fitted = ( scaled + 40 ) & ~63; if ( scaled != fitted ) @@ -772,20 +772,21 @@ } /* contours */ - /* now slightly increase the height of segments when this makes sense - * this is used to better detect and ignore serifs - */ + /* now slightly increase the height of segments when this makes */ + /* sense -- this is used to better detect and ignore serifs */ { - AF_Segment segments = axis->segments; + AF_Segment segments = axis->segments; AF_Segment segments_end = segments + axis->num_segments; + for ( segment = segments; segment < segments_end; segment++ ) { - AF_Point first = segment->first; - AF_Point last = segment->last; + AF_Point first = segment->first; + AF_Point last = segment->last; FT_Pos first_v = first->v; FT_Pos last_v = last->v; + if ( first == last ) continue; @@ -793,25 +794,27 @@ { AF_Point p; + p = first->prev; if ( p->v < first_v ) - segment->height += (first_v - p->v) >> 1; + segment->height += ( first_v - p->v ) >> 1; p = last->next; if ( p->v > last_v ) - segment->height += (p->v - last_v) >> 1; + segment->height += ( p->v - last_v ) >> 1; } else { AF_Point p; + p = first->prev; if ( p->v > first_v ) - segment->height += (p->v - first_v) >> 1; + segment->height += ( p->v - first_v ) >> 1; p = last->next; if ( p->v < last_v ) - segment->height += (last_v - p->v) >> 1; + segment->height += ( last_v - p->v ) >> 1; } } } @@ -1841,9 +1844,11 @@ else edge->pos = FT_PIX_ROUND( edge->opos ); - AF_LOG(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f) snapped to (%.2f) (%.2f)\n", - edge-edges, edge->opos / 64., edge2-edges, edge2->opos/64., - edge->pos / 64., edge2->pos / 64. )); + AF_LOG(( "ANCHOR: edge %d (opos=%.2f) and %d (opos=%.2f) " + "snapped to (%.2f) (%.2f)\n", + edge-edges, edge->opos / 64.0, + edge2-edges, edge2->opos / 64.0, + edge->pos / 64.0, edge2->pos / 64.0 )); anchor = edge; edge->flags |= AF_EDGE_DONE; @@ -2020,10 +2025,12 @@ { FT_Pos delta; + if ( edge->flags & AF_EDGE_DONE ) continue; delta = 1000; + if ( edge->serif ) { delta = edge->serif->opos - edge->opos; @@ -2031,45 +2038,49 @@ delta = -delta; } - if ( delta < 64+16 ) + if ( delta < 64 + 16 ) { af_latin_align_serif_edge( hints, edge->serif, edge ); - AF_LOG(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f) aligned to (%.2f)\n", edge-edges, - edge->opos/64., edge->serif - edges, edge->serif->opos/64., edge->pos/64.0 )); + AF_LOG(( "SERIF: edge %d (opos=%.2f) serif to %d (opos=%.2f) " + "aligned to (%.2f)\n", + edge-edges, edge->opos / 64.0, + edge->serif - edges, edge->serif->opos / 64.0, + edge->pos / 64.0 )); } else if ( !anchor ) { AF_LOG(( "SERIF_ANCHOR: edge %d (opos=%.2f) snapped to (%.2f)\n", - edge-edges, edge->opos/64., edge->pos/64. )); + edge-edges, edge->opos / 64.0, edge->pos / 64.0 )); edge->pos = FT_PIX_ROUND( edge->opos ); anchor = edge; } else { - AF_Edge before, after; + AF_Edge before, after; - for ( before = edge-1; before >= edges; before-- ) + + for ( before = edge - 1; before >= edges; before-- ) if ( before->flags & AF_EDGE_DONE ) - break; + break; - for ( after = edge+1; after < edge_limit; after++ ) + for ( after = edge + 1; after < edge_limit; after++ ) if ( after->flags & AF_EDGE_DONE ) - break; + break; - if ( before >= edges && before < edge && - after < edge_limit && after > edge ) - { - edge->pos = before->pos + FT_MulDiv( edge->opos - before->opos, - after->pos - before->pos, - after->opos - before->opos ); - } + if ( before >= edges && before < edge && + after < edge_limit && after > edge ) + edge->pos = before->pos + + FT_MulDiv( edge->opos - before->opos, + after->pos - before->pos, + after->opos - before->opos ); else - edge->pos = anchor->pos + + edge->pos = anchor->pos + FT_PIX_ROUND( edge->opos - anchor->opos ); AF_LOG(( "SERIF_LINK: edge %d (opos=%.2f) snapped to (%.2f)\n", - edge-edges, edge->opos/64., edge->pos/64. )); + edge-edges, edge->opos / 64.0, edge->pos / 64.0 )); } + edge->flags |= AF_EDGE_DONE; if ( edge > edges && edge->pos < edge[-1].pos ) diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 0b9a6e705..32a5848b7 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -75,37 +75,6 @@ } - /* convert a UCS-4 name entry to ASCII */ - static FT_String* - tt_name_entry_ascii_from_ucs4( TT_NameEntry entry, - FT_Memory memory ) - { - FT_String* string; - FT_UInt len, code, n; - FT_Byte* read = (FT_Byte*)entry->string; - FT_Error error; - - - len = (FT_UInt)entry->stringLength / 4; - - if ( FT_NEW_ARRAY( string, len + 1 ) ) - return NULL; - - for ( n = 0; n < len; n++ ) - { - code = (FT_UInt)FT_NEXT_ULONG( read ); - if ( code < 32 || code > 127 ) - code = '?'; - - string[n] = (char)code; - } - - string[len] = 0; - - return string; - } - - /* convert an Apple Roman or symbol name entry to ASCII */ static FT_String* tt_name_entry_ascii_from_other( TT_NameEntry entry, @@ -253,13 +222,11 @@ rec = face->name_table.names + found_win; switch ( rec->encodingID ) { + /* all Unicode strings are encoded using UTF-16BE */ case TT_MS_ID_UNICODE_CS: case TT_MS_ID_SYMBOL_CS: - convert = tt_name_entry_ascii_from_utf16; - break; - case TT_MS_ID_UCS_4: - convert = tt_name_entry_ascii_from_ucs4; + convert = tt_name_entry_ascii_from_utf16; break; default: diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index e17a5b53d..e6167956c 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -1783,17 +1783,17 @@ return ErrRaster_Invalid_Outline; /* if direct mode is not set, we must have a target bitmap */ - if ( (params->flags & FT_RASTER_FLAG_DIRECT) == 0 ) + if ( ( params->flags & FT_RASTER_FLAG_DIRECT ) == 0 ) { - if ( !target_map ) - return ErrRaster_Invalid_Argument; + if ( !target_map ) + return ErrRaster_Invalid_Argument; - /* nothing to do */ - if ( !target_map->width || !target_map->rows ) - return 0; + /* nothing to do */ + if ( !target_map->width || !target_map->rows ) + return 0; - if ( !target_map->buffer ) - return ErrRaster_Invalid_Argument; + if ( !target_map->buffer ) + return ErrRaster_Invalid_Argument; } /* this version does not support monochrome rendering */ diff --git a/src/tools/docmaker/tohtml.py b/src/tools/docmaker/tohtml.py index bf4f60922..63c123d6f 100644 --- a/src/tools/docmaker/tohtml.py +++ b/src/tools/docmaker/tohtml.py @@ -107,6 +107,16 @@ chapter_header = '<br><table align=center width="75%"><tr><td><h2>' chapter_inter = '</h2><ul class="empty"><li>' chapter_footer = '</li></ul></td></tr></table>' +# Index footer. +index_footer_start = """\ +<hr> +<table><tr><td width="100%"></td> +<td><font size=-2>[<a href=" +""" +index_footer_end = """\ +">TOC</a>]</font></td></tr></table> +""" + # source language keyword coloration/styling # @@ -360,7 +370,7 @@ class HtmlFormatter(Formatter): # block_index already contains the sorted list of index names count = len( self.block_index ) - rows = (count + self.columns - 1)/self.columns + rows = (count + self.columns - 1) / self.columns print "<table align=center border=0 cellpadding=0 cellspacing=0>" for r in range(rows): @@ -377,7 +387,11 @@ class HtmlFormatter(Formatter): print line print "</table>" - print self.html_footer + + print index_footer_start + \ + self.file_prefix + "toc.html" + \ + index_footer_end + self.index_items = {} def index_dump( self, index_filename = None ):