mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
IGUIFont / CGUITTFont code cleanups (#15581)
This commit is contained in:
parent
0bfd9bc09e
commit
c49ff76955
12 changed files with 135 additions and 626 deletions
|
@ -194,9 +194,9 @@ void GUIEditBoxWithScrollBar::draw()
|
|||
mbegin = font->getDimension(s.c_str()).Width;
|
||||
|
||||
// deal with kerning
|
||||
mbegin += font->getKerningWidth(
|
||||
&((*txt_line)[realmbgn - start_pos]),
|
||||
realmbgn - start_pos > 0 ? &((*txt_line)[realmbgn - start_pos - 1]) : 0);
|
||||
mbegin += font->getKerning(
|
||||
(*txt_line)[realmbgn - start_pos],
|
||||
realmbgn - start_pos > 0 ? (*txt_line)[realmbgn - start_pos - 1] : 0).X;
|
||||
|
||||
lineStartPos = realmbgn - start_pos;
|
||||
}
|
||||
|
@ -242,7 +242,8 @@ void GUIEditBoxWithScrollBar::draw()
|
|||
}
|
||||
s = txt_line->subString(0, m_cursor_pos - start_pos);
|
||||
charcursorpos = font->getDimension(s.c_str()).Width +
|
||||
font->getKerningWidth(L"_", m_cursor_pos - start_pos > 0 ? &((*txt_line)[m_cursor_pos - start_pos - 1]) : 0);
|
||||
font->getKerning(L'_',
|
||||
m_cursor_pos - start_pos > 0 ? (*txt_line)[m_cursor_pos - start_pos - 1] : 0).X;
|
||||
|
||||
if (focus && (porting::getTimeMs() - m_blink_start_time) % 700 < 350) {
|
||||
setTextRect(cursor_line);
|
||||
|
@ -431,7 +432,7 @@ void GUIEditBoxWithScrollBar::setTextRect(s32 line)
|
|||
d = font->getDimension(Text.c_str());
|
||||
d.Height = AbsoluteRect.getHeight();
|
||||
}
|
||||
d.Height += font->getKerningHeight();
|
||||
d.Height += font->getKerning(L'A').Y;
|
||||
|
||||
// justification
|
||||
switch (m_halign) {
|
||||
|
@ -536,7 +537,7 @@ void GUIEditBoxWithScrollBar::calculateScrollPos()
|
|||
|
||||
// calculate vertical scrolling
|
||||
if (has_broken_text) {
|
||||
irr::u32 line_height = font->getDimension(L"A").Height + font->getKerningHeight();
|
||||
irr::u32 line_height = font->getDimension(L"A").Height + font->getKerning(L'A').Y;
|
||||
// only up to 1 line fits?
|
||||
if (line_height >= (irr::u32)m_frame_rect.getHeight()) {
|
||||
m_vscroll_pos = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue