Skip to content

Commit 781bc67

Browse files
thankyouverycoolalimpfard
authored andcommitted
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.
1 parent 78724fd commit 781bc67

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Userland/Libraries/LibGfx/BitmapFont.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ NonnullRefPtr<BitmapFont> BitmapFont::unmasked_character_set() const
7676
auto index = glyph_index(code_point);
7777
if (index.has_value()) {
7878
memcpy(&new_widths[code_point], &m_glyph_widths[index.value()], 1);
79-
memcpy(&new_rows[code_point * glyph_height()], &m_rows[index.value() * glyph_height()], bytes_per_glyph);
79+
memcpy(&new_rows[code_point * bytes_per_glyph], &m_rows[index.value() * bytes_per_glyph], bytes_per_glyph);
8080
}
8181
}
8282
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> BitmapFont::masked_character_set() const
107107
continue;
108108
}
109109
memcpy(&new_widths[i - j * 256], &m_glyph_widths[i], 1);
110-
memcpy(&new_rows[(i - j * 256) * glyph_height()], &m_rows[i * glyph_height()], bytes_per_glyph);
110+
memcpy(&new_rows[(i - j * 256) * bytes_per_glyph], &m_rows[i * bytes_per_glyph], bytes_per_glyph);
111111
}
112112
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));
113113
}

0 commit comments

Comments
 (0)