More mcufont encoder fixes

ugfx_release_2.6
Joel Bodenmann 2015-12-20 17:57:46 +01:00
parent 8b42161f3f
commit 1008effc01
3 changed files with 17 additions and 0 deletions

View File

@ -22,6 +22,9 @@ static void encode_glyph(const DataFile::glyphentry_t &glyph,
{
const int threshold = 8;
if (glyph.data.size() == 0)
return;
// Find the number of columns in the glyph data
if (num_cols == 0)
{

View File

@ -162,6 +162,11 @@ std::vector<char_range_t> compute_char_ranges(const DataFile &datafile,
if (data_length > maximum_size)
{
last_char = j - 1;
// Return the rest of characters to be processed by next range.
while (chars.at(i-1) > last_char)
i--;
break;
}

View File

@ -53,6 +53,9 @@ void crop_glyphs(std::vector<DataFile::glyphentry_t> &glyphtable,
bbox_t bbox;
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 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
size_t old_w = fontinfo.max_width;
size_t new_w = bbox.right - bbox.left + 1;
size_t new_h = bbox.bottom - bbox.top + 1;
for (DataFile::glyphentry_t &glyph : glyphtable)
{
if (glyph.data.size() == 0)
continue; // Dummy glyph
DataFile::pixels_t old = glyph.data;
glyph.data.clear();