From dcf520652cd2279a1d4dd78361d589ede0c36eaf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Thu, 24 Jun 2021 07:19:09 +0300
Subject: [PATCH 1/1] Text: Tune kerning on Nunito
src/ui/text.c | 28 +++++++++++++++++++++++++---
src/ui/text.h | 3 ++-
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/src/ui/text.c b/src/ui/text.c
index db922715..51865654 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -116,6 +116,7 @@ iDefineTypeConstructionArgs(Glyph, (iChar ch), ch)
struct Impl_Font {
iBlock * data;
stbtt_fontinfo font;
float xScale, yScale;
int vertOffset; /* offset due to scaling */
@@ -134,6 +135,15 @@ static void init_Font(iFont *d, const iBlock *data, int height, float scale,
enum iFontSize sizeId, iBool isMonospaced) {
init_Hash(&d->glyphs);
d->data = NULL;
family
currently for applying a kerning fix to Nunito. */ data == &fontNunitoBold_Embedded ||
data == &fontNunitoExtraBold_Embedded ||
data == &fontNunitoLightItalic_Embedded ||
data == &fontNunitoExtraLight_Embedded) {
d->family = nunito_TextFont;
d->isMonospaced = isMonospaced;
d->height = height;
iZap(d->font);
@@ -1128,14 +1138,26 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
const iChar next = nextChar_(&peek, args->text.end);
if (enableKerning_Text && !d->manualKernOnly && next) {
const uint32_t nextGlyphIndex = glyphIndex_Font_(glyph->font, next);
const int kern = stbtt_GetGlyphKernAdvance(
int kern = stbtt_GetGlyphKernAdvance(
&glyph->font->font, glyph->glyphIndex, nextGlyphIndex);
/* Nunito needs some kerning fixes. */
if (glyph->font->family == nunito_TextFont) {
if (ch == 'W' && (next == 'i' || next == 'h')) {
kern = -30;
}
else if (ch == 'T' && next == 'h') {
kern = -15;
}
else if (ch == 'V' && next == 'i') {
kern = -15;
}
}
if (kern) {
// printf("%lc(%u) -> %lc(%u): kern %d (%f)\n", ch, glyph->glyphIndex, next,
// nextGlyphIndex,
// kern, d->xScale * kern);
xpos += d->xScale * kern;
xposExtend += d->xScale * kern;
xpos += glyph->font->xScale * kern;
xposExtend += glyph->font->xScale * kern;
}
}
}
diff --git a/src/ui/text.h b/src/ui/text.h
index 2f2bcf3a..768713ee 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -116,7 +116,8 @@ iLocalDef iBool isJapanese_FontId(enum iFontId id) {
#define emojiVariationSelector_Char ((iChar) 0xfe0f)
enum iTextFont {
firaSans_TextFont,
literata_TextFont,
tinos_TextFont,
--
2.25.1
text/plain
This content has been proxied by September (3851b).