[1mdiff --git a/src/ui/text.c b/src/ui/text.c[m
[1mindex 1761a87c..a8be33b6 100644[m
[1m--- a/src/ui/text.c[m
[1m+++ b/src/ui/text.c[m
[36m@@ -85,7 +85,7 @@[m [miDefineTypeConstructionArgs(Glyph, (iChar ch), ch)[m
struct Impl_Font {[m
iBlock * data;[m
stbtt_fontinfo font;[m
[31m- float scale;[m
[32m+[m[32m float xScale, yScale;[m
int vertOffset; /* offset due to scaling */[m
int height;[m
int baseline;[m
[36m@@ -100,21 +100,33 @@[m [mstruct Impl_Font {[m
[m
static iFont *font_Text_(enum iFontId id);[m
[m
[31m-static void init_Font(iFont *d, const iBlock *data, int height, float scale, enum iFontId symbolsFont) {[m
[32m+[m[32mstatic void init_Font(iFont *d, const iBlock *data, int height, float scale,[m
[32m+[m[32m enum iFontId symbolsFont, iBool isMonospaced) {[m
init_Hash(&d->glyphs);[m
d->data = NULL;[m
[32m+[m[32m d->isMonospaced = isMonospaced;[m
d->height = height;[m
iZap(d->font);[m
stbtt_InitFont(&d->font, constData_Block(data), 0);[m
[31m- d->scale = stbtt_ScaleForPixelHeight(&d->font, height) * scale;[m
[32m+[m[32m d->xScale = d->yScale = stbtt_ScaleForPixelHeight(&d->font, height) * scale;[m
[32m+[m[32m if (d->isMonospaced) {[m
[32m+[m[32m /* It is important that monospaced fonts align 1:1 with the pixel grid so that[m
[32m+[m[32m box-drawing characters don't have partially occupied edge pixels, leading to seams[m
[32m+[m[32m between adjacent glyphs. */[m
[32m+[m[32m int adv;[m
[32m+[m[32m stbtt_GetCodepointHMetrics(&d->font, 'M', &adv, NULL);[m
[32m+[m[32m const float advance = (float) adv * d->xScale;[m
[32m+[m[32m if (advance > 4) { /* not too tiny */[m
[32m+[m[32m d->xScale *= floorf(advance) / advance;[m
[32m+[m[32m }[m
[32m+[m[32m }[m
d->vertOffset = height * (1.0f - scale) / 2;[m
int ascent;[m
stbtt_GetFontVMetrics(&d->font, &ascent, NULL, NULL);[m
[31m- d->baseline = ceil(ascent * d->scale);[m
[32m+[m[32m d->baseline = ceil(ascent * d->yScale);[m
d->symbolsFont = symbolsFont;[m
d->japaneseFont = regularJapanese_FontId;[m
d->koreanFont = regularKorean_FontId;[m
[31m- d->isMonospaced = iFalse;[m
memset(d->indexTable, 0xff, sizeof(d->indexTable));[m
}[m
[m
[36m@@ -271,11 +283,12 @@[m [mstatic void initFonts_Text_(iText *d) {[m
};[m
iForIndices(i, fontData) {[m
iFont *font = &d->fonts[i];[m
[31m- init_Font([m
[31m- font, fontData[i].ttf, fontData[i].size, fontData[i].scaling, fontData[i].symbolsFont);[m
[31m- if (fontData[i].ttf == &fontFiraMonoRegular_Embedded) {[m
[31m- font->isMonospaced = iTrue;[m
[31m- }[m
[32m+[m[32m init_Font(font,[m
[32m+[m[32m fontData[i].ttf,[m
[32m+[m[32m fontData[i].size,[m
[32m+[m[32m fontData[i].scaling,[m
[32m+[m[32m fontData[i].symbolsFont,[m
[32m+[m[32m fontData[i].ttf == &fontFiraMonoRegular_Embedded);[m
if (i == default_FontId || i == defaultMedium_FontId) {[m
font->manualKernOnly = iTrue;[m
}[m
[36m@@ -423,7 +436,7 @@[m [mstatic void freeBmp_(void *ptr) {[m
static SDL_Surface *rasterizeGlyph_Font_(const iFont *d, uint32_t glyphIndex, float xShift) {[m
int w, h;[m
uint8_t *bmp = stbtt_GetGlyphBitmapSubpixel([m
[31m- &d->font, d->scale, d->scale, xShift, 0.0f, glyphIndex, &w, &h, 0, 0);[m
[32m+[m[32m &d->font, d->xScale, d->yScale, xShift, 0.0f, glyphIndex, &w, &h, 0, 0);[m
collect_Garbage(bmp, freeBmp_); /* `bmp` must be freed afterwards. */[m
SDL_Surface *surface8 =[m
SDL_CreateRGBSurfaceWithFormatFrom(bmp, w, h, 8, w, SDL_PIXELFORMAT_INDEX8);[m
[36m@@ -478,12 +491,12 @@[m [mstatic void cache_Font_(iFont *d, iGlyph *glyph, int hoff) {[m
int adv;[m
const uint32_t gIndex = glyph->glyphIndex;[m
stbtt_GetGlyphHMetrics(&d->font, gIndex, &adv, NULL);[m
[31m- glyph->advance = d->scale * adv;[m
[32m+[m[32m glyph->advance = d->xScale * adv;[m
}[m
stbtt_GetGlyphBitmapBoxSubpixel(&d->font,[m
glyph->glyphIndex,[m
[31m- d->scale,[m
[31m- d->scale,[m
[32m+[m[32m d->xScale,[m
[32m+[m[32m d->yScale,[m
hoff * 0.5f,[m
0.0f,[m
&glyph->d[hoff].x,[m
[36m@@ -734,11 +747,7 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
}[m
const iBool useMonoAdvance =[m
monoAdvance > 0 && !isJapanese_FontId(fontId_Text_(glyph->font));[m
[31m- /* The -0.25f is to mitigate issues with box-drawing characters sometimes rounding[m
[31m- up to leave a hairline gap with the previous character. The purpose is to overlap[m
[31m- the glyphs slightly, since they are rendered antialiased and unhinted, which means[m
[31m- the right edge pixels may end up partially non-opaque. */[m
[31m- const float advance = (useMonoAdvance ? monoAdvance - 0.25f : glyph->advance);[m
[32m+[m[32m const float advance = (useMonoAdvance ? monoAdvance : glyph->advance);[m
if (!isMeasuring_(mode)) {[m
if (useMonoAdvance && dst.w > advance && glyph->font != d) {[m
/* Glyphs from a different font may need recentering to look better. */[m
[36m@@ -769,7 +778,7 @@[m [mstatic iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe[m
const char *peek = chPos;[m
const iChar next = nextChar_(&peek, text.end);[m
if (enableKerning_Text && !d->manualKernOnly && next) {[m
[31m- xpos += d->scale * stbtt_GetGlyphKernAdvance(&d->font, glyph->glyphIndex, next);[m
[32m+[m[32m xpos += d->xScale * stbtt_GetGlyphKernAdvance(&d->font, glyph->glyphIndex, next);[m
}[m
}[m
#endif[m
text/plain
This content has been proxied by September (ba2dc).