freetype
[Top][All Lists]
Advanced

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

Re: [ft] Font units to pixels in line height


From: Werner LEMBERG
Subject: Re: [ft] Font units to pixels in line height
Date: Sat, 31 Dec 2016 15:37:46 +0100 (CET)

> I want to convert the "height" value from FT_FaceRec to pixels. IIUC
> this can be done like this:
> 
>      double lineHeight =
>        (double) FT_MulFix(face->height,
>                           face->size->metrics.y_scale) / (double) 64;
> 
> Is that right? 

Yes.

> Since the value will typically be a fractional value I was also
> wondering whether I should apply any rounding using floor() or
> ceil() here.  For example, when opening Arial in 28pt, the above
> formula yields 32.203125 pixels.  So should I use 32 pixels or 33
> pixels as the line height in this case?

I suggest simple rounding; the above then changes to

  double lineHeight =
    (double) (FT_MulFix(face->height,
                        face->size->metrics.y_scale) +32)
             / (double) 64;


    Werner



reply via email to

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