[Top][All Lists]

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

Re: [Freetype] How do I render italic or bold if no file

From: Dave Williss
Subject: Re: [Freetype] How do I render italic or bold if no file
Date: Thu, 19 Sep 2002 10:07:29 -0500

I see nobody answered your question yet.

You can implement synthetic italics by applying a shear angle.  Here's a
snippet of code that I use to do this (FT1, probably similar for FT2)

double sintheta = sin(-angle);    // For rotating the glyph.. optional
double costheta = cos(-angle);
TT_Matrix mat;
mat.xx = (TT_Fixed)(costheta * (1<<16));
mat.xy = (TT_Fixed)(sintheta * (1<<16));
mat.yx = -mat.xy;
mat.yy = mat.xx;
TT_Fixed f = (TT_Fixed)(tan(shear) * (1<<16));    // suggest shear == 10deg
converted to radians
mat.xy += TT_MulFix(f, mat.xx);
mat.yy += TT_MulFix(f, mat.yx);
TT_SetInstanceTransform_Flags(instance, (angle != 0), (shear != 0));

If there's no bold variation, I do synthetic bold by blitting the bitmap N
times, where N is a percentage of the glyph with (but always at least 2).
Each additional blit is moved over one pixel in a direction dictated by the
glyph angle (normally one pixel to the right for upright text).  I also
account for this when doing character placement, as this synthetic bold
makes each glyph a bit wider.  Of course, for efficiency, this blitting N
times is only done when loading a glyph into a bitmap glyph cache.  I then
actually render out of the cache.

----- Original Message -----
From: "Riccardo Cohen" <address@hidden>
To: <address@hidden>; <address@hidden>
Sent: Monday, September 09, 2002 5:59 PM
Subject: [Freetype] How do I render italic or bold if no file

> Hi,
> Any idea ?? I re-send my question :
> There is something I do not understand about ttf files.
> On my PC (WinNT). When I look in c:\winnt\fonts, I find only one file
called "chevara" for instance (chvr____.ttf), which is regular (normal). I
cannot find any chevara bold or italic.
> But when I open MSWord, or any standard Windows font panel, I can use
chevara bold, italic and bold-italic. Where did it find it ???
> I tried to use the index in FT_New_Face but it did not render italic or
bold... How do they do that miracle ???
> Is it at render time, or is there any way to extract them from the ttf
file ?
> Thanks
> --
> Riccardo Cohen
> Articque
> Les Roches
> 37230 Fondettes
> France
> email = address@hidden
> web =
> tel: +33 02 47 49 90 49
> fax: +33 02 47 49 91 49
> _______________________________________________
> Freetype mailing list
> address@hidden

reply via email to

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