Font (typeface.js?) size

I’m trying to figure out how to scale the three.js generated fonts and i am failing.

Given some glyph, from some font.json, which space are these numbers in, and how do they relate to each other?

The same goes for these props:

20%20PM

Eventually, once i get some BufferGeometry from these values, how should i scale it to match say a div with font-size: 10px if i’m rendering in pixel space?

1 Like

I’ve had to read the code yesterday, not being able to find documentation, so here’s what I gathered:

  • ha is probably meant to be “horizontal advance”, as it’s used to calculate X offsets
  • x_min and x_max aren’t used
  • o is in a format similar to SVG, but not quite. I wrote a script to convert to and from, I’m going to ask my boss if I can publish it as OSS
  • The units are relative to resolution, as in, 1 unit corresponds to 1 / resolution THREE.js units
  • underlineThickness is used, but underlinePosition is not
  • ascender and descender are not used
  • cssFontStyle and cssFontWeight aren’t used

To more directly answer your question, the pixel size of the result depends on the size of the viewport and the zoom, so it’s not very meaningful, in general, but you could use those measures to calculate it