[autofit] Introduce two more slots for standard characters.

This is useful for OpenType features like `c2sc' (caps to small
caps) that don't have lowercase letters by definition, or other
features that mainly operate on numerals.

* src/autofit/afscript.h: Add more standard characters.

* src/autofit/aftypes.h: Update use of `SCRIPT' macro.
(AF_ScriptClassRec): Add members to hold two more standard
characters.
(AF_DEFINE_SCRIPT_CLASS): Updated.

* src/autofit/afglobal.c, src/autofit/afglobal.h,
* src/autofit/afpic.c, src/autofit/afranges.h, src/autofit/hbshim.c:
Update use of `SCRIPT' macro.

* src/autofit/afcjk.c (af_cjk_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Scan two more
standard characters.
This commit is contained in:
Werner Lemberg 2014-01-26 09:45:23 +01:00
parent eb7691cc3d
commit a336400112
10 changed files with 152 additions and 54 deletions

View File

@ -1,3 +1,26 @@
2014-01-26 Werner Lemberg <wl@gnu.org>
[autofit] Introduce two more slots for standard characters.
This is useful for OpenType features like `c2sc' (caps to small
caps) that don't have lowercase letters by definition, or other
features that mainly operate on numerals.
* src/autofit/afscript.h: Add more standard characters.
* src/autofit/aftypes.h: Update use of `SCRIPT' macro.
(AF_ScriptClassRec): Add members to hold two more standard
characters.
(AF_DEFINE_SCRIPT_CLASS): Updated.
* src/autofit/afglobal.c, src/autofit/afglobal.h,
* src/autofit/afpic.c, src/autofit/afranges.h, src/autofit/hbshim.c:
Update use of `SCRIPT' macro.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Scan two more
standard characters.
2014-01-24 Werner Lemberg <wl@gnu.org> 2014-01-24 Werner Lemberg <wl@gnu.org>
Fix Savannah bug #41320. Fix Savannah bug #41320.

View File

@ -101,16 +101,46 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script]; [style_class->script];
FT_UInt32 standard_char;
af_get_char_index( &metrics->root, af_get_char_index( &metrics->root,
script_class->standard_char, script_class->standard_char1,
&glyph_index, &glyph_index,
&y_offset ); &y_offset );
if ( glyph_index == 0 ) if ( glyph_index == 0 )
goto Exit; {
if ( script_class->standard_char2 )
{
af_get_char_index( &metrics->root,
script_class->standard_char2,
&glyph_index,
&y_offset );
if ( glyph_index == 0 )
{
if ( script_class->standard_char3 )
{
af_get_char_index( &metrics->root,
script_class->standard_char3,
&glyph_index,
&y_offset );
if ( glyph_index == 0 )
goto Exit;
else
standard_char = script_class->standard_char3;
}
}
else
standard_char = script_class->standard_char2;
}
else
goto Exit;
}
else
standard_char = script_class->standard_char1;
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n", FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
script_class->standard_char, glyph_index )); standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE ); error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 ) if ( error || face->glyph->outline.n_points <= 0 )

View File

@ -42,12 +42,12 @@
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \ #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
AF_DEFINE_SCRIPT_CLASS( \ AF_DEFINE_SCRIPT_CLASS( \
af_ ## s ## _script_class, \ af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \ AF_SCRIPT_ ## S, \
af_ ## s ## _uniranges, \ af_ ## s ## _uniranges, \
dc ) sc1, sc2, sc3 )
#include "afscript.h" #include "afscript.h"
@ -82,7 +82,7 @@
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \ #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
&af_ ## s ## _script_class, &af_ ## s ## _script_class,
FT_LOCAL_ARRAY_DEF( AF_ScriptClass ) FT_LOCAL_ARRAY_DEF( AF_ScriptClass )

View File

@ -5,7 +5,7 @@
/* Auto-fitter routines to compute global hinting values */ /* Auto-fitter routines to compute global hinting values */
/* (specification). */ /* (specification). */
/* */ /* */
/* Copyright 2003-2005, 2007, 2009, 2011-2013 by */ /* Copyright 2003-2005, 2007, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -34,7 +34,7 @@ FT_BEGIN_HEADER
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \ #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class ) AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
#include "afscript.h" #include "afscript.h"

View File

@ -88,19 +88,53 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script]; [style_class->script];
FT_UInt32 standard_char;
/*
* We check more than a single standard character to catch features
* like `c2sc' (small caps from caps) that don't contain lowercase
* letters by definition, or other features that mainly operate on
* numerals.
*/
/* XXX: Extend this with a list of possible standard characters: */
/* Especially in non-default coverages, a single standard */
/* character may not be available. */
af_get_char_index( &metrics->root, af_get_char_index( &metrics->root,
script_class->standard_char, script_class->standard_char1,
&glyph_index, &glyph_index,
&y_offset ); &y_offset );
if ( glyph_index == 0 ) if ( glyph_index == 0 )
goto Exit; {
if ( script_class->standard_char2 )
{
af_get_char_index( &metrics->root,
script_class->standard_char2,
&glyph_index,
&y_offset );
if ( glyph_index == 0 )
{
if ( script_class->standard_char3 )
{
af_get_char_index( &metrics->root,
script_class->standard_char3,
&glyph_index,
&y_offset );
if ( glyph_index == 0 )
goto Exit;
else
standard_char = script_class->standard_char3;
}
}
else
standard_char = script_class->standard_char2;
}
else
goto Exit;
}
else
standard_char = script_class->standard_char1;
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n", FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
script_class->standard_char, glyph_index )); standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE ); error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 ) if ( error || face->glyph->outline.n_points <= 0 )

View File

@ -4,7 +4,7 @@
/* */ /* */
/* The FreeType position independent code services for autofit module. */ /* The FreeType position independent code services for autofit module. */
/* */ /* */
/* Copyright 2009-2013 by */ /* Copyright 2009-2014 by */
/* Oran Agra and Mickey Gabel. */ /* Oran Agra and Mickey Gabel. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -122,7 +122,7 @@
#include "afwrtsys.h" #include "afwrtsys.h"
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \ #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
FT_Init_Class_af_ ## s ## _script_class( \ FT_Init_Class_af_ ## s ## _script_class( \
&container->af_script_classes_rec[ss++] ); &container->af_script_classes_rec[ss++] );

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Auto-fitter Unicode script ranges (specification). */ /* Auto-fitter Unicode script ranges (specification). */
/* */ /* */
/* Copyright 2013 by */ /* Copyright 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -26,7 +26,7 @@
FT_BEGIN_HEADER FT_BEGIN_HEADER
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \ #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[]; extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
#include "afscript.h" #include "afscript.h"

View File

@ -20,108 +20,108 @@
/* Define `SCRIPT' as needed. */ /* Define `SCRIPT' as needed. */
/* Add new scripts here. The first and second arguments are the */ /* Add new scripts here. The first and second arguments are the */
/* script name in lowercase and uppercase, respectively, followed */ /* script name in lowercase and uppercase, respectively, followed */
/* by a description string. Then comes the corresponding HarfBuzz */ /* by a description string. Then comes the corresponding HarfBuzz */
/* script name tag, followed by the default character (to derive */ /* script name tag, followed by a string of standard characters (to */
/* the standard width and height of stems). */ /* derive the standard width and height of stems). */
SCRIPT( cyrl, CYRL, SCRIPT( cyrl, CYRL,
"Cyrillic", "Cyrillic",
HB_SCRIPT_CYRILLIC, HB_SCRIPT_CYRILLIC,
0x43E ) /* о */ 0x43E, 0x41E, 0x0 ) /* оО */
SCRIPT( grek, GREK, SCRIPT( grek, GREK,
"Greek", "Greek",
HB_SCRIPT_GREEK, HB_SCRIPT_GREEK,
0x3BF ) /* ο */ 0x3BF, 0x39F, 0x0 ) /* οΟ */
SCRIPT( hebr, HEBR, SCRIPT( hebr, HEBR,
"Hebrew", "Hebrew",
HB_SCRIPT_HEBREW, HB_SCRIPT_HEBREW,
0x5DD ) /* ם */ 0x5DD, 0x0, 0x0 ) /* ם */
SCRIPT( latn, LATN, SCRIPT( latn, LATN,
"Latin", "Latin",
HB_SCRIPT_LATIN, HB_SCRIPT_LATIN,
'o' ) 'o', 'O', '0' )
SCRIPT( none, NONE, SCRIPT( none, NONE,
"no script", "no script",
HB_SCRIPT_INVALID, HB_SCRIPT_INVALID,
'\0' ) 0x0, 0x0, 0x0 )
#ifdef AF_CONFIG_OPTION_INDIC #ifdef AF_CONFIG_OPTION_INDIC
SCRIPT( beng, BENG, SCRIPT( beng, BENG,
"Bengali", "Bengali",
HB_SCRIPT_BENGALI, HB_SCRIPT_BENGALI,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( deva, DEVA, SCRIPT( deva, DEVA,
"Devanagari", "Devanagari",
HB_SCRIPT_DEVANAGARI, HB_SCRIPT_DEVANAGARI,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( gujr, GUJR, SCRIPT( gujr, GUJR,
"Gujarati", "Gujarati",
HB_SCRIPT_GUJARATI, HB_SCRIPT_GUJARATI,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( guru, GURU, SCRIPT( guru, GURU,
"Gurmukhi", "Gurmukhi",
HB_SCRIPT_GURMUKHI, HB_SCRIPT_GURMUKHI,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( knda, KNDA, SCRIPT( knda, KNDA,
"Kannada", "Kannada",
HB_SCRIPT_KANNADA, HB_SCRIPT_KANNADA,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( limb, LIMB, SCRIPT( limb, LIMB,
"Limbu", "Limbu",
HB_SCRIPT_LIMBU, HB_SCRIPT_LIMBU,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( mlym, MLYM, SCRIPT( mlym, MLYM,
"Malayalam", "Malayalam",
HB_SCRIPT_MALAYALAM, HB_SCRIPT_MALAYALAM,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( orya, ORYA, SCRIPT( orya, ORYA,
"Oriya", "Oriya",
HB_SCRIPT_ORIYA, HB_SCRIPT_ORIYA,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( sinh, SINH, SCRIPT( sinh, SINH,
"Sinhala", "Sinhala",
HB_SCRIPT_SINHALA, HB_SCRIPT_SINHALA,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( sund, SUND, SCRIPT( sund, SUND,
"Sundanese", "Sundanese",
HB_SCRIPT_SUNDANESE, HB_SCRIPT_SUNDANESE,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( sylo, SYLO, SCRIPT( sylo, SYLO,
"Syloti Nagri", "Syloti Nagri",
HB_SCRIPT_SYLOTI_NAGRI, HB_SCRIPT_SYLOTI_NAGRI,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( taml, TAML, SCRIPT( taml, TAML,
"Tamil", "Tamil",
HB_SCRIPT_TAMIL, HB_SCRIPT_TAMIL,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( telu, TELU, SCRIPT( telu, TELU,
"Telugu", "Telugu",
HB_SCRIPT_TELUGU, HB_SCRIPT_TELUGU,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
SCRIPT( tibt, TIBT, SCRIPT( tibt, TIBT,
"Tibetan", "Tibetan",
HB_SCRIPT_TIBETAN, HB_SCRIPT_TIBETAN,
'o' ) /* XXX */ 'o', 0x0, 0x0 ) /* XXX */
#endif /* AF_CONFIG_OPTION_INDIC */ #endif /* AF_CONFIG_OPTION_INDIC */
@ -130,7 +130,7 @@
SCRIPT( hani, HANI, SCRIPT( hani, HANI,
"CJKV ideographs", "CJKV ideographs",
HB_SCRIPT_HAN, HB_SCRIPT_HAN,
0x7530 ) /* 田 */ 0x7530, 0x56D7, 0x0 ) /* 田 */
#endif /* AF_CONFIG_OPTION_CJK */ #endif /* AF_CONFIG_OPTION_CJK */

View File

@ -303,7 +303,7 @@ extern void* _af_debug_hints;
*/ */
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \ #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
AF_SCRIPT_ ## S, AF_SCRIPT_ ## S,
/* The list of known scripts. */ /* The list of known scripts. */
@ -334,7 +334,10 @@ extern void* _af_debug_hints;
AF_Script script; AF_Script script;
AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */ AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */
FT_UInt32 standard_char; /* for default width and height */
FT_UInt32 standard_char1; /* for default width and height */
FT_UInt32 standard_char2; /* ditto */
FT_UInt32 standard_char3; /* ditto */
} AF_ScriptClassRec; } AF_ScriptClassRec;
@ -510,13 +513,17 @@ extern void* _af_debug_hints;
script_class, \ script_class, \
script, \ script, \
ranges, \ ranges, \
std_char ) \ std_char1, \
std_char2, \
std_char3 ) \
FT_CALLBACK_TABLE_DEF \ FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \ const AF_ScriptClassRec script_class = \
{ \ { \
script, \ script, \
ranges, \ ranges, \
std_char \ std_char1, \
std_char2, \
std_char3 \
}; };
@ -580,13 +587,17 @@ extern void* _af_debug_hints;
script_class, \ script_class, \
script_, \ script_, \
ranges, \ ranges, \
std_char ) \ std_char1, \
std_char2, \
std_char3 ) \
FT_LOCAL_DEF( void ) \ 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 = script_; \
ac->script_uni_ranges = ranges; \ ac->script_uni_ranges = ranges; \
ac->standard_char = std_char; \ ac->standard_char1 = std_char1; \
ac->standard_char2 = std_char2; \
ac->standard_char3 = std_char3; \
} }

View File

@ -84,7 +84,7 @@
/* load HarfBuzz script tags */ /* load HarfBuzz script tags */
#undef SCRIPT #undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) h, #define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) h,
static const hb_tag_t scripts[] = static const hb_tag_t scripts[] =