diff options
-rw-r--r-- | src/gmdocument.c | 22 | ||||
-rw-r--r-- | src/ui/text.c | 18 | ||||
-rw-r--r-- | src/ui/text.h | 1 |
3 files changed, 32 insertions, 9 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index 49a19cb9..17c44105 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -301,6 +301,11 @@ static iBool isNormalized_GmDocument_(const iGmDocument *d) { | |||
301 | return iTrue; | 301 | return iTrue; |
302 | } | 302 | } |
303 | 303 | ||
304 | static enum iGmDocumentTheme currentTheme_(void) { | ||
305 | return (isDark_ColorTheme(colorTheme_App()) ? prefs_App()->docThemeDark | ||
306 | : prefs_App()->docThemeLight); | ||
307 | } | ||
308 | |||
304 | static void doLayout_GmDocument_(iGmDocument *d) { | 309 | static void doLayout_GmDocument_(iGmDocument *d) { |
305 | const iBool isMono = isForcedMonospace_GmDocument_(d); | 310 | const iBool isMono = isForcedMonospace_GmDocument_(d); |
306 | const iBool isNarrow = d->size.x < 90 * gap_Text; | 311 | const iBool isNarrow = d->size.x < 90 * gap_Text; |
@@ -313,7 +318,7 @@ static void doLayout_GmDocument_(iGmDocument *d) { | |||
313 | heading1_FontId, | 318 | heading1_FontId, |
314 | heading2_FontId, | 319 | heading2_FontId, |
315 | heading3_FontId, | 320 | heading3_FontId, |
316 | isMono ? regularMonospace_FontId : regular_FontId, | 321 | isMono ? regularMonospace_FontId : bold_FontId, |
317 | }; | 322 | }; |
318 | static const int colors[max_GmLineType] = { | 323 | static const int colors[max_GmLineType] = { |
319 | tmParagraph_ColorId, | 324 | tmParagraph_ColorId, |
@@ -820,8 +825,7 @@ static void updateIconBasedOnUrl_GmDocument_(iGmDocument *d) { | |||
820 | 825 | ||
821 | void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | 826 | void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { |
822 | const iPrefs * prefs = prefs_App(); | 827 | const iPrefs * prefs = prefs_App(); |
823 | enum iGmDocumentTheme theme = | 828 | enum iGmDocumentTheme theme = currentTheme_(); |
824 | (isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight); | ||
825 | static const iChar siteIcons[] = { | 829 | static const iChar siteIcons[] = { |
826 | 0x203b, 0x2042, 0x205c, 0x2182, 0x25ed, 0x2600, 0x2601, 0x2604, 0x2605, 0x2606, | 830 | 0x203b, 0x2042, 0x205c, 0x2182, 0x25ed, 0x2600, 0x2601, 0x2604, 0x2605, 0x2606, |
827 | 0x265c, 0x265e, 0x2690, 0x2691, 0x2693, 0x2698, 0x2699, 0x26f0, 0x270e, 0x2728, | 831 | 0x265c, 0x265e, 0x2690, 0x2691, 0x2693, 0x2698, 0x2699, 0x26f0, 0x270e, 0x2728, |
@@ -971,6 +975,9 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
971 | set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(tmBackground_ColorId), get_Color(brown_ColorId), 0.15f)); | 975 | set_Color(tmBannerBackground_ColorId, mix_Color(get_Color(tmBackground_ColorId), get_Color(brown_ColorId), 0.15f)); |
972 | set_Color(tmBannerTitle_ColorId, get_Color(brown_ColorId)); | 976 | set_Color(tmBannerTitle_ColorId, get_Color(brown_ColorId)); |
973 | set_Color(tmBannerIcon_ColorId, get_Color(brown_ColorId)); | 977 | set_Color(tmBannerIcon_ColorId, get_Color(brown_ColorId)); |
978 | set_Color(tmLinkText_ColorId, get_Color(tmHeading2_ColorId)); | ||
979 | set_Color(tmHypertextLinkText_ColorId, get_Color(tmHeading2_ColorId)); | ||
980 | set_Color(tmGopherLinkText_ColorId, get_Color(tmHeading2_ColorId)); | ||
974 | } | 981 | } |
975 | else if (theme == white_GmDocumentTheme) { | 982 | else if (theme == white_GmDocumentTheme) { |
976 | const iHSLColor base = { 40, 0, 1.0f, 1.0f }; | 983 | const iHSLColor base = { 40, 0, 1.0f, 1.0f }; |
@@ -1177,7 +1184,14 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
1177 | setHsl_Color(tmBannerTitle_ColorId, primDim); | 1184 | setHsl_Color(tmBannerTitle_ColorId, primDim); |
1178 | setHsl_Color(tmBannerIcon_ColorId, primDim); | 1185 | setHsl_Color(tmBannerIcon_ColorId, primDim); |
1179 | } | 1186 | } |
1180 | 1187 | /* Tone down the link colors a bit because bold white is quite strong to look at. */ | |
1188 | if (isDark_GmDocumentTheme(theme) || theme == white_GmDocumentTheme) { | ||
1189 | iHSLColor base = { hues[primIndex], 1.0f, normLum[primIndex], 1.0f }; | ||
1190 | set_Color(tmLinkText_ColorId, mix_Color(get_Color(tmLinkText_ColorId), | ||
1191 | rgb_HSLColor(base), 0.25f)); | ||
1192 | set_Color(tmHypertextLinkText_ColorId, get_Color(tmLinkText_ColorId)); | ||
1193 | set_Color(tmGopherLinkText_ColorId, get_Color(tmLinkText_ColorId)); | ||
1194 | } | ||
1181 | /* Adjust colors based on light/dark mode. */ | 1195 | /* Adjust colors based on light/dark mode. */ |
1182 | for (int i = tmFirst_ColorId; i < max_ColorId; i++) { | 1196 | for (int i = tmFirst_ColorId; i < max_ColorId; i++) { |
1183 | iHSLColor color = hsl_Color(get_Color(i)); | 1197 | iHSLColor color = hsl_Color(get_Color(i)); |
diff --git a/src/ui/text.c b/src/ui/text.c index d9ddf2b2..520ae74a 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -210,41 +210,48 @@ static void initFonts_Text_(iText *d) { | |||
210 | const float monoSize = textSize * 0.71f; | 210 | const float monoSize = textSize * 0.71f; |
211 | const float smallMonoSize = monoSize * 0.8f; | 211 | const float smallMonoSize = monoSize * 0.8f; |
212 | const iBlock *regularFont = &fontNunitoRegular_Embedded; | 212 | const iBlock *regularFont = &fontNunitoRegular_Embedded; |
213 | const iBlock *boldFont = &fontNunitoExtraBold_Embedded; | ||
213 | const iBlock *italicFont = &fontNunitoLightItalic_Embedded; | 214 | const iBlock *italicFont = &fontNunitoLightItalic_Embedded; |
214 | const iBlock *h12Font = &fontNunitoExtraBold_Embedded; | 215 | const iBlock *h12Font = &fontNunitoExtraBold_Embedded; |
215 | const iBlock *h3Font = &fontNunitoRegular_Embedded; | 216 | const iBlock *h3Font = &fontNunitoRegular_Embedded; |
216 | const iBlock *lightFont = &fontNunitoExtraLight_Embedded; | 217 | const iBlock *lightFont = &fontNunitoExtraLight_Embedded; |
217 | float scaling = 1.0f; /* glyph scaling (<=1.0), for increasing line spacing */ | 218 | float scaling = 1.0f; /* glyph scaling (<=1.0), for increasing line spacing */ |
219 | float italicScaling= 1.0f; | ||
218 | float lightScaling = 1.0f; | 220 | float lightScaling = 1.0f; |
219 | float h123Scaling = 1.0f; /* glyph scaling (<=1.0), for increasing line spacing */ | 221 | float h123Scaling = 1.0f; /* glyph scaling (<=1.0), for increasing line spacing */ |
220 | if (d->contentFont == firaSans_TextFont) { | 222 | if (d->contentFont == firaSans_TextFont) { |
221 | regularFont = &fontFiraSansRegular_Embedded; | 223 | regularFont = &fontFiraSansRegular_Embedded; |
224 | boldFont = &fontFiraSansBold_Embedded; | ||
222 | lightFont = &fontFiraSansLight_Embedded; | 225 | lightFont = &fontFiraSansLight_Embedded; |
223 | italicFont = &fontFiraSansItalic_Embedded; | 226 | italicFont = &fontFiraSansItalic_Embedded; |
224 | scaling = lightScaling = 0.85f; | 227 | scaling = italicScaling = lightScaling = 0.85f; |
225 | } | 228 | } |
226 | else if (d->contentFont == tinos_TextFont) { | 229 | else if (d->contentFont == tinos_TextFont) { |
227 | regularFont = &fontTinosRegular_Embedded; | 230 | regularFont = &fontTinosRegular_Embedded; |
231 | boldFont = &fontTinosBold_Embedded; | ||
228 | lightFont = &fontLiterataExtraLightopsz18_Embedded; | 232 | lightFont = &fontLiterataExtraLightopsz18_Embedded; |
229 | italicFont = &fontTinosItalic_Embedded; | 233 | italicFont = &fontTinosItalic_Embedded; |
230 | scaling = 0.85f; | 234 | scaling = italicScaling = 0.85f; |
231 | } | 235 | } |
232 | else if (d->contentFont == literata_TextFont) { | 236 | else if (d->contentFont == literata_TextFont) { |
233 | regularFont = &fontLiterataRegularopsz14_Embedded; | 237 | regularFont = &fontLiterataRegularopsz14_Embedded; |
238 | boldFont = &fontLiterataBoldopsz36_Embedded; | ||
234 | italicFont = &fontLiterataLightItalicopsz10_Embedded; | 239 | italicFont = &fontLiterataLightItalicopsz10_Embedded; |
235 | lightFont = &fontLiterataExtraLightopsz18_Embedded; | 240 | lightFont = &fontLiterataExtraLightopsz18_Embedded; |
236 | } | 241 | } |
237 | else if (d->contentFont == sourceSansPro_TextFont) { | 242 | else if (d->contentFont == sourceSansPro_TextFont) { |
238 | regularFont = &fontSourceSansProRegular_Embedded; | 243 | regularFont = &fontSourceSansProRegular_Embedded; |
244 | boldFont = &fontSourceSansProBold_Embedded; | ||
239 | italicFont = &fontFiraSansItalic_Embedded; | 245 | italicFont = &fontFiraSansItalic_Embedded; |
240 | lightFont = &fontFiraSansLight_Embedded; | 246 | lightFont = &fontFiraSansLight_Embedded; |
241 | lightScaling = 0.85f; | 247 | lightScaling = italicScaling = 0.85f; |
242 | } | 248 | } |
243 | else if (d->contentFont == iosevka_TextFont) { | 249 | else if (d->contentFont == iosevka_TextFont) { |
244 | regularFont = &fontIosevkaTermExtended_Embedded; | 250 | regularFont = &fontIosevkaTermExtended_Embedded; |
251 | boldFont = &fontIosevkaTermExtended_Embedded; | ||
245 | italicFont = &fontIosevkaTermExtended_Embedded; | 252 | italicFont = &fontIosevkaTermExtended_Embedded; |
246 | lightFont = &fontIosevkaTermExtended_Embedded; | 253 | lightFont = &fontIosevkaTermExtended_Embedded; |
247 | scaling = lightScaling = 0.866f; | 254 | scaling = italicScaling = lightScaling = 0.866f; |
248 | } | 255 | } |
249 | if (d->headingFont == firaSans_TextFont) { | 256 | if (d->headingFont == firaSans_TextFont) { |
250 | h12Font = &fontFiraSansBold_Embedded; | 257 | h12Font = &fontFiraSansBold_Embedded; |
@@ -291,11 +298,12 @@ static void initFonts_Text_(iText *d) { | |||
291 | { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId }, | 298 | { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId }, |
292 | /* content fonts */ | 299 | /* content fonts */ |
293 | { regularFont, textSize, scaling, symbols_FontId }, | 300 | { regularFont, textSize, scaling, symbols_FontId }, |
301 | { boldFont, textSize, scaling, symbols_FontId }, | ||
294 | { &fontIosevkaTermExtended_Embedded, monoSize, 1.0f, monospaceSymbols_FontId }, | 302 | { &fontIosevkaTermExtended_Embedded, monoSize, 1.0f, monospaceSymbols_FontId }, |
295 | { &fontIosevkaTermExtended_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId }, | 303 | { &fontIosevkaTermExtended_Embedded, smallMonoSize, 1.0f, monospaceSmallSymbols_FontId }, |
296 | { regularFont, textSize * 1.200f, scaling, mediumSymbols_FontId }, | 304 | { regularFont, textSize * 1.200f, scaling, mediumSymbols_FontId }, |
297 | { h3Font, textSize * 1.333f, h123Scaling, bigSymbols_FontId }, | 305 | { h3Font, textSize * 1.333f, h123Scaling, bigSymbols_FontId }, |
298 | { italicFont, textSize, scaling, symbols_FontId }, | 306 | { italicFont, textSize, italicScaling,symbols_FontId }, |
299 | { h12Font, textSize * 1.666f, h123Scaling, largeSymbols_FontId }, | 307 | { h12Font, textSize * 1.666f, h123Scaling, largeSymbols_FontId }, |
300 | { h12Font, textSize * 2.000f, h123Scaling, hugeSymbols_FontId }, | 308 | { h12Font, textSize * 2.000f, h123Scaling, hugeSymbols_FontId }, |
301 | { lightFont, textSize * 1.666f, lightScaling, largeSymbols_FontId }, | 309 | { lightFont, textSize * 1.666f, lightScaling, largeSymbols_FontId }, |
diff --git a/src/ui/text.h b/src/ui/text.h index 99f81d9f..b46c15c6 100644 --- a/src/ui/text.h +++ b/src/ui/text.h | |||
@@ -42,6 +42,7 @@ enum iFontId { | |||
42 | defaultContentSized_FontId, | 42 | defaultContentSized_FontId, |
43 | /* content fonts */ | 43 | /* content fonts */ |
44 | regular_FontId, | 44 | regular_FontId, |
45 | bold_FontId, | ||
45 | monospace_FontId, | 46 | monospace_FontId, |
46 | monospaceSmall_FontId, | 47 | monospaceSmall_FontId, |
47 | medium_FontId, | 48 | medium_FontId, |