diff options
author | Akira TAGOH <akira@tagoh.org> | 2012-05-09 17:07:58 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2017-09-11 11:47:54 +0900 |
commit | c668bf6e0d8ccc867628a63511bc1ab6d37f0ab5 (patch) | |
tree | afa9af5dd4c3ff017b66838bf3d3caa7ac1d886e | |
parent | 4d3410bd08a0f61272ca1dbb1dd27ac8c5f222de (diff) |
Bug 24613 - fc-query can't query face 0bz24613
Try to support non-Unicode encoded PCF/BDF fonts as far as possible.
XXX: this is demonstration code and no real function to convert
something to Unicode.
-rw-r--r-- | src/fcfreetype.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 724f2752..73424c74 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -2423,6 +2423,77 @@ FcFreeTypeCharSetAndSpacingForSize (FT_Face face, FcBlanks *blanks, int *spacing } } #endif + /* This is maybe a broken BDF/PCF font. + * it might be figured out by setting up the charmap manually + * and go through all of glyphs available. + */ + if (face->num_fixed_sizes == 1 && FcCharSetCount (fcs) == 0) + { + const char *cs_encoding, *cs_registry; + FcChar32 c; + + FT_Set_Charmap (face, face->charmaps[0]); + FT_Get_BDF_Charset_ID (face, &cs_encoding, &cs_registry); + page = ~0; + leaf = NULL; + c = FT_Get_First_Char (face, &glyph); + while (glyph != 0) + { + /* XXX: convert "c" to ucs4 according to "cs_encoding" and "cs_registry" */ + ucs4 = c; + + if (FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance, using_strike)) + { + if (advance) + { + if (!has_advance) + { + has_advance = FcTrue; + advance_one = advance; + } + else if (!APPROXIMATELY_EQUAL (advance, advance_one)) + { + if (fixed_advance) + { + dual_advance = FcTrue; + fixed_advance = FcFalse; + advance_two = advance; + } + else if (!APPROXIMATELY_EQUAL (advance, advance_two)) + dual_advance = FcFalse; + } + } + + if ((ucs4 >> 8) != page) + { + page = (ucs4 >> 8); + leaf = FcCharSetFindLeafCreate (fcs, ucs4); + if (!leaf) + goto bail1; + } + off = ucs4 & 0xff; + leaf->map[off >> 5] |= (1 << (off & 0x1f)); +#ifdef CHECK + if (ucs4 > font_max) + font_max = ucs4; +#endif + } + c = FT_Get_Next_Char (face, ucs4, &glyph); + } +#ifdef CHECK + for (ucs4 = 0; ucs4 < 0x10000; ucs4++) + { + FcBool FT_Has, FC_Has; + + FT_Has = FT_Get_Char_Index (face, ucs4) != 0; + FC_Has = FcCharSetHasChar (fcs, ucs4); + if (FT_Has != FC_Has) + { + printf ("0x%08x FT says %d FC says %d\n", ucs4, FT_Has, FC_Has); + } + } +#endif + } #ifdef CHECK printf ("%d glyphs %d encoded\n", (int) face->num_glyphs, FcCharSetCount (fcs)); for (ucs4 = 0; ucs4 <= font_max; ucs4++) @@ -2458,6 +2529,9 @@ FcCharSet * FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing) { FcCharSet *cs; +#if HAVE_FT_GET_BDF_PROPERTY + BDF_PropertyRec prop; +#endif /* * Check for bitmap-only ttf fonts that are missing the glyf table. @@ -2478,6 +2552,13 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing) } cs = FcFreeTypeCharSetAndSpacingForSize (face, blanks, spacing, strike_index); } +#if HAVE_FT_GET_BDF_PROPERTY + else if (face->num_fixed_sizes == 1 && + FT_Get_BDF_Property (face, "PIXEL_SIZE", &prop) == 0) + { + cs = FcFreeTypeCharSetAndSpacingForSize (face, blanks, spacing, 0); + } +#endif else cs = FcFreeTypeCharSetAndSpacingForSize (face, blanks, spacing, -1); return cs; |