freetype
[Top][All Lists]
Advanced

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

Re: [ft] Drawing unfilled shapes with FreeType2


From: Marco Wertz
Subject: Re: [ft] Drawing unfilled shapes with FreeType2
Date: Fri, 7 Nov 2014 23:39:22 +0100

> > How can I get FreeType2 to draw only the outline of my FT_Outline
> > object with a fixed pixel stroke width?
> 
> Have a look at the function `Render_Stroke' in the `ftview' demo
> program.  It uses the FreeType stroker API.

I have successfully adapted the code from the FT_Glyph_Stroke() API
used in the example mentioned above to work without FT_Glyphs as I'm
not working with glyphs but with paths stored in FT_Stroker objects.

There is only one remaining problem now: I want to apply a transformation
matrix before letting FreeType draw the unfilled shape. This is of
course possible using FT_Outline_Transform() but the problem is that
FT_Outline_Transform() will also apply the transformation matrix to
the outline stroke size and I don't want that. For example, I set
an outline stroke size of 8 pixels like this:

    FT_Stroker_Set(stroker, (int) ((double) 8.0 * 32.0), 
FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);                       

Now when applying the following transformation matrix, the outline
stroke size is reduced to 4 pixels on the y-axis:

    m.xx = Float2Fixed(1.0);
    m.xy = Float2Fixed(0.0);
    m.yx = Float2Fixed(0.0);
    m.yy = Float2Fixed(0.5);

But I don't want this! I want FreeType to use a constant outline stroke
size. The outline stroke size should always be the value that has been
set with FT_Stroker_Set(). Transformations shouldn't change the outline
stroke size. It should always be of size 8 pixels or whatever has been
set using FT_Stroker_Set().

Unfortunately, it is not possible to apply a transformation matrix to
an FT_Stroker AFAICS. If that was possible, I could first apply the
transformation matrix to the stroker and then export it into an FT_Outline.
This would probably leave the outline stroke size intact. But as of
now, I first have to export the path from the FT_Stroker object into
an FT_Outline, and then apply the matrix. This leads to the matrix
getting applied to the outline stroke size as well which I don't
want.

Is there any way around this?

I attach a small example source that shows the problem.

Marco

Attachment: test.c
Description: Text document


reply via email to

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