[cairo] FT_Bitmap_Convert, and FreeType's bitmap format vs Cairo's

Bill Spitzak spitzak at gmail.com
Tue Apr 25 16:51:35 UTC 2017


> Also I am wondering about a little drawing issue I have - I want to scale a freetype bitmap up and draw a larger version of it (useful for illustrations for rasterization issues...) but it seems that cairo always anti-alias the edges at the original resolution, and I haven't figured out how to turn it off yet.
> Let's say, I have rendered a glyph to a 24x24 grid in FreeType, and want to draw that in cairo to 480 x 480 . I'd like cairo to render at the destination resolution - i.e. do whatever at the 1-pixel boundary in 480x480, but it seems that it is doing it in the original grid, which blows up to be extra blurry at ~20 pixels wide in 480x480. Here is how it looks (the corner S is original resolution drawn as is):
>
> http://htl10.users.sourceforge.net/tmp/S.png
>
> This is from a word-in-progress rewrite of freetype-py's glyph-alpha/glyph-monochrome examples which uses numpy and matplotlib, to using pycairo for drawing.

Possibly you want to do cairo_patter_set_filter(source,
CAIRO_FILTER_BEST) or CAIRO_FILTER_NEAREST (the difference is that
BEST will actually antialias the boundaries between the pixels which
looks nicer if the image is rotated or scaled by a non-integer).


More information about the cairo mailing list