--- src/fcfreetype.c.orig Sun Nov 6 00:54:34 2005 +++ src/fcfreetype.c Sun Nov 6 01:01:29 2005 @@ -1780,6 +1780,7 @@ { 0x007C, 0x7C }, /* VERTICAL LINE */ { 0x007D, 0x7D }, /* RIGHT CURLY BRACKET */ { 0x007E, 0x7E }, /* TILDE */ +#if 0 { 0x00A0, 0xCA }, /* NO-BREAK SPACE */ { 0x00A1, 0xC1 }, /* INVERTED EXCLAMATION MARK */ { 0x00A2, 0xA2 }, /* CENT SIGN */ @@ -1908,6 +1909,7 @@ { 0xF8FF, 0xF0 }, /* Apple logo */ { 0xFB01, 0xDE }, /* LATIN SMALL LIGATURE FI */ { 0xFB02, 0xDF }, /* LATIN SMALL LIGATURE FL */ +#endif }; static const FcCharMap AppleRoman = { @@ -2286,8 +2288,8 @@ * to be cached by higher levels, so performance isn't critical */ -FT_UInt -FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4) +static FT_UInt +FcFreeTypeCharIndex_ (FT_Face face, FcChar32 ucs4) { int initial, offset, decode; FT_UInt glyphindex; @@ -2351,6 +2353,64 @@ return 0; } +#define NELEM(a) (sizeof(a)/sizeof(a[0])) + +static struct { + FcChar32 s, d; +} Jp[] = { + /* Ucs */ /* JISX0208 */ + /* { 0x005C , 0xFF3C }, */ /* 2140 */ + { 0x00A2 , 0xFFE0 }, /* 2171 */ + { 0x00A3 , 0xFFE1 }, /* 2172 */ + { 0x00AC , 0xFFE2 }, /* 224C */ + { 0x2015 , 0x2014 }, /* 213D */ + { 0x2016 , 0x2225 }, /* 2142 */ + { 0x2212 , 0xFF0D }, /* 215D */ + { 0x301C , 0xFF5E }, /* 2141 */ + { 0xFFE3 , 0x203E }, /* 2131 */ + { 0xFFE5 , 0x00A5 }, /* 216F */ +}; + +static FcChar32 +SubstJp(FcChar32 ucs4) +{ + int j; + + switch (ucs4 >> 8) { + case 0x00: + case 0x20: + case 0x22: + case 0x30: + case 0xFF: + for (j = 0; j < NELEM(Jp); j++) + if (ucs4 == Jp[j].s) + return Jp[j].d; + } + return 0; +} + +static void +SubstJpCharSetAdd(FcCharSet *fcs) +{ + int j; + + for (j = 0; j < NELEM(Jp); j++) + if (FcCharSetHasChar(fcs, Jp[j].d)) + FcCharSetAddChar(fcs, Jp[j].s); +} + +FT_UInt +FcFreeTypeCharIndex(FT_Face face, FcChar32 ucs4) +{ + FT_UInt index; + + if ((index = FcFreeTypeCharIndex_(face, ucs4)) == 0) { + /* printf("U+%04X -> U+%04X", ucs4, SubstJp(ucs4)); */ + index = FcFreeTypeCharIndex_(face, SubstJp(ucs4)); + } + return index; +} + static FcBool FcFreeTypeCheckGlyph (FT_Face face, FcChar32 ucs4, FT_UInt glyph, FcBlanks *blanks, @@ -2631,6 +2691,7 @@ *spacing = FC_DUAL; else *spacing = FC_PROPORTIONAL; + SubstJpCharSetAdd(fcs); return fcs; bail1: FcCharSetDestroy (fcs);