[1mdiff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c[m
[1mindex 4f9bd367..018daec8 100644[m
[1m--- a/src/ui/inputwidget.c[m
[1m+++ b/src/ui/inputwidget.c[m
[36m@@ -98,7 +98,7 @@[m [mvoid init_InputWidget(iInputWidget *d, size_t maxLen) {[m
init_Array(&d->oldText, sizeof(iChar));[m
init_String(&d->hint);[m
init_Array(&d->undoStack, sizeof(iInputUndo));[m
[31m- d->font = uiInput_FontId;[m
[32m+[m[32m d->font = uiInput_FontId | alwaysVariableFlag_FontId;[m
d->cursor = 0;[m
d->lastCursor = 0;[m
d->inFlags = eatEscape_InputWidgetFlag;[m
[36m@@ -789,11 +789,13 @@[m [mstatic void draw_InputWidget_(const iInputWidget *d) {[m
else {[m
initCStr_String(&cur, " ");[m
}[m
[32m+[m[32m /* The gap_UI
offsets below are a hack. They are used because for some reason the[m
[32m+[m[32m cursor rect and the glyph inside don't quite position like during run_Text_()
. */[m
const iInt2 prefixSize = advanceN_Text(d->font, cstr_String(text), d->cursor);[m
const iInt2 curPos = addX_I2(textOrigin, prefixSize.x);[m
[31m- const iRect curRect = { curPos, addX_I2(advance_Text(d->font, cstr_String(&cur)), 1) };[m
[32m+[m[32m const iRect curRect = { curPos, addX_I2(advance_Text(d->font, cstr_String(&cur)), iMin(2, gap_UI / 4)) };[m
fillRect_Paint(&p, curRect, uiInputCursor_ColorId);[m
[31m- draw_Text(d->font, curPos, uiInputCursorText_ColorId, "%s", cstr_String(&cur));[m
[32m+[m[32m draw_Text(d->font, addX_I2(curPos, iMin(1, gap_UI / 8)), uiInputCursorText_ColorId, "%s", cstr_String(&cur));[m
deinit_String(&cur);[m
}[m
delete_String(text);[m
[1mdiff --git a/src/ui/text.c b/src/ui/text.c[m
[1mindex 3e1d732a..4229217c 100644[m
[1m--- a/src/ui/text.c[m
[1m+++ b/src/ui/text.c[m
[36m@@ -426,7 +426,7 @@[m [mvoid resetFonts_Text(void) {[m
}[m
[m
iLocalDef iFont *font_Text_(enum iFontId id) {[m
[31m- return &text_.fonts[id];[m
[32m+[m[32m return &text_.fonts[id & mask_FontId];[m
}[m
[m
static void freeBmp_(void *ptr) {[m
[36m@@ -582,11 +582,14 @@[m [mstatic const iGlyph *glyph_Font_(iFont *d, iChar ch) {[m
}[m
[m
enum iRunMode {[m
[31m- measure_RunMode,[m
[31m- measureNoWrap_RunMode,[m
[31m- measureVisual_RunMode, /* actual visible bounding box of the glyph, e.g., for icons */[m
[31m- draw_RunMode,[m
[31m- drawPermanentColor_RunMode[m
[32m+[m[32m measure_RunMode = 0,[m
[32m+[m[32m draw_RunMode = 1,[m
[32m+[m[32m modeMask_RunMode = 0x00ff,[m
[32m+[m[32m flagsMask_RunMode = 0xff00,[m
[32m+[m[32m noWrapFlag_RunMode = iBit(9),[m
[32m+[m[32m visualFlag_RunMode = iBit(10), /* actual visible bounding box of the glyph, e.g., for icons */[m
[32m+[m[32m permanentColorFlag_RunMode = iBit(11),[m
[32m+[m[32m alwaysVariableWidthFlag_RunMode = iBit(12),[m
};[m
[m
static iChar nextChar_(const char **chPos, const char *end) {[m
[36m@@ -625,8 +628,7 @@[m [miLocalDef iBool isWrapBoundary_(iChar prevC, iChar c) {[m
}[m
[m
iLocalDef iBool isMeasuring_(enum iRunMode mode) {[m
[31m- return mode == measure_RunMode || mode == measureNoWrap_RunMode ||[m
[31m- mode == measureVisual_RunMode;[m
[32m+[m[32m return (mode & modeMask_RunMode) == measure_RunMode;[m
}[m
[m
static iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLen, iInt2 pos,[m
[36m@@ -642,7 +644,8 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
*continueFrom_out = text.end;[m
}[m
iChar prevCh = 0;[m
[31m- if (d->isMonospaced) {[m
[32m+[m[32m const iBool isMonospaced = d->isMonospaced && !(mode & alwaysVariableWidthFlag_RunMode);[m
[32m+[m[32m if (isMonospaced) {[m
monoAdvance = glyph_Font_(d, 'M')->advance;[m
}[m
for (const char *chPos = text.start; chPos != text.end; ) {[m
[36m@@ -654,7 +657,7 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
iRegExpMatch m;[m
init_RegExpMatch(&m);[m
if (match_RegExp(text_.ansiEscape, chPos, text.end - chPos, &m)) {[m
[31m- if (mode == draw_RunMode) {[m
[32m+[m[32m if (mode & draw_RunMode) {[m
/* Change the color. */[m
const iColor clr =[m
ansiForeground_Color(capturedRange_RegExpMatch(&m, 1), tmParagraph_ColorId);[m
[36m@@ -713,7 +716,7 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
}[m
if (ch == '\r') {[m
const iChar esc = nextChar_(&chPos, text.end);[m
[31m- if (mode == draw_RunMode) {[m
[32m+[m[32m if (mode & draw_RunMode) {[m
const iColor clr = get_Color(esc - asciiBase_ColorEscape);[m
SDL_SetTextureColorMod(text_.cache, clr.r, clr.g, clr.b);[m
}[m
[36m@@ -743,8 +746,14 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
pos.y + glyph->font->baseline + glyph->d[hoff].y,[m
glyph->rect[hoff].size.x,[m
glyph->rect[hoff].size.y };[m
[32m+[m[32m if (glyph->font != d) {[m
[32m+[m[32m if (glyph->font->height > d->height) {[m
[32m+[m[32m /* Center-align vertically so the baseline isn't totally offset. */[m
[32m+[m[32m dst.y -= (glyph->font->height - d->height) / 2;[m
[32m+[m[32m }[m
[32m+[m[32m }[m
/* Update the bounding box. */[m
[31m- if (mode == measureVisual_RunMode) {[m
[32m+[m[32m if (mode & visualFlag_RunMode) {[m
if (isEmpty_Rect(bounds)) {[m
bounds = init_Rect(dst.x, dst.y, dst.w, dst.h);[m
}[m
[36m@@ -779,12 +788,12 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
is monospaced. Except with Japanese script, that's larger than the normal monospace. */[m
xpos += advance;[m
xposMax = iMax(xposMax, xpos);[m
[31m- if (continueFrom_out && (mode == measureNoWrap_RunMode || isWrapBoundary_(prevCh, ch))) {[m
[32m+[m[32m if (continueFrom_out && ((mode & noWrapFlag_RunMode) || isWrapBoundary_(prevCh, ch))) {[m
lastWordEnd = chPos;[m
}[m
#if defined (LAGRANGE_ENABLE_KERNING)[m
/* Check the next character. */[m
[31m- if (!d->isMonospaced && glyph->font == d) {[m
[32m+[m[32m if (!isMonospaced && glyph->font == d) {[m
/* TODO: No need to decode the next char twice; check this on the next iteration. */[m
const char *peek = chPos;[m
const iChar next = nextChar_(&peek, text.end);[m
[36m@@ -805,14 +814,14 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
}[m
[m
int lineHeight_Text(int fontId) {[m
[31m- return text_.fonts[fontId].height;[m
[32m+[m[32m return font_Text_(fontId)->height;[m
}[m
[m
iInt2 measureRange_Text(int fontId, iRangecc text) {[m
if (isEmpty_Range(&text)) {[m
return init_I2(0, lineHeight_Text(fontId));[m
}[m
[31m- return run_Font_(&text_.fonts[fontId],[m
[32m+[m[32m return run_Font_(font_Text_(fontId),[m
measure_RunMode,[m
text,[m
iInvalidSize,[m
[36m@@ -823,18 +832,32 @@[m [miInt2 measureRange_Text(int fontId, iRangecc text) {[m
}[m
[m
iRect visualBounds_Text(int fontId, iRangecc text) {[m
[31m- return run_Font_([m
[31m- font_Text_(fontId), measureVisual_RunMode, text, iInvalidSize, zero_I2(), 0, NULL, NULL);[m
[32m+[m[32m return run_Font_(font_Text_(fontId),[m
[32m+[m[32m measure_RunMode | visualFlag_RunMode,[m
[32m+[m[32m text,[m
[32m+[m[32m iInvalidSize,[m
[32m+[m[32m zero_I2(),[m
[32m+[m[32m 0,[m
[32m+[m[32m NULL,[m
[32m+[m[32m NULL);[m
}[m
[m
iInt2 measure_Text(int fontId, const char *text) {[m
return measureRange_Text(fontId, range_CStr(text));[m
}[m
[m
[32m+[m[32mstatic int runFlagsFromId_(enum iFontId fontId) {[m
[32m+[m[32m int runFlags = 0;[m
[32m+[m[32m if (fontId & alwaysVariableFlag_FontId) {[m
[32m+[m[32m runFlags |= alwaysVariableWidthFlag_RunMode;[m
[32m+[m[32m }[m
[32m+[m[32m return runFlags;[m
[32m+[m[32m}[m
[32m+[m
iInt2 advanceRange_Text(int fontId, iRangecc text) {[m
int advance;[m
[31m- const int height = run_Font_(&text_.fonts[fontId],[m
[31m- measure_RunMode,[m
[32m+[m[32m const int height = run_Font_(font_Text_(fontId),[m
[32m+[m[32m measure_RunMode | runFlagsFromId_(fontId),[m
text,[m
iInvalidSize,[m
zero_I2(),[m
[36m@@ -847,8 +870,8 @@[m [miInt2 advanceRange_Text(int fontId, iRangecc text) {[m
[m
iInt2 tryAdvance_Text(int fontId, iRangecc text, int width, const char **endPos) {[m
int advance;[m
[31m- const int height = run_Font_(&text_.fonts[fontId],[m
[31m- measure_RunMode,[m
[32m+[m[32m const int height = run_Font_(font_Text_(fontId),[m
[32m+[m[32m measure_RunMode | runFlagsFromId_(fontId),[m
text,[m
iInvalidSize,[m
zero_I2(),[m
[36m@@ -861,8 +884,8 @@[m [miInt2 tryAdvance_Text(int fontId, iRangecc text, int width, const char **endPos)[m
[m
iInt2 tryAdvanceNoWrap_Text(int fontId, iRangecc text, int width, const char **endPos) {[m
int advance;[m
[31m- const int height = run_Font_(&text_.fonts[fontId],[m
[31m- measureNoWrap_RunMode,[m
[32m+[m[32m const int height = run_Font_(font_Text_(fontId),[m
[32m+[m[32m measure_RunMode | noWrapFlag_RunMode | runFlagsFromId_(fontId),[m
text,[m
iInvalidSize,[m
zero_I2(),[m
[36m@@ -882,8 +905,14 @@[m [miInt2 advanceN_Text(int fontId, const char *text, size_t n) {[m
return init_I2(0, lineHeight_Text(fontId));[m
}[m
int advance;[m
[31m- run_Font_([m
[31m- &text_.fonts[fontId], measure_RunMode, range_CStr(text), n, zero_I2(), 0, NULL, &advance);[m
[32m+[m[32m run_Font_(font_Text_(fontId),[m
[32m+[m[32m measure_RunMode | runFlagsFromId_(fontId),[m
[32m+[m[32m range_CStr(text),[m
[32m+[m[32m n,[m
[32m+[m[32m zero_I2(),[m
[32m+[m[32m 0,[m
[32m+[m[32m NULL,[m
[32m+[m[32m &advance);[m
return init_I2(advance, lineHeight_Text(fontId));[m
}[m
[m
[36m@@ -891,8 +920,9 @@[m [mstatic void draw_Text_(int fontId, iInt2 pos, int color, iRangecc text) {[m
iText *d = &text_;[m
const iColor clr = get_Color(color & mask_ColorId);[m
SDL_SetTextureColorMod(d->cache, clr.r, clr.g, clr.b);[m
[31m- run_Font_(&d->fonts[fontId],[m
[31m- color & permanent_ColorId ? drawPermanentColor_RunMode : draw_RunMode,[m
[32m+[m[32m run_Font_(font_Text_(fontId),[m
[32m+[m[32m draw_RunMode | (color & permanent_ColorId ? permanentColorFlag_RunMode : 0) |[m
[32m+[m[32m runFlagsFromId_(fontId),[m
text,[m
iInvalidSize,[m
pos,[m
[1mdiff --git a/src/ui/text.h b/src/ui/text.h[m
[1mindex a0b2dc1a..6728bb62 100644[m
[1m--- a/src/ui/text.h[m
[1m+++ b/src/ui/text.h[m
[36m@@ -91,6 +91,8 @@[m [menum iFontId {[m
[m
/* Meta: */[m
fromSymbolsToEmojiOffset_FontId = 10,[m
[32m+[m[32m mask_FontId = 0xffff,[m
[32m+[m[32m alwaysVariableFlag_FontId = 0x10000,[m
[m
/* UI fonts: */[m
uiLabel_FontId = default_FontId,[m
text/plain
This content has been proxied by September (ba2dc).