diff --git a/tools/mcufontencoder/src/export_bwfont.cc b/tools/mcufontencoder/src/export_bwfont.cc index 5e9a6779..9b97fb9c 100644 --- a/tools/mcufontencoder/src/export_bwfont.cc +++ b/tools/mcufontencoder/src/export_bwfont.cc @@ -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) { diff --git a/tools/mcufontencoder/src/exporttools.cc b/tools/mcufontencoder/src/exporttools.cc index b58ee8ec..df7a14c0 100644 --- a/tools/mcufontencoder/src/exporttools.cc +++ b/tools/mcufontencoder/src/exporttools.cc @@ -162,6 +162,11 @@ std::vector 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; } diff --git a/tools/mcufontencoder/src/importtools.cc b/tools/mcufontencoder/src/importtools.cc index c219c207..fdd7108e 100644 --- a/tools/mcufontencoder/src/importtools.cc +++ b/tools/mcufontencoder/src/importtools.cc @@ -53,6 +53,9 @@ void crop_glyphs(std::vector &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 &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();