freetype-devel
[Top][All Lists]
Advanced

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

Re: [Devel] Need Bold, italic


From: Thomas Hudson
Subject: Re: [Devel] Need Bold, italic
Date: Mon, 16 Apr 2001 17:56:13 +0100

I generate bold and italic for fonts that don't have these files in my
app.
>From trial and error I found that transforming 1.5 in the x axis (along
the
base line)  "thickens" enough to simulate a decent bold. For italic I
slant
15 degrees  from vertical. I also had to modify the advance for bold to
be 1.3 times  the original.

// These transforms are used to synthesis missing standard font styles
FT_Matrix BoldMatrix;
FT_Matrix ItalicMatrix;
FT_Matrix BoldItalicMatrix;
#define FT_THICKEN_PERCENTAGE 1.5
#define FT_ITALIC_SLANT 75.
#define FT_THICKEN_ADVANCE 1.3f

static void build_synthetic_font_transforms()
{
   BoldMatrix.xx = (FT_Fixed)(0x10000 * FT_THICKEN_PERCENTAGE);
   BoldMatrix.xy = 0;
   BoldMatrix.yx = 0;
   BoldMatrix.yy = (FT_Fixed)(0x10000);

   float tshear = tan((90 - FT_ITALIC_SLANT)/180. * M_PI);

   ItalicMatrix.xx = (FT_Fixed)(0x10000);
   ItalicMatrix.xy = (FT_Fixed)(tshear * 0x10000);
   ItalicMatrix.yx = (FT_Fixed)0;
   ItalicMatrix.yy = (FT_Fixed)(0x10000);

    BoldItalicMatrix.xx = FT_MulFix( BoldMatrix.xx, ItalicMatrix.xx ) +
FT_MulFix( BoldMatrix.xy, ItalicMatrix.yx );
    BoldItalicMatrix.xy = FT_MulFix( BoldMatrix.xx, ItalicMatrix.xy ) +
FT_MulFix( BoldMatrix.xy, ItalicMatrix.yy );
    BoldItalicMatrix.yx = FT_MulFix( BoldMatrix.yx, ItalicMatrix.xx ) +
FT_MulFix( BoldMatrix.yy, ItalicMatrix.yx );
    BoldItalicMatrix.yy = FT_MulFix( BoldMatrix.yx, ItalicMatrix.xy ) +
FT_MulFix( BoldMatrix.yy, ItalicMatrix.yy );
}

Thomas

Nathan Hurst wrote:

> On Mon, 16 Apr 2001, Werner LEMBERG wrote:
>
> > > Now I would like to try adding bolding to the truetype font I am
> > > using.  I have found reference to attributes in the documentation
> > > but have not figured the proper way to select them.  Is there a
> > > function call used to select these attributes?
> >
> > What exactly do you want?  Make a TTF outline bolder?  This isn't
> > supported since it is non-trivial (volunteers welcome to implement
> > that).  Applying a transformation matrix you can only
> > slant/rotate/distort the font.
>
> Does a horizontal scale of say 1.01 give a bold effect?  What is the
> correct def. of bold?
>
> > A brute-force method is to print the produced pixel image slightly
> > offset multiple times.
>
> So bold means 1pixel wider?
>
> njh
>
> _______________________________________________
> Devel mailing list
> address@hidden
> http://www.freetype.org/mailman/listinfo/devel




reply via email to

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