From 781bc67a96065cceacf2bb34d14c7f0b782ab50d Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Wed, 24 Nov 2021 07:16:57 -0500 Subject: [PATCH] LibGfx: Correct BitmapFont row indexing when un/masking fonts Now indexes by total bytes per glyph to account for changes made to row's pointer type in 3ca00c8. Fixes glyphs not showing and saving correctly in FontEditor. --- Userland/Libraries/LibGfx/BitmapFont.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index c7db009236..d7d55e0dd6 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -76,7 +76,7 @@ NonnullRefPtr BitmapFont::unmasked_character_set() const auto index = glyph_index(code_point); if (index.has_value()) { memcpy(&new_widths[code_point], &m_glyph_widths[index.value()], 1); - memcpy(&new_rows[code_point * glyph_height()], &m_rows[index.value() * glyph_height()], bytes_per_glyph); + memcpy(&new_rows[code_point * bytes_per_glyph], &m_rows[index.value() * bytes_per_glyph], bytes_per_glyph); } } return adopt_ref(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, s_max_range_mask_size, new_range_mask, m_baseline, m_mean_line, m_presentation_size, m_weight, m_slope, true)); @@ -107,7 +107,7 @@ NonnullRefPtr BitmapFont::masked_character_set() const continue; } memcpy(&new_widths[i - j * 256], &m_glyph_widths[i], 1); - memcpy(&new_rows[(i - j * 256) * glyph_height()], &m_rows[i * glyph_height()], bytes_per_glyph); + memcpy(&new_rows[(i - j * 256) * bytes_per_glyph], &m_rows[i * bytes_per_glyph], bytes_per_glyph); } return adopt_ref(*new BitmapFont(m_name, m_family, new_rows, new_widths, m_fixed_width, m_glyph_width, m_glyph_height, m_glyph_spacing, new_range_mask_size, new_range_mask, m_baseline, m_mean_line, m_presentation_size, m_weight, m_slope, true)); }