GNOME Bugzilla – Bug 317121
pango does not follow fontconfig pixelsize reassignment rules
Last modified: 2005-11-21 13:14:38 UTC
Distribution/Version: Mandriva 2006 When using cairo as rendering engine, pango does not follow fontconfig pixelsize reassignment rules. As in Mandriva, we've placed /etc/fonts/conf.d/02-mdk-disable-antialias.conf: <match target="font"> <test name="family" qual="any"> <string>AR PL New Sung</string> <string>SimSun</string> <string>NSimSun</string> </test> <test name="pixelsize" compare="less_eq"> <double>12</double> </test> <edit name="pixelsize" mode="assign"> <double>12</double> </edit> </match> As you can see, the code means to set the minimal font size of certain font as 12px. But it doesn't work in gtk2.8. Don't know if this bug should be posted to cairo or pango. Regards.
Created attachment 54031 [details] [review] pango-cairo-fcfont.patch Patch to fix this problem.
Any news?
any news?
Is it possible to check this patch??
How is it going?
Funda, Please stop sending "any news" comments everyday. Bugs are in bugzilla and never get lost, we get to them as time permits.
If you are about to get them, please mark it as NEW or ASSIGNED.
We don't care whether a bug is UNCONFIRMED or NEW. Not even about ASSIGNED really. But as I said, we get to them *as time permits*. So, be nice.
(02:31:06) keithp: behdad: I'm not sure that's a bug... (02:31:15) keithp: behdad: I mean, cairo is supposed to provide scalable graphics... (02:33:06) keithp: behdad: I think cairo computes the pixel size itself, without reference to the data in the fontconfig pattern (02:37:53) behdad: keithp: how is pixelsize supposed to be used then? (02:38:42) keithp: well, fontconfig computes pixel size from point size and dpi, but applications don't realy have to listen to it(02:39:31) keithp: It looks like Pango explicitly ignores pixel size though, looking at the patch in that bug (02:40:24) behdad: so you say NOTABUG? (02:40:53) behdad: in other words, assigning to pixelsize is not supposed to work? (02:44:25) keithp: Well, it's not *obviously* a bug; you'd have to ask Owen whether it's supposed to listen to pixelsize Owen, any idea?
I think I actually discussed this with Keith some months ago on IRC, and we agreed that setting pixel size in fonts.conf didn't make sense. (I think Frederic asked me about this particular part of fonts.conf.) Which made me happy, because I thought it was going to be really hard to implement. Then a few hours later, as I was drifting off to sleep that night, it occurred to me that it was in fact really easy to do, with a patch similar to this one. Note that the else in: + else if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch) + return size * PANGO_SCALE; + else would only come into play if the fonts.conf *deleted* the pixel size, since we set FC_PIXEL_SIZE before calling FcConfigSubstitute(). So, it would be good to have a comment to that effect. /* Just in case FC_PIXEL_SIZE got unset between pango_fc_make_pattern() * and here. */ In fact, I don't see any reason to honor not honor FC_PIXEL_SIZE changing if the font size specification was absolute - it really should be: if (FcPatternGetDouble (pattern, FC_PIXEL_SIZE, 0, &size) == FcResultMatch) return size * PANGO_SCALE; /* Just in case FC_PIXEL_SIZE got unset between pango_fc_make_pattern() * and here. */ if (pango_font_description_get_size_is_absolute (desc)) return pango_font_description_get_size (desc); else { double dpi = pango_cairo_context_get_resolution (context); And there needs to be a comment above the /* The reason why we read FC_PIXEL_SIZE here rather than just * using the specified size is to support operations like clamping * a font to a minimal readable size in fonts.conf. This is pretty weird, * since it could mean that changing the Cairo CTM doesn't change the * font size, but it's just a more radical version of the non-linear * font scaling we already have due to hinting and due to bitmap * fonts being only available at a few sizes. * * If honoring FC_PIXEL_SIZE gets in the way of more useful features * it should be removed since it only matters in the unusual case * of people doing exotic stuff in fonts.conf. */ above the whole thing. But other than those changes, I'm happy with this going in.
As long as all the settings provided by fontconfig can be rendered correctly by pango/cairo, I don't care how it is implemented :)
Reworked patch with Owen's suggestions committed to HEAD and pango-1-10 branch. 2005-11-14 Behdad Esfahbod <behdad@gnome.org> * pango/pangocairo-fcfont.c: Respect fontconfig reassignment of pixelsize. (#317121, Funda Wang)
This caused regression reported in bug 321891. When fixing that, I figure out something kinda weird. In pangofc-fontmap.c we call FcFontRenderPrepare, passing the pattern and a font, and get back the final pattern that is used to create a PangoFont. The font passed to FcFontRenderPrepare only has a pixelsize set, while the pattern has both size and pixelsize. The result is that the merged pattern has a pixelsize arbitrarily different from size. So I think using pixelsize as done in this bug is in fact preferred. Owen?