|
|
f745335 |
diff -r -u abiword-2.4.6.orig/abi/src/af/xap/unix/xap_UnixFontManager.cpp abiword-2.4.6/abi/src/af/xap/unix/xap_UnixFontManager.cpp
|
|
|
f745335 |
--- abiword-2.4.6.orig/abi/src/af/xap/unix/xap_UnixFontManager.cpp 2006-05-12 15:08:58.000000000 +0200
|
|
|
f745335 |
+++ abiword-2.4.6/abi/src/af/xap/unix/xap_UnixFontManager.cpp 2007-04-06 17:36:20.000000000 +0200
|
|
|
f745335 |
@@ -87,7 +87,7 @@
|
|
|
f745335 |
return pVec;
|
|
|
f745335 |
}
|
|
|
f745335 |
|
|
|
f745335 |
-static XAP_UnixFont* buildFont(XAP_UnixFontManager* pFM, FcPattern* fp)
|
|
|
f745335 |
+static void buildFonts(XAP_UnixFontManager* pFM, FcPattern* fp, UT_GenericVector<XAP_UnixFont*>& vFonts)
|
|
|
f745335 |
{
|
|
|
f745335 |
unsigned char* fontFile = NULL;
|
|
|
f745335 |
bool bold = false;
|
|
|
f745335 |
@@ -102,7 +102,7 @@
|
|
|
f745335 |
{
|
|
|
f745335 |
// ok, and now what? If we can not get the font file of the font, we can not print it!
|
|
|
f745335 |
UT_DEBUGMSG(("Unknown font file!!\n"));
|
|
|
f745335 |
- return false;
|
|
|
f745335 |
+ return;
|
|
|
f745335 |
}
|
|
|
f745335 |
|
|
|
f745335 |
if (FcPatternGetInteger(fp, FC_WEIGHT, 0, &weight) != FcResultMatch)
|
|
|
f745335 |
@@ -117,7 +117,7 @@
|
|
|
f745335 |
size_t ffs = metricFile.size();
|
|
|
f745335 |
if ( !((ffs >= 4 && fontFile[ffs - 4] == '.') ||
|
|
|
f745335 |
(ffs >= 5 && fontFile[ffs - 5] == '.') )) // Separate check to avoid [-1]
|
|
|
f745335 |
- return NULL;
|
|
|
f745335 |
+ return;
|
|
|
f745335 |
|
|
|
f745335 |
// handle '.font'
|
|
|
f745335 |
if (fontFile[ffs - 5] == '.')
|
|
|
f745335 |
@@ -137,9 +137,6 @@
|
|
|
f745335 |
char* xlfd = reinterpret_cast<char*>(FcNameUnparse(fp));
|
|
|
f745335 |
// UT_String sXLFD = xlfd;
|
|
|
f745335 |
// UT_ASSERT(sXLFD.size() < 100);
|
|
|
f745335 |
- // get the family of the font
|
|
|
f745335 |
- unsigned char *family;
|
|
|
f745335 |
- FcPatternGetString(fp, FC_FAMILY, 0, &family);
|
|
|
f745335 |
|
|
|
f745335 |
XAP_UnixFont::style s = XAP_UnixFont::STYLE_NORMAL;
|
|
|
f745335 |
|
|
|
f745335 |
@@ -158,19 +155,31 @@
|
|
|
f745335 |
break;
|
|
|
f745335 |
}
|
|
|
f745335 |
|
|
|
f745335 |
- XAP_UnixFont* font = new XAP_UnixFont(pFM);
|
|
|
f745335 |
- /* we try to open the font. If we fail, we try to open it removing the bold/italic info, if we fail again, we don't try again */
|
|
|
f745335 |
- if (!font->openFileAs(reinterpret_cast<char*>(fontFile), metricFile.utf8_str(), reinterpret_cast<char*>(family), xlfd, s) &&
|
|
|
f745335 |
- !font->openFileAs(reinterpret_cast<char*>(fontFile), metricFile.utf8_str(), reinterpret_cast<char*>(family), xlfd, XAP_UnixFont::STYLE_NORMAL))
|
|
|
f745335 |
- {
|
|
|
f745335 |
- UT_DEBUGMSG(("Impossible to open font file [%s] [%d]\n.", reinterpret_cast<char*>(fontFile), s));
|
|
|
f745335 |
- font->setFontManager(NULL); // This font isn't in the FontManager cache (yet), so it doesn't need to unregister itself
|
|
|
f745335 |
- delete font;
|
|
|
f745335 |
- font = NULL;
|
|
|
f745335 |
- }
|
|
|
f745335 |
+ unsigned char *family;
|
|
|
f745335 |
+ int id;
|
|
|
f745335 |
+
|
|
|
f745335 |
+ id = 0;
|
|
|
f745335 |
+ // get the families of the font
|
|
|
f745335 |
+ while (FcPatternGetString(fp, FC_FAMILY, id, &family) == FcResultMatch)
|
|
|
f745335 |
+ {
|
|
|
f745335 |
+
|
|
|
f745335 |
+ XAP_UnixFont* font = new XAP_UnixFont(pFM);
|
|
|
f745335 |
+ /* we try to open the font. If we fail, we try to open it removing the bold/italic info, if we fail again, we don't try again */
|
|
|
f745335 |
+ if (!font->openFileAs(reinterpret_cast<char*>(fontFile), metricFile.utf8_str(), reinterpret_cast<char*>(family), xlfd, s) &&
|
|
|
f745335 |
+ !font->openFileAs(reinterpret_cast<char*>(fontFile), metricFile.utf8_str(), reinterpret_cast<char*>(family), xlfd, XAP_UnixFont::STYLE_NORMAL))
|
|
|
f745335 |
+ {
|
|
|
f745335 |
+ UT_DEBUGMSG(("Impossible to open font file [%s] [%d]\n.", reinterpret_cast<char*>(fontFile), s));
|
|
|
f745335 |
+ font->setFontManager(NULL); // This font isn't in the FontManager cache (yet), so it doesn't need to unregister itself
|
|
|
f745335 |
+ DELETEP(font);
|
|
|
f745335 |
+ }
|
|
|
f745335 |
+ else
|
|
|
f745335 |
+ {
|
|
|
f745335 |
+ vFonts.addItem(font);
|
|
|
f745335 |
+ }
|
|
|
f745335 |
+ id++;
|
|
|
f745335 |
+ }
|
|
|
f745335 |
|
|
|
f745335 |
free(xlfd);
|
|
|
f745335 |
- return font;
|
|
|
f745335 |
}
|
|
|
f745335 |
|
|
|
f745335 |
/* add to the cache all the scalable fonts that we find */
|
|
|
f745335 |
@@ -180,29 +189,24 @@
|
|
|
f745335 |
return true;
|
|
|
f745335 |
|
|
|
f745335 |
FcFontSet* fs;
|
|
|
f745335 |
- XAP_UnixFont* pFont;
|
|
|
f745335 |
-
|
|
|
f745335 |
fs = FcConfigGetFonts(FcConfigGetCurrent(), FcSetSystem);
|
|
|
f745335 |
-
|
|
|
f745335 |
- if (fs)
|
|
|
f745335 |
- {
|
|
|
f745335 |
+ if (fs)
|
|
|
f745335 |
+ {
|
|
|
f745335 |
m_pFontSet = FcFontSetCreate();
|
|
|
f745335 |
-
|
|
|
f745335 |
for (UT_sint32 j = 0; j < fs->nfont; j++)
|
|
|
f745335 |
{
|
|
|
f745335 |
- // we want to create two fonts: one layout, and one device.
|
|
|
f745335 |
-
|
|
|
f745335 |
/* if the font file ends on .ttf, .pfa or .pfb we add it */
|
|
|
f745335 |
- pFont = buildFont(this, fs->fonts[j]);
|
|
|
f745335 |
-
|
|
|
f745335 |
- if (pFont)
|
|
|
f745335 |
- {
|
|
|
f745335 |
+ UT_GenericVector<XAP_UnixFont*> vFonts;
|
|
|
f745335 |
+ buildFonts(this, fs->fonts[j], vFonts);
|
|
|
f745335 |
+ if (vFonts.size() > 0)
|
|
|
f745335 |
FcFontSetAdd(m_pFontSet, fs->fonts[j]);
|
|
|
f745335 |
- _addFont(pFont,NULL);
|
|
|
f745335 |
- }
|
|
|
f745335 |
+ for (UT_uint32 i = 0; i < vFonts.size(); i++)
|
|
|
f745335 |
+ {
|
|
|
f745335 |
+ XAP_UnixFont *pFont = vFonts.getNthItem(i);
|
|
|
f745335 |
+ _addFont(pFont, NULL);
|
|
|
f745335 |
+ }
|
|
|
f745335 |
}
|
|
|
f745335 |
-
|
|
|
f745335 |
- }
|
|
|
f745335 |
+ }
|
|
|
f745335 |
|
|
|
f745335 |
return true;
|
|
|
f745335 |
}
|