stb_truetype - reimplementing PackFontRanges
to split across multiple textures
#1303
-
Hey there, I'd like to reimplement
With significant work I could probably overcome these, but I was wondering if there was a better approach than what I've outlined? Perhaps something more explicitly supported by stb_truetype? Otherwise, any tips on the above challenges? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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 Now, when you call The only limitation of this is that the packer will stop trying to pack as soon as the first character fails, instead of trying to pack as much as possible in. It's possible to try to hack on the packer to change this, but I wouldn't recommend it; I believe it requires totally different packing strategies to do well. Most of the time it'll still require the same total number of textures whether you pack the extra bits in or not. |
Beta Was this translation helpful? Give feedback.
PackFontRanges
already takes a max texture size, specified inPackBegin
(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 callPackFontRanges