diff options
author | Lars Muldjord <muldjordlars@gmail.com> | 2016-11-22 17:55:41 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-12-02 16:59:33 +0100 |
commit | 8c29d60059f63e8b90f853cecd41d06dc8879567 (patch) | |
tree | 4d10c81da40b4f2d13d454c91af7e0a4f0e640ab | |
parent | 47252eeb1f757f7c9ab2f5c412a9aeee9c6bb3d0 (diff) |
Now checks on alpha on horiz to make sure we dont have too much spacing
-rw-r--r-- | tools/fontgen/generator.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/fontgen/generator.cc b/tools/fontgen/generator.cc index cb83974..89f0bc4 100644 --- a/tools/fontgen/generator.cc +++ b/tools/fontgen/generator.cc @@ -116,10 +116,10 @@ void Generator::setVertLimits(int &vertOffset, int &fontHeight) p.setPen(QPen(QColor(0, 0, 0, 255))); p.setFont(font); - // Render the hars that will give us a maximum overall font height - p.drawText(maxSize / 2, maxSize / 2, "Û"); - p.drawText(maxSize / 2, maxSize / 2, "¿"); - p.drawText(maxSize / 2, maxSize / 2, "j"); + // Render all chars to give us a maximum overall font height + for(int a = 0; a <= 255; ++a) { + p.drawText(maxSize / 2, maxSize / 2, QChar(a)); + } vertOffset = getVertOffset(image); fontHeight = getFontHeight(image, vertOffset); @@ -168,7 +168,8 @@ int Generator::getHorizOffset(const QImage &image) { for(int x = 0; x < maxSize; ++x) { for(int y = 0; y < maxSize; ++y) { - if(image.pixelColor(x, y) != Qt::transparent) { + // Check for alpha threshold to make sure we don't get too much space between chars + if(image.pixelColor(x, y).alpha() > 30) { return x; } } @@ -180,7 +181,8 @@ int Generator::getFontWidth(const QImage &image, const int &horizOffset) { for(int x = maxSize - 1; x > horizOffset; --x) { for(int y = 0; y < maxSize; ++y) { - if(image.pixelColor(x, y) != Qt::transparent) { + // Check for alpha threshold to make sure we don't get too much space between chars + if(image.pixelColor(x, y).alpha() > 30) { return x + 1 - horizOffset; } } |