|
@@ -725,24 +725,7 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
|
|
// NOTE: Using simple packaging, one char after another
|
|
// NOTE: Using simple packaging, one char after another
|
|
for (int i = 0; i < glyphCount; i++)
|
|
for (int i = 0; i < glyphCount; i++)
|
|
{
|
|
{
|
|
- // Copy pixel data from fc.data to atlas
|
|
|
|
- for (int y = 0; y < chars[i].image.height; y++)
|
|
|
|
- {
|
|
|
|
- for (int x = 0; x < chars[i].image.width; x++)
|
|
|
|
- {
|
|
|
|
- ((unsigned char *)atlas.data)[(offsetY + y)*atlas.width + (offsetX + x)] = ((unsigned char *)chars[i].image.data)[y*chars[i].image.width + x];
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // Fill chars rectangles in atlas info
|
|
|
|
- recs[i].x = (float)offsetX;
|
|
|
|
- recs[i].y = (float)offsetY;
|
|
|
|
- recs[i].width = (float)chars[i].image.width;
|
|
|
|
- recs[i].height = (float)chars[i].image.height;
|
|
|
|
-
|
|
|
|
- // Move atlas position X for next character drawing
|
|
|
|
- offsetX += (chars[i].image.width + 2*padding);
|
|
|
|
-
|
|
|
|
|
|
+ // Check remaining space for glyph
|
|
if (offsetX >= (atlas.width - chars[i].image.width - 2*padding))
|
|
if (offsetX >= (atlas.width - chars[i].image.width - 2*padding))
|
|
{
|
|
{
|
|
offsetX = padding;
|
|
offsetX = padding;
|
|
@@ -766,6 +749,24 @@ Image GenImageFontAtlas(const GlyphInfo *chars, Rectangle **charRecs, int glyphC
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Copy pixel data from fc.data to atlas
|
|
|
|
+ for (int y = 0; y < chars[i].image.height; y++)
|
|
|
|
+ {
|
|
|
|
+ for (int x = 0; x < chars[i].image.width; x++)
|
|
|
|
+ {
|
|
|
|
+ ((unsigned char *)atlas.data)[(offsetY + y)*atlas.width + (offsetX + x)] = ((unsigned char *)chars[i].image.data)[y*chars[i].image.width + x];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Fill chars rectangles in atlas info
|
|
|
|
+ recs[i].x = (float)offsetX;
|
|
|
|
+ recs[i].y = (float)offsetY;
|
|
|
|
+ recs[i].width = (float)chars[i].image.width;
|
|
|
|
+ recs[i].height = (float)chars[i].image.height;
|
|
|
|
+
|
|
|
|
+ // Move atlas position X for next character drawing
|
|
|
|
+ offsetX += (chars[i].image.width + 2*padding);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (packMethod == 1) // Use Skyline rect packing algorithm (stb_pack_rect)
|
|
else if (packMethod == 1) // Use Skyline rect packing algorithm (stb_pack_rect)
|