summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--res/fonts/NotoSansSC-Regular.ttfbin0 -> 10237648 bytes
-rw-r--r--src/gmcerts.c31
-rw-r--r--src/gmcerts.h2
-rw-r--r--src/gmrequest.c2
-rw-r--r--src/ui/text.c180
-rw-r--r--src/ui/text.h97
-rw-r--r--src/ui/util.c10
-rw-r--r--src/ui/window.c2
9 files changed, 149 insertions, 176 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 22f8e9ec..b4200728 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,7 @@ set (EMBED_RESOURCES
65 res/fonts/NanumGothic-Regular.ttf 65 res/fonts/NanumGothic-Regular.ttf
66 res/fonts/NotoEmoji-Regular.ttf 66 res/fonts/NotoEmoji-Regular.ttf
67 res/fonts/NotoSansJP-Regular.ttf 67 res/fonts/NotoSansJP-Regular.ttf
68 res/fonts/NotoSansSC-Regular.ttf
68 res/fonts/Nunito-Bold.ttf 69 res/fonts/Nunito-Bold.ttf
69 res/fonts/Nunito-ExtraBold.ttf 70 res/fonts/Nunito-ExtraBold.ttf
70 res/fonts/Nunito-ExtraLight.ttf 71 res/fonts/Nunito-ExtraLight.ttf
diff --git a/res/fonts/NotoSansSC-Regular.ttf b/res/fonts/NotoSansSC-Regular.ttf
new file mode 100644
index 00000000..5bf2eb48
--- /dev/null
+++ b/res/fonts/NotoSansSC-Regular.ttf
Binary files differ
diff --git a/src/gmcerts.c b/src/gmcerts.c
index 6a1ba98c..2cc10a3d 100644
--- a/src/gmcerts.c
+++ b/src/gmcerts.c
@@ -374,6 +374,35 @@ void deinit_GmCerts(iGmCerts *d) {
374 delete_Mutex(d->mtx); 374 delete_Mutex(d->mtx);
375} 375}
376 376
377static iRangecc stripFirstDomainLabel_(iRangecc domain) {
378 iRangecc label = iNullRange;
379 if (nextSplit_Rangecc(domain, ".", &label) && nextSplit_Rangecc(domain, ".", &label)) {
380 return (iRangecc){ label.start, domain.end };
381 }
382 return iNullRange;
383}
384
385iBool verifyDomain_GmCerts(const iTlsCertificate *cert, iRangecc domain) {
386 if (verifyDomain_TlsCertificate(cert, domain)) {
387 return iTrue;
388 }
389 /* Allow for an implicit wildcard in the domain name. Self-signed TOFU is really only
390 about the public/private key pair; any other details should be considered
391 complementary. */
392 for (iRangecc higherDomain = stripFirstDomainLabel_(domain);
393 !isEmpty_Range(&higherDomain);
394 higherDomain = stripFirstDomainLabel_(higherDomain)) {
395 if (!iStrStrN(higherDomain.start, ".", size_Range(&higherDomain))) {
396 /* Must have two labels at least. */
397 break;
398 }
399 if (verifyDomain_TlsCertificate(cert, higherDomain)) {
400 return iTrue;
401 }
402 }
403 return iFalse;
404}
405
377iBool checkTrust_GmCerts(iGmCerts *d, iRangecc domain, const iTlsCertificate *cert) { 406iBool checkTrust_GmCerts(iGmCerts *d, iRangecc domain, const iTlsCertificate *cert) {
378 if (!cert) { 407 if (!cert) {
379 return iFalse; 408 return iFalse;
@@ -383,7 +412,7 @@ iBool checkTrust_GmCerts(iGmCerts *d, iRangecc domain, const iTlsCertificate *ce
383 } 412 }
384 /* We trust CA verification implicitly. */ 413 /* We trust CA verification implicitly. */
385 const iBool isAuth = verify_TlsCertificate(cert) == authority_TlsCertificateVerifyStatus; 414 const iBool isAuth = verify_TlsCertificate(cert) == authority_TlsCertificateVerifyStatus;
386 if (!isAuth && !verifyDomain_TlsCertificate(cert, domain)) { 415 if (!isAuth && !verifyDomain_GmCerts(cert, domain)) {
387 return iFalse; 416 return iFalse;
388 } 417 }
389 /* TODO: Could call setTrusted_GmCerts() instead of duplicating the trust-setting. */ 418 /* TODO: Could call setTrusted_GmCerts() instead of duplicating the trust-setting. */
diff --git a/src/gmcerts.h b/src/gmcerts.h
index a28c050e..a9859845 100644
--- a/src/gmcerts.h
+++ b/src/gmcerts.h
@@ -95,3 +95,5 @@ const iPtrArray * listIdentities_GmCerts (const iGmCerts *, iGmCertsIdentityF
95 95
96void signIn_GmCerts (iGmCerts *, iGmIdentity *identity, const iString *url); 96void signIn_GmCerts (iGmCerts *, iGmIdentity *identity, const iString *url);
97void signOut_GmCerts (iGmCerts *, const iString *url); 97void signOut_GmCerts (iGmCerts *, const iString *url);
98
99iBool verifyDomain_GmCerts (const iTlsCertificate *cert, iRangecc domain);
diff --git a/src/gmrequest.c b/src/gmrequest.c
index f065f935..c968990c 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -157,7 +157,7 @@ static void checkServerCertificate_GmRequest_(iGmRequest *d) {
157 if (!isExpired_TlsCertificate(cert)) { 157 if (!isExpired_TlsCertificate(cert)) {
158 resp->certFlags |= timeVerified_GmCertFlag; 158 resp->certFlags |= timeVerified_GmCertFlag;
159 } 159 }
160 if (verifyDomain_TlsCertificate(cert, domain)) { 160 if (verifyDomain_GmCerts(cert, domain)) {
161 resp->certFlags |= domainVerified_GmCertFlag; 161 resp->certFlags |= domainVerified_GmCertFlag;
162 } 162 }
163 if (checkTrust_GmCerts(d->certs, domain, cert)) { 163 if (checkTrust_GmCerts(d->certs, domain, cert)) {
diff --git a/src/ui/text.c b/src/ui/text.c
index ac879af4..1af7bb5d 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -1,4 +1,4 @@
1/* Copyright 2020 Jaakko Keränen <jaakko.keranen@iki.fi> 1/* Copyright 2020 Jaakko Keränen <jaakko.keranen@iki.fi>
2 2
3Redistribution and use in source and binary forms, with or without 3Redistribution and use in source and binary forms, with or without
4modification, are permitted provided that the following conditions are met: 4modification, are permitted provided that the following conditions are met:
@@ -113,16 +113,18 @@ struct Impl_Font {
113 iHash glyphs; 113 iHash glyphs;
114 iBool isMonospaced; 114 iBool isMonospaced;
115 iBool manualKernOnly; 115 iBool manualKernOnly;
116 enum iFontId symbolsFont; /* font to use for symbols */ 116 enum iFontSize sizeId; /* used to look up different fonts of matching size */
117 enum iFontId japaneseFont; /* font to use for Japanese glyphs */ 117// enum iFontId
118 enum iFontId koreanFont; /* font to use for Korean glyphs */ 118// enum iFontId japaneseFont; /* font to use for Japanese glyphs */
119 uint32_t indexTable[128 - 32]; 119// enum iFontId chineseFont; /* font to use for Simplified Chinese glyphs */
120// enum iFontId koreanFont; /* font to use for Korean glyphs */
121 uint32_t indexTable[128 - 32]; /* quick ASCII lookup */
120}; 122};
121 123
122static iFont *font_Text_(enum iFontId id); 124static iFont *font_Text_(enum iFontId id);
123 125
124static void init_Font(iFont *d, const iBlock *data, int height, float scale, 126static void init_Font(iFont *d, const iBlock *data, int height, float scale,
125 enum iFontId symbolsFont, iBool isMonospaced) { 127 enum iFontSize sizeId, iBool isMonospaced) {
126 init_Hash(&d->glyphs); 128 init_Hash(&d->glyphs);
127 d->data = NULL; 129 d->data = NULL;
128 d->isMonospaced = isMonospaced; 130 d->isMonospaced = isMonospaced;
@@ -145,9 +147,11 @@ static void init_Font(iFont *d, const iBlock *data, int height, float scale,
145 } 147 }
146 d->vertOffset = height * (1.0f - scale) / 2; 148 d->vertOffset = height * (1.0f - scale) / 2;
147 d->baseline = ascent * d->yScale; 149 d->baseline = ascent * d->yScale;
148 d->symbolsFont = symbolsFont; 150 d->sizeId = sizeId;
149 d->japaneseFont = regularJapanese_FontId; 151// d->symbolsFont = symbolsFont;
150 d->koreanFont = regularKorean_FontId; 152// d->japaneseFont = regularJapanese_FontId;
153// d->chineseFont = regularChinese_FontId;
154// d->koreanFont = regularKorean_FontId;
151 memset(d->indexTable, 0xff, sizeof(d->indexTable)); 155 memset(d->indexTable, 0xff, sizeof(d->indexTable));
152} 156}
153 157
@@ -281,73 +285,52 @@ static void initFonts_Text_(iText *d) {
281 const iBlock *ttf; 285 const iBlock *ttf;
282 int size; 286 int size;
283 float scaling; 287 float scaling;
284 int symbolsFont; 288 enum iFontSize sizeId;
289 /* UI sizes: 1.0, 1.125, 1.333, 1.666 */
290 /* Content sizes: smallmono, mono, 1.0, 1.2, 1.333, 1.666, 2.0 */
285 } fontData[max_FontId] = { 291 } fontData[max_FontId] = {
286 { &fontSourceSansProRegular_Embedded, uiSize, 1.0f, defaultSymbols_FontId }, 292 /* UI fonts: normal weight */
287 { &fontSourceSansProBold_Embedded, uiSize, 1.0f, defaultSymbols_FontId }, 293 { &fontSourceSansProRegular_Embedded, uiSize, 1.0f, uiNormal_FontSize },
288 { &fontSourceSansProRegular_Embedded, uiSize * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 294 { &fontSourceSansProRegular_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize },
289 { &fontSourceSansProBold_Embedded, uiSize * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 295 { &fontSourceSansProRegular_Embedded, uiSize * 1.333f, 1.0f, uiBig_FontSize },
290 { &fontSourceSansProRegular_Embedded, uiSize * 1.333f, 1.0f, defaultBigSymbols_FontId }, 296 { &fontSourceSansProRegular_Embedded, uiSize * 1.666f, 1.0f, uiLarge_FontSize },
291 { &fontSourceSansProBold_Embedded, uiSize * 1.333f, 1.0f, defaultBigSymbols_FontId }, 297 /* UI fonts: bold weight */
292 { &fontSourceSansProRegular_Embedded, uiSize * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 298 { &fontSourceSansProBold_Embedded, uiSize, 1.0f, uiNormal_FontSize },
293 { &fontSourceSansProBold_Embedded, uiSize * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 299 { &fontSourceSansProBold_Embedded, uiSize * 1.125f, 1.0f, uiMedium_FontSize },
294 { &fontIosevkaTermExtended_Embedded, uiSize * 0.866f, 1.0f, defaultSymbols_FontId }, 300 { &fontSourceSansProBold_Embedded, uiSize * 1.333f, 1.0f, uiBig_FontSize },
295 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId }, 301 { &fontSourceSansProBold_Embedded, uiSize * 1.666f, 1.0f, uiLarge_FontSize },
296 /* content fonts */ 302 /* content fonts */
297 { regularFont, textSize, scaling, symbols_FontId }, 303 { regularFont, textSize, scaling, contentRegular_FontSize },
298 { boldFont, textSize, scaling, symbols_FontId }, 304 { boldFont, textSize, scaling, contentRegular_FontSize },
299 { &fontIosevkaTermExtended_Embedded, monoSize, 1.0f, monospaceSymbols_FontId }, 305 { italicFont, textSize, italicScaling,contentRegular_FontSize },
300 { &fontIosevkaTermExtended_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId }, 306 { regularFont, textSize * 1.200f, scaling, contentMedium_FontSize },
301 { regularFont, textSize * 1.200f, scaling, mediumSymbols_FontId }, 307 { h3Font, textSize * 1.333f, h123Scaling, contentBig_FontSize },
302 { h3Font, textSize * 1.333f, h123Scaling, bigSymbols_FontId }, 308 { h12Font, textSize * 1.666f, h123Scaling, contentLarge_FontSize },
303 { italicFont, textSize, italicScaling,symbols_FontId }, 309 { lightFont, textSize * 1.666f, lightScaling, contentLarge_FontSize },
304 { h12Font, textSize * 1.666f, h123Scaling, largeSymbols_FontId }, 310 { h12Font, textSize * 2.000f, h123Scaling, contentHuge_FontSize },
305 { h12Font, textSize * 2.000f, h123Scaling, hugeSymbols_FontId }, 311 { &fontIosevkaTermExtended_Embedded, smallMonoSize, 1.0f, contentMonoSmall_FontSize },
306 { lightFont, textSize * 1.666f, lightScaling, largeSymbols_FontId }, 312 { &fontIosevkaTermExtended_Embedded, monoSize, 1.0f, contentMono_FontSize },
307 /* monospace content fonts */ 313 /* extra content fonts */
308 { &fontIosevkaTermExtended_Embedded, textSize, 0.866f, symbols_FontId }, 314 { &fontSourceSansProRegular_Embedded, textSize, scaling, contentRegular_FontSize },
309 /* symbol fonts */ 315 { &fontIosevkaTermExtended_Embedded, textSize, 0.866f, contentRegular_FontSize },
310 { &fontSymbola_Embedded, uiSize, 1.0f, defaultSymbols_FontId }, 316 /* symbols and scripts */
311 { &fontSymbola_Embedded, uiSize * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 317#define DEFINE_FONT_SET(data) \
312 { &fontSymbola_Embedded, uiSize * 1.333f, 1.0f, defaultBigSymbols_FontId }, 318 { &data, uiSize, 1.0f, uiNormal_FontSize }, \
313 { &fontSymbola_Embedded, uiSize * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 319 { &data, uiSize * 1.125f, 1.0f, uiMedium_FontSize }, \
314 { &fontSymbola_Embedded, textSize, 1.0f, symbols_FontId }, 320 { &data, uiSize * 1.333f, 1.0f, uiBig_FontSize }, \
315 { &fontSymbola_Embedded, textSize * 1.200f, 1.0f, mediumSymbols_FontId }, 321 { &data, uiSize * 1.666f, 1.0f, uiLarge_FontSize }, \
316 { &fontSymbola_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId }, 322 { &data, textSize, 1.0f, contentRegular_FontSize }, \
317 { &fontSymbola_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId }, 323 { &data, textSize * 1.200f, 1.0f, contentMedium_FontSize }, \
318 { &fontSymbola_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId }, 324 { &data, textSize * 1.333f, 1.0f, contentBig_FontSize }, \
319 { &fontSymbola_Embedded, monoSize, 1.0f, monospaceSymbols_FontId }, 325 { &data, textSize * 1.666f, 1.0f, contentLarge_FontSize }, \
320 { &fontSymbola_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId }, 326 { &data, textSize * 2.000f, 1.0f, contentHuge_FontSize }, \
321 /* emoji fonts */ 327 { &data, smallMonoSize, 1.0f, contentMonoSmall_FontSize }, \
322 { &fontNotoEmojiRegular_Embedded, uiSize, 1.0f, defaultSymbols_FontId }, 328 { &data, monoSize, 1.0f, contentMono_FontSize }
323 { &fontNotoEmojiRegular_Embedded, uiSize * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 329 DEFINE_FONT_SET(fontSymbola_Embedded),
324 { &fontNotoEmojiRegular_Embedded, uiSize * 1.333f, 1.0f, defaultBigSymbols_FontId }, 330 DEFINE_FONT_SET(fontNotoEmojiRegular_Embedded),
325 { &fontNotoEmojiRegular_Embedded, uiSize * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 331 DEFINE_FONT_SET(fontNotoSansJPRegular_Embedded),
326 { &fontNotoEmojiRegular_Embedded, textSize, 1.0f, symbols_FontId }, 332 DEFINE_FONT_SET(fontNotoSansSCRegular_Embedded),
327 { &fontNotoEmojiRegular_Embedded, textSize * 1.200f, 1.0f, mediumSymbols_FontId }, 333 DEFINE_FONT_SET(fontNanumGothicRegular_Embedded), /* TODO: should use Noto Sans here, too */
328 { &fontNotoEmojiRegular_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId },
329 { &fontNotoEmojiRegular_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId },
330 { &fontNotoEmojiRegular_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId },
331 { &fontNotoEmojiRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId },
332 { &fontNotoEmojiRegular_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId },
333 /* japanese fonts */
334 { &fontNotoSansJPRegular_Embedded, uiSize, 1.0f, defaultSymbols_FontId },
335 { &fontNotoSansJPRegular_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId },
336 { &fontNotoSansJPRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId },
337 { &fontNotoSansJPRegular_Embedded, textSize, 1.0f, symbols_FontId },
338 { &fontNotoSansJPRegular_Embedded, textSize * 1.200f, 1.0f, mediumSymbols_FontId },
339 { &fontNotoSansJPRegular_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId },
340 { &fontNotoSansJPRegular_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId },
341 { &fontNotoSansJPRegular_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId },
342 /* korean fonts */
343 { &fontNanumGothicRegular_Embedded, uiSize, 1.0f, defaultSymbols_FontId },
344 { &fontNanumGothicRegular_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId },
345 { &fontNanumGothicRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId },
346 { &fontNanumGothicRegular_Embedded, textSize, 1.0f, symbols_FontId },
347 { &fontNanumGothicRegular_Embedded, textSize * 1.200f, 1.0f, mediumSymbols_FontId },
348 { &fontNanumGothicRegular_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId },
349 { &fontNanumGothicRegular_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId },
350 { &fontNanumGothicRegular_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId },
351 }; 334 };
352 iForIndices(i, fontData) { 335 iForIndices(i, fontData) {
353 iFont *font = &d->fonts[i]; 336 iFont *font = &d->fonts[i];
@@ -355,42 +338,12 @@ static void initFonts_Text_(iText *d) {
355 fontData[i].ttf, 338 fontData[i].ttf,
356 fontData[i].size, 339 fontData[i].size,
357 fontData[i].scaling, 340 fontData[i].scaling,
358 fontData[i].symbolsFont, 341 fontData[i].sizeId,
359 fontData[i].ttf == &fontIosevkaTermExtended_Embedded); 342 fontData[i].ttf == &fontIosevkaTermExtended_Embedded);
360 if (i == default_FontId || i == defaultMedium_FontId) { 343 if (i == default_FontId || i == defaultMedium_FontId) {
361 font->manualKernOnly = iTrue; 344 font->manualKernOnly = iTrue;
362 } 345 }
363 } 346 }
364 /* Japanese script. */ {
365 /* Everything defaults to the regular sized japanese font, so these are just
366 the other sizes. */
367 font_Text_(default_FontId)->japaneseFont = defaultJapanese_FontId;
368 font_Text_(defaultMedium_FontId)->japaneseFont = defaultJapanese_FontId;
369 font_Text_(defaultBig_FontId)->japaneseFont = defaultJapanese_FontId;
370 font_Text_(defaultLarge_FontId)->japaneseFont = defaultJapanese_FontId;
371 font_Text_(defaultMonospace_FontId)->japaneseFont = defaultJapanese_FontId;
372 font_Text_(monospaceSmall_FontId)->japaneseFont = monospaceSmallJapanese_FontId;
373 font_Text_(monospace_FontId)->japaneseFont = monospaceJapanese_FontId;
374 font_Text_(medium_FontId)->japaneseFont = mediumJapanese_FontId;
375 font_Text_(big_FontId)->japaneseFont = bigJapanese_FontId;
376 font_Text_(largeBold_FontId)->japaneseFont = largeJapanese_FontId;
377 font_Text_(largeLight_FontId)->japaneseFont = largeJapanese_FontId;
378 font_Text_(hugeBold_FontId)->japaneseFont = hugeJapanese_FontId;
379 }
380 /* Korean script. */ {
381 font_Text_(default_FontId)->koreanFont = defaultKorean_FontId;
382 font_Text_(defaultMedium_FontId)->koreanFont = defaultKorean_FontId;
383 font_Text_(defaultBig_FontId)->koreanFont = defaultKorean_FontId;
384 font_Text_(defaultLarge_FontId)->koreanFont = defaultKorean_FontId;
385 font_Text_(defaultMonospace_FontId)->koreanFont = defaultKorean_FontId;
386 font_Text_(monospaceSmall_FontId)->koreanFont = monospaceSmallKorean_FontId;
387 font_Text_(monospace_FontId)->koreanFont = monospaceKorean_FontId;
388 font_Text_(medium_FontId)->koreanFont = mediumKorean_FontId;
389 font_Text_(big_FontId)->koreanFont = bigKorean_FontId;
390 font_Text_(largeBold_FontId)->koreanFont = largeKorean_FontId;
391 font_Text_(largeLight_FontId)->koreanFont = largeKorean_FontId;
392 font_Text_(hugeBold_FontId)->koreanFont = hugeKorean_FontId;
393 }
394 gap_Text = iRound(gap_UI * d->contentFontSize); 347 gap_Text = iRound(gap_UI * d->contentFontSize);
395} 348}
396 349
@@ -522,9 +475,11 @@ static SDL_Surface *rasterizeGlyph_Font_(const iFont *d, uint32_t glyphIndex, fl
522 return surface8; 475 return surface8;
523} 476}
524 477
478#if 0
525iLocalDef SDL_Rect sdlRect_(const iRect rect) { 479iLocalDef SDL_Rect sdlRect_(const iRect rect) {
526 return (SDL_Rect){ rect.pos.x, rect.pos.y, rect.size.x, rect.size.y }; 480 return (SDL_Rect){ rect.pos.x, rect.pos.y, rect.size.x, rect.size.y };
527} 481}
482#endif
528 483
529iLocalDef iCacheRow *cacheRow_Text_(iText *d, int height) { 484iLocalDef iCacheRow *cacheRow_Text_(iText *d, int height) {
530 return at_Array(&d->cacheRows, (height - 1) / d->cacheRowAllocStep); 485 return at_Array(&d->cacheRows, (height - 1) / d->cacheRowAllocStep);
@@ -603,21 +558,28 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
603 } 558 }
604 /* Not defined in current font, try Noto Emoji (for selected characters). */ 559 /* Not defined in current font, try Noto Emoji (for selected characters). */
605 if ((ch >= 0x1f300 && ch < 0x1f600) || (ch >= 0x1f680 && ch <= 0x1f6c5)) { 560 if ((ch >= 0x1f300 && ch < 0x1f600) || (ch >= 0x1f680 && ch <= 0x1f6c5)) {
606 iFont *emoji = font_Text_(d->symbolsFont + fromSymbolsToEmojiOffset_FontId); 561 iFont *emoji = font_Text_(emoji_FontId + d->sizeId);
607 if (emoji != d && (*glyphIndex = glyphIndex_Font_(emoji, ch)) != 0) { 562 if (emoji != d && (*glyphIndex = glyphIndex_Font_(emoji, ch)) != 0) {
608 return emoji; 563 return emoji;
609 } 564 }
610 } 565 }
566 /* Try Simplified Chinese. */
567 if (ch >= 0x2e80) {
568 iFont *sc = font_Text_(chineseSimplified_FontId + d->sizeId);
569 if (sc != d && (*glyphIndex = glyphIndex_Font_(sc, ch)) != 0) {
570 return sc;
571 }
572 }
611 /* Could be Korean. */ 573 /* Could be Korean. */
612 if (ch >= 0x3000) { 574 if (ch >= 0x3000) {
613 iFont *korean = font_Text_(d->koreanFont); 575 iFont *korean = font_Text_(korean_FontId + d->sizeId);
614 if (korean != d && (*glyphIndex = glyphIndex_Font_(korean, ch)) != 0) { 576 if (korean != d && (*glyphIndex = glyphIndex_Font_(korean, ch)) != 0) {
615 return korean; 577 return korean;
616 } 578 }
617 } 579 }
618 /* Japanese perhaps? */ 580 /* Japanese perhaps? */
619 if (ch > 0x3040) { 581 if (ch > 0x3040) {
620 iFont *japanese = font_Text_(d->japaneseFont); 582 iFont *japanese = font_Text_(japanese_FontId + d->sizeId);
621 if (japanese != d && (*glyphIndex = glyphIndex_Font_(japanese, ch)) != 0) { 583 if (japanese != d && (*glyphIndex = glyphIndex_Font_(japanese, ch)) != 0) {
622 return japanese; 584 return japanese;
623 } 585 }
@@ -631,7 +593,7 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
631 } 593 }
632#endif 594#endif
633 /* Fall back to Symbola for anything else. */ 595 /* Fall back to Symbola for anything else. */
634 iFont *font = font_Text_(d->symbolsFont); 596 iFont *font = font_Text_(symbols_FontId + d->sizeId);
635 *glyphIndex = glyphIndex_Font_(font, ch); 597 *glyphIndex = glyphIndex_Font_(font, ch);
636// if (!*glyphIndex) { 598// if (!*glyphIndex) {
637// fprintf(stderr, "failed to find %08x (%lc)\n", ch, ch); fflush(stderr); 599// fprintf(stderr, "failed to find %08x (%lc)\n", ch, ch); fflush(stderr);
diff --git a/src/ui/text.h b/src/ui/text.h
index 136e14e9..d86754cc 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -27,80 +27,59 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
27 27
28#include <SDL_render.h> 28#include <SDL_render.h>
29 29
30/* Size names: regular (1x) -> medium (1.2x) -> big (1.33x) -> large (1.67x) -> huge (2x) */ 30/* Content sizes: regular (1x) -> medium (1.2x) -> big (1.33x) -> large (1.67x) -> huge (2x) */
31
32enum iFontSize {
33 uiNormal_FontSize, /* 1.000 */
34 uiMedium_FontSize, /* 1.125 */
35 uiBig_FontSize, /* 1.333 */
36 uiLarge_FontSize, /* 1.666 */
37 contentRegular_FontSize,
38 contentMedium_FontSize,
39 contentBig_FontSize,
40 contentLarge_FontSize,
41 contentHuge_FontSize,
42 contentMonoSmall_FontSize,
43 contentMono_FontSize,
44 max_FontSize,
45};
31 46
32enum iFontId { 47enum iFontId {
33 default_FontId, 48 /* UI fonts: normal weight (1x, 1.125x, 1.33x, 1.67x) */
34 defaultBold_FontId, 49 default_FontId = 0,
35 defaultMedium_FontId, 50 defaultMedium_FontId,
36 defaultMediumBold_FontId,
37 defaultBig_FontId, 51 defaultBig_FontId,
38 defaultBigBold_FontId,
39 defaultLarge_FontId, 52 defaultLarge_FontId,
53 /* UI fonts: bold weight */
54 defaultBold_FontId,
55 defaultMediumBold_FontId,
56 defaultBigBold_FontId,
40 defaultLargeBold_FontId, 57 defaultLargeBold_FontId,
41 defaultMonospace_FontId,
42 defaultContentSized_FontId,
43 /* content fonts */ 58 /* content fonts */
44 regular_FontId, 59 regular_FontId,
45 bold_FontId, 60 bold_FontId,
46 monospace_FontId, 61 italic_FontId,
47 monospaceSmall_FontId,
48 medium_FontId, 62 medium_FontId,
49 big_FontId, 63 big_FontId,
50 italic_FontId,
51 largeBold_FontId, 64 largeBold_FontId,
52 hugeBold_FontId,
53 largeLight_FontId, 65 largeLight_FontId,
54 /* monospace content fonts */ 66 hugeBold_FontId,
67 monospaceSmall_FontId,
68 monospace_FontId,
69 /* extra content fonts */
70 defaultContentSized_FontId, /* UI font but sized to regular_FontId */
55 regularMonospace_FontId, 71 regularMonospace_FontId,
56 /* symbol fonts */ 72 /* symbols and scripts */
57 defaultSymbols_FontId,
58 defaultMediumSymbols_FontId,
59 defaultBigSymbols_FontId,
60 defaultLargeSymbols_FontId,
61 symbols_FontId, 73 symbols_FontId,
62 mediumSymbols_FontId, 74 emoji_FontId = symbols_FontId + max_FontSize,
63 bigSymbols_FontId, 75 japanese_FontId = emoji_FontId + max_FontSize,
64 largeSymbols_FontId, 76 chineseSimplified_FontId = japanese_FontId + max_FontSize,
65 hugeSymbols_FontId, 77 korean_FontId = chineseSimplified_FontId + max_FontSize,
66 monospaceSymbols_FontId, 78 max_FontId = korean_FontId + max_FontSize,
67 monospaceSmallSymbols_FontId,
68 /* emoji fonts */
69 defaultEmoji_FontId,
70 defaultMediumEmoji_FontId,
71 defaultBigEmoji_FontId,
72 defaultLargeEmoji_FontId,
73 emoji_FontId,
74 mediumEmoji_FontId,
75 bigEmoji_FontId,
76 largeEmoji_FontId,
77 hugeEmoji_FontId,
78 monospaceEmoji_FontId,
79 monospaceSmallEmoji_FontId,
80 /* japanese script */
81 defaultJapanese_FontId,
82 monospaceSmallJapanese_FontId,
83 monospaceJapanese_FontId,
84 regularJapanese_FontId,
85 mediumJapanese_FontId,
86 bigJapanese_FontId,
87 largeJapanese_FontId,
88 hugeJapanese_FontId,
89 /* korean script */
90 defaultKorean_FontId,
91 monospaceSmallKorean_FontId,
92 monospaceKorean_FontId,
93 regularKorean_FontId,
94 mediumKorean_FontId,
95 bigKorean_FontId,
96 largeKorean_FontId,
97 hugeKorean_FontId,
98 max_FontId,
99 79
100 /* Meta: */ 80 /* Meta: */
101 fromSymbolsToEmojiOffset_FontId = 11, 81 mask_FontId = 0xffff,
102 mask_FontId = 0xffff, 82 alwaysVariableFlag_FontId = 0x10000,
103 alwaysVariableFlag_FontId = 0x10000,
104 83
105 /* UI fonts: */ 84 /* UI fonts: */
106 uiLabel_FontId = default_FontId, 85 uiLabel_FontId = default_FontId,
@@ -111,7 +90,7 @@ enum iFontId {
111 uiInput_FontId = defaultMedium_FontId, 90 uiInput_FontId = defaultMedium_FontId,
112 uiContent_FontId = defaultMedium_FontId, 91 uiContent_FontId = defaultMedium_FontId,
113 uiContentBold_FontId = defaultMediumBold_FontId, 92 uiContentBold_FontId = defaultMediumBold_FontId,
114 uiContentSymbols_FontId = defaultMediumSymbols_FontId, 93 uiContentSymbols_FontId = symbols_FontId + uiMedium_FontSize,
115 /* Document fonts: */ 94 /* Document fonts: */
116 paragraph_FontId = regular_FontId, 95 paragraph_FontId = regular_FontId,
117 firstParagraph_FontId = medium_FontId, 96 firstParagraph_FontId = medium_FontId,
@@ -125,7 +104,7 @@ enum iFontId {
125}; 104};
126 105
127iLocalDef iBool isJapanese_FontId(enum iFontId id) { 106iLocalDef iBool isJapanese_FontId(enum iFontId id) {
128 return id >= defaultJapanese_FontId && id <= hugeJapanese_FontId; 107 return id >= japanese_FontId && id < japanese_FontId + max_FontSize;
129} 108}
130iLocalDef iBool isVariationSelector_Char(iChar c) { 109iLocalDef iBool isVariationSelector_Char(iChar c) {
131 return (c >= 0xfe00 && c <= 0xfe0f) || (c >= 0xe0100 && c <= 0xe0121); 110 return (c >= 0xfe00 && c <= 0xfe0f) || (c >= 0xe0100 && c <= 0xe0121);
diff --git a/src/ui/util.c b/src/ui/util.c
index c5e92b92..ea910eb6 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1828,11 +1828,11 @@ iWidget *makePreferences_Widget(void) {
1828 /* UI languages. */ { 1828 /* UI languages. */ {
1829 iArray *uiLangs = collectNew_Array(sizeof(iMenuItem)); 1829 iArray *uiLangs = collectNew_Array(sizeof(iMenuItem));
1830 const iMenuItem langItems[] = { 1830 const iMenuItem langItems[] = {
1831 { "${lang.de} - " uiTextAction_ColorEscape "de", 0, 0, "uilang id:de" }, 1831 { "${lang.de} - de", 0, 0, "uilang id:de" },
1832 { "${lang.en} - " uiTextAction_ColorEscape "en", 0, 0, "uilang id:en" }, 1832 { "${lang.en} - en", 0, 0, "uilang id:en" },
1833 { "${lang.fi} - " uiTextAction_ColorEscape "fi", 0, 0, "uilang id:fi" }, 1833 { "${lang.fi} - fi", 0, 0, "uilang id:fi" },
1834 { "${lang.ru} - " uiTextAction_ColorEscape "ru", 0, 0, "uilang id:ru" }, 1834 { "${lang.ru} - ru", 0, 0, "uilang id:ru" },
1835 { "${lang.zh.hans} - " uiTextAction_ColorEscape "zh_Hans", 0, 0, "uilang id:zh_Hans" }, 1835 { "${lang.zh.hans} - zh", 0, 0, "uilang id:zh_Hans" },
1836 }; 1836 };
1837 pushBackN_Array(uiLangs, langItems, iElemCount(langItems)); 1837 pushBackN_Array(uiLangs, langItems, iElemCount(langItems));
1838 //sort_Array(uiLangs, cmp_MenuItem_); 1838 //sort_Array(uiLangs, cmp_MenuItem_);
diff --git a/src/ui/window.c b/src/ui/window.c
index 97500b22..9b132da1 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -986,7 +986,7 @@ static void setupUserInterface_Window(iWindow *d) {
986 iClob(newIcon_LabelWidget("\U0001f513", SDLK_i, KMOD_PRIMARY, "document.info")), 986 iClob(newIcon_LabelWidget("\U0001f513", SDLK_i, KMOD_PRIMARY, "document.info")),
987 embedFlags | moveToParentLeftEdge_WidgetFlag); 987 embedFlags | moveToParentLeftEdge_WidgetFlag);
988 setId_Widget(as_Widget(lock), "navbar.lock"); 988 setId_Widget(as_Widget(lock), "navbar.lock");
989 setFont_LabelWidget(lock, defaultSymbols_FontId); 989 setFont_LabelWidget(lock, symbols_FontId + uiNormal_FontSize);
990 updateTextCStr_LabelWidget(lock, "\U0001f512"); 990 updateTextCStr_LabelWidget(lock, "\U0001f512");
991 } 991 }
992 iWidget *rightEmbed = new_Widget(); 992 iWidget *rightEmbed = new_Widget();