summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-03 08:22:11 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-03 08:22:11 +0300
commita54468a67c27dca0cae0b54ca32b67515e0e366e (patch)
tree6e91d3c128bb465d054b361914c8dade55547841 /src
parent6f7408cbe91523a3dae80952790a4a8ec0d87cf4 (diff)
Changed default font to Nunito
Nunito is licensed under OFL.
Diffstat (limited to 'src')
-rw-r--r--src/app.c2
-rw-r--r--src/gmdocument.c6
-rw-r--r--src/ui/documentwidget.c2
-rw-r--r--src/ui/text.c32
4 files changed, 24 insertions, 18 deletions
diff --git a/src/app.c b/src/app.c
index dc61c103..5bce7b19 100644
--- a/src/app.c
+++ b/src/app.c
@@ -273,7 +273,7 @@ static void init_App_(iApp *d, int argc, char **argv) {
273 d->lastTickerTime = SDL_GetTicks(); 273 d->lastTickerTime = SDL_GetTicks();
274 d->elapsedSinceLastTicker = 0; 274 d->elapsedSinceLastTicker = 0;
275 d->commandEcho = checkArgument_CommandLine(&d->args, "echo") != NULL; 275 d->commandEcho = checkArgument_CommandLine(&d->args, "echo") != NULL;
276 d->initialWindowRect = init_Rect(-1, -1, 800, 500); 276 d->initialWindowRect = init_Rect(-1, -1, 900, 560);
277 d->theme = dark_ColorTheme; 277 d->theme = dark_ColorTheme;
278 d->useSystemTheme = iTrue; 278 d->useSystemTheme = iTrue;
279 d->running = iFalse; 279 d->running = iFalse;
diff --git a/src/gmdocument.c b/src/gmdocument.c
index fc49dac4..eea0d1f9 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -310,16 +310,16 @@ static void doLayout_GmDocument_(iGmDocument *d) {
310 6, 12, 6, 12, 0, 0, 0, 6 310 6, 12, 6, 12, 0, 0, 0, 6
311 }; 311 };
312 static const float topMargin[max_GmLineType] = { 312 static const float topMargin[max_GmLineType] = {
313 0.0f, 0.5f, 1.0f, 0.5f, 2.0f, 2.0f, 1.5f, 1.0f 313 0.0f, 0.5f, 1.0f, 0.5f, 2.0f, 1.5f, 1.0f, 1.0f
314 }; 314 };
315 static const float bottomMargin[max_GmLineType] = { 315 static const float bottomMargin[max_GmLineType] = {
316 0.0f, 0.5f, 1.0f, 0.5f, 1.0f, 1.0f, 1.0f, 1.0f 316 0.0f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 1.0f
317 }; 317 };
318 static const char *arrow = "\u2192"; 318 static const char *arrow = "\u2192";
319 static const char *bullet = "\u2022"; 319 static const char *bullet = "\u2022";
320 static const char *folder = "\U0001f4c1"; 320 static const char *folder = "\U0001f4c1";
321 static const char *globe = "\U0001f310"; 321 static const char *globe = "\U0001f310";
322 const float midRunSkip = 0.120f; /* extra space between wrapped text/quote lines */ 322 const float midRunSkip = 0; /*0.120f;*/ /* extra space between wrapped text/quote lines */
323 clear_Array(&d->layout); 323 clear_Array(&d->layout);
324 clearLinks_GmDocument_(d); 324 clearLinks_GmDocument_(d);
325 clear_Array(&d->headings); 325 clear_Array(&d->headings);
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index fb3c9ad5..c7056383 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -271,7 +271,7 @@ static int documentWidth_DocumentWidget_(const iDocumentWidget *d) {
271 const iWidget *w = constAs_Widget(d); 271 const iWidget *w = constAs_Widget(d);
272 const iRect bounds = bounds_Widget(w); 272 const iRect bounds = bounds_Widget(w);
273 return iMini(bounds.size.x - gap_UI * d->pageMargin * 2, 273 return iMini(bounds.size.x - gap_UI * d->pageMargin * 2,
274 fontSize_UI * 38 * zoom_App() / 100); /* TODO: Add user preference .*/ 274 fontSize_UI * 40 * zoom_App() / 100); /* TODO: Add user preference .*/
275} 275}
276 276
277static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) { 277static iRect documentBounds_DocumentWidget_(const iDocumentWidget *d) {
diff --git a/src/ui/text.c b/src/ui/text.c
index 8ed04bb4..6f87a6d0 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -46,6 +46,8 @@ iDeclareType(Font)
46iDeclareType(Glyph) 46iDeclareType(Glyph)
47iDeclareTypeConstructionArgs(Glyph, iChar ch) 47iDeclareTypeConstructionArgs(Glyph, iChar ch)
48 48
49static const float contentScale_Text_ = 1.3f;
50
49int gap_Text; /* cf. gap_UI in metrics.h */ 51int gap_Text; /* cf. gap_UI in metrics.h */
50int enableHalfPixelGlyphs_Text = iTrue; /* debug setting */ 52int enableHalfPixelGlyphs_Text = iTrue; /* debug setting */
51int enableKerning_Text = iTrue; /* looking up kern pairs is slow */ 53int enableKerning_Text = iTrue; /* looking up kern pairs is slow */
@@ -139,6 +141,7 @@ static iText text_;
139 141
140static void initFonts_Text_(iText *d) { 142static void initFonts_Text_(iText *d) {
141 const float textSize = fontSize_UI * d->contentFontSize; 143 const float textSize = fontSize_UI * d->contentFontSize;
144 const float monoSize = fontSize_UI * d->contentFontSize / contentScale_Text_ * 0.866f;
142 const struct { 145 const struct {
143 const iBlock *ttf; 146 const iBlock *ttf;
144 int size; 147 int size;
@@ -147,16 +150,16 @@ static void initFonts_Text_(iText *d) {
147 { &fontSourceSansProRegular_Embedded, fontSize_UI, defaultSymbols_FontId }, 150 { &fontSourceSansProRegular_Embedded, fontSize_UI, defaultSymbols_FontId },
148 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId }, 151 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId },
149 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, defaultSymbols_FontId }, 152 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, defaultSymbols_FontId },
150 { &fontFiraSansRegular_Embedded, textSize, symbols_FontId }, 153 { &fontNunitoRegular_Embedded, textSize, symbols_FontId },
151 { &fontFiraMonoRegular_Embedded, textSize * 0.866f, smallSymbols_FontId }, 154 { &fontFiraMonoRegular_Embedded, monoSize, smallSymbols_FontId },
152 { &fontFiraMonoRegular_Embedded, textSize * 0.666f, smallSymbols_FontId }, 155 { &fontFiraMonoRegular_Embedded, monoSize * 0.750f, smallSymbols_FontId },
153 { &fontFiraSansRegular_Embedded, textSize * 1.333f, mediumSymbols_FontId }, 156 { &fontNunitoRegular_Embedded, textSize * 1.333f, mediumSymbols_FontId },
154 { &fontFiraSansItalic_Embedded, textSize, symbols_FontId }, 157 { &fontNunitoLightItalic_Embedded, textSize, symbols_FontId },
155 { &fontFiraSansBold_Embedded, textSize, symbols_FontId }, 158 { &fontNunitoBold_Embedded, textSize, symbols_FontId },
156 { &fontFiraSansBold_Embedded, textSize * 1.333f, mediumSymbols_FontId }, 159 { &fontNunitoBold_Embedded, textSize * 1.333f, mediumSymbols_FontId },
157 { &fontFiraSansBold_Embedded, textSize * 1.666f, largeSymbols_FontId }, 160 { &fontNunitoBold_Embedded, textSize * 1.666f, largeSymbols_FontId },
158 { &fontFiraSansBold_Embedded, textSize * 2.000f, hugeSymbols_FontId }, 161 { &fontNunitoBold_Embedded, textSize * 2.000f, hugeSymbols_FontId },
159 { &fontFiraSansLight_Embedded, textSize * 1.666f, largeSymbols_FontId }, 162 { &fontNunitoExtraLight_Embedded, textSize * 1.666f, largeSymbols_FontId },
160 { &fontSymbola_Embedded, fontSize_UI, defaultSymbols_FontId }, 163 { &fontSymbola_Embedded, fontSize_UI, defaultSymbols_FontId },
161 { &fontSymbola_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId }, 164 { &fontSymbola_Embedded, fontSize_UI * 1.125f, defaultMediumSymbols_FontId },
162 { &fontSymbola_Embedded, textSize, symbols_FontId }, 165 { &fontSymbola_Embedded, textSize, symbols_FontId },
@@ -219,7 +222,7 @@ static void deinitCache_Text_(iText *d) {
219 222
220void init_Text(SDL_Renderer *render) { 223void init_Text(SDL_Renderer *render) {
221 iText *d = &text_; 224 iText *d = &text_;
222 d->contentFontSize = 1.0f; 225 d->contentFontSize = contentScale_Text_;
223 d->ansiEscape = new_RegExp("\\[([0-9;]+)m", 0); 226 d->ansiEscape = new_RegExp("\\[([0-9;]+)m", 0);
224 d->render = render; 227 d->render = render;
225 /* A grayscale palette for rasterized glyphs. */ { 228 /* A grayscale palette for rasterized glyphs. */ {
@@ -244,6 +247,7 @@ void deinit_Text(void) {
244} 247}
245 248
246void setContentFontSize_Text(float fontSizeFactor) { 249void setContentFontSize_Text(float fontSizeFactor) {
250 fontSizeFactor *= contentScale_Text_;
247 iAssert(fontSizeFactor > 0); 251 iAssert(fontSizeFactor > 0);
248 if (iAbs(text_.contentFontSize - fontSizeFactor) > 0.001f) { 252 if (iAbs(text_.contentFontSize - fontSizeFactor) > 0.001f) {
249 text_.contentFontSize = fontSizeFactor; 253 text_.contentFontSize = fontSizeFactor;
@@ -522,12 +526,14 @@ static iRect run_Font_(iFont *d, enum iRunMode mode, iRangecc text, size_t maxLe
522 /* TODO: No need to decode the next char twice; check this on the next iteration. */ 526 /* TODO: No need to decode the next char twice; check this on the next iteration. */
523 const char *peek = chPos; 527 const char *peek = chPos;
524 const iChar next = nextChar_(&peek, text.end); 528 const iChar next = nextChar_(&peek, text.end);
529#if 0
525 if (ch == '/' && next == '/') { 530 if (ch == '/' && next == '/') {
526 /* Manual kerning for double-slash. */ 531 /* Manual kerning for double-slash. */
527 xpos -= glyph->rect[hoff].size.x * 0.5f; 532 xpos -= glyph->rect[hoff].size.x * 0.5f;
528 } 533 } else
534#endif
529#if defined (LAGRANGE_ENABLE_KERNING) 535#if defined (LAGRANGE_ENABLE_KERNING)
530 else if (enableKerning_Text && !d->manualKernOnly && next) { 536 if (enableKerning_Text && !d->manualKernOnly && next) {
531 xpos += d->scale * stbtt_GetCodepointKernAdvance(&d->font, ch, next); 537 xpos += d->scale * stbtt_GetCodepointKernAdvance(&d->font, ch, next);
532 } 538 }
533#endif 539#endif