[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
diff --git a/ChangeLog b/ChangeLog
index d696e8a..b13a536 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2015-12-06 Werner Lemberg <wl@gnu.org>
+
+ [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 <wl@gnu.org>
* 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 <mpsuzuki@hiroshima-u.ac.jp>
-
+
[base] Fix a leak by broken sfnt-PS or resource fork (#46028).
open_face_from_buffer() frees passed buffer if valid font
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index 792950d..089e66d 100644
--- 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 )
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index f5a3957..ecd333e 100644
--- 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 )
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index a3112de..0a54a96 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -34,7 +34,7 @@ FT_BEGIN_HEADER
#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"
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 53851e7..6d06731 100644
--- 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 )
diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c
index 5589e61..37254a2 100644
--- 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++] );
diff --git a/src/autofit/afranges.h b/src/autofit/afranges.h
index b080873..bca5084 100644
--- 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"
diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h
index b92e84f..d249098 100644
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -33,126 +33,126 @@
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
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 */
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index cbe8bc2..b483619 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -309,7 +309,7 @@ extern void* _af_debug_hints;
*/
#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 @@ extern void* _af_debug_hints;
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,18 +522,14 @@ extern void* _af_debug_hints;
script, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 ) \
+ std_charstring ) \
FT_CALLBACK_TABLE_DEF \
const AF_ScriptClassRec script_class = \
{ \
script, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 \
+ std_charstring, \
};
@@ -601,18 +595,14 @@ extern void* _af_debug_hints;
script_, \
ranges, \
nonbase_ranges, \
- std_char1, \
- std_char2, \
- std_char3 ) \
+ std_charstring ) \
FT_LOCAL_DEF( void ) \
FT_Init_Class_ ## script_class( AF_ScriptClassRec* ac ) \
{ \
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; \
}
diff --git a/src/autofit/hbshim.c b/src/autofit/hbshim.c
index 7a45059..7b05823 100644
--- 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[] =