Introduce experimental autofit CJK module based on akito's autohint

patch.  You need to #define AF_MOD_CJK in afcjk.c to enable it.

* src/autofit/afglobal.c, src/autofit/afcjk.h, src/autofit/afcjk.c,
src/autofit/rules.mk, src/autofit/autofit.c, src/autofit/aftypes.h:
Add CJK module based on akito's autohint patch.

* src/autofit/afhints.h (AF_SegmentRec): New field `len' for the
overlap length of the segments.  (AF_SEGMENT_LEN, AF_SEGMENT_DIST):
New macros.

* src/autofit/aflatin.h (af_latin_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Made `FT_LOCAL'.
Use the character given by the caller.
(af_latin_metrics_init_widths, af_latin_hints_link_segments): Scale
the thresholds.

* src/autofit/afloader.c (af_loader_load_g): Respect
AF_SCALER_FLAG_NO_ADVANCE.
This commit is contained in:
Wu, Chia-I (吳佳一) 2006-02-09 14:17:04 +00:00
parent 6be99f9104
commit 4cdb45c01e
11 changed files with 1607 additions and 10 deletions

View File

@ -1,3 +1,25 @@
2006-02-09 Chia-I Wu <b90201047@ntu.edu.tw>
Introduce experimental autofit CJK module based on akito's autohint
patch. You need to #define AF_MOD_CJK in afcjk.c to enable it.
* src/autofit/afglobal.c, src/autofit/afcjk.h, src/autofit/afcjk.c,
src/autofit/rules.mk, src/autofit/autofit.c, src/autofit/aftypes.h:
Add CJK module based on akito's autohint patch.
* src/autofit/afhints.h (AF_SegmentRec): New field `len' for the
overlap length of the segments. (AF_SEGMENT_LEN, AF_SEGMENT_DIST):
New macros.
* src/autofit/aflatin.h (af_latin_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Made `FT_LOCAL'.
Use the character given by the caller.
(af_latin_metrics_init_widths, af_latin_hints_link_segments): Scale
the thresholds.
* src/autofit/afloader.c (af_loader_load_g): Respect
AF_SCALER_FLAG_NO_ADVANCE.
2006-02-09 Werner Lemberg <wl@gnu.org>
* src/cid/cidparse.c (cid_parse_new): Remove shadowing variable.

1508
src/autofit/afcjk.c Normal file

File diff suppressed because it is too large Load Diff

41
src/autofit/afcjk.h Normal file
View File

@ -0,0 +1,41 @@
/***************************************************************************/
/* */
/* afcjk.h */
/* */
/* Auto-fitter hinting routines for CJK script (specification). */
/* */
/* Copyright 2006 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 __AFCJK_H__
#define __AFCJK_H__
#include "afhints.h"
FT_BEGIN_HEADER
/* the CJK-specific script class */
FT_CALLBACK_TABLE const AF_ScriptClassRec
af_cjk_script_class;
/* */
FT_END_HEADER
#endif /* __AFCJK_H__ */
/* END */

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter routines to compute global hinting values (body). */
/* */
/* Copyright 2003, 2004, 2005 by */
/* Copyright 2003, 2004, 2005, 2006 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 "afglobal.h"
#include "afdummy.h"
#include "aflatin.h"
#include "afcjk.h"
#include "aferrors.h"
@ -27,6 +28,7 @@
{
&af_dummy_script_class,
&af_latin_script_class,
&af_cjk_script_class,
NULL /* do not remove */
};

View File

@ -133,6 +133,7 @@ FT_BEGIN_HEADER
AF_Segment serif; /* primary segment for serifs */
FT_Pos num_linked; /* number of linked segments */
FT_Pos score; /* used during stem matching */
FT_Pos len; /* used during stem matching */
AF_Point first; /* first point in edge segment */
AF_Point last; /* last point in edge segment */
@ -285,6 +286,14 @@ FT_BEGIN_HEADER
/* */
#define AF_SEGMENT_LEN( seg ) \
( ( seg )->max_coord - ( seg )->min_coord )
#define AF_SEGMENT_DIST( seg1, seg2 ) \
( ( ( seg1 )->pos > ( seg2 )->pos ) \
? ( seg1 )->pos - ( seg2 )->pos \
: ( seg2 )->pos - ( seg1 )->pos )
FT_END_HEADER

View File

@ -33,9 +33,10 @@
/*************************************************************************/
/*************************************************************************/
static void
FT_LOCAL_DEF( void )
af_latin_metrics_init_widths( AF_LatinMetrics metrics,
FT_Face face )
FT_Face face,
FT_ULong charcode )
{
/* scan the array of segments in each direction */
AF_GlyphHintsRec hints[1];
@ -46,7 +47,6 @@
metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
metrics->axis[AF_DIMENSION_VERT].width_count = 0;
/* For now, compute the standard width and height from the `o'. */
{
FT_Error error;
FT_UInt glyph_index;
@ -55,7 +55,7 @@
AF_Scaler scaler = &dummy->scaler;
glyph_index = FT_Get_Char_Index( face, 'o' );
glyph_index = FT_Get_Char_Index( face, charcode );
if ( glyph_index == 0 )
goto Exit;
@ -127,7 +127,7 @@
/* Now, compute the edge distance threshold as a fraction of the */
/* smallest width in the font. Set it in `hinter->glyph' too! */
if ( edge_distance_threshold == 32000 )
edge_distance_threshold = 50;
edge_distance_threshold = 50 * metrics->units_per_em / 2048;
/* let's try 20% */
axis->edge_distance_threshold = edge_distance_threshold / 5;
@ -409,7 +409,8 @@
if ( !error )
{
af_latin_metrics_init_widths( metrics, face );
/* For now, compute the standard width and height from the `o'. */
af_latin_metrics_init_widths( metrics, face, 'o' );
af_latin_metrics_init_blues( metrics, face );
}
@ -746,6 +747,7 @@
segment->last = point;
segment->contour = contour;
segment->score = 32000;
segment->len = 0;
segment->link = NULL;
on_edge = 1;
@ -812,6 +814,7 @@
segment->last = min_point;
segment->pos = min_pos;
segment->score = 32000;
segment->len = 0;
segment->link = NULL;
segment = NULL;
@ -831,6 +834,7 @@
segment->last = max_point;
segment->pos = max_pos;
segment->score = 32000;
segment->len = 0;
segment->link = NULL;
segment = NULL;
@ -851,9 +855,13 @@
AF_Segment segments = axis->segments;
AF_Segment segment_limit = segments + axis->num_segments;
AF_Direction major_dir = axis->major_dir;
FT_UShort len_threshold;
AF_Segment seg1, seg2;
len_threshold = ( (AF_LatinMetrics)hints->metrics )->units_per_em;
len_threshold = ( len_threshold * 8 ) / 2048;
/* now compare each segment to the others */
for ( seg1 = segments; seg1 < segment_limit; seg1++ )
{
@ -886,7 +894,7 @@
max = seg2->max_coord;
len = max - min;
if ( len >= 8 )
if ( len >= len_threshold )
{
score = dist + 3000 / len;

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter hinting routines for latin script (specification). */
/* */
/* Copyright 2003, 2004, 2005 by */
/* Copyright 2003, 2004, 2005, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -126,6 +126,10 @@ FT_BEGIN_HEADER
af_latin_metrics_scale( AF_LatinMetrics metrics,
AF_Scaler scaler );
FT_LOCAL( void )
af_latin_metrics_init_widths( AF_LatinMetrics metrics,
FT_Face face,
FT_ULong charcode );
/*************************************************************************/

View File

@ -193,7 +193,7 @@
axis->num_edges - 1; /* rightmost edge */
if ( axis->num_edges > 1 )
if ( axis->num_edges > 1 && AF_HINTS_DO_ADVANCE( hints ) )
{
old_advance = loader->pp2.x;
old_rsb = old_advance - edge2->opos;

View File

@ -259,6 +259,7 @@ FT_BEGIN_HEADER
{
AF_SCRIPT_NONE = 0,
AF_SCRIPT_LATIN = 1,
AF_SCRIPT_CJK = 2,
/* add new scripts here. Don't forget to update the list in */
/* `afglobal.c'. */

View File

@ -23,6 +23,7 @@
#include "afhints.c"
#include "afdummy.c"
#include "aflatin.c"
#include "afcjk.c"
#include "afloader.c"
#include "afmodule.c"

View File

@ -30,6 +30,7 @@ AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \
$(AUTOF_DIR)/afglobal.c \
$(AUTOF_DIR)/afhints.c \
$(AUTOF_DIR)/aflatin.c \
$(AUTOF_DIR)/afcjk.c \
$(AUTOF_DIR)/afloader.c \
$(AUTOF_DIR)/afmodule.c \
$(AUTOF_DIR)/afwarp.c