freetype
[Top][All Lists]
Advanced

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

Re: [ft] font size confusion (NOMINAL & REAL_DIM)


From: Werner LEMBERG
Subject: Re: [ft] font size confusion (NOMINAL & REAL_DIM)
Date: Fri, 02 Mar 2012 10:10:33 +0100 (CET)

Thanks for the example.

>     /* set the REAL_DIM size, fontSize1 */
>     rq.type = FT_SIZE_REQUEST_TYPE_REAL_DIM;
>
>     /* set the NOMINAL size, fontSize2 */
>     fontSize2 = fontSize1 - 4;
>     /* How to calculate fontSize2 to meet the following
>        requirements? I tried to -1, -2, -3, and finally found -4 is
>        good */

As the documentation describes, the scaling value of `nominal' is the
units per EM, and the scaling value of `real dim' is the sum of the
ascender and the descender (since descender has negative values if
below the baseline, it's actually a subtraction):

  scaling_nominal = face->units_per_EM
  scaling_realdim = face->ascender - face->descender

Remember, these values are *scaling values*.  Consequently, to
transform from one scaling framework to another, simply compute the
quotient and use it as a factor.

Using arial (version 5.06), I get

  face->ascender  = 1854
  face->descender = -434
  units per EM    = 2048

This gives

       1854 + 434
  f = ------------ = 1.11719...
         2048

In your example, the `real dim' font size is 40, thus the `nominal'
font size is

  40 / 1.11719 = 35.804...

which rounds to 36, as you've deduced by experimentation.

It would be great if you could provide a patch to enhance the
documentation in case you consider it as necessary.


    Werner



reply via email to

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