Commit d3284462c3f227a4bc396fa9f3b716e46d43f5c8

Werner Lemberg 2015-03-11T16:45:58

[autofit] Add support for Arabic script. Thanks to Titus Nemeth <tn@tntypography.eu> for guidance! * src/autofit/afblue.dat: Add blue zone data for Arabic. * src/autofit/afblue.c, src/autofit/afblue.h: Regenerated. * src/autofit/afscript.h: Add Arabic standard characters. * src/autofit/afranges.c: Add Arabic data. * src/autofit/afstyles.h: Add Arabic data. * docs/CHANGES: Document it.

diff --git a/ChangeLog b/ChangeLog
index 431a405..37e5e48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2015-03-11  Werner Lemberg  <wl@gnu.org>
 
+	[autofit] Add support for Arabic script.
+
+	Thanks to Titus Nemeth <tn@tntypography.eu> for guidance!
+
+	* src/autofit/afblue.dat: Add blue zone data for Arabic.
+
+	* src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.
+
+	* src/autofit/afscript.h: Add Arabic standard characters.
+
+	* src/autofit/afranges.c: Add Arabic data.
+
+	* src/autofit/afstyles.h: Add Arabic data.
+
+	* docs/CHANGES: Document it.
+
+2015-03-11  Werner Lemberg  <wl@gnu.org>
+
 	Rename `svxf86nm.h' to `svfntfmt.h'; update related symbols.
 
 	* include/internal/ftserv.h (FT_SERVICE_XFREE86_NAME_H): Renamed
diff --git a/docs/CHANGES b/docs/CHANGES
index 2153e3a..b85a71e 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -23,6 +23,8 @@ CHANGES BETWEEN 2.5.5 and 2.6
 
     - Thai script support has been added to the auto-hinter.
 
+    - Arabic script support has been added to the auto-hinter.
+
 
   III. MISCELLANEOUS
 
diff --git a/src/autofit/afblue.c b/src/autofit/afblue.c
index 1f9869f..e2b2451 100644
--- a/src/autofit/afblue.c
+++ b/src/autofit/afblue.c
@@ -26,6 +26,10 @@
   af_blue_strings[] =
   {
     /* */
+    '\xD8', '\xA7', '\xD8', '\xA5', '\xD9', '\x84', '\xD9', '\x83', '\xD8', '\xB7', '\xD8', '\xB8',  /* ا إ ل ك ط ظ */
+    '\0',
+    '\xD8', '\xAA', '\xD8', '\xAB', '\xD8', '\xB7', '\xD8', '\xB8', '\xD9', '\x83',  /* ت ث ط ظ ك */
+    '\0',
     '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\x9F', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD',  /* БВЕПЗОСЭ */
     '\0',
     '\xD0', '\x91', '\xD0', '\x92', '\xD0', '\x95', '\xD0', '\xA8', '\xD0', '\x97', '\xD0', '\x9E', '\xD0', '\xA1', '\xD0', '\xAD',  /* БВЕШЗОСЭ */
@@ -135,6 +139,9 @@
   af_blue_stringsets[] =
   {
     /* */
+    { AF_BLUE_STRING_ARABIC_TOP,   AF_BLUE_PROPERTY_LATIN_TOP },
+    { AF_BLUE_STRING_ARABIC_JOIN,  0                          },
+    { AF_BLUE_STRING_MAX,          0                          },
     { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        },
     { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 },
     { AF_BLUE_STRING_CYRILLIC_SMALL,           AF_BLUE_PROPERTY_LATIN_TOP      |
diff --git a/src/autofit/afblue.dat b/src/autofit/afblue.dat
index 4c35b22..fd5684e 100644
--- a/src/autofit/afblue.dat
+++ b/src/autofit/afblue.dat
@@ -67,6 +67,11 @@
 
 AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
 
+  AF_BLUE_STRING_ARABIC_TOP
+    "ا إ ل ك ط ظ"
+  AF_BLUE_STRING_ARABIC_JOIN
+    "ت ث ط ظ ك"
+
   AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP
     "БВЕПЗОСЭ"
   AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM
@@ -283,6 +288,11 @@ AF_BLUE_STRING_ENUM AF_BLUE_STRINGS_ARRAY AF_BLUE_STRING_MAX_LEN:
 
 AF_BLUE_STRINGSET_ENUM AF_BLUE_STRINGSETS_ARRAY AF_BLUE_STRINGSET_MAX_LEN:
 
+  AF_BLUE_STRINGSET_ARAB
+    { AF_BLUE_STRING_ARABIC_TOP,   AF_BLUE_PROPERTY_LATIN_TOP }
+    { AF_BLUE_STRING_ARABIC_JOIN,  0                          }
+    { AF_BLUE_STRING_MAX,          0                          }
+
   AF_BLUE_STRINGSET_CYRL
     { AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP,     AF_BLUE_PROPERTY_LATIN_TOP        }
     { AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM,  0                                 }
diff --git a/src/autofit/afblue.h b/src/autofit/afblue.h
index c27de4f..94e33a9 100644
--- a/src/autofit/afblue.h
+++ b/src/autofit/afblue.h
@@ -74,37 +74,39 @@ FT_BEGIN_HEADER
 
   typedef enum  AF_Blue_String_
   {
-    AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 0,
-    AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 17,
-    AF_BLUE_STRING_CYRILLIC_SMALL = 34,
-    AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 51,
-    AF_BLUE_STRING_DEVANAGARI_BASE = 58,
-    AF_BLUE_STRING_DEVANAGARI_TOP = 83,
-    AF_BLUE_STRING_DEVANAGARI_HEAD = 108,
-    AF_BLUE_STRING_DEVANAGARI_BOTTOM = 133,
-    AF_BLUE_STRING_GREEK_CAPITAL_TOP = 140,
-    AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 155,
-    AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 168,
-    AF_BLUE_STRING_GREEK_SMALL = 181,
-    AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 198,
-    AF_BLUE_STRING_HEBREW_TOP = 215,
-    AF_BLUE_STRING_HEBREW_BOTTOM = 232,
-    AF_BLUE_STRING_HEBREW_DESCENDER = 245,
-    AF_BLUE_STRING_LATIN_CAPITAL_TOP = 256,
-    AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 265,
-    AF_BLUE_STRING_LATIN_SMALL_F_TOP = 274,
-    AF_BLUE_STRING_LATIN_SMALL = 282,
-    AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 290,
-    AF_BLUE_STRING_TELUGU_TOP = 296,
-    AF_BLUE_STRING_TELUGU_BOTTOM = 318,
-    AF_BLUE_STRING_THAI_TOP = 340,
-    AF_BLUE_STRING_THAI_BOTTOM = 359,
-    AF_BLUE_STRING_THAI_ASCENDER = 381,
-    AF_BLUE_STRING_THAI_LARGE_ASCENDER = 391,
-    AF_BLUE_STRING_THAI_DESCENDER = 401,
-    AF_BLUE_STRING_THAI_LARGE_DESCENDER = 414,
-    AF_BLUE_STRING_THAI_DIGIT_TOP = 421,
-    af_blue_1_1 = 430,
+    AF_BLUE_STRING_ARABIC_TOP = 0,
+    AF_BLUE_STRING_ARABIC_JOIN = 13,
+    AF_BLUE_STRING_CYRILLIC_CAPITAL_TOP = 24,
+    AF_BLUE_STRING_CYRILLIC_CAPITAL_BOTTOM = 41,
+    AF_BLUE_STRING_CYRILLIC_SMALL = 58,
+    AF_BLUE_STRING_CYRILLIC_SMALL_DESCENDER = 75,
+    AF_BLUE_STRING_DEVANAGARI_BASE = 82,
+    AF_BLUE_STRING_DEVANAGARI_TOP = 107,
+    AF_BLUE_STRING_DEVANAGARI_HEAD = 132,
+    AF_BLUE_STRING_DEVANAGARI_BOTTOM = 157,
+    AF_BLUE_STRING_GREEK_CAPITAL_TOP = 164,
+    AF_BLUE_STRING_GREEK_CAPITAL_BOTTOM = 179,
+    AF_BLUE_STRING_GREEK_SMALL_BETA_TOP = 192,
+    AF_BLUE_STRING_GREEK_SMALL = 205,
+    AF_BLUE_STRING_GREEK_SMALL_DESCENDER = 222,
+    AF_BLUE_STRING_HEBREW_TOP = 239,
+    AF_BLUE_STRING_HEBREW_BOTTOM = 256,
+    AF_BLUE_STRING_HEBREW_DESCENDER = 269,
+    AF_BLUE_STRING_LATIN_CAPITAL_TOP = 280,
+    AF_BLUE_STRING_LATIN_CAPITAL_BOTTOM = 289,
+    AF_BLUE_STRING_LATIN_SMALL_F_TOP = 298,
+    AF_BLUE_STRING_LATIN_SMALL = 306,
+    AF_BLUE_STRING_LATIN_SMALL_DESCENDER = 314,
+    AF_BLUE_STRING_TELUGU_TOP = 320,
+    AF_BLUE_STRING_TELUGU_BOTTOM = 342,
+    AF_BLUE_STRING_THAI_TOP = 364,
+    AF_BLUE_STRING_THAI_BOTTOM = 383,
+    AF_BLUE_STRING_THAI_ASCENDER = 405,
+    AF_BLUE_STRING_THAI_LARGE_ASCENDER = 415,
+    AF_BLUE_STRING_THAI_DESCENDER = 425,
+    AF_BLUE_STRING_THAI_LARGE_DESCENDER = 438,
+    AF_BLUE_STRING_THAI_DIGIT_TOP = 445,
+    af_blue_1_1 = 454,
 #ifdef AF_CONFIG_OPTION_CJK
     AF_BLUE_STRING_CJK_TOP = af_blue_1_1 + 1,
     AF_BLUE_STRING_CJK_BOTTOM = af_blue_1_1 + 153,
@@ -162,14 +164,15 @@ FT_BEGIN_HEADER
 
   typedef enum  AF_Blue_Stringset_
   {
-    AF_BLUE_STRINGSET_CYRL = 0,
-    AF_BLUE_STRINGSET_DEVA = 6,
-    AF_BLUE_STRINGSET_GREK = 12,
-    AF_BLUE_STRINGSET_HEBR = 19,
-    AF_BLUE_STRINGSET_LATN = 23,
-    AF_BLUE_STRINGSET_TELU = 30,
-    AF_BLUE_STRINGSET_THAI = 33,
-    af_blue_2_1 = 41,
+    AF_BLUE_STRINGSET_ARAB = 0,
+    AF_BLUE_STRINGSET_CYRL = 3,
+    AF_BLUE_STRINGSET_DEVA = 9,
+    AF_BLUE_STRINGSET_GREK = 15,
+    AF_BLUE_STRINGSET_HEBR = 22,
+    AF_BLUE_STRINGSET_LATN = 26,
+    AF_BLUE_STRINGSET_TELU = 33,
+    AF_BLUE_STRINGSET_THAI = 36,
+    af_blue_2_1 = 44,
 #ifdef AF_CONFIG_OPTION_CJK
     AF_BLUE_STRINGSET_HANI = af_blue_2_1 + 0,
     af_blue_2_1_1 = af_blue_2_1 + 2,
diff --git a/src/autofit/afranges.c b/src/autofit/afranges.c
index 15837b4..c1e0afb 100644
--- a/src/autofit/afranges.c
+++ b/src/autofit/afranges.c
@@ -19,6 +19,17 @@
 #include "afranges.h"
 
 
+  const AF_Script_UniRangeRec  af_arab_uniranges[] =
+  {
+    AF_UNIRANGE_REC(  0x0600UL,  0x06FFUL ),  /* Arabic                                 */
+    AF_UNIRANGE_REC(  0x0750UL,  0x07FFUL ),  /* Arabic Supplement                      */
+    AF_UNIRANGE_REC(  0x08A0UL,  0x08FFUL ),  /* Arabic Extended-A                      */
+    AF_UNIRANGE_REC(  0xFB50UL,  0xFDFFUL ),  /* Arabic Presentation Forms-A            */
+    AF_UNIRANGE_REC(  0xFE70UL,  0xFEFFUL ),  /* Arabic Presentation Forms-B            */
+    AF_UNIRANGE_REC( 0x1EE00UL, 0x1EEFFUL ),  /* Arabic Mathematical Alphabetic Symbols */
+    AF_UNIRANGE_REC(       0UL,       0UL )
+  };
+
   const AF_Script_UniRangeRec  af_cyrl_uniranges[] =
   {
     AF_UNIRANGE_REC(  0x0400UL,  0x04FFUL ),  /* Cyrillic            */
diff --git a/src/autofit/afscript.h b/src/autofit/afscript.h
index 362c75e..dfcc830 100644
--- a/src/autofit/afscript.h
+++ b/src/autofit/afscript.h
@@ -26,6 +26,11 @@
   /* script name tag, followed by a string of standard characters (to */
   /* derive the standard width and height of stems).                  */
 
+  SCRIPT( arab, ARAB,
+          "Arabic",
+          HB_SCRIPT_ARABIC,
+          0x644, 0x62D, 0x640 ) /* ل ح ـ */
+
   SCRIPT( cyrl, CYRL,
           "Cyrillic",
           HB_SCRIPT_CYRILLIC,
diff --git a/src/autofit/afstyles.h b/src/autofit/afstyles.h
index a65b429..bfd5bb9 100644
--- a/src/autofit/afstyles.h
+++ b/src/autofit/afstyles.h
@@ -80,6 +80,14 @@
                        "default",                        \
                        DEFAULT )
 
+
+  STYLE( arab_dflt, ARAB_DFLT,
+         "Arabic default style",
+         AF_WRITING_SYSTEM_LATIN,
+         AF_SCRIPT_ARAB,
+         AF_BLUE_STRINGSET_ARAB,
+         AF_COVERAGE_DEFAULT )
+
   META_STYLE_LATIN( cyrl, CYRL, "Cyrillic" )
 
   META_STYLE_LATIN( grek, GREK, "Greek" )