nanovg icon indicating copy to clipboard operation
nanovg copied to clipboard

Vertical centering of text based on the ascender only

Open icecoldone opened this issue 4 years ago • 1 comments

I needed an option to center text vertically based on the cap height only. When choosing NVG_ALIGN_MIDDLE, the ascender and the descender are taken into account, so a string containing upper-case characters only, e.g., TEXT, is not centered vertically, but shifted upwards.

Therefore I added a new option NVG_ALIGN_MIDDLE_ASCENT, which is based in the height of the ascender only.

I think that cap height would be an even better option, but the fontstash library does not provide access to this measure.

icecoldone avatar Mar 22 '20 11:03 icecoldone

I found a valuable use for this same feature. Thanks for PRing it!

rgb2hsv avatar Aug 14 '22 21:08 rgb2hsv