freetype
[Top][All Lists]
Advanced

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

Re: [ft] Examples?


From: Werner LEMBERG
Subject: Re: [ft] Examples?
Date: Fri, 17 Aug 2012 09:29:12 +0200 (CEST)

> I've just started with Freetype. I haven't found too many examples
> of the library usage, [...]

The tutorial comes with a basic one:

  http://www.freetype.org/freetype2/docs/tutorial/example1.c

> I've tried to make an oblique version of a font using this transform
> (like the one in ftsynth.c):
>
>     transform.xx = 0x10000L;
>     transform.yx = 0x00000L;
>     transform.xy = 0x06000L;
>     transform.yy = 0x10000L;
>     FT_Glyph_Transform( glyph, &transform, 0 );
>
> This does make the font slant slightly, however it also adds a lot
> of white-space to the left of the text and I'm not sure why.

Slanting means that everything above the baseline gets slanted to the
right, and everything below the baseline gets slanted to the left...

However, without some sample code it's hard to say what you are
observing.

> I'm also not certain how the 0x06000L value is derived - I believe
> it is fixed point representation of 0.6

No.

> but how was 0.6 derived?

  arctan(0x6000 / 65536.0) = 20.56° approx.

I now see that we have a problem.  The comment in ftsynth.c says that
the shear angle is 12° (and this is a common value in typography).
However, the code doesn't do that, as the formula above shows.  Given
that the code is tagged as `experimental', I've just changed the value
so that it conforms to the comment.

> The other thing I've been trying to do is rotate individual glyphs -
> I've seen the tutorial that writes a string of characters, that
> works, but if I wanted a horizontal run of characters that had been
> rotated, does anyone have an example of how to do that? Everything
> I've tried seems to change the location of the glyphs rather then
> spin them.

The rotation origin is the glyph's coordinate origin.  The standard
solution is

  (1) Shift the glyph so that the new origin is the glyphs' center.
  (2) Rotate it.
  (3) Shift the glyph back to the previous origin.


    Werner

>
> _______________________________________________
> Freetype mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/freetype



reply via email to

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