[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.
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
diff --git a/ChangeLog b/ChangeLog
index 918e86c..61ca9d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/src/autofit/afcjk.c b/src/autofit/afcjk.c
index a1f0dca..96a2093 100644
--- a/src/autofit/afcjk.c
+++ b/src/autofit/afcjk.c
@@ -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 )
- 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",
- 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 )
diff --git a/src/autofit/afglobal.c b/src/autofit/afglobal.c
index b587a90..7aa2e11 100644
--- a/src/autofit/afglobal.c
+++ b/src/autofit/afglobal.c
@@ -42,12 +42,12 @@
#undef SCRIPT
-#define SCRIPT( s, S, d, h, dc ) \
- AF_DEFINE_SCRIPT_CLASS( \
- af_ ## s ## _script_class, \
- AF_SCRIPT_ ## S, \
- af_ ## s ## _uniranges, \
- dc )
+#define SCRIPT( s, S, d, h, sc1, sc2, sc3 ) \
+ AF_DEFINE_SCRIPT_CLASS( \
+ af_ ## s ## _script_class, \
+ AF_SCRIPT_ ## S, \
+ af_ ## s ## _uniranges, \
+ 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 )
diff --git a/src/autofit/afglobal.h b/src/autofit/afglobal.h
index 0a7d273..d2da40e 100644
--- a/src/autofit/afglobal.h
+++ b/src/autofit/afglobal.h
@@ -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"
diff --git a/src/autofit/aflatin.c b/src/autofit/aflatin.c
index 8dac220..13351c2 100644
--- a/src/autofit/aflatin.c
+++ b/src/autofit/aflatin.c
@@ -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 )
- 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",
- 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 )
diff --git a/src/autofit/afpic.c b/src/autofit/afpic.c
index 3980307..cb29fd7 100644
--- a/src/autofit/afpic.c
+++ b/src/autofit/afpic.c
@@ -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++] );
diff --git a/src/autofit/afranges.h b/src/autofit/afranges.h
index cb04a3b..fe5b2aa 100644
--- a/src/autofit/afranges.h
+++ b/src/autofit/afranges.h
@@ -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"
diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h
index 562e15b..ae20932 100644
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -20,108 +20,108 @@
/* Define `SCRIPT' as needed. */
- /* 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). */
+ /* 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 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 */
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index 0f599f7..61badd1 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -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; \
}
diff --git a/src/autofit/hbshim.c b/src/autofit/hbshim.c
index 35cf1d3..812cd53 100644
--- a/src/autofit/hbshim.c
+++ b/src/autofit/hbshim.c
@@ -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[] =