freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] one question answered, and another comes (Re: FT_Bitmap_Conve


From: Hin-Tak Leung
Subject: [ft-devel] one question answered, and another comes (Re: FT_Bitmap_Convert, and FreeType's bitmap format vs Cairo's)
Date: Tue, 25 Apr 2017 07:41:47 +0000 (UTC)

To answer my own question at the last post, the answer is

SurfacePattern.set_filter(pattern, FILTER_NEAREST)

and the desired outcome is this:

http://htl10.users.sourceforge.net/tmp/S-fixed.png


So I have managed re-written all almost all of freetype-py's drawing examples 
from doing very slow numpy-based compositing to using cairo (pycairo), except 
one last problem I think. One of freetype-py's drawing example uses a vector 
sum between a clip of the drawing surface with the current drawing pattern to 
see if we are drawing over something that's already drawn in this single line:

if (I[y-h//2:y-h//2+h, x-w//2:x-w//2+w,0] * L).sum() == 0:

i.e. this calculates if L will draw on anything previously drawn in I. I am 
trying to figure out how to do this in cairo.

How does one check if two shapes overlap, or two paths intersect, in cairo?

--------------------------------------------
On Tue, 25/4/17, Hin-Tak Leung <address@hidden> wrote:

...
 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.
 
 Hin-Tak
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]