Skip to content

How to use generated atlas? png+json? #30

Answered by Chlumsky
sergeyvin asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, how else would you know where the glyphs are? Here is code that generates vertex data for a given text:

for (const unicode_t *cp = text; *cp; ++cp) {
if (*cp == '\r')
continue;
if (*cp == '\n') {
textWidth = std::max(textWidth, x);
x = 0;
y -= fsScale*fontMetrics.lineHeight;
continue;
}
for (int i = 0; i < fontCount; ++i) {
const GlyphGeometry *glyph = fonts[i].getGlyph(*cp);
if (glyph) {
if (!glyph->isWhitespace()) {
double pl, pb, pr, pt;
double il, ib, ir, it;
glyph->getQuadPlaneBounds(pl, pb, pr, pt);
g…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sergeyvin
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