[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>
Fix Savannah bug #41320.

View File

@ -101,16 +101,46 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
FT_UInt32 standard_char;
af_get_char_index( &metrics->root,
script_class->standard_char,
script_class->standard_char1,
&glyph_index,
&y_offset );
if ( glyph_index == 0 )
{
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",
script_class->standard_char, glyph_index ));
standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )

View File

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

View File

@ -5,7 +5,7 @@
/* Auto-fitter routines to compute global hinting values */
/* (specification). */
/* */
/* Copyright 2003-2005, 2007, 2009, 2011-2013 by */
/* Copyright 2003-2005, 2007, 2009, 2011-2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -34,7 +34,7 @@ FT_BEGIN_HEADER
#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 )
#include "afscript.h"

View File

@ -88,19 +88,53 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[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,
script_class->standard_char,
script_class->standard_char1,
&glyph_index,
&y_offset );
if ( glyph_index == 0 )
{
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",
script_class->standard_char, glyph_index ));
standard_char, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for autofit module. */
/* */
/* Copyright 2009-2013 by */
/* Copyright 2009-2014 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -122,7 +122,7 @@
#include "afwrtsys.h"
#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( \
&container->af_script_classes_rec[ss++] );

View File

@ -4,7 +4,7 @@
/* */
/* Auto-fitter Unicode script ranges (specification). */
/* */
/* Copyright 2013 by */
/* Copyright 2013, 2014 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -26,7 +26,7 @@
FT_BEGIN_HEADER
#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[];
#include "afscript.h"

View File

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

View File

@ -303,7 +303,7 @@ extern void* _af_debug_hints;
*/
#undef SCRIPT
#define SCRIPT( s, S, d, h, dc ) \
#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
AF_SCRIPT_ ## S,
/* The list of known scripts. */
@ -334,7 +334,10 @@ extern void* _af_debug_hints;
AF_Script script;
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;
@ -510,13 +513,17 @@ extern void* _af_debug_hints;
script_class, \
script, \
ranges, \
std_char ) \
std_char1, \
std_char2, \
std_char3 ) \
FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \
{ \
script, \
ranges, \
std_char \
std_char1, \
std_char2, \
std_char3 \
};
@ -580,13 +587,17 @@ extern void* _af_debug_hints;
script_class, \
script_, \
ranges, \
std_char ) \
std_char1, \
std_char2, \
std_char3 ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
{ \
ac->script = script_; \
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 */
#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[] =