Skip to content

Commit

Permalink
[rmkit] interim fix for diacritic crashes
Browse files Browse the repository at this point in the history
we no longer allow rendering at Y offsets below 0
  • Loading branch information
okay committed Dec 21, 2023
1 parent b2df05f commit 1a7887f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/rmkit/fb/stb_text.cpy
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,14 @@ namespace stbtext:
stbtt_GetCodepointHMetrics(&font, utf32[ch], &advance, &lsb);
stbtt_GetCodepointBitmapBox(&font, utf32[ch], scale,scale,&x0,&y0,&x1,&y1);

offset := (baseline+y0) * image.w + (int)xpos + x0
text_pos := (baseline + y0)*image.w + ((int) xpos + x0)

// if we go above the baseline, re-adjust the starting Y position to 0
// to prevent crashes.
// TODO: do this the correct way
if (baseline + y0) < 0:
text_pos = (int) xpos + x0

stbtt_MakeCodepointBitmapSubpixel(&font, &text_buffer[text_pos], x1-x0,y1-y0, image.w, scale,scale,x_shift,0, utf32[ch]);
// note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong
// because this API is really for baking character bitmaps into textures. if you want to render
Expand Down

0 comments on commit 1a7887f

Please sign in to comment.