From fd17eeda7afc59a3e6613aeb28727248732351e9 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Wed, 24 Feb 2021 17:50:44 +0200 Subject: Source Sans Pro and Iosevka as font options Allow the UI and monospace fonts to be used as page content fonts. --- src/ui/text.c | 20 ++++++++++++++++++++ src/ui/text.h | 2 ++ src/ui/util.c | 29 ++++++++++++++++++----------- 3 files changed, 40 insertions(+), 11 deletions(-) (limited to 'src/ui') 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) { italicFont = &fontLiterataLightItalicopsz10_Embedded; lightFont = &fontLiterataExtraLightopsz18_Embedded; } + else if (d->contentFont == sourceSansPro_TextFont) { + regularFont = &fontSourceSansProRegular_Embedded; + italicFont = &fontFiraSansItalic_Embedded; + lightFont = &fontFiraSansLight_Embedded; + lightScaling = 0.85f; + } + else if (d->contentFont == iosevka_TextFont) { + regularFont = &fontIosevkaTermExtended_Embedded; + italicFont = &fontIosevkaTermExtended_Embedded; + lightFont = &fontIosevkaTermExtended_Embedded; + scaling = lightScaling = 0.866f; + } if (d->headingFont == firaSans_TextFont) { h12Font = &fontFiraSansBold_Embedded; h3Font = &fontFiraSansRegular_Embedded; @@ -246,6 +258,14 @@ static void initFonts_Text_(iText *d) { h12Font = &fontLiterataBoldopsz36_Embedded; h3Font = &fontLiterataRegularopsz14_Embedded; } + else if (d->headingFont == sourceSansPro_TextFont) { + h12Font = &fontSourceSansProBold_Embedded; + h3Font = &fontSourceSansProRegular_Embedded; + } + else if (d->headingFont == iosevka_TextFont) { + h12Font = &fontIosevkaTermExtended_Embedded; + h3Font = &fontIosevkaTermExtended_Embedded; + } #if defined (iPlatformAppleMobile) const float uiSize = fontSize_UI * 1.1f; #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 { firaSans_TextFont, literata_TextFont, tinos_TextFont, + sourceSansPro_TextFont, + iosevka_TextFont, }; 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, static void addFontButtons_(iWidget *parent, const char *id) { const char *fontNames[] = { - "Nunito", "Fira Sans", "Literata", "Tinos" + "Nunito", "Fira Sans", "Literata", "Tinos", "Source Sans Pro", "Iosevka" }; + iArray *items = new_Array(sizeof(iMenuItem)); iForIndices(i, fontNames) { - addRadioButton_(parent, - format_CStr("prefs.%s.%u", id, i), - fontNames[i], - format_CStr("%s.set arg:%u", id, i)); + pushBack_Array(items, + &(iMenuItem){ fontNames[i], 0, 0, format_CStr("!%s.set arg:%d", id, i) }); } +// addRadioButton_(parent, +// format_CStr("prefs.%s.%u", id, i), +// fontNames[i], +// format_CStr("%s.set arg:%u", id, i)); + iLabelWidget *button = makeMenuButton_LabelWidget("Source Sans Pro", data_Array(items), size_Array(items)); + setId_Widget(as_Widget(button), format_CStr("prefs.%s", id)); + addChild_Widget(parent, iClob(button)); + delete_Array(items); } iWidget *makePreferences_Widget(void) { @@ -1243,13 +1250,13 @@ iWidget *makePreferences_Widget(void) { /* Fonts. */ { iWidget *fonts; addChild_Widget(headings, iClob(makeHeading_Widget("Heading font:"))); - fonts = new_Widget(); - addFontButtons_(fonts, "headingfont"); - addChildFlags_Widget(values, iClob(fonts), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); +// fonts = new_Widget(); + addFontButtons_(values, "headingfont"); +// addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); addChild_Widget(headings, iClob(makeHeading_Widget("Body font:"))); - fonts = new_Widget(); - addFontButtons_(fonts, "font"); - addChildFlags_Widget(values, iClob(fonts), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); +// fonts = new_Widget(); + addFontButtons_(values, "font"); +// addChildFlags_Widget(values, iClob(fonts), 0); //arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:"))); iWidget *mono = new_Widget(); /* TODO: Needs labels! */ -- cgit v1.2.3