Browse Source

MagnumFontConverter: avoid double padding around the glyphs.

The glyphs were exported with the padding and when they were inserted
back into the cache later, the padding was added again.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
c22740543f
  1. 12
      src/Plugins/MagnumFont/Test/font.conf
  2. 9
      src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp

12
src/Plugins/MagnumFont/Test/font.conf

@ -19,11 +19,11 @@ unicode=76
advance=11 0
glyph=0
[glyph]
position=0 0
rectangle=0 0 0 0
position=24 24
rectangle=24 24 -24 -24
[glyph]
position=1 -12
rectangle=-8 -20 88 56
position=25 12
rectangle=16 4 64 32
[glyph]
position=1 10
rectangle=-24 -16 40 152
position=25 34
rectangle=0 8 16 128

9
src/Plugins/MagnumFontConverter/MagnumFontConverter.cpp

@ -78,12 +78,15 @@ std::vector<std::pair<std::string, Containers::Array<unsigned char>>> MagnumFont
group->setValue("glyph", found == glyphIdMap.end() ? 0 : glyphIdMap.at(glyphId));
}
/* Save glyph properties in order which preserves their IDs */
/* Save glyph properties in order which preserves their IDs, remove padding
from the values so they aren't added twice when using the font later */
/** @todo Some better way to handle this padding stuff */
for(UnsignedInt oldGlyphId: inverseGlyphIdMap) {
std::pair<Vector2i, Rectanglei> glyph = (*cache)[oldGlyphId];
Utility::ConfigurationGroup* group = configuration.addGroup("glyph");
group->setValue("position", glyph.first);
group->setValue("rectangle", glyph.second);
group->setValue("position", glyph.first+cache->padding());
group->setValue("rectangle", Rectanglei(glyph.second.bottomLeft()+cache->padding(),
glyph.second.topRight()-cache->padding()));
}
std::ostringstream confOut;

Loading…
Cancel
Save