Replies: 1 comment 4 replies
-
|
stb_truetype doesn't compute a font bounding box itself. The font bounding box returned by that function is just exposing 4 numbers stored in the font file which are not used anywhere else in the code. It is possible I misunderstood the spec, or it is possible you have a bad font file with incorrect values stored for those 4 numbers (possible since they're not used anywhere else in the file, so this would have no other bad effects). The "bad font file" scenario is more likely to happen for a random fun font off the internet rather than a standard well-used font like those shipped with an operating system. Because I wrote the code in 2009 I don't remember how much testing/validation I did on this function specifically. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First a bit of context, I'm implementing the "print "Hello World!" banner, with bugs" example, but without the bugs, to learn the API. I'm trying to create an offscreen buffer to render the characters too, and for that I'm using
stbtt_GetFontBoundingBoxIf I am to believe the documentation,
y0gives the maximum offset from the cursor to the TOP of any glyph, whiley1goes from the cursor to the bottom.In the example I'm doing (loading
"c:/windows/fonts/times.ttf"),y0 = -628andy1 = 2129.Now, in
stbtt_GetGlyphBitmapBoxSubpixel, when asking for an "H" for the exact same font with a scaling of1.0I'm gettingy0 = -1356andy1 = 0, which immediately places them out of bounds.My question would be, I am assuming something wrong here? Or is really
stbtt_GetFontBoundingBoxreturning y0 and y1 in reverse of what I'm expecting?Beta Was this translation helpful? Give feedback.
All reactions