Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to draw text based on pixel height? #8737

Answered by radarhere
thebest132 asked this question in Q&A
Discussion options

I figured maintainers know a thing or two about texts and fonts. I'm trying to draw text on a 1920x1080 image with a given pixel height. This pixel height is from the top pixel in the line of text to the bottom pixel in the line of text.

How do I efficiently convert the pixel height to a font size to draw in that area (top - bottom)?

You must be logged in to vote

https://app.uxcel.com/courses/design-lingo/typography-605/font-size-2298

Font size is the height of a typeface. Let's first define typographical terms like ascender and descender before moving on to a more detailed explanation.

  • Ascender is the vertical stroke found on lowercase letters (b, d, f, h, k, l, t) that extends above the typeface's x-height.
  • Descender is the part of a lowercase letter that extends below the baseline.

Font size equals the distance between the top of the ascender height to the bottom of the descender height.

So my expectation is that they would be the same. If you find otherwise, I suspect you're not considering ascenders and descenders.

I don't think this is a...

Replies: 1 comment

Comment options

https://app.uxcel.com/courses/design-lingo/typography-605/font-size-2298

Font size is the height of a typeface. Let's first define typographical terms like ascender and descender before moving on to a more detailed explanation.

  • Ascender is the vertical stroke found on lowercase letters (b, d, f, h, k, l, t) that extends above the typeface's x-height.
  • Descender is the part of a lowercase letter that extends below the baseline.

Font size equals the distance between the top of the ascender height to the bottom of the descender height.

So my expectation is that they would be the same. If you find otherwise, I suspect you're not considering ascenders and descenders.

I don't think this is a Skia question yet - if you had just kept this as a generic question about fonts, I would have presumed that you were still using Pillow. As a general rule though, it would be helpful if questions and problems posted here were kept to Pillow-related ones. This is partly for other users, so that when they search for information, they don't find unrelated content. It is also partly for those of us who answer questions - there already isn't enough time available to address Pillow matters without increasing scope.

You must be logged in to vote
0 replies
Answer selected by radarhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /