After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 317121 - pango does not follow fontconfig pixelsize reassignment rules
pango does not follow fontconfig pixelsize reassignment rules
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.10.x
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2005-09-24 19:25 UTC by Funda Wang
Modified: 2005-11-21 13:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pango-cairo-fcfont.patch (1.13 KB, patch)
2005-10-29 07:55 UTC, Funda Wang
none Details | Review

Description Funda Wang 2005-09-24 19:25:06 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.
Comment 1 Funda Wang 2005-10-29 07:55:35 UTC
Created attachment 54031 [details] [review]
pango-cairo-fcfont.patch

Patch to fix this problem.
Comment 2 Funda Wang 2005-10-30 19:22:25 UTC
Any news?
Comment 3 Funda Wang 2005-11-05 08:47:44 UTC
any news?
Comment 4 Funda Wang 2005-11-07 13:21:00 UTC
Is it possible to check this patch??
Comment 5 Funda Wang 2005-11-08 10:29:54 UTC
How is it going?
Comment 6 Behdad Esfahbod 2005-11-08 13:20:59 UTC
Funda,

Please stop sending "any news" comments everyday.  Bugs are in bugzilla and
never get lost, we get to them as time permits.
Comment 7 Funda Wang 2005-11-09 06:53:24 UTC
If you are about to get them, please mark it as NEW or ASSIGNED.
Comment 8 Behdad Esfahbod 2005-11-09 07:25:18 UTC
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.
Comment 9 Behdad Esfahbod 2005-11-09 07:46:10 UTC
(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?
Comment 10 Owen Taylor 2005-11-14 05:30:10 UTC
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.
Comment 11 Funda Wang 2005-11-14 10:35:32 UTC
As long as all the settings provided by fontconfig can be rendered correctly by 
pango/cairo, I don't care how it is implemented :)
Comment 12 Behdad Esfahbod 2005-11-15 07:45:20 UTC
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)

Comment 13 Behdad Esfahbod 2005-11-21 13:14:38 UTC
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?