space character spacing in bitmap manual font

marshmonkey

27-08-2009 02:09:47

I have gotten bitmap based fonts to work in MyGUI using this kind of description in the font xml:

<Font name="ManualFont" default_height="17" space_width="4" source="Vera.19.png">
<Code index="32" coord="436 165 12 33" />
<Code index="33" coord="57 0 11 33" />
<Code index="34" coord="68 0 14 33" />
<Code index="35" coord="82 0 23 33" />
<Code index="36" coord="105 0 18 33" />


And it appears fine, except for the spacing is huge:


I have tried changing the space_width in the font XML as well as the width of the first character code index 32 (which I believe is a space?) but neither one seems to have changed the spacing. Is there a way to adjust this?

Altren

27-08-2009 10:21:01

Well, looks like there was bug with spaces in bitmap fonts in 2.2.2 - replace Font::addRange with next function:
void Font::addRange(VectorPairCodeCoord & _info, size_t _first, size_t _last, int _width, int _height, float _aspect)
{
RangeInfo range = RangeInfo(_info[_first].code, _info[_last].code);

for (size_t pos=_first; pos<=_last; ++pos)
{
GlyphInfo* info = range.getInfo(_info[pos].code);
const IntCoord& coord = _info[pos].coord;
addGlyph(info, _info[pos].code, coord.left, coord.top, coord.right(), coord.bottom(), _width, _height, _aspect);

if (_info[pos].code == FONT_CODE_SPACE)
mSpaceGlyphInfo = *info;
else if (_info[pos].code == FONT_CODE_TAB)
mTabGlyphInfo = *info;
}

mVectorRangeInfo.push_back(range);
}