Keith Packard
2006-Sep-07 14:30 UTC
[Fontconfig] fontconfig: Branch ''master'' - 2 commits
src/fccache.c | 7 +++- src/fcfreetype.c | 83 +++++++++++++++++++------------------------------------ 2 files changed, 36 insertions(+), 54 deletions(-) New commits: diff-tree 31e0f0321057a7612ed5a7fa890dad09e6a53ee6 (from 8d779ce4b3cdac796e20ca568654c0ef1c576809) Author: David Turner <david@freetype.org> Date: Thu Sep 7 14:29:35 2006 -0700 Replace character discovery loop with simpler, faster version. The existing loop for discovering which characters map to glyphs is ugly and inefficient. The replacement is functionally identical, but far cleaner and faster. diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 96f70c3..83c58d6 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -2584,71 +2584,48 @@ FcFreeTypeCharSetAndSpacing (FT_Face fac } else { - FT_UInt gindex; - - /* - * Find the first encoded character in the font - */ - if (FT_Get_Char_Index (face, 0)) + page = ~0; + leaf = NULL; + ucs4 = FT_Get_First_Char (face, &glyph); + while (glyph != 0) { - ucs4 = 0; - gindex = 1; - } - else - { - ucs4 = FT_Get_Next_Char (face, 0, &gindex); - if (!ucs4) - gindex = 0; - } - - while (gindex) - { - page = ucs4 >> 8; - leaf = 0; - while ((ucs4 >> 8) == page) + if (FcFreeTypeCheckGlyph (face, ucs4, glyph, blanks, &advance)) { - glyph = FT_Get_Char_Index (face, ucs4); - if (glyph && FcFreeTypeCheckGlyph (face, ucs4, - glyph, blanks, &advance)) + if (advance) { - if (advance) + if (!has_advance) { - if (!has_advance) - { - has_advance = FcTrue; - advance_one = advance; - } - else if (!APPROXIMATELY_EQUAL (advance, advance_one)) + has_advance = FcTrue; + advance_one = advance; + } + else if (!APPROXIMATELY_EQUAL (advance, advance_one)) + { + if (fixed_advance) { - if (fixed_advance) - { - dual_advance = FcTrue; - fixed_advance = FcFalse; - advance_two = advance; - } - else if (!APPROXIMATELY_EQUAL (advance, advance_two)) - dual_advance = FcFalse; + 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) - { - leaf = FcCharSetFindLeafCreate (fcs, ucs4); - if (!leaf) - goto bail1; - } - off = ucs4 & 0xff; - leaf->map[off >> 5] |= (1 << (off & 0x1f)); + goto bail1; + } + off = ucs4 & 0xff; + leaf->map[off >> 5] |= (1 << (off & 0x1f)); #ifdef CHECK - if (ucs4 > font_max) - font_max = ucs4; + if (ucs4 > font_max) + font_max = ucs4; #endif - } - ucs4++; } - ucs4 = FT_Get_Next_Char (face, ucs4 - 1, &gindex); - if (!ucs4) - gindex = 0; + ucs4 = FT_Get_Next_Char (face, ucs4, &glyph); } #ifdef CHECK for (ucs4 = 0; ucs4 < 0x10000; ucs4++) diff-tree 8d779ce4b3cdac796e20ca568654c0ef1c576809 (from 4c34c0c52a4e943c6770a6178e5012a3d6fe96d0) Author: Keith Packard <keithp@neko.keithp.com> Date: Thu Sep 7 14:22:16 2006 -0700 Reference patterns in FcCacheCopySet. As patterns are put into the font set copy, mark them as referenced so the cache stays around while the font set is in use. diff --git a/src/fccache.c b/src/fccache.c index e4b04fc..11f88a7 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -816,11 +816,16 @@ FcCacheCopySet args(const FcCache *c) if (!new) return NULL; for (i = 0; i < old->nfont; i++) - if (!FcFontSetAdd (new, FcFontSetFont (old, i))) + { + FcPattern *font = FcFontSetFont (old, i); + + FcPatternReference (font); + if (!FcFontSetAdd (new, font)) { FcFontSetDestroy (new); return NULL; } + } return new; }