diff options
author | Jonathan Kew <jfkthame@googlemail.com> | 2008-08-09 16:17:36 +0000 |
---|---|---|
committer | Jonathan Kew <jfkthame@googlemail.com> | 2008-08-09 16:17:36 +0000 |
commit | e625056e4b48f938b88f367d13e2de0bbb142903 (patch) | |
tree | d01926f0f562d9783da4bb036d4785ce43ef68e2 /Build | |
parent | d4926c229feab358ccaf89210f07688f00ec9594 (diff) |
xetex 0.999.6, inc. revised font-searching code
git-svn-id: svn://tug.org/texlive/trunk@10208 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp | 3 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp | 71 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h | 7 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/xetex.ch | 2 |
4 files changed, 57 insertions, 26 deletions
diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp index 70913b368e0..1ce80956461 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr.cpp @@ -615,6 +615,9 @@ XeTeXFontMgr::prependToList(std::list<std::string>* list, const char* str) void XeTeXFontMgr::addToMaps(PlatformFontRef platformFont, const NameCollection* names) { + if (platformRefToFont.find(platformFont) != platformRefToFont.end()) + return; // this font has already been cached + if (names->psName.length() == 0) return; // can't use a font that lacks a PostScript name diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp index 56e2dd92316..c57f3100b81 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.cpp @@ -1,6 +1,6 @@ /****************************************************************************\ Part of the XeTeX typesetting system - copyright (c) 1994-2006 by SIL International + copyright (c) 1994-2008 by SIL International written by Jonathan Kew Permission is hereby granted, free of charge, to any person obtaining @@ -202,25 +202,36 @@ XeTeXFontMgr_FC::getOpSizeRecAndStyleFlags(Font* theFont) } void +XeTeXFontMgr_FC::cacheFamilyMembers(const std::list<std::string>& familyNames) +{ + if (familyNames.size() == 0) + return; + for (int f = 0; f < allFonts->nfont; ++f) { + FcPattern* pat = allFonts->fonts[f]; + if (platformRefToFont.find(pat) != platformRefToFont.end()) + continue; + char* s; + for (int i = 0; FcPatternGetString(pat, FC_FAMILY, i, (FcChar8**)&s) == FcResultMatch; ++i) { + for (std::list<std::string>::const_iterator j = familyNames.begin(); j != familyNames.end(); ++j) { + if (*j == s) { + NameCollection* names = readNames(pat); + addToMaps(pat, names); + delete names; + goto cached; + } + } + } + cached: + ; + } +} + +void XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) { - static bool cacheAll = false; - static FcFontSet* allFonts = NULL; - - if (cacheAll) // we've already loaded everything on an earlier search + if (cachedAll) // we've already loaded everything on an earlier search return; - if (allFonts == NULL) { - FcPattern* pat = FcNameParse((const FcChar8*)":outline=true"); - FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_FILE, FC_INDEX, - FC_FULLNAME, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL); - - allFonts = FcFontList(FcConfigGetCurrent(), pat, os); - - FcObjectSetDestroy(os); - FcPatternDestroy(pat); - } - std::string famName; int hyph = name.find('-'); if (hyph > 0 && hyph < name.length() - 1) @@ -236,7 +247,7 @@ XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) if (platformRefToFont.find(pat) != platformRefToFont.end()) continue; - if (cacheAll) { + if (cachedAll) { // failed to find it via FC; add everything to our maps (potentially slow) as a last resort NameCollection* names = readNames(pat); addToMaps(pat, names); @@ -250,6 +261,7 @@ XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) if (name == s) { NameCollection* names = readNames(pat); addToMaps(pat, names); + cacheFamilyMembers(names->familyNames); delete names; found = true; goto next_font; @@ -260,6 +272,7 @@ XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) if (name == s || (hyph && famName == s)) { NameCollection* names = readNames(pat); addToMaps(pat, names); + cacheFamilyMembers(names->familyNames); delete names; found = true; goto next_font; @@ -270,11 +283,12 @@ XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) full += " "; full += t; if (name == full) { - // need to ensure we'll pick up the whole family - famName = s; - hyph = 1; - f = 0; - goto restart; + NameCollection* names = readNames(pat); + addToMaps(pat, names); + cacheFamilyMembers(names->familyNames); + delete names; + found = true; + goto next_font; } } } @@ -283,9 +297,9 @@ XeTeXFontMgr_FC::searchForHostPlatformFonts(const std::string& name) ; } - if (found || cacheAll) + if (found || cachedAll) break; - cacheAll = true; + cachedAll = true; } } @@ -310,6 +324,15 @@ XeTeXFontMgr_FC::initialize() fprintf(stderr, "internal error; cannot read font names\n"); exit(3); } + + FcPattern* pat = FcNameParse((const FcChar8*)":outline=true"); + FcObjectSet* os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_FILE, FC_INDEX, + FC_FULLNAME, FC_WEIGHT, FC_WIDTH, FC_SLANT, NULL); + allFonts = FcFontList(FcConfigGetCurrent(), pat, os); + FcObjectSetDestroy(os); + FcPatternDestroy(pat); + + cachedAll = false; } void diff --git a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h index 9ebc2134a9a..7b4fc743b54 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h +++ b/Build/source/texk/web2c/xetexdir/XeTeXFontMgr_FC.h @@ -1,6 +1,6 @@ /****************************************************************************\ Part of the XeTeX typesetting system - copyright (c) 1994-2006 by SIL International + copyright (c) 1994-2008 by SIL International written by Jonathan Kew Permission is hereby granted, free of charge, to any person obtaining @@ -53,6 +53,11 @@ protected: virtual NameCollection* readNames(FcPattern* pat); std::string getPlatformFontDesc(PlatformFontRef font) const; + + void cacheFamilyMembers(const std::list<std::string>& familyNames); + + FcFontSet* allFonts; + bool cachedAll; }; #endif /* __XETEX_FONT_MGR_FC_H */ diff --git a/Build/source/texk/web2c/xetexdir/xetex.ch b/Build/source/texk/web2c/xetexdir/xetex.ch index b2e45b8cdf7..71415864a52 100644 --- a/Build/source/texk/web2c/xetexdir/xetex.ch +++ b/Build/source/texk/web2c/xetexdir/xetex.ch @@ -65,7 +65,7 @@ authorization from SIL International. @d XeTeX_version=0 @d XeTeX_revision==".999" -@d XeTeX_version_string=='-0.999.5' {current \XeTeX\ version} +@d XeTeX_version_string=='-0.999.6' {current \XeTeX\ version} @z @x |