ref: f45c0bf96372c038e1f72e52a8c7b7e2849c4567
parent: a8a54c30603ddedef5a2a96615e9fd66504356bf
author: Werner Lemberg <[email protected]>
date: Sun Dec 6 04:58:18 EST 2015
[autofit] Use string of standard characters. This is more flexible; additionally, it would allow character clusters. * src/autofit/aftypes.h (SCRIPT, AF_DEFINE_SCRIPT_CLASS): Updated. (AF_ScriptClassRec): Replace `standard_char[123]' with `standard_charstring'. * src/autofit/afscript.h: Replace last three character arguments of the `SCRIPT' calls with a string parameter, holding the standard characters (in UTF-8 encoding) separated with spaces. * src/autofit/afglobal.c, src/autofit/afglobal.h, src/autofit/afpic.c, src/autofit/afranges.c, src/autofit/hbshim.c (SCRIPT): Updated. * src/autofit/afcjk.c (af_cjk_metrics_init_widths), src/autofit/aflatin.c (af_latin_metrics_init_widths): Updated.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2015-12-06 Werner Lemberg <[email protected]>
+
+ [autofit] Use string of standard characters.
+
+ This is more flexible; additionally, it would allow character
+ clusters.
+
+ * src/autofit/aftypes.h (SCRIPT, AF_DEFINE_SCRIPT_CLASS): Updated.
+ (AF_ScriptClassRec): Replace `standard_char[123]' with
+ `standard_charstring'.
+
+ * src/autofit/afscript.h: Replace last three character arguments
+ of the `SCRIPT' calls with a string parameter, holding the standard
+ characters (in UTF-8 encoding) separated with spaces.
+
+ * src/autofit/afglobal.c, src/autofit/afglobal.h,
+ src/autofit/afpic.c, src/autofit/afranges.c, src/autofit/hbshim.c
+ (SCRIPT): Updated.
+
+ * src/autofit/afcjk.c (af_cjk_metrics_init_widths),
+ src/autofit/aflatin.c (af_latin_metrics_init_widths): Updated.
+
2015-12-05 Werner Lemberg <[email protected]>
* src/autofit/afblue.dat: Separate blue zone characters with spaces.
@@ -425,7 +447,7 @@
(PFR_CHECK_SIZE): ... this.
(PFR_SIZE): [!PFR_CONFIG_NO_CHECKS]: Define to PFR_CHECK_SIZE.
- * src/pfr/pfrload.c (pfr_log_font_count): Check `count'.
+ * src/pfr/pfrload.c (pfr_log_font_count): Check `count'.
(pfr_extra_item_load_kerning_pairs): Remove tracing message.
(pfr_phy_font_load): Use PFR_CHECK_SIZE where appropriate.
Allocate `chars' after doing a size checks.
@@ -1017,7 +1039,7 @@
* src/autofit/afstyles.h: Add Lao data.
2015-09-27 suzuki toshiya <[email protected]>
-
+
[base] Fix a leak by broken sfnt-PS or resource fork (#46028).
open_face_from_buffer() frees passed buffer if valid font
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -101,45 +101,36 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
- FT_UInt32 standard_char;
+ const char* p;
+ FT_ULong ch;
- standard_char = script_class->standard_char1;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
+
+ p = script_class->standard_charstring;
+
+ /* We check a list of standard characters. The first match wins. */
+
+ glyph_index = 0;
+ while ( *p )
{
- if ( script_class->standard_char2 )
- {
- standard_char = script_class->standard_char2;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- {
- if ( script_class->standard_char3 )
- {
- standard_char = script_class->standard_char3;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- goto Exit;
- }
- else
- goto Exit;
- }
- }
- else
- goto Exit;
+ while ( *p == ' ' )
+ p++;
+
+ GET_UTF8_CHAR( ch, p );
+
+ af_get_char_index( &metrics->root,
+ ch,
+ &glyph_index,
+ &y_offset );
+ if ( glyph_index )
+ break;
}
+ if ( !glyph_index )
+ goto Exit;
+
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
- standard_char, glyph_index ));
+ ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -42,13 +42,13 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
AF_DEFINE_SCRIPT_CLASS( \
af_ ## s ## _script_class, \
AF_SCRIPT_ ## S, \
af_ ## s ## _uniranges, \
af_ ## s ## _nonbase_uniranges, \
- sc1, sc2, sc3 )
+ ss )
#include "afscript.h"
@@ -83,7 +83,7 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
&af_ ## s ## _script_class,
FT_LOCAL_ARRAY_DEF( AF_ScriptClass )
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -34,7 +34,7 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
AF_DECLARE_SCRIPT_CLASS( af_ ## s ## _script_class )
#include "afscript.h"
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -92,52 +92,41 @@
AF_ScriptClass script_class = AF_SCRIPT_CLASSES_GET
[style_class->script];
- FT_UInt32 standard_char;
+ const char* p;
+ FT_ULong ch;
+
+ p = script_class->standard_charstring;
+
/*
- * 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.
+ * We check a list of standard characters 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.
+ * The first match wins.
*/
- standard_char = script_class->standard_char1;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
+ glyph_index = 0;
+ while ( *p )
{
- if ( script_class->standard_char2 )
- {
- standard_char = script_class->standard_char2;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- {
- if ( script_class->standard_char3 )
- {
- standard_char = script_class->standard_char3;
- af_get_char_index( &metrics->root,
- standard_char,
- &glyph_index,
- &y_offset );
- if ( !glyph_index )
- goto Exit;
- }
- else
- goto Exit;
- }
- }
- else
- goto Exit;
+ while ( *p == ' ' )
+ p++;
+
+ GET_UTF8_CHAR( ch, p );
+
+ af_get_char_index( &metrics->root,
+ ch,
+ &glyph_index,
+ &y_offset );
+ if ( glyph_index )
+ break;
}
+ if ( !glyph_index )
+ goto Exit;
+
FT_TRACE5(( "standard character: U+%04lX (glyph index %d)\n",
- standard_char, glyph_index ));
+ ch, glyph_index ));
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
if ( error || face->glyph->outline.n_points <= 0 )
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -122,7 +122,7 @@
#include "afwrtsys.h"
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, sss ) \
FT_Init_Class_af_ ## s ## _script_class( \
&container->af_script_classes_rec[ss++] );
--- a/src/autofit/afranges.h
+++ b/src/autofit/afranges.h
@@ -26,13 +26,13 @@
FT_BEGIN_HEADER
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
extern const AF_Script_UniRangeRec af_ ## s ## _uniranges[];
#include "afscript.h"
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
extern const AF_Script_UniRangeRec af_ ## s ## _nonbase_uniranges[];
#include "afscript.h"
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -33,64 +33,64 @@
SCRIPT( arab, ARAB,
"Arabic",
HB_SCRIPT_ARABIC,
- 0x644, 0x62D, 0x640 ) /* ل ح ـ */
+ "\xD9\x84 \xD8\xAD \xD9\x80" ) /* ل ح ـ */
SCRIPT( cyrl, CYRL,
"Cyrillic",
HB_SCRIPT_CYRILLIC,
- 0x43E, 0x41E, 0x0 ) /* о О */
+ "\xD0\xBE \xD0\x9E" ) /* о О */
SCRIPT( deva, DEVA,
"Devanagari",
HB_SCRIPT_DEVANAGARI,
- 0x920, 0x935, 0x91F ) /* ठ व ट */
+ "\xE0\xA4\xA0 \xE0\xA4\xB5 \xE0\xA4\x9F" ) /* ठ व ट */
SCRIPT( grek, GREK,
"Greek",
HB_SCRIPT_GREEK,
- 0x3BF, 0x39F, 0x0 ) /* ο Ο */
+ "\xCE\xBF \xCE\x9F" ) /* ο Ο */
SCRIPT( hebr, HEBR,
"Hebrew",
HB_SCRIPT_HEBREW,
- 0x5DD, 0x0, 0x0 ) /* ם */
+ "\xD7\x9D" ) /* ם */
/* only digit zero has a simple shape in the Lao script */
SCRIPT( lao, LAO,
"Lao",
HB_SCRIPT_LAO,
- 0xED0, 0x0, 0x0 ) /* ໐ */
+ "\xE0\xBB\x90" ) /* ໐ */
SCRIPT( latn, LATN,
"Latin",
HB_SCRIPT_LATIN,
- 'o', 'O', '0' )
+ "o O 0" )
SCRIPT( latb, LATB,
"Latin Subscript Fallback",
HB_SCRIPT_INVALID,
- 0x2092, 0x2080, 0x0 ) /* ₒ ₀ */
+ "\xE2\x82\x92 \xE2\x82\x80" ) /* ₒ ₀ */
SCRIPT( latp, LATP,
"Latin Superscript Fallback",
HB_SCRIPT_INVALID,
- 0x1D52, 0x1D3C, 0x2070 ) /* ᵒ ᴼ ⁰ */
+ "\xE1\xB5\x92 \xE1\xB4\xBC \xE2\x81\xB0" ) /* ᵒ ᴼ ⁰ */
SCRIPT( none, NONE,
"no script",
HB_SCRIPT_INVALID,
- 0x0, 0x0, 0x0 )
+ NULL )
/* there are no simple forms for letters; we thus use two digit shapes */
SCRIPT( telu, TELU,
"Telugu",
HB_SCRIPT_TELUGU,
- 0xC66, 0xC67, 0x0 ) /* ౦ ౧ */
+ "\xE0\xB1\xA6 \xE0\xB1\xA7" ) /* ౦ ౧ */
SCRIPT( thai, THAI,
"Thai",
HB_SCRIPT_THAI,
- 0xE32, 0xE45, 0xE50 ) /* า ๅ ๐ */
+ "\xE0\xB8\xB2 \xE0\xB9\x85 \xE0\xB9\x90" ) /* า ๅ ๐ */
#ifdef AF_CONFIG_OPTION_INDIC
@@ -97,62 +97,62 @@
SCRIPT( beng, BENG,
"Bengali",
HB_SCRIPT_BENGALI,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( gujr, GUJR,
"Gujarati",
HB_SCRIPT_GUJARATI,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( guru, GURU,
"Gurmukhi",
HB_SCRIPT_GURMUKHI,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( knda, KNDA,
"Kannada",
HB_SCRIPT_KANNADA,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( limb, LIMB,
"Limbu",
HB_SCRIPT_LIMBU,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( mlym, MLYM,
"Malayalam",
HB_SCRIPT_MALAYALAM,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( orya, ORYA,
"Oriya",
HB_SCRIPT_ORIYA,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( sinh, SINH,
"Sinhala",
HB_SCRIPT_SINHALA,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( sund, SUND,
"Sundanese",
HB_SCRIPT_SUNDANESE,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( sylo, SYLO,
"Syloti Nagri",
HB_SCRIPT_SYLOTI_NAGRI,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( taml, TAML,
"Tamil",
HB_SCRIPT_TAMIL,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
SCRIPT( tibt, TIBT,
"Tibetan",
HB_SCRIPT_TIBETAN,
- 'o', 0x0, 0x0 ) /* XXX */
+ "o" ) /* XXX */
#endif /* AF_CONFIG_OPTION_INDIC */
@@ -161,7 +161,7 @@
SCRIPT( hani, HANI,
"CJKV ideographs",
HB_SCRIPT_HAN,
- 0x7530, 0x56D7, 0x0 ) /* 田囗 */
+ "\xE7\x94\xB0 \xE5\x9B\x97" ) /* 田 囗 */
#endif /* AF_CONFIG_OPTION_CJK */
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -309,7 +309,7 @@
*/
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+#define SCRIPT( s, S, d, h, ss ) \
AF_SCRIPT_ ## S,
/* The list of known scripts. */
@@ -343,9 +343,7 @@
AF_Script_UniRange script_uni_ranges;
AF_Script_UniRange script_uni_nonbase_ranges;
- FT_UInt32 standard_char1; /* for default width and height */
- FT_UInt32 standard_char2; /* ditto */
- FT_UInt32 standard_char3; /* ditto */
+ const char* standard_charstring; /* for default width and height */
} AF_ScriptClassRec;
@@ -524,9 +522,7 @@
script, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 ) \
+ std_charstring ) \
FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \
{ \
@@ -533,9 +529,7 @@
script, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 \
+ std_charstring, \
};
@@ -601,9 +595,7 @@
script_, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 ) \
+ std_charstring ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
{ \
@@ -610,9 +602,7 @@
ac->script = script_; \
ac->script_uni_ranges = ranges; \
ac->script_uni_nonbase_ranges = nonbase_ranges; \
- ac->standard_char1 = std_char1; \
- ac->standard_char2 = std_char2; \
- ac->standard_char3 = std_char3; \
+ ac->standard_charstring = std_charstring; \
}
--- a/src/autofit/hbshim.c
+++ b/src/autofit/hbshim.c
@@ -86,7 +86,7 @@
/* load HarfBuzz script tags */
#undef SCRIPT
-#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) h,
+#define SCRIPT( s, S, d, h, ss ) h,
static const hb_script_t scripts[] =