More mcufont encoder fixes
This commit is contained in:
parent
8b42161f3f
commit
1008effc01
@ -22,6 +22,9 @@ static void encode_glyph(const DataFile::glyphentry_t &glyph,
|
|||||||
{
|
{
|
||||||
const int threshold = 8;
|
const int threshold = 8;
|
||||||
|
|
||||||
|
if (glyph.data.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// Find the number of columns in the glyph data
|
// Find the number of columns in the glyph data
|
||||||
if (num_cols == 0)
|
if (num_cols == 0)
|
||||||
{
|
{
|
||||||
|
@ -162,6 +162,11 @@ std::vector<char_range_t> compute_char_ranges(const DataFile &datafile,
|
|||||||
if (data_length > maximum_size)
|
if (data_length > maximum_size)
|
||||||
{
|
{
|
||||||
last_char = j - 1;
|
last_char = j - 1;
|
||||||
|
|
||||||
|
// Return the rest of characters to be processed by next range.
|
||||||
|
while (chars.at(i-1) > last_char)
|
||||||
|
i--;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ void crop_glyphs(std::vector<DataFile::glyphentry_t> &glyphtable,
|
|||||||
bbox_t bbox;
|
bbox_t bbox;
|
||||||
for (DataFile::glyphentry_t &glyph : glyphtable)
|
for (DataFile::glyphentry_t &glyph : glyphtable)
|
||||||
{
|
{
|
||||||
|
if (glyph.data.size() == 0)
|
||||||
|
continue; // Dummy glyph
|
||||||
|
|
||||||
for (int y = 0; y < fontinfo.max_height; y++)
|
for (int y = 0; y < fontinfo.max_height; y++)
|
||||||
{
|
{
|
||||||
for (int x = 0; x < fontinfo.max_width; x++)
|
for (int x = 0; x < fontinfo.max_width; x++)
|
||||||
@ -63,12 +66,18 @@ void crop_glyphs(std::vector<DataFile::glyphentry_t> &glyphtable,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bbox.right < bbox.left)
|
||||||
|
return; // There were no glyphs
|
||||||
|
|
||||||
// Crop the glyphs to that
|
// Crop the glyphs to that
|
||||||
size_t old_w = fontinfo.max_width;
|
size_t old_w = fontinfo.max_width;
|
||||||
size_t new_w = bbox.right - bbox.left + 1;
|
size_t new_w = bbox.right - bbox.left + 1;
|
||||||
size_t new_h = bbox.bottom - bbox.top + 1;
|
size_t new_h = bbox.bottom - bbox.top + 1;
|
||||||
for (DataFile::glyphentry_t &glyph : glyphtable)
|
for (DataFile::glyphentry_t &glyph : glyphtable)
|
||||||
{
|
{
|
||||||
|
if (glyph.data.size() == 0)
|
||||||
|
continue; // Dummy glyph
|
||||||
|
|
||||||
DataFile::pixels_t old = glyph.data;
|
DataFile::pixels_t old = glyph.data;
|
||||||
glyph.data.clear();
|
glyph.data.clear();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user