Bug 23539 - bitmap font is not scaled by cairo_scale()
Summary: bitmap font is not scaled by cairo_scale()
Status: RESOLVED FIXED
Alias: None
Product: cairo
Classification: Unclassified
Component: freetype font backend (show other bugs)
Version: 1.9.3
Hardware: All Linux (All)
: medium normal
Assignee: David Turner
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-27 02:23 UTC by Ginn Chen
Modified: 2015-05-01 19:38 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
cairo_bitmap_font_scale.c (4.26 KB, text/plain)
2009-08-27 02:23 UTC, Ginn Chen
Details
try.patch (1.60 KB, patch)
2009-08-27 02:25 UTC, Ginn Chen
Details | Splinter Review
the buggy result (9.37 KB, image/png)
2009-08-27 02:26 UTC, Ginn Chen
Details
result after applying try.patch (11.87 KB, image/png)
2009-08-27 02:27 UTC, Ginn Chen
Details

Description Ginn Chen 2009-08-27 02:23:31 UTC
Created attachment 28944 [details]
cairo_bitmap_font_scale.c

This bug was reported as bug 18001 about 1 year ago.
Actually it is not only reproducible with PS backend, but also with image and PDF backend perhaps all backend.
It is not only reproducible with freetype fonts either. I can reproduce it with Windows. See (https://bugzilla.mozilla.org/show_bug.cgi?id=448186)

However I filed this bug against freetype font backend, because I think different font backend may require different fixes.
Please correct me if I were wrong.

Steps to reproduce:
1) Enable bitmap font on Ubuntu or use Solaris.
See: http://www.alanbriolat.co.uk/2009/04/enable-bitmap-fonts-on-ubuntu-jaunty/

2) Run fc-match Courier
Make sure you get a *.pcf or *.pcf.gz file.

3) Compile and run attached cairo_bitmap_font_scale.c.

4) If you change "Courier" to a non bitmap font, the result is correct.

I've proposed a draft fix half a year ago in mozilla bug 448186.
Attached try.patch.

However I don't think it's the right fix.
If we do _transform_glyph_bitmap() there, it will make the glyph unreadable if it is scaled down to 50% or 30%.

For PS, if we use "scale" operator inside "/Glyphs", we can get a better result.
(suggested by Adrian Johnson in https://bugzilla.mozilla.org/show_bug.cgi?id=448186#c7)
But I don't know how should I pass the "CTM" through "scaled_glyph".
Comment 1 Ginn Chen 2009-08-27 02:25:34 UTC
Created attachment 28945 [details] [review]
try.patch
Comment 2 Ginn Chen 2009-08-27 02:26:06 UTC
Created attachment 28946 [details]
the buggy result
Comment 3 Ginn Chen 2009-08-27 02:27:50 UTC
Created attachment 28947 [details]
result after applying try.patch
Comment 4 Adrian Johnson 2009-08-27 05:11:55 UTC
> For PS, if we use "scale" operator inside "/Glyphs", we can get a better
> result.
> (suggested by Adrian Johnson in
> https://bugzilla.mozilla.org/show_bug.cgi?id=448186#c7)
> But I don't know how should I pass the "CTM" through "scaled_glyph".

User fonts is the feature that will give you better control of bitmap fonts in PS/PDF output:

  http://www.cairographics.org/manual/cairo-user-font.html

An example of creating bitmap fonts using user fonts is in cairo/test/user-font-mask.c
Comment 5 Behdad Esfahbod 2009-08-27 11:04:32 UTC
This issue (how to scale bitmaps) should be brought up on cairo list for discussion first.  Thanks.
Comment 6 Behdad Esfahbod 2012-12-30 00:53:21 UTC
This is now being discussed:
http://lists.freedesktop.org/archives/fontconfig/2012-December/004498.html
Comment 7 Behdad Esfahbod 2012-12-31 01:22:46 UTC
In fact, this recent commit of mind fixed your test case:

http://cgit.freedesktop.org/cairo/commit/?id=b94a519aad3d5b50aa6de47ee16ee6a099de9791

The fontconfig part is still ongoing, but that's not in the scope of this bug anymore.  That said, there seems to be issues with vertical text and bitmap fonts, so someone may want to investigate.
Comment 8 Behdad Esfahbod 2015-05-01 19:38:50 UTC
This should be fixed now.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.