Commit e7f5d624 authored by VanillaSalt's avatar VanillaSalt

kerning

parent 475bddc9
......@@ -723,12 +723,16 @@ void Game::InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cH
void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos) {
int pbuffer = 0;
u32 _width = 0, _height = 0;
wchar_t prev = 0;
for(size_t i = 0; text[i] != 0 && i < wcslen(text); ++i) {
u32 w = font->getCharDimension(text[i]).Width;
wchar_t c = text[i];
u32 w = font->getCharDimension(c).Width + font->getKerningWidth(c, prev);
prev = c;
if(text[i] == L'\n') {
dataManager.strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
prev = 0;
if(_height == pos)
pbuffer = 0;
continue;
......@@ -736,11 +740,12 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager.strBuffer[pbuffer++] = L'\n';
_width = 0;
_height++;
prev = 0;
if(_height == pos)
pbuffer = 0;
}
_width += w;
dataManager.strBuffer[pbuffer++] = text[i];
dataManager.strBuffer[pbuffer++] = c;
}
dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment