don't scale glyph runs

This commit is contained in:
jacob 2025-12-30 03:30:45 -06:00
parent 9b94f02a27
commit db2f5b9bd3
4 changed files with 21 additions and 21 deletions

View File

@ -28,7 +28,7 @@ u64 GC_HashFromGlyphDesc(GC_GlyphDesc desc)
//~ Run
// TODO: Thread-local cache
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size, f32 scale)
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size)
{
GC_Run result = Zi;
if (str.len > 0)
@ -179,21 +179,21 @@ GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size
GC_Glyph *glyph = ready_glyphs[glyph_idx];
GC_RunRect *rect = &result.rects[glyph_idx];
f32 advance = 0;
if (TweakB32("Ceil glyph advances", 1))
f32 advance = advance = glyph->advance;
if (TweakB32("Ceil glyph advances", 0))
{
advance = CeilF32(glyph->advance * scale);
advance = CeilF32(advance);
}
else
if (TweakB32("Floor glyph advances", 1))
{
advance = FloorF32(glyph->advance * scale);
advance = FloorF32(advance);
}
if (TweakB32("Round glyph advances", 0))
{
advance = RoundF32(advance);
}
Rng2 bounds = Zi;
bounds.p0 = glyph->bounds.p0;
bounds.p1 = glyph->bounds.p1;
bounds.p0 = MulVec2(bounds.p0, scale);
bounds.p1 = MulVec2(bounds.p1, scale);
Rng2 bounds = glyph->bounds;
rect->tex = glyph->atlas->tex_ref;
rect->tex_slice = glyph->tex_slice;
@ -220,10 +220,10 @@ GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size
if (ready_glyphs_count > 0)
{
GC_Glyph *glyph = ready_glyphs[0];
result.font_size = glyph->font_size * scale;
result.font_ascent = glyph->font_ascent * scale;
result.font_descent = glyph->font_descent * scale;
result.font_cap = glyph->font_cap * scale;
result.font_size = glyph->font_size;
result.font_ascent = glyph->font_ascent;
result.font_descent = glyph->font_descent;
result.font_cap = glyph->font_cap;
}
EndScratch(scratch);

View File

@ -155,7 +155,7 @@ u64 GC_HashFromGlyphDesc(GC_GlyphDesc desc);
////////////////////////////////////////////////////////////
//~ Run
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size, f32 scale);
GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size);
////////////////////////////////////////////////////////////
//~ Async

View File

@ -86,7 +86,7 @@ V_WidgetTheme V_GetWidgetTheme(void)
// theme.font_size = 16;
theme.font = GC_FontKeyFromResource(ResourceKeyFromStore(&V_Resources, Lit("font/seguisb.ttf")));
theme.font_size = 16;
theme.font_size = 12;
theme.window_background_color = Rgb32(0xff1a1d1e);
theme.window_border_color = Rgb32(0xff343a3b);
@ -1279,7 +1279,7 @@ void V_TickForever(WaveLaneCtx *lane)
//- Build command palette
V_Palette *palette = &frame->palette;
palette->show = LerpF32(palette->show, palette->pref_show, 30.0 * frame->dt);
palette->show = LerpF32(palette->show, palette->pref_show, 50.0 * frame->dt);
if (palette->show > 0.001)
{
palette->key = UI_KeyF("command palette");

View File

@ -980,7 +980,7 @@ void UI_EndFrame(UI_Frame *frame)
{
box->desc = cmd.box;
box->glyph_run = GC_RunFromString(frame->arena, box->desc.text, box->desc.font, box->desc.font_size, box->desc.scale);
box->glyph_run = GC_RunFromString(frame->arena, box->desc.text, box->desc.font, box->desc.font_size);
}
box->last_build_tick = frame->tick;
} break;
@ -1117,7 +1117,7 @@ void UI_EndFrame(UI_Frame *frame)
{
text_size = box->glyph_run.font_ascent + box->glyph_run.font_descent;
}
box->solved_dims.v[axis] = RoundF32(text_size + (sem_dims.v * 2 * box->desc.scale));
box->solved_dims.v[axis] = RoundF32(text_size + (sem_dims.v * 2));
}
}
}
@ -1498,7 +1498,7 @@ void UI_EndFrame(UI_Frame *frame)
if (should_truncate)
{
// Get elipses run
GC_Run elipses_run = GC_RunFromString(scratch.arena, Lit("..."), box->desc.font, box->desc.font_size, box->desc.scale);
GC_Run elipses_run = GC_RunFromString(scratch.arena, Lit("..."), box->desc.font, box->desc.font_size);
f32 truncation_offset = max_baseline - elipses_run.baseline_length;
// Append non-overflowed rects