From 319337567abf5adb2dc2011d49f79c0c634d1ca3 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 6 Oct 2009 22:38:24 +0100 Subject: [PATCH] Initial attempt at Arabic shaping. Not sure if it'll work. --- ttxt.c | 73 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/ttxt.c b/ttxt.c index e020628..f658a2e 100644 --- a/ttxt.c +++ b/ttxt.c @@ -101,7 +101,12 @@ struct glyph { int unicode; char const *name; unsigned char flags; -#define SC 1 /* Character has a small-caps variant. */ +#define SC 1 /* Character has a small-caps variant. */ +#define A1 2 /* Arabic character with upwards tail. */ +#define A2 4 /* Arabic character with downwards tail. */ +#define A3 8 /* Arabic character with loopy tail. */ +#define AF 16 /* Arabic character with a dedicated final form. */ +#define AFI 32 /* Arabic character with a final/isolated from. */ } glyphs[] = { /* * The first batch of glyphs comes from the code tables at the end of @@ -367,33 +372,33 @@ struct glyph { */ /* ASV-CODAR glyphs from Appendix 3 */ {{001,001,001,001,001,001,000,000,000}, 0x0627 }, /* alef */ - {{000,000,000,001,001,077,000,004,000}, 0x0628 }, /* beh */ + {{000,000,000,001,001,077,000,004,000}, 0x0628, 0, A1 }, /* beh */ {{000,012,000,001,001,077,000,000,000}, 0x062a }, /* teh */ - {{004,012,000,001,001,077,000,000,000}, 0x062b }, /* theh */ - {{000,000,010,024,002,077,000,004,000}, 0x062c }, /* jeem */ - {{000,000,010,024,002,077,000,000,000}, 0x062d }, /* hah */ - {{004,000,010,024,002,077,000,000,000}, 0x062e }, /* khah */ - {{000,004,002,001,001,017,000,000,000}, 0x062f }, /* dal */ + {{004,012,000,001,001,077,000,000,000}, 0x062b, 0, A1 }, /* theh */ + {{000,000,010,024,002,077,000,004,000}, 0x062c, 0, A1 }, /* jeem */ + {{000,000,010,024,002,077,000,000,000}, 0x062d, 0, A2 }, /* hah */ + {{004,000,010,024,002,077,000,000,000}, 0x062e, 0, A2 }, /* khah */ + {{000,004,002,001,001,017,000,000,000}, 0x062f, 0, A2 }, /* dal */ {{001,004,002,001,001,017,000,000,000}, 0x0630 }, /* thal */ {{000,000,000,001,001,001,002,004,010}, 0x0631 }, /* ra */ {{000,004,000,001,001,001,002,004,010}, 0x0632 }, /* zain */ - {{000,000,000,025,025,077,000,000,000}, 0x0633 }, /* seen */ - {{004,012,000,025,025,077,000,000,000}, 0x0634 }, /* sheen */ - {{000,000,000,007,011,077,000,000,000}, 0x0635 }, /* sad */ - {{000,004,000,007,011,077,000,000,000}, 0x0636 }, /* dad */ + {{000,000,000,025,025,077,000,000,000}, 0x0633, 0, A3 }, /* seen */ + {{004,012,000,025,025,077,000,000,000}, 0x0634, 0, A3 }, /* sheen */ + {{000,000,000,007,011,077,000,000,000}, 0x0635, 0, A3 }, /* sad */ + {{000,004,000,007,011,077,000,000,000}, 0x0636, 0, A3 }, /* dad */ {{010,010,010,017,011,077,000,000,000}, 0x0637 }, /* tah */ {{010,012,010,017,011,077,000,000,000}, 0x0638 }, /* zah */ - {{000,000,006,010,010,077,000,000,000}, 0x0639 }, /* ain */ - {{004,000,006,010,010,077,000,000,000}, 0x063a }, /* ghain */ - {{002,000,002,005,003,077,000,000,000}, 0x0641 }, /* feh */ - {{012,000,002,005,003,077,000,000,000}, 0x0642 }, /* qaf */ - {{001,002,004,016,001,077,000,000,000}, 0x0643 }, /* kaf */ - {{001,001,001,001,001,077,000,000,000}, 0x0644 }, /* lam */ - {{000,000,000,000,006,071,006,000,000}, 0x0645 }, /* meem */ - {{000,004,000,001,001,077,000,000,000}, 0x0646 }, /* noon */ - {{000,006,001,015,013,077,000,000,000}, 0x0647 }, /* heh */ + {{000,000,006,010,010,077,000,000,000}, 0x0639, 0, A2 }, /* ain */ + {{004,000,006,010,010,077,000,000,000}, 0x063a, 0, A2 }, /* ghain */ + {{002,000,002,005,003,077,000,000,000}, 0x0641, 0, A1 }, /* feh */ + {{012,000,002,005,003,077,000,000,000}, 0x0642, 0, A1 }, /* qaf */ + {{001,002,004,016,001,077,000,000,000}, 0x0643, 0, A1 }, /* kaf */ + {{001,001,001,001,001,077,000,000,000}, 0x0644, 0, A1 }, /* lam */ + {{000,000,000,000,006,071,006,000,000}, 0x0645, 0, A2 }, /* meem */ + {{000,004,000,001,001,077,000,000,000}, 0x0646, 0, A1 }, /* noon */ + {{000,006,001,015,013,077,000,000,000}, 0x0647, 0, AF }, /* heh */ {{000,000,000,003,005,007,001,001,016}, 0x0648 }, /* waw */ - {{000,000,000,001,001,077,000,012,000}, 0x064a }, /* yeh */ + {{000,000,000,001,001,077,000,012,000}, 0x064a, 0, AFI }, /* yeh */ {{000,000,006,010,010,006,010,000,000}, 0x0621 }, /* hamza */ {{000,000,000,003,025,025,034,000,012}, 0xfef2, "uni064A.fina" }, /* yeh */ {{000,000,000,003,025,025,034,000,000}, 0x0649 }, /* alef maksura */ @@ -473,6 +478,11 @@ struct glyph { {{022,022,011,000,000,000,000,000,000}, 0x201f }, /* quotedblreversed */ {{000,004,004,025,016,004,000,000,000}, 0x2193, "arrowdown" }, + /* Arabic tails */ + {{000,000,000,001,001,001,000,000,000}, -1, "tail1" }, + {{000,000,000,000,000,001,002,002,001}, -1, "tail2" }, + {{000,000,000,004,004,003,000,000,000}, -1, "tail3" }, + /* This is getting silly. */ {{000,000,016,021,037,021,021,000,000}, -1, "a.sc" }, {{000,000,036,021,036,021,036,000,000}, -1, "b.sc" }, @@ -539,6 +549,12 @@ main(int argc, char **argv) "['smcp' ('latn' <'dflt'>)]\n"); printf("Lookup: 1 0 0 \"c2sc: upper-case to small caps\" {\"c2sc\"} " "['c2sc' ('latn' <'dflt'>)]\n"); + printf("Lookup: 2 0 0 \"fina: Arabic tails\" {\"tails\"} " + "['fina' ('arab' <'dflt'>)]\n"); + printf("Lookup: 1 0 0 \"fina: Arabic final form\" {\"fina\"} " + "['fina' ('arab' <'dflt'>)]\n"); + printf("Lookup: 1 0 0 \"isol: Arabic isolated form\" {\"isol\"} " + "['isol' ('arab' <'dflt'>)]\n"); printf("BeginChars: %d %d\n", 65536 + extraglyphs, nglyphs); extraglyphs = 0; for (i = 0; i < nglyphs; i++) { @@ -559,6 +575,21 @@ main(int argc, char **argv) "c2sc" : "smcp", tolower((unsigned char)glyphs[i].name[0]), glyphs[i].name + 1); + if ((glyphs[i].flags & A1)) + printf("MultipleSubs2: \"tails\" uni%04X tail1\n", + (unsigned)glyphs[i].unicode); + if ((glyphs[i].flags & A2)) + printf("MultipleSubs2: \"tails\" uni%04X tail2\n", + (unsigned)glyphs[i].unicode); + if ((glyphs[i].flags & A3)) + printf("MultipleSubs2: \"tails\" uni%04X tail3\n", + (unsigned)glyphs[i].unicode); + if ((glyphs[i].flags & (AF|AFI))) + printf("Substitution2: \"fina\" uni%04X.fina\n", + (unsigned)glyphs[i].unicode); + if ((glyphs[i].flags & AFI)) + printf("Substitution2: \"isol\" uni%04X.fina\n", + (unsigned)glyphs[i].unicode); dochar(glyphs[i].data); printf("EndChar\n"); } -- 2.30.2