Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculating extents using freetype-go #5

Open
BurntSushi opened this issue Aug 6, 2012 · 0 comments
Open

Calculating extents using freetype-go #5

BurntSushi opened this issue Aug 6, 2012 · 0 comments

Comments

@BurntSushi
Copy link
Owner

The freetype-go package API doesn't yet support computing text extents without actually rendering the text to the image. Currently, the workaround is to calculate a "maximum" bounding box using the number of pixels in a single em unit. While this prevents text from ever being cut off, it tends to dramatically overestimate when fonts aren't monospace (since many characters have a width or height less than one em unit). Thus, the image is then cropped using the (x, y) offset returned from (*Context).DrawString.

Ideally, we should be able to calculate extents before rendering, therefore saving wasteful allocation. (For my use cases, the wasted allocation isn't too big of a deal.)

For more details, see Issue 5 on the freetype-go issue tracker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant