=> 10999deaeec452e8db76b4d017e922f74a6dccf6
[1mdiff --git a/src/ui/text.c b/src/ui/text.c[m [1mindex bf71b0e9..2c17b3da 100644[m [1m--- a/src/ui/text.c[m [1m+++ b/src/ui/text.c[m [36m@@ -121,6 +121,8 @@[m [miDefineTypeConstructionArgs(Glyph, (iChar ch), ch)[m [m /*-----------------------------------------------------------------------------------------------*/[m [m [32m+[m[32mstatic iGlyph *glyph_Font_(iFont *d, iChar ch);[m [32m+[m struct Impl_Font {[m iBlock * data;[m enum iTextFont family;[m [36m@@ -131,6 +133,7 @@[m [mstruct Impl_Font {[m int baseline;[m iHash glyphs; /* key is glyph index in the font */ /* TODO: does not need to be a Hash */[m iBool isMonospaced;[m [32m+[m[32m float emAdvance;[m enum iFontSize sizeId; /* used to look up different fonts of matching size */[m uint32_t indexTable[128 - 32]; /* quick ASCII lookup */[m #if defined (LAGRANGE_ENABLE_HARFBUZZ)[m [36m@@ -178,20 +181,20 @@[m [mstatic void init_Font(iFont *d, const iBlock *data, int height, float scale,[m d->height = height;[m iZap(d->font);[m stbtt_InitFont(&d->font, constData_Block(data), 0);[m [31m- int ascent, descent;[m [32m+[m[32m int ascent, descent, emAdv;[m stbtt_GetFontVMetrics(&d->font, &ascent, &descent, NULL);[m [32m+[m[32m stbtt_GetCodepointHMetrics(&d->font, 'M', &emAdv, NULL);[m d->xScale = d->yScale = stbtt_ScaleForPixelHeight(&d->font, height) * scale;[m if (d->isMonospaced) {[m /* It is important that monospaced fonts align 1:1 with the pixel grid so that[m box-drawing characters don't have partially occupied edge pixels, leading to seams[m between adjacent glyphs. */[m [31m- int adv;[m [31m- stbtt_GetCodepointHMetrics(&d->font, 'M', &adv, NULL);[m [31m- const float advance = (float) adv * d->xScale;[m [32m+[m[32m const float advance = (float) emAdv * d->xScale;[m if (advance > 4) { /* not too tiny */[m d->xScale *= floorf(advance) / advance;[m }[m }[m [32m+[m[32m d->emAdvance = emAdv * d->xScale;[m d->baseline = ascent * d->yScale;[m d->vertOffset = height * (1.0f - scale) / 2;[m /* Custom tweaks. */[m [36m@@ -1335,6 +1338,11 @@[m [mstatic void shape_GlyphBuffer_(iGlyphBuffer *d) {[m }[m }[m [m [32m+[m[32mstatic float nextTabStop_Font_(const iFont *d, float x) {[m [32m+[m[32m const float stop = 4 * d->emAdvance;[m [32m+[m[32m return floorf(x / stop) * stop + stop;[m [32m+[m[32m}[m [32m+[m static float advance_GlyphBuffer_(const iGlyphBuffer *d, iRangei wrapPosRange) {[m float x = 0.0f;[m for (unsigned int i = 0; i < d->glyphCount; i++) {[m [36m@@ -1343,6 +1351,9 @@[m [mstatic float advance_GlyphBuffer_(const iGlyphBuffer *d, iRangei wrapPosRange) {[m continue;[m }[m x += d->font->xScale * d->glyphPos[i].x_advance;[m [32m+[m[32m if (d->logicalText[logPos] == '\t') {[m [32m+[m[32m x = nextTabStop_Font_(d->font, x);[m [32m+[m[32m }[m if (i + 1 < d->glyphCount) {[m x += horizKern_Font_(d->font,[m d->glyphInfo[i].codepoint,[m [36m@@ -1354,7 +1365,7 @@[m [mstatic float advance_GlyphBuffer_(const iGlyphBuffer *d, iRangei wrapPosRange) {[m [m static void evenMonospaceAdvances_GlyphBuffer_(iGlyphBuffer *d, iFont *baseFont) {[m shape_GlyphBuffer_(d);[m [31m- const float monoAdvance = glyph_Font_(baseFont, 'M')->advance;[m [32m+[m[32m const float monoAdvance = baseFont->emAdvance;[m for (unsigned int i = 0; i < d->glyphCount; ++i) {[m const hb_glyph_info_t *info = d->glyphInfo + i;[m if (d->glyphPos[i].x_advance > 0 && d->font != baseFont) {[m [36m@@ -1498,10 +1509,10 @@[m [mstatic iRect run_Font_(iFont *d, const iRunArgs *args) {[m const int glyphFlags = hb_glyph_info_get_glyph_flags(info);[m const float xOffset = run->font->xScale * buf->glyphPos[i].x_offset;[m const float xAdvance = run->font->xScale * buf->glyphPos[i].x_advance;[m [32m+[m[32m const iChar ch = logicalText[logPos];[m iAssert(xAdvance >= 0);[m if (args->wrap->mode == word_WrapTextMode) {[m /* When word wrapping, only consider certain places breakable. */[m [31m- const iChar ch = logicalText[logPos];[m if ((ch >= 128 || !ispunct(ch)) && (prevCh == '-' || prevCh == '/')) {[m safeBreakPos = logPos;[m breakAdvance = wrapAdvance;[m [36m@@ -1527,6 +1538,9 @@[m [mstatic iRect run_Font_(iFont *d, const iRunArgs *args) {[m wrap->hitGlyphNormX_out = (wrap->hitPoint.x - wrapAdvance) / xAdvance;[m }[m }[m [32m+[m[32m if (ch == '\t') {[m [32m+[m[32m wrapAdvance = nextTabStop_Font_(d, wrapAdvance) - xAdvance;[m [32m+[m[32m }[m /* Out of room? */[m if (wrap->maxWidth > 0 &&[m wrapAdvance + xOffset + glyph->d[0].x + glyph->rect[0].size.x >[m [36m@@ -1681,6 +1695,21 @@[m [mstatic iRect run_Font_(iFont *d, const iRunArgs *args) {[m const float xAdvance = run->font->xScale * buf->glyphPos[i].x_advance;[m const float yAdvance = run->font->yScale * buf->glyphPos[i].y_advance;[m const iGlyph *glyph = glyphByIndex_Font_(run->font, glyphId);[m [32m+[m[32m if (logicalText[logPos] == '\t') {[m [32m+[m[32m if (mode & draw_RunMode) {[m [32m+[m[32m /* Tab indicator. */[m [32m+[m[32m iColor tabColor = get_Color(uiTextAction_ColorId);[m [32m+[m[32m SDL_SetRenderDrawColor(activeText_->render, tabColor.r, tabColor.g, tabColor.b, 255);[m [32m+[m[32m const int pad = d->height / 6;[m [32m+[m[32m SDL_RenderFillRect(activeText_->render, &(SDL_Rect){[m [32m+[m[32m orig.x + xCursor,[m [32m+[m[32m orig.y + yCursor + d->height / 2 - pad / 2,[m [32m+[m[32m pad,[m [32m+[m[32m pad[m [32m+[m[32m });[m [32m+[m[32m }[m [32m+[m[32m xCursor = nextTabStop_Font_(d, xCursor) - xAdvance;[m [32m+[m[32m }[m const float xf = xCursor + xOffset;[m const int hoff = enableHalfPixelGlyphs_Text ? (xf - ((int) xf) > 0.5f ? 1 : 0) : 0;[m /* Output position for the glyph. */[m
text/gemini; charset=utf-8
This content has been proxied by September (3851b).