aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@seriouslyembedded.com>2015-12-20 17:57:46 +0100
committerJoel Bodenmann <joel@seriouslyembedded.com>2015-12-20 17:57:46 +0100
commit1008effc0177794f75b79656a45c6636510ab4c3 (patch)
tree75497b62824fd36413943a0a56b39f2107f2c340 /tools
parent8b42161f3f927245ffbea9c6b98018334706c441 (diff)
downloaduGFX-1008effc0177794f75b79656a45c6636510ab4c3.tar.gz
uGFX-1008effc0177794f75b79656a45c6636510ab4c3.tar.bz2
uGFX-1008effc0177794f75b79656a45c6636510ab4c3.zip
More mcufont encoder fixes
Diffstat (limited to 'tools')
-rw-r--r--tools/mcufontencoder/src/export_bwfont.cc3
-rw-r--r--tools/mcufontencoder/src/exporttools.cc5
-rw-r--r--tools/mcufontencoder/src/importtools.cc9
3 files changed, 17 insertions, 0 deletions
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<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;
}
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<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();