1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-30 03:10:06 +00:00

Ceil rather than Floor.

Looks more correct and more in line with other parts of the code.
This commit is contained in:
Green Sky 2025-10-24 17:39:13 +02:00
parent f8e941e72f
commit 85d3a874a4
No known key found for this signature in database
GPG key ID: DBE05085D874AB4A

View file

@ -576,8 +576,8 @@ static bool ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConf
// Pack and retrieve position inside texture atlas
if (is_visible)
{
const int w = (int)ImFloor(bitmap_w * bitmap_x_scale);
const int h = (int)ImFloor(bitmap_h * bitmap_y_scale);
const int w = (int)ImCeil(bitmap_w * bitmap_x_scale);
const int h = (int)ImCeil(bitmap_h * bitmap_y_scale);
IM_ASSERT(!((h < bitmap_h && w > bitmap_w) || (h > bitmap_h && w < bitmap_w))); // Can't up AND downscale at the same time // TODO: or can we?
const bool down_scaling = h < bitmap_h || w < bitmap_w;
@ -632,8 +632,8 @@ static bool ImGui_ImplFreeType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConf
float recip_v = 1.0f / rasterizer_density;
// Register glyph
float glyph_off_x = ImFloor((float)face->glyph->bitmap_left * bitmap_x_scale);
float glyph_off_y = ImFloor((float)-face->glyph->bitmap_top * bitmap_y_scale);
float glyph_off_x = ImCeil((float)face->glyph->bitmap_left * bitmap_x_scale);
float glyph_off_y = ImCeil((float)-face->glyph->bitmap_top * bitmap_y_scale);
out_glyph->X0 = glyph_off_x * recip_h + font_off_x;
out_glyph->Y0 = glyph_off_y * recip_v + font_off_y;
out_glyph->X1 = (glyph_off_x + w) * recip_h + font_off_x;