[poppler] [KPDF-PATCH] Fontconfig support

Albert Astals Cid tsdgeos at yahoo.es
Tue Mar 22 03:32:06 PST 2005


Ouch i forgot to end the "That should be improved a bit, " part, i send the 
mail again, sorry.

A Dimarts 22 Març 2005 08:05, vàreu escriure:
> Albert Astals Cid wrote:
> > Hi, here comes our fontconfig patch, i see poppler has inherited from
> > evince a fontconfig function that xpdf does not have, but i think ours is
> > better, i explain the reasons:
> >
> >  - The fontconfig code in poppler right now is not able to use winddings
> > font i have installed in my system to properly render · (a dot) in
> > http://usuarios.lycos.es/tsdgeos/test.pdf and instead it renders Ÿ (Y
> > with dieresis) while our code does.
> >
> >  - FcNameParse does not works with pdf font names, we have a custom
> > parsing function.
>
> I finally got around to looking into this patch.  I do like the idea of
> parsing the weight and slant settings from the PDF font name; that
> should improve the font matching heuristic a great deal.
That algorithm should be improved a bit, PDF spec says only , can be used to 
give Bold, Oblique etc to fonts (i can not find it in the spec right now but 
i'm almost sure i saw it), but i have some pdf that use - instead of , so 
having - to is good in some cases but bad in some others, for example there 
are fonts called MS-Mincho that means our algorithm splits it in MS and 
Mincho, right now i've modified it a big and have 

if (name.find("MS-") == 0) name = "MS " + name.remove(0,3);
if (!name.contains('-') && !name.contains(',')) return;
QString type = name.section(QRegExp("[-,]"),-1);
name = name.section(QRegExp("[-,]"),0,-2);
if (type.contains("Oblique")) slant=FC_SLANT_OBLIQUE;
if (type.contains("Italic")) slant=FC_SLANT_ITALIC;
if (type.contains("Bold")) weight=FC_WEIGHT_BOLD;
if (type.contains("Light")) weight=FC_WEIGHT_LIGHT;
if (type.contains("Condensed")) width=FC_WIDTH_CONDENSED;

That is, i've added weights Light and Condensed (i think we should add all of 
them) and have created a hack to avoid MS-Mincho problem, but i think that a 
better solution could be found.

> Martin Kretzschmar did point out to me, though, that the patch removes
> the GlobalParams::setupBaseFontsFc() function from evince, which
> initializes the 14 standard fonts using fontconfig.  But reading the
> kpdf source, it looks like you don't initialize the standard fonts at
> all (i.e. you don't call GlobalParams::setupBaseFonts() either), but
> handle all font references through the general font matching
> algorithm... correct?
No, we do globalParams->setupBaseFonts(NULL); on part.cpp but i have just 
remove it and i get the same substitutions that xpdf has (displayFontTab), 
you can test that on your system with the test program i sent
./fonttest Times-BoldItalic gets me n021024l.pfb file. (that is with 
-DWEIRD_FUN) probably thanks of my fontconfig setup? (i did not edit it)

> Provided you get decent matches for the standard fonts, I'd say this is
> probably the best way to do it.  In any case, it should be tunable by
> either adjusting the fontconfig config file, so I think it should work
> fine.  Unless anybody has any objections, I'll commit this patch in a
> day or two.
I think the same, doing forced substitutions seems a bad thing. Someone on kde 
lists told me we should work out substitutions for lots of fonts more but i 
think that is bad as we already have fontconfig for font configuring, why 
would poppler(kpdf) want to force you to have a specific font-substitution 
when you can configure it for all the system?

Albert

>
> cheers,
> Kristian



More information about the poppler mailing list