[cairo] one question answered, and another comes (Re: FT_Bitmap_Convert, and FreeType's bitmap format vs Cairo's)
htl10 at users.sourceforge.net
Tue Apr 25 07:41:47 UTC 2017
To answer my own question at the last post, the answer is
and the desired outcome is this:
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 <htl10 at users.sourceforge.net> 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):
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.
More information about the cairo