Skip to main content
Known Participant
December 20, 2022
Question

Getting point size from pixels (to fit in a rectangle) - c.c++ sdk

  • December 20, 2022
  • 1 reply
  • 345 views

When passed in a rectangle for an annotation, I want to create an appearance stream that has a point size that will mostly fill the rectangle. I calculate a smaller one that I want to fill. I have it working fine of I just use an arbitrary point size, but my first few attempts at computing it are failing.

This topic has been closed for replies.

1 reply

Legend
December 20, 2022

There is a big challenge he because there is not a fixed connection between point size and filling a space with text. Most (not all) fonts are designed so they can be set with 0 leading (no space between lines) without overlap. This means there is room above the characters for descenders from g, j etc. filling a space will depend on the characters and font used, and is more an exercise in geometry. You could try examining the font metrics in detail but bear in mind the scaling has to change if the characters used change.