diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 17:50:44 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-24 17:50:44 +0200 |
commit | fd17eeda7afc59a3e6613aeb28727248732351e9 (patch) | |
tree | e5d6defb65df3a3cabd1f1401742232c3fa8e03c /src/ui | |
parent | 5f9199d081a47241fefed7b2af1f53f4995b62ab (diff) |
Source Sans Pro and Iosevka as font options
Allow the UI and monospace fonts to be used as page content fonts.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/text.c | 20 | ||||
-rw-r--r-- | src/ui/text.h | 2 | ||||
-rw-r--r-- | src/ui/util.c | 29 |
3 files changed, 40 insertions, 11 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 6f6a52ed..d3b8df37 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -232,6 +232,18 @@ static void initFonts_Text_(iText *d) { | |||
232 | italicFont = &fontLiterataLightItalicopsz10_Embedded; | 232 | italicFont = &fontLiterataLightItalicopsz10_Embedded; |
233 | lightFont = &fontLiterataExtraLightopsz18_Embedded; | 233 | lightFont = &fontLiterataExtraLightopsz18_Embedded; |
234 | } | 234 | } |
235 | else if (d->contentFont == sourceSansPro_TextFont) { | ||
236 | regularFont = &fontSourceSansProRegular_Embedded; | ||
237 | italicFont = &fontFiraSansItalic_Embedded; | ||
238 | lightFont = &fontFiraSansLight_Embedded; | ||
239 | lightScaling = 0.85f; | ||
240 | } | ||
241 | else if (d->contentFont == iosevka_TextFont) { | ||
242 | regularFont = &fontIosevkaTermExtended_Embedded; | ||
243 | italicFont = &fontIosevkaTermExtended_Embedded; | ||
244 | lightFont = &fontIosevkaTermExtended_Embedded; | ||
245 | scaling = lightScaling = 0.866f; | ||
246 | } | ||
235 | if (d->headingFont == firaSans_TextFont) { | 247 | if (d->headingFont == firaSans_TextFont) { |
236 | h12Font = &fontFiraSansBold_Embedded; | 248 | h12Font = &fontFiraSansBold_Embedded; |
237 | h3Font = &fontFiraSansRegular_Embedded; | 249 | h3Font = &fontFiraSansRegular_Embedded; |
@@ -246,6 +258,14 @@ static void initFonts_Text_(iText *d) { | |||
246 | h12Font = &fontLiterataBoldopsz36_Embedded; | 258 | h12Font = &fontLiterataBoldopsz36_Embedded; |
247 | h3Font = &fontLiterataRegularopsz14_Embedded; | 259 | h3Font = &fontLiterataRegularopsz14_Embedded; |
248 | } | 260 | } |
261 | else if (d->headingFont == sourceSansPro_TextFont) { | ||
262 | h12Font = &fontSourceSansProBold_Embedded; | ||
263 | h3Font = &fontSourceSansProRegular_Embedded; | ||
264 | } | ||
265 | else if (d->headingFont == iosevka_TextFont) { | ||
266 | h12Font = &fontIosevkaTermExtended_Embedded; | ||
267 | h3Font = &fontIosevkaTermExtended_Embedded; | ||
268 | } | ||
249 | #if defined (iPlatformAppleMobile) | 269 | #if defined (iPlatformAppleMobile) |
250 | const float uiSize = fontSize_UI * 1.1f; | 270 | const float uiSize = fontSize_UI * 1.1f; |
251 | #else | 271 | #else |
diff --git a/src/ui/text.h b/src/ui/text.h index 55524db1..f696b2e3 100644 --- a/src/ui/text.h +++ b/src/ui/text.h | |||
@@ -148,6 +148,8 @@ enum iTextFont { | |||
148 | firaSans_TextFont, | 148 | firaSans_TextFont, |
149 | literata_TextFont, | 149 | literata_TextFont, |
150 | tinos_TextFont, | 150 | tinos_TextFont, |
151 | sourceSansPro_TextFont, | ||
152 | iosevka_TextFont, | ||
151 | }; | 153 | }; |
152 | 154 | ||
153 | extern int gap_Text; /* affected by content font size */ | 155 | extern int gap_Text; /* affected by content font size */ |
diff --git a/src/ui/util.c b/src/ui/util.c index 4f0cb2fa..d255bde4 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -1144,14 +1144,21 @@ static void addRadioButton_(iWidget *parent, const char *id, const char *label, | |||
1144 | 1144 | ||
1145 | static void addFontButtons_(iWidget *parent, const char *id) { | 1145 | static void addFontButtons_(iWidget *parent, const char *id) { |
1146 | const char *fontNames[] = { | 1146 | const char *fontNames[] = { |
1147 | "Nunito", "Fira Sans", "Literata", "Tinos" | 1147 | "Nunito", "Fira Sans", "Literata", "Tinos", "Source Sans Pro", "Iosevka" |
1148 | }; | 1148 | }; |
1149 | iArray *items = new_Array(sizeof(iMenuItem)); | ||
1149 | iForIndices(i, fontNames) { | 1150 | iForIndices(i, fontNames) { |
1150 | addRadioButton_(parent, | 1151 | pushBack_Array(items, |
1151 | format_CStr("prefs.%s.%u", id, i), | 1152 | &(iMenuItem){ fontNames[i], 0, 0, format_CStr("!%s.set arg:%d", id, i) }); |
1152 | fontNames[i], | ||
1153 | format_CStr("%s.set arg:%u", id, i)); | ||
1154 | } | 1153 | } |
1154 | // addRadioButton_(parent, | ||
1155 | // format_CStr("prefs.%s.%u", id, i), | ||
1156 | // fontNames[i], | ||
1157 | // format_CStr("%s.set arg:%u", id, i)); | ||
1158 | iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans Pro", data_Array(items), size_Array(items)); | ||
1159 | setId_Widget(as_Widget(button), format_CStr("prefs.%s", id)); | ||
1160 | addChild_Widget(parent, iClob(button)); | ||
1161 | delete_Array(items); | ||
1155 | } | 1162 | } |
1156 | 1163 | ||
1157 | iWidget *makePreferences_Widget(void) { | 1164 | iWidget *makePreferences_Widget(void) { |
@@ -1243,13 +1250,13 @@ iWidget *makePreferences_Widget(void) { | |||
1243 | /* Fonts. */ { | 1250 | /* Fonts. */ { |
1244 | iWidget *fonts; | 1251 | iWidget *fonts; |
1245 | addChild_Widget(headings, iClob(makeHeading_Widget("Heading font:"))); | 1252 | addChild_Widget(headings, iClob(makeHeading_Widget("Heading font:"))); |
1246 | fonts = new_Widget(); | 1253 | // fonts = new_Widget(); |
1247 | addFontButtons_(fonts, "headingfont"); | 1254 | addFontButtons_(values, "headingfont"); |
1248 | addChildFlags_Widget(values, iClob(fonts), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 1255 | // addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
1249 | addChild_Widget(headings, iClob(makeHeading_Widget("Body font:"))); | 1256 | addChild_Widget(headings, iClob(makeHeading_Widget("Body font:"))); |
1250 | fonts = new_Widget(); | 1257 | // fonts = new_Widget(); |
1251 | addFontButtons_(fonts, "font"); | 1258 | addFontButtons_(values, "font"); |
1252 | addChildFlags_Widget(values, iClob(fonts), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); | 1259 | // addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); |
1253 | addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:"))); | 1260 | addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:"))); |
1254 | iWidget *mono = new_Widget(); | 1261 | iWidget *mono = new_Widget(); |
1255 | /* TODO: Needs labels! */ | 1262 | /* TODO: Needs labels! */ |