Commit 553bb3c3caa38bf73d01f5c3a3ebe5a96070f527

Werner Lemberg 2012-10-24T14:22:14

[autofit] Add standard character to `AF_ScriptClassRec' structure. * src/autofit/aftypes.h (AF_ScriptClassRec): Add `standard_char' member. (AF_DEFINE_SCRIPT_CLASS): Updated. * src/autofit/aflatin.c (af_latin_metrics_init_widths): Use it. (af_latin_metrics_init, af_latin_script_class): Updated. * src/autofit/aflatin.c (af_latin2_metrics_init_widths): Use it. (af_latin2_metrics_init, af_latin2_script_class): Updated. * src/autofit/afcjk.c (af_cjk_metrics_init_widths): Use it. (af_cjk_metrics_init, af_cjk_script_class): Updated. * src/autofit/afindic.c(af_indic_metrics_init, af_indic_script_class): Updated. * src/autofit/afcjk.h, src/autofit/aflatin.h: Updated. * src/autofit/afdummy.c: Updated.

diff --git a/ChangeLog b/ChangeLog
index a2581b4..82abe63 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,33 @@
 2012-10-24  Werner Lemberg  <wl@gnu.org>
 
+	[autofit] Add standard character to `AF_ScriptClassRec' structure.
+
+	* src/autofit/aftypes.h (AF_ScriptClassRec): Add `standard_char'
+	member.
+	(AF_DEFINE_SCRIPT_CLASS): Updated.
+
+	* src/autofit/aflatin.c (af_latin_metrics_init_widths): Use it.
+	(af_latin_metrics_init, af_latin_script_class): Updated.
+
+	* src/autofit/aflatin.c (af_latin2_metrics_init_widths): Use it.
+	(af_latin2_metrics_init, af_latin2_script_class): Updated.
+
+	* src/autofit/afcjk.c (af_cjk_metrics_init_widths): Use it.
+	(af_cjk_metrics_init, af_cjk_script_class): Updated.
+
+	* src/autofit/afindic.c	(af_indic_metrics_init,
+	af_indic_script_class): Updated.
+
+	* src/autofit/afcjk.h, src/autofit/aflatin.h: Updated.
+
+	* src/autofit/afdummy.c: Updated.
+
+2012-10-24  Werner Lemberg  <wl@gnu.org>
+
 	[autofit] Only use Unicode CMap.
 
 	* src/autofit/aflatin.c (af_latin_metrics_init): Implement it, to be
-	in sync with `af_face_globals_compute_script_coverage)'.
+	in sync with `af_face_globals_compute_script_coverage'.
 
 2012-10-21  Werner Lemberg  <wl@gnu.org>
 
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index b8009c5..38325f6 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -67,8 +67,7 @@
 
   FT_LOCAL_DEF( void )
   af_cjk_metrics_init_widths( AF_CJKMetrics  metrics,
-                              FT_Face        face,
-                              FT_ULong       charcode )
+                              FT_Face        face )
   {
     /* scan the array of segments in each direction */
     AF_GlyphHintsRec  hints[1];
@@ -87,7 +86,8 @@
       AF_Scaler         scaler = &dummy->root.scaler;
 
 
-      glyph_index = FT_Get_Char_Index( face, charcode );
+      glyph_index = FT_Get_Char_Index( face,
+                                       metrics->root.clazz->standard_char );
       if ( glyph_index == 0 )
         goto Exit;
 
@@ -559,7 +559,7 @@
       face->charmap = NULL;
     else
     {
-      af_cjk_metrics_init_widths( metrics, face, 0x7530 );
+      af_cjk_metrics_init_widths( metrics, face );
       af_cjk_metrics_init_blues( metrics, face, af_cjk_hani_blue_chars );
       af_cjk_metrics_check_digits( metrics, face );
     }
@@ -2232,6 +2232,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_cjk_script_class,
     AF_SCRIPT_CJK,
     af_cjk_uniranges,
+    0x7530, /* 田 */
 
     sizeof ( AF_CJKMetricsRec ),
 
@@ -2254,6 +2255,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_cjk_script_class,
     AF_SCRIPT_CJK,
     af_cjk_uniranges,
+    0,
 
     sizeof ( AF_CJKMetricsRec ),
 
diff --git a/src/autofit/afcjk.h b/src/autofit/afcjk.h
index dc8f892..ab816f2 100644
--- a/src/autofit/afcjk.h
+++ b/src/autofit/afcjk.h
@@ -28,7 +28,7 @@ FT_BEGIN_HEADER
 
   /* the CJK-specific script class */
 
-  AF_DECLARE_SCRIPT_CLASS(af_cjk_script_class)
+  AF_DECLARE_SCRIPT_CLASS( af_cjk_script_class )
 
   /* CJK (global) metrics management */
 
@@ -121,15 +121,14 @@ FT_BEGIN_HEADER
                       FT_Outline*    outline,
                       AF_CJKMetrics  metrics );
 
-  /* Shared. called from afindic.c */
+  /* shared; called from afindic.c */
   FT_LOCAL( void )
   af_cjk_metrics_check_digits( AF_CJKMetrics  metrics,
                                FT_Face        face );
 
   FT_LOCAL( void )
   af_cjk_metrics_init_widths( AF_CJKMetrics  metrics,
-                              FT_Face        face,
-                              FT_ULong       charcode );
+                              FT_Face        face );
 #endif /* AF_CONFIG_OPTION_CJK */
 
 
diff --git a/src/autofit/afdummy.c b/src/autofit/afdummy.c
index 8dc03e8..2258a19 100644
--- a/src/autofit/afdummy.c
+++ b/src/autofit/afdummy.c
@@ -46,6 +46,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_dummy_script_class,
     AF_SCRIPT_DUMMY,
     NULL,
+    0,
 
     sizeof ( AF_ScriptMetricsRec ),
 
diff --git a/src/autofit/afindic.c b/src/autofit/afindic.c
index 9c74838..70de70b 100644
--- a/src/autofit/afindic.c
+++ b/src/autofit/afindic.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for Indic scripts (body).               */
 /*                                                                         */
-/*  Copyright 2007, 2011 by                                                */
+/*  Copyright 2007, 2011, 2012 by                                          */
 /*  Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.    */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -46,7 +46,7 @@
       face->charmap = NULL;
     else
     {
-      af_cjk_metrics_init_widths( metrics, face, 0x7530 );
+      af_cjk_metrics_init_widths( metrics, face );
 #if 0
       /* either need indic specific blue_chars[] or just skip blue zones */
       af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
@@ -116,6 +116,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_indic_script_class,
     AF_SCRIPT_INDIC,
     af_indic_uniranges,
+    'o', /* XXX */
 
     sizeof ( AF_CJKMetricsRec ),
 
@@ -138,6 +139,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_indic_script_class,
     AF_SCRIPT_INDIC,
     af_indic_uniranges,
+    0,
 
     sizeof ( AF_CJKMetricsRec ),
 
diff --git a/src/autofit/afindic.h b/src/autofit/afindic.h
index 662a982..c252cf2 100644
--- a/src/autofit/afindic.h
+++ b/src/autofit/afindic.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for Indic scripts (specification).      */
 /*                                                                         */
-/*  Copyright 2007 by                                                      */
+/*  Copyright 2007, 2012 by                                                */
 /*  Rahul Bhalerao <rahul.bhalerao@redhat.com>, <b.rahul.pm@gmail.com>.    */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -27,7 +27,7 @@ FT_BEGIN_HEADER
 
   /* the Indic-specific script class */
 
-  AF_DECLARE_SCRIPT_CLASS(af_indic_script_class)
+  AF_DECLARE_SCRIPT_CLASS( af_indic_script_class )
 
 
 /* */
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 001d8fb..fb4e20b 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -54,8 +54,7 @@
 
   FT_LOCAL_DEF( void )
   af_latin_metrics_init_widths( AF_LatinMetrics  metrics,
-                                FT_Face          face,
-                                FT_ULong         charcode )
+                                FT_Face          face )
   {
     /* scan the array of segments in each direction */
     AF_GlyphHintsRec  hints[1];
@@ -67,14 +66,15 @@
     metrics->axis[AF_DIMENSION_VERT].width_count = 0;
 
     {
-      FT_Error             error;
-      FT_UInt              glyph_index;
-      int                  dim;
-      AF_LatinMetricsRec   dummy[1];
-      AF_Scaler            scaler = &dummy->root.scaler;
+      FT_Error            error;
+      FT_UInt             glyph_index;
+      int                 dim;
+      AF_LatinMetricsRec  dummy[1];
+      AF_Scaler           scaler = &dummy->root.scaler;
 
 
-      glyph_index = FT_Get_Char_Index( face, charcode );
+      glyph_index = FT_Get_Char_Index( face,
+                                       metrics->root.clazz->standard_char );
       if ( glyph_index == 0 )
         goto Exit;
 
@@ -530,8 +530,7 @@
 
     if ( !FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
     {
-      /* For now, compute the standard width and height from the `o'. */
-      af_latin_metrics_init_widths( metrics, face, 'o' );
+      af_latin_metrics_init_widths( metrics, face );
       af_latin_metrics_init_blues( metrics, face );
       af_latin_metrics_check_digits( metrics, face );
     }
@@ -2404,6 +2403,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_latin_script_class,
     AF_SCRIPT_LATIN,
     af_latin_uniranges,
+    'o',
 
     sizeof ( AF_LatinMetricsRec ),
 
diff --git a/src/autofit/aflatin.h b/src/autofit/aflatin.h
index e80a7cb..d9170b3 100644
--- a/src/autofit/aflatin.h
+++ b/src/autofit/aflatin.h
@@ -27,7 +27,7 @@ FT_BEGIN_HEADER
 
   /* the latin-specific script class */
 
-  AF_DECLARE_SCRIPT_CLASS(af_latin_script_class)
+  AF_DECLARE_SCRIPT_CLASS( af_latin_script_class )
 
 
   /* constants are given with units_per_em == 2048 in mind */
@@ -133,8 +133,7 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   af_latin_metrics_init_widths( AF_LatinMetrics  metrics,
-                                FT_Face          face,
-                                FT_ULong         charcode );
+                                FT_Face          face );
 
   FT_LOCAL( void )
   af_latin_metrics_check_digits( AF_LatinMetrics  metrics,
diff --git a/src/autofit/aflatin2.c b/src/autofit/aflatin2.c
index b173cb7..40a5ffd 100644
--- a/src/autofit/aflatin2.c
+++ b/src/autofit/aflatin2.c
@@ -57,8 +57,7 @@
 
   FT_LOCAL_DEF( void )
   af_latin2_metrics_init_widths( AF_LatinMetrics  metrics,
-                                 FT_Face          face,
-                                 FT_ULong         charcode )
+                                 FT_Face          face )
   {
     /* scan the array of segments in each direction */
     AF_GlyphHintsRec  hints[1];
@@ -77,7 +76,8 @@
       AF_Scaler            scaler = &dummy->root.scaler;
 
 
-      glyph_index = FT_Get_Char_Index( face, charcode );
+      glyph_index = FT_Get_Char_Index( face,
+                                       metrics->root.clazz->standard_char );
       if ( glyph_index == 0 )
         goto Exit;
 
@@ -501,8 +501,7 @@
 
     if ( !error )
     {
-      /* For now, compute the standard width and height from the `o'. */
-      af_latin2_metrics_init_widths( metrics, face, 'o' );
+      af_latin2_metrics_init_widths( metrics, face );
       af_latin2_metrics_init_blues( metrics, face );
       af_latin2_metrics_check_digits( metrics, face );
     }
@@ -2388,6 +2387,7 @@
   AF_DEFINE_SCRIPT_CLASS( af_latin2_script_class,
     AF_SCRIPT_LATIN2,
     af_latin2_uniranges,
+    'o',
 
     sizeof ( AF_LatinMetricsRec ),
 
diff --git a/src/autofit/aflatin2.h b/src/autofit/aflatin2.h
index 925c621..cbfa395 100644
--- a/src/autofit/aflatin2.h
+++ b/src/autofit/aflatin2.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    Auto-fitter hinting routines for latin script (specification).       */
 /*                                                                         */
-/*  Copyright 2003, 2004, 2005, 2006, 2007 by                              */
+/*  Copyright 2003-2007, 2012 by                                           */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -27,7 +27,7 @@ FT_BEGIN_HEADER
 
   /* the latin-specific script class */
 
-  AF_DECLARE_SCRIPT_CLASS(af_latin2_script_class)
+  AF_DECLARE_SCRIPT_CLASS( af_latin2_script_class )
 
 /* */
 
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index cda05a0..9acd7ad 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -298,8 +298,9 @@ extern void*  _af_debug_hints;
 
   typedef struct  AF_ScriptClassRec_
   {
-    AF_Script                   script;
-    AF_Script_UniRange          script_uni_ranges; /* last must be { 0, 0 } */
+    AF_Script           script;
+    AF_Script_UniRange  script_uni_ranges; /* last must be { 0, 0 }        */
+    FT_UInt32           standard_char;     /* for default width and height */
 
     FT_Offset                   script_metrics_size;
     AF_Script_InitMetricsFunc   script_metrics_init;
@@ -319,13 +320,14 @@ extern void*  _af_debug_hints;
   FT_CALLBACK_TABLE const AF_ScriptClassRec     \
   script_class;
 
-#define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, m_size,     \
+#define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, def_char,   \
+                                m_size,                                    \
                                 m_init, m_scale, m_done, h_init, h_apply ) \
-  FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec                            \
-  script_class =                                                           \
+  FT_CALLBACK_TABLE_DEF const AF_ScriptClassRec  script_class =            \
   {                                                                        \
     script_,                                                               \
     ranges,                                                                \
+    def_char,                                                              \
                                                                            \
     m_size,                                                                \
                                                                            \
@@ -339,17 +341,19 @@ extern void*  _af_debug_hints;
 
 #else /* FT_CONFIG_OPTION_PIC */
 
-#define AF_DECLARE_SCRIPT_CLASS( script_class )          \
-  FT_LOCAL( void )                                       \
-  FT_Init_Class_##script_class( AF_ScriptClassRec* ac );
+#define AF_DECLARE_SCRIPT_CLASS( script_class )             \
+  FT_LOCAL( void )                                          \
+  FT_Init_Class_ ## script_class( AF_ScriptClassRec*  ac );
 
-#define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, m_size,     \
+#define AF_DEFINE_SCRIPT_CLASS( script_class, script_, ranges, def_char,   \
+                                m_size,                                    \
                                 m_init, m_scale, m_done, h_init, h_apply ) \
   FT_LOCAL_DEF( void )                                                     \
-  FT_Init_Class_##script_class( AF_ScriptClassRec* ac )                    \
+  FT_Init_Class_ ## script_class( AF_ScriptClassRec*  ac )                 \
   {                                                                        \
     ac->script               = script_;                                    \
     ac->script_uni_ranges    = ranges;                                     \
+    ac->default_char         = def_char;                                   \
                                                                            \
     ac->script_metrics_size  = m_size;                                     \
                                                                            \