|
@@ -17,7 +17,7 @@ struct [[gnu::packed]] FontFileHeader {
|
|
char magic[4];
|
|
char magic[4];
|
|
u8 glyph_width;
|
|
u8 glyph_width;
|
|
u8 glyph_height;
|
|
u8 glyph_height;
|
|
- u8 type;
|
|
|
|
|
|
+ u16 range_mask_size;
|
|
u8 is_variable_width;
|
|
u8 is_variable_width;
|
|
u8 glyph_spacing;
|
|
u8 glyph_spacing;
|
|
u8 baseline;
|
|
u8 baseline;
|
|
@@ -26,34 +26,95 @@ struct [[gnu::packed]] FontFileHeader {
|
|
u16 weight;
|
|
u16 weight;
|
|
char name[32];
|
|
char name[32];
|
|
char family[32];
|
|
char family[32];
|
|
- u16 unused;
|
|
|
|
|
|
+ u8 unused;
|
|
};
|
|
};
|
|
|
|
|
|
static_assert(AssertSize<FontFileHeader, 80>());
|
|
static_assert(AssertSize<FontFileHeader, 80>());
|
|
|
|
|
|
|
|
+static constexpr size_t s_max_glyph_count = 0x110000;
|
|
|
|
+static constexpr size_t s_max_range_mask_size = s_max_glyph_count / (256 * 8);
|
|
|
|
+
|
|
NonnullRefPtr<Font> BitmapFont::clone() const
|
|
NonnullRefPtr<Font> BitmapFont::clone() const
|
|
{
|
|
{
|
|
|
|
+ auto* new_range_mask = static_cast<u8*>(malloc(m_range_mask_size));
|
|
|
|
+ memcpy(new_range_mask, m_range_mask, m_range_mask_size);
|
|
size_t bytes_per_glyph = sizeof(u32) * glyph_height();
|
|
size_t bytes_per_glyph = sizeof(u32) * glyph_height();
|
|
- auto* new_rows = static_cast<unsigned*>(kmalloc_array(m_glyph_count, bytes_per_glyph));
|
|
|
|
|
|
+ auto* new_rows = static_cast<u32*>(kmalloc_array(m_glyph_count, bytes_per_glyph));
|
|
memcpy(new_rows, m_rows, bytes_per_glyph * m_glyph_count);
|
|
memcpy(new_rows, m_rows, bytes_per_glyph * m_glyph_count);
|
|
auto* new_widths = static_cast<u8*>(malloc(m_glyph_count));
|
|
auto* new_widths = static_cast<u8*>(malloc(m_glyph_count));
|
|
memcpy(new_widths, m_glyph_widths, m_glyph_count);
|
|
memcpy(new_widths, m_glyph_widths, m_glyph_count);
|
|
- 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, m_type, m_baseline, m_mean_line, m_presentation_size, m_weight, true));
|
|
|
|
|
|
+ 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, m_range_mask_size, new_range_mask, m_baseline, m_mean_line, m_presentation_size, m_weight, true));
|
|
}
|
|
}
|
|
|
|
|
|
-NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, FontTypes type)
|
|
|
|
|
|
+NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bool fixed, size_t glyph_count)
|
|
{
|
|
{
|
|
|
|
+ glyph_count += 256 - (glyph_count % 256);
|
|
|
|
+ glyph_count = min(glyph_count, s_max_glyph_count);
|
|
|
|
+ size_t glyphs_per_range = 8 * 256;
|
|
|
|
+ u16 range_mask_size = ceil_div(glyph_count, glyphs_per_range);
|
|
|
|
+ auto* new_range_mask = static_cast<u8*>(calloc(range_mask_size, 1));
|
|
|
|
+ for (size_t i = 0; i < glyph_count; i += 256) {
|
|
|
|
+ new_range_mask[i / 256 / 8] |= 1 << (i / 256 % 8);
|
|
|
|
+ }
|
|
size_t bytes_per_glyph = sizeof(u32) * glyph_height;
|
|
size_t bytes_per_glyph = sizeof(u32) * glyph_height;
|
|
- size_t count = glyph_count_by_type(type);
|
|
|
|
- auto* new_rows = static_cast<unsigned*>(calloc(count, bytes_per_glyph));
|
|
|
|
- auto* new_widths = static_cast<u8*>(calloc(count, 1));
|
|
|
|
- return adopt_ref(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true));
|
|
|
|
|
|
+ auto* new_rows = static_cast<u32*>(calloc(glyph_count, bytes_per_glyph));
|
|
|
|
+ auto* new_widths = static_cast<u8*>(calloc(glyph_count, 1));
|
|
|
|
+ return adopt_ref(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, range_mask_size, new_range_mask, 0, 0, 0, 400, true));
|
|
}
|
|
}
|
|
|
|
|
|
-BitmapFont::BitmapFont(String name, String family, unsigned* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, FontTypes type, u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, bool owns_arrays)
|
|
|
|
|
|
+NonnullRefPtr<BitmapFont> BitmapFont::unmasked_character_set() const
|
|
|
|
+{
|
|
|
|
+ auto* new_range_mask = static_cast<u8*>(malloc(s_max_range_mask_size));
|
|
|
|
+ constexpr u8 max_bits { 0b1111'1111 };
|
|
|
|
+ memset(new_range_mask, max_bits, s_max_range_mask_size);
|
|
|
|
+ size_t bytes_per_glyph = sizeof(u32) * glyph_height();
|
|
|
|
+ auto* new_rows = static_cast<u32*>(kmalloc_array(s_max_glyph_count, bytes_per_glyph));
|
|
|
|
+ auto* new_widths = static_cast<u8*>(calloc(s_max_glyph_count, 1));
|
|
|
|
+ for (size_t code_point = 0; code_point < s_max_glyph_count; ++code_point) {
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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, true));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+NonnullRefPtr<BitmapFont> BitmapFont::masked_character_set() const
|
|
|
|
+{
|
|
|
|
+ auto* new_range_mask = static_cast<u8*>(calloc(s_max_range_mask_size, 1));
|
|
|
|
+ u16 new_range_mask_size { 0 };
|
|
|
|
+ for (size_t i = 0; i < s_max_glyph_count; ++i) {
|
|
|
|
+ if (m_glyph_widths[i] > 0) {
|
|
|
|
+ new_range_mask[i / 256 / 8] |= 1 << (i / 256 % 8);
|
|
|
|
+ if (i / 256 / 8 + 1 > new_range_mask_size)
|
|
|
|
+ new_range_mask_size = i / 256 / 8 + 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ size_t new_glyph_count { 0 };
|
|
|
|
+ for (size_t i = 0; i < new_range_mask_size; ++i) {
|
|
|
|
+ new_glyph_count += 256 * __builtin_popcount(new_range_mask[i]);
|
|
|
|
+ }
|
|
|
|
+ size_t bytes_per_glyph = sizeof(u32) * m_glyph_height;
|
|
|
|
+ auto* new_rows = static_cast<u32*>(calloc(new_glyph_count, bytes_per_glyph));
|
|
|
|
+ auto* new_widths = static_cast<u8*>(calloc(new_glyph_count, 1));
|
|
|
|
+ for (size_t i = 0, j = 0; i < s_max_glyph_count; ++i) {
|
|
|
|
+ if (!(new_range_mask[i / 256 / 8] & 1 << (i / 256 % 8))) {
|
|
|
|
+ j++;
|
|
|
|
+ i += 255;
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ 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, true));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+BitmapFont::BitmapFont(String name, String family, u32* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, u16 range_mask_size, u8* range_mask, u8 baseline, u8 mean_line, u8 presentation_size, u16 weight, bool owns_arrays)
|
|
: m_name(name)
|
|
: m_name(name)
|
|
, m_family(family)
|
|
, m_family(family)
|
|
- , m_type(type)
|
|
|
|
|
|
+ , m_range_mask_size(range_mask_size)
|
|
|
|
+ , m_range_mask(range_mask)
|
|
, m_rows(rows)
|
|
, m_rows(rows)
|
|
, m_glyph_widths(widths)
|
|
, m_glyph_widths(widths)
|
|
, m_glyph_width(glyph_width)
|
|
, m_glyph_width(glyph_width)
|
|
@@ -68,12 +129,22 @@ BitmapFont::BitmapFont(String name, String family, unsigned* rows, u8* widths, b
|
|
, m_fixed_width(is_fixed_width)
|
|
, m_fixed_width(is_fixed_width)
|
|
, m_owns_arrays(owns_arrays)
|
|
, m_owns_arrays(owns_arrays)
|
|
{
|
|
{
|
|
|
|
+ VERIFY(m_range_mask);
|
|
VERIFY(m_rows);
|
|
VERIFY(m_rows);
|
|
VERIFY(m_glyph_widths);
|
|
VERIFY(m_glyph_widths);
|
|
|
|
|
|
update_x_height();
|
|
update_x_height();
|
|
|
|
|
|
- m_glyph_count = glyph_count_by_type(m_type);
|
|
|
|
|
|
+ for (size_t i = 0, index = 0; i < m_range_mask_size; ++i) {
|
|
|
|
+ for (size_t j = 0; j < 8; ++j) {
|
|
|
|
+ if (m_range_mask[i] & (1 << j)) {
|
|
|
|
+ m_glyph_count += 256;
|
|
|
|
+ m_range_indices.append(index++);
|
|
|
|
+ } else {
|
|
|
|
+ m_range_indices.append({});
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
if (!m_fixed_width) {
|
|
if (!m_fixed_width) {
|
|
u8 maximum = 0;
|
|
u8 maximum = 0;
|
|
@@ -92,6 +163,7 @@ BitmapFont::~BitmapFont()
|
|
if (m_owns_arrays) {
|
|
if (m_owns_arrays) {
|
|
free(m_glyph_widths);
|
|
free(m_glyph_widths);
|
|
free(m_rows);
|
|
free(m_rows);
|
|
|
|
+ free(m_range_mask);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -112,60 +184,14 @@ RefPtr<BitmapFont> BitmapFont::load_from_memory(const u8* data)
|
|
return nullptr;
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
- FontTypes type;
|
|
|
|
- if (header.type == 0)
|
|
|
|
- type = FontTypes::Default;
|
|
|
|
- else if (header.type == 1)
|
|
|
|
- type = FontTypes::LatinExtendedA;
|
|
|
|
- else if (header.type == 2)
|
|
|
|
- type = FontTypes::Cyrillic;
|
|
|
|
- else if (header.type == 3)
|
|
|
|
- type = FontTypes::Hebrew;
|
|
|
|
- else
|
|
|
|
- VERIFY_NOT_REACHED();
|
|
|
|
-
|
|
|
|
- size_t count = glyph_count_by_type(type);
|
|
|
|
- size_t bytes_per_glyph = sizeof(unsigned) * header.glyph_height;
|
|
|
|
-
|
|
|
|
- auto* rows = const_cast<unsigned*>((const unsigned*)(data + sizeof(FontFileHeader)));
|
|
|
|
- u8* widths = (u8*)(rows) + count * bytes_per_glyph;
|
|
|
|
- return adopt_ref(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, type, header.baseline, header.mean_line, header.presentation_size, header.weight));
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-size_t BitmapFont::glyph_count_by_type(FontTypes type)
|
|
|
|
-{
|
|
|
|
- if (type == FontTypes::Default)
|
|
|
|
- return 256;
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::LatinExtendedA)
|
|
|
|
- return 384;
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::Cyrillic)
|
|
|
|
- return 1280;
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::Hebrew)
|
|
|
|
- return 1536;
|
|
|
|
-
|
|
|
|
- dbgln("Unknown font type: {}", (int)type);
|
|
|
|
- VERIFY_NOT_REACHED();
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-String BitmapFont::type_name_by_type(FontTypes type)
|
|
|
|
-{
|
|
|
|
- if (type == FontTypes::Default)
|
|
|
|
- return "Default";
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::LatinExtendedA)
|
|
|
|
- return "LatinExtendedA";
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::Cyrillic)
|
|
|
|
- return "Cyrillic";
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::Hebrew)
|
|
|
|
- return "Hebrew";
|
|
|
|
-
|
|
|
|
- dbgln("Unknown font type: {}", (int)type);
|
|
|
|
- VERIFY_NOT_REACHED();
|
|
|
|
|
|
+ size_t bytes_per_glyph = sizeof(u32) * header.glyph_height;
|
|
|
|
+ size_t glyph_count { 0 };
|
|
|
|
+ u8* range_mask = const_cast<u8*>(data + sizeof(FontFileHeader));
|
|
|
|
+ for (size_t i = 0; i < header.range_mask_size; ++i)
|
|
|
|
+ glyph_count += 256 * __builtin_popcount(range_mask[i]);
|
|
|
|
+ u32* rows = (u32*)(range_mask + header.range_mask_size);
|
|
|
|
+ u8* widths = (u8*)(rows) + glyph_count * bytes_per_glyph;
|
|
|
|
+ return adopt_ref(*new BitmapFont(String(header.name), String(header.family), rows, widths, !header.is_variable_width, header.glyph_width, header.glyph_height, header.glyph_spacing, header.range_mask_size, range_mask, header.baseline, header.mean_line, header.presentation_size, header.weight));
|
|
}
|
|
}
|
|
|
|
|
|
RefPtr<BitmapFont> BitmapFont::load_from_file(String const& path)
|
|
RefPtr<BitmapFont> BitmapFont::load_from_file(String const& path)
|
|
@@ -192,7 +218,7 @@ bool BitmapFont::write_to_file(String const& path)
|
|
memcpy(header.magic, "!Fnt", 4);
|
|
memcpy(header.magic, "!Fnt", 4);
|
|
header.glyph_width = m_glyph_width;
|
|
header.glyph_width = m_glyph_width;
|
|
header.glyph_height = m_glyph_height;
|
|
header.glyph_height = m_glyph_height;
|
|
- header.type = m_type;
|
|
|
|
|
|
+ header.range_mask_size = m_range_mask_size;
|
|
header.baseline = m_baseline;
|
|
header.baseline = m_baseline;
|
|
header.mean_line = m_mean_line;
|
|
header.mean_line = m_mean_line;
|
|
header.is_variable_width = !m_fixed_width;
|
|
header.is_variable_width = !m_fixed_width;
|
|
@@ -202,17 +228,16 @@ bool BitmapFont::write_to_file(String const& path)
|
|
memcpy(header.name, m_name.characters(), min(m_name.length(), sizeof(header.name) - 1));
|
|
memcpy(header.name, m_name.characters(), min(m_name.length(), sizeof(header.name) - 1));
|
|
memcpy(header.family, m_family.characters(), min(m_family.length(), sizeof(header.family) - 1));
|
|
memcpy(header.family, m_family.characters(), min(m_family.length(), sizeof(header.family) - 1));
|
|
|
|
|
|
- size_t bytes_per_glyph = sizeof(unsigned) * m_glyph_height;
|
|
|
|
- size_t count = glyph_count_by_type(m_type);
|
|
|
|
-
|
|
|
|
auto stream_result = Core::OutputFileStream::open_buffered(path);
|
|
auto stream_result = Core::OutputFileStream::open_buffered(path);
|
|
if (stream_result.is_error())
|
|
if (stream_result.is_error())
|
|
return false;
|
|
return false;
|
|
auto& stream = stream_result.value();
|
|
auto& stream = stream_result.value();
|
|
|
|
|
|
|
|
+ size_t bytes_per_glyph = sizeof(u32) * m_glyph_height;
|
|
stream << ReadonlyBytes { &header, sizeof(header) };
|
|
stream << ReadonlyBytes { &header, sizeof(header) };
|
|
- stream << ReadonlyBytes { m_rows, count * bytes_per_glyph };
|
|
|
|
- stream << ReadonlyBytes { m_glyph_widths, count };
|
|
|
|
|
|
+ stream << ReadonlyBytes { m_range_mask, m_range_mask_size };
|
|
|
|
+ stream << ReadonlyBytes { m_rows, m_glyph_count * bytes_per_glyph };
|
|
|
|
+ stream << ReadonlyBytes { m_glyph_widths, m_glyph_count };
|
|
|
|
|
|
stream.flush();
|
|
stream.flush();
|
|
if (stream.handle_any_error())
|
|
if (stream.handle_any_error())
|
|
@@ -223,7 +248,20 @@ bool BitmapFont::write_to_file(String const& path)
|
|
|
|
|
|
Glyph BitmapFont::glyph(u32 code_point) const
|
|
Glyph BitmapFont::glyph(u32 code_point) const
|
|
{
|
|
{
|
|
- auto width = glyph_width(code_point);
|
|
|
|
|
|
+ // Note: Until all fonts support the 0xFFFD replacement
|
|
|
|
+ // character, fall back to painting '?' if necessary.
|
|
|
|
+ auto index = glyph_index(code_point).value_or('?');
|
|
|
|
+ auto width = m_glyph_widths[index];
|
|
|
|
+ return Glyph(
|
|
|
|
+ GlyphBitmap(&m_rows[index * m_glyph_height], { width, m_glyph_height }),
|
|
|
|
+ 0,
|
|
|
|
+ width,
|
|
|
|
+ m_glyph_height);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+Glyph BitmapFont::raw_glyph(u32 code_point) const
|
|
|
|
+{
|
|
|
|
+ auto width = m_glyph_widths[code_point];
|
|
return Glyph(
|
|
return Glyph(
|
|
GlyphBitmap(&m_rows[code_point * m_glyph_height], { width, m_glyph_height }),
|
|
GlyphBitmap(&m_rows[code_point * m_glyph_height], { width, m_glyph_height }),
|
|
0,
|
|
0,
|
|
@@ -231,18 +269,46 @@ Glyph BitmapFont::glyph(u32 code_point) const
|
|
m_glyph_height);
|
|
m_glyph_height);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+Optional<size_t> BitmapFont::glyph_index(u32 code_point) const
|
|
|
|
+{
|
|
|
|
+ auto index = code_point / 256;
|
|
|
|
+ if (index >= m_range_indices.size())
|
|
|
|
+ return {};
|
|
|
|
+ if (!m_range_indices[index].has_value())
|
|
|
|
+ return {};
|
|
|
|
+ return m_range_indices[index].value() * 256 + code_point % 256;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool BitmapFont::contains_glyph(u32 code_point) const
|
|
|
|
+{
|
|
|
|
+ auto index = glyph_index(code_point);
|
|
|
|
+ return index.has_value() && m_glyph_widths[index.value()] > 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+u8 BitmapFont::glyph_width(u32 code_point) const
|
|
|
|
+{
|
|
|
|
+ if (is_ascii(code_point) && !is_ascii_printable(code_point))
|
|
|
|
+ return 0;
|
|
|
|
+ auto index = glyph_index(code_point);
|
|
|
|
+ return m_fixed_width || !index.has_value() ? m_glyph_width : m_glyph_widths[index.value()];
|
|
|
|
+}
|
|
|
|
+
|
|
int BitmapFont::glyph_or_emoji_width_for_variable_width_font(u32 code_point) const
|
|
int BitmapFont::glyph_or_emoji_width_for_variable_width_font(u32 code_point) const
|
|
{
|
|
{
|
|
- if (code_point < m_glyph_count) {
|
|
|
|
- if (m_glyph_widths[code_point] > 0)
|
|
|
|
|
|
+ // FIXME: This is a hack in lieu of proper code point identification.
|
|
|
|
+ // 0xFFFF is arbitrary but also the end of the Basic Multilingual Plane.
|
|
|
|
+ if (code_point < 0xFFFF) {
|
|
|
|
+ auto index = glyph_index(code_point);
|
|
|
|
+ if (!index.has_value())
|
|
|
|
+ return glyph_width(0xFFFD);
|
|
|
|
+ if (m_glyph_widths[index.value()] > 0)
|
|
return glyph_width(code_point);
|
|
return glyph_width(code_point);
|
|
- else
|
|
|
|
- return glyph_width('?');
|
|
|
|
|
|
+ return glyph_width(0xFFFD);
|
|
}
|
|
}
|
|
|
|
|
|
auto* emoji = Emoji::emoji_for_code_point(code_point);
|
|
auto* emoji = Emoji::emoji_for_code_point(code_point);
|
|
if (emoji == nullptr)
|
|
if (emoji == nullptr)
|
|
- return glyph_width('?');
|
|
|
|
|
|
+ return glyph_width(0xFFFD);
|
|
return emoji->size().width();
|
|
return emoji->size().width();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -275,39 +341,6 @@ ALWAYS_INLINE int BitmapFont::unicode_view_width(T const& view) const
|
|
return longest_width;
|
|
return longest_width;
|
|
}
|
|
}
|
|
|
|
|
|
-void BitmapFont::set_type(FontTypes type)
|
|
|
|
-{
|
|
|
|
- if (type == m_type)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- if (type == FontTypes::Default)
|
|
|
|
- return;
|
|
|
|
-
|
|
|
|
- size_t new_glyph_count = glyph_count_by_type(type);
|
|
|
|
- if (new_glyph_count <= m_glyph_count) {
|
|
|
|
- m_glyph_count = new_glyph_count;
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- int item_count_to_copy = min(m_glyph_count, new_glyph_count);
|
|
|
|
-
|
|
|
|
- size_t bytes_per_glyph = sizeof(u32) * glyph_height();
|
|
|
|
-
|
|
|
|
- auto* new_rows = static_cast<unsigned*>(calloc(new_glyph_count, bytes_per_glyph));
|
|
|
|
- memcpy(new_rows, m_rows, bytes_per_glyph * item_count_to_copy);
|
|
|
|
-
|
|
|
|
- auto* new_widths = static_cast<u8*>(calloc(new_glyph_count, 1));
|
|
|
|
- memcpy(new_widths, m_glyph_widths, item_count_to_copy);
|
|
|
|
-
|
|
|
|
- kfree(m_rows);
|
|
|
|
- kfree(m_glyph_widths);
|
|
|
|
-
|
|
|
|
- m_type = type;
|
|
|
|
- m_glyph_count = new_glyph_count;
|
|
|
|
- m_rows = new_rows;
|
|
|
|
- m_glyph_widths = new_widths;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
String BitmapFont::qualified_name() const
|
|
String BitmapFont::qualified_name() const
|
|
{
|
|
{
|
|
return String::formatted("{} {} {}", family(), presentation_size(), weight());
|
|
return String::formatted("{} {} {}", family(), presentation_size(), weight());
|