Skip to content

stb_truetype - reimplementing PackFontRanges to split across multiple textures #1303

Answered by nothings
philipguin asked this question in Q&A
Discussion options

You must be logged in to vote

PackFontRanges already takes a max texture size, specified in PackBegin (width & height).

All you have to do is change the code in the "else" clause inside the loop, currently line 4283, which handles the case where a character wasn't packed, and have that set a flag value into the return value for this character. That's the variable 'bc' in the main if clause, which you'd need to copy the definition of into this clause. Then maybe set bc->x0,y0,x1,y1 to -1, which isn't ever valid, ot add a new 'was_packed' field.

Now, when you call PackFontRanges, you can find out which characters weren't packed by checking for those -1 values, and recompute a new set of pack ranges, and call PackFontRanges

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@philipguin
Comment options

@nothings
Comment options

Answer selected by philipguin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants