summaryrefslogtreecommitdiff
path: root/src/ui/text.h
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-08 15:27:14 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-08 15:27:14 +0300
commit52b6013cc01e17f4b500ea79fb786ccc14b1f7ec (patch)
treed3f1a91a282cbb225d8578fabf18a2690205738d /src/ui/text.h
parentdeea4951aa8e4068daccb15b7960aa84ebfe906f (diff)
Font configuration; Prefs has a string value array
Added a second version of Iosevka with more line spacing, to be used as the default monospace document font.
Diffstat (limited to 'src/ui/text.h')
-rw-r--r--src/ui/text.h116
1 files changed, 43 insertions, 73 deletions
diff --git a/src/ui/text.h b/src/ui/text.h
index af69795a..ac59e7c8 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -34,80 +34,49 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
34#define FONT_ID(name, style, size) ((name) + ((style) * max_FontSize) + (size)) 34#define FONT_ID(name, style, size) ((name) + ((style) * max_FontSize) + (size))
35 35
36enum iFontId { 36enum iFontId {
37 default_FontId = 0, /* default is always the first font */ 37 default_FontId = 0, /* default is always the first font */
38 monospace_FontId = maxVariants_Fonts, /* 2nd font is always the monospace font */ 38 monospace_FontId = maxVariants_Fonts, /* 2nd font is always the monospace font */
39 documentBody_FontId = maxVariants_Fonts * 2, /* 3rd font is the body font */ 39 documentHeading_FontId = maxVariants_Fonts * 2, /* heading font */
40 documentHeading_FontId = maxVariants_Fonts * 3, /* heading font */ 40 documentBody_FontId = maxVariants_Fonts * 3, /* body font */
41 auxiliary_FontId = maxVariants_Fonts * 4, /* the first auxiliary font (e.g., symbols) */ 41 documentMonospace_FontId = maxVariants_Fonts * 4,
42 42 auxiliary_FontId = maxVariants_Fonts * 5, /* the first auxiliary font (e.g., symbols) */
43 // defaultMedium_FontId,
44// defaultBig_FontId,
45// defaultLarge_FontId,
46// defaultTiny_FontId,
47// defaultSmall_FontId,
48 /* UI fonts: bold weight */
49// defaultBold_FontId,
50// defaultMediumBold_FontId,
51// defaultBigBold_FontId,
52// defaultLargeBold_FontId,
53 /* content fonts */
54// bold_FontId,
55// italic_FontId,
56// medium_FontId,
57// big_FontId,
58// largeBold_FontId,
59// largeLight_FontId,
60// hugeBold_FontId,
61// monospaceSmall_FontId,
62 /* extra content fonts */
63// defaultContentRegular_FontId, /* UI font but sized to regular_FontId */
64// defaultContentSmall_FontId, /* UI font but sized smaller */
65 /* symbols and scripts */
66// userSymbols_FontId,
67// iosevka_FontId = userSymbols_FontId + max_FontSize,
68// symbols_FontId = iosevka_FontId + max_FontSize,
69// symbols2_FontId = symbols_FontId + max_FontSize,
70// smolEmoji_FontId = symbols2_FontId + max_FontSize,
71// notoEmoji_FontId = smolEmoji_FontId + max_FontSize,
72// japanese_FontId = notoEmoji_FontId + max_FontSize,
73// chineseSimplified_FontId = japanese_FontId + max_FontSize,
74// korean_FontId = chineseSimplified_FontId + max_FontSize,
75// arabic_FontId = korean_FontId + max_FontSize,
76// max_FontId = arabic_FontId + max_FontSize,
77 43
78 /* Meta: */ 44 /* Meta: */
79 mask_FontId = 0x0000ffff, /* font IDs are 16-bit; see GmRun's packing */ 45 mask_FontId = 0x0000ffff, /* font IDs are 16-bit; see GmRun's packing */
80 alwaysVariableFlag_FontId = 0x00010000, 46 alwaysVariableFlag_FontId = 0x00010000,
81 47
82 /* UI fonts: */ 48 /* UI fonts: */
83 uiLabelTiny_FontId = FONT_ID(default_FontId, semiBold_FontStyle, uiTiny_FontSize), 49 uiLabelTiny_FontId = FONT_ID(default_FontId, semiBold_FontStyle, uiTiny_FontSize),
84 uiLabelSmall_FontId = FONT_ID(default_FontId, regular_FontStyle, uiSmall_FontSize), 50 uiLabelSmall_FontId = FONT_ID(default_FontId, regular_FontStyle, uiSmall_FontSize),
85 uiLabel_FontId = FONT_ID(default_FontId, regular_FontStyle, uiNormal_FontSize), 51 uiLabel_FontId = FONT_ID(default_FontId, regular_FontStyle, uiNormal_FontSize),
86 uiLabelMedium_FontId = FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize), 52 uiLabelMedium_FontId = FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize),
87 uiLabelMediumBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiMedium_FontSize), 53 uiLabelMediumBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiMedium_FontSize),
88 uiLabelBig_FontId = FONT_ID(default_FontId, regular_FontStyle, uiBig_FontSize), 54 uiLabelBig_FontId = FONT_ID(default_FontId, regular_FontStyle, uiBig_FontSize),
89 uiLabelBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiNormal_FontSize), 55 uiLabelBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiNormal_FontSize),
90 uiLabelBigBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiBig_FontSize), 56 uiLabelBigBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiBig_FontSize),
91 uiLabelLarge_FontId = FONT_ID(default_FontId, regular_FontStyle, uiLarge_FontSize), 57 uiLabelLarge_FontId = FONT_ID(default_FontId, regular_FontStyle, uiLarge_FontSize),
92 uiLabelLargeBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiLarge_FontSize), 58 uiLabelLargeBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiLarge_FontSize),
93 uiLabelSymbols_FontId = FONT_ID(auxiliary_FontId, regular_FontStyle, uiNormal_FontSize), 59 uiLabelSymbols_FontId = FONT_ID(auxiliary_FontId, regular_FontStyle, uiNormal_FontSize),
94 uiShortcuts_FontId = FONT_ID(default_FontId, regular_FontStyle, uiNormal_FontSize), 60 uiShortcuts_FontId = FONT_ID(default_FontId, regular_FontStyle, uiNormal_FontSize),
95 uiInput_FontId = FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize), 61 uiInput_FontId = FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize),
96 uiContent_FontId = FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize), 62 uiContent_FontId = FONT_ID(default_FontId, regular_FontStyle, uiMedium_FontSize),
97 uiContentBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiMedium_FontSize), 63 uiContentBold_FontId = FONT_ID(default_FontId, bold_FontStyle, uiMedium_FontSize),
98 uiContentSymbols_FontId = FONT_ID(auxiliary_FontId, regular_FontStyle, uiMedium_FontSize), 64 uiContentSymbols_FontId = FONT_ID(auxiliary_FontId, regular_FontStyle, uiMedium_FontSize),
99 /* Document fonts: */ 65
100 paragraph_FontId = FONT_ID(documentBody_FontId, regular_FontStyle, contentRegular_FontSize), 66 /* Document fonts: */
101 bold_FontId = FONT_ID(documentBody_FontId, semiBold_FontStyle, contentRegular_FontSize), 67 paragraph_FontId = FONT_ID(documentBody_FontId, regular_FontStyle, contentRegular_FontSize),
102 firstParagraph_FontId = FONT_ID(documentBody_FontId, regular_FontStyle, contentMedium_FontSize), 68 bold_FontId = FONT_ID(documentBody_FontId, semiBold_FontStyle, contentRegular_FontSize),
103 preformatted_FontId = FONT_ID(monospace_FontId, regular_FontStyle, contentMono_FontSize), 69 firstParagraph_FontId = FONT_ID(documentBody_FontId, regular_FontStyle, contentMedium_FontSize),
104 preformattedSmall_FontId = FONT_ID(monospace_FontId, regular_FontStyle, contentMonoSmall_FontSize), 70 preformatted_FontId = FONT_ID(monospace_FontId, regular_FontStyle, contentSmall_FontSize),
105 quote_FontId = FONT_ID(documentBody_FontId, italic_FontStyle, contentRegular_FontSize), 71 preformattedSmall_FontId = FONT_ID(monospace_FontId, regular_FontStyle, contentTiny_FontSize),
106 heading1_FontId = FONT_ID(documentHeading_FontId, bold_FontStyle, contentHuge_FontSize), 72 quote_FontId = FONT_ID(documentBody_FontId, italic_FontStyle, contentRegular_FontSize),
107 heading2_FontId = FONT_ID(documentHeading_FontId, bold_FontStyle, contentLarge_FontSize), 73 heading1_FontId = FONT_ID(documentHeading_FontId, bold_FontStyle, contentHuge_FontSize),
108 heading3_FontId = FONT_ID(documentHeading_FontId, regular_FontStyle, contentBig_FontSize), 74 heading2_FontId = FONT_ID(documentHeading_FontId, bold_FontStyle, contentLarge_FontSize),
109 banner_FontId = FONT_ID(documentHeading_FontId, light_FontStyle, contentLarge_FontSize), 75 heading3_FontId = FONT_ID(documentHeading_FontId, regular_FontStyle, contentBig_FontSize),
110 regularMonospace_FontId = FONT_ID(monospace_FontId, regular_FontStyle, contentRegular_FontSize), 76 banner_FontId = FONT_ID(documentHeading_FontId, light_FontStyle, contentLarge_FontSize),
77 monospaceParagraph_FontId = FONT_ID(documentMonospace_FontId, regular_FontStyle, contentRegular_FontSize),
78 monospaceBold_FontId = FONT_ID(documentMonospace_FontId, semiBold_FontStyle, contentRegular_FontSize),
79 plainText_FontId = FONT_ID(documentMonospace_FontId, regular_FontStyle, contentRegular_FontSize),
111}; 80};
112 81
113//iLocalDef iBool isJapanese_FontId(enum iFontId id) { 82//iLocalDef iBool isJapanese_FontId(enum iFontId id) {
@@ -116,6 +85,7 @@ enum iFontId {
116 85
117#define emojiVariationSelector_Char ((iChar) 0xfe0f) 86#define emojiVariationSelector_Char ((iChar) 0xfe0f)
118 87
88#if 0
119/* TODO: get rid of this; configure using font ID strings, check RTL from FontFile flags */ 89/* TODO: get rid of this; configure using font ID strings, check RTL from FontFile flags */
120enum iTextFont { 90enum iTextFont {
121 undefined_TextFont = -1, 91 undefined_TextFont = -1,
@@ -129,6 +99,7 @@ enum iTextFont {
129 arabic_TextFont, 99 arabic_TextFont,
130 emojiAndSymbols_TextFont, 100 emojiAndSymbols_TextFont,
131}; 101};
102#endif
132 103
133extern int gap_Text; /* affected by content font size */ 104extern int gap_Text; /* affected by content font size */
134 105
@@ -140,11 +111,10 @@ void deinit_Text (iText *);
140 111
141void setCurrent_Text (iText *); 112void setCurrent_Text (iText *);
142 113
143//void loadUserFonts_Text (void); /* based on Prefs */ 114//void setContentFont_Text (iText *, enum iTextFont font);
144 115//void setHeadingFont_Text (iText *, enum iTextFont font);
145void setContentFont_Text (iText *, enum iTextFont font); 116//void setFont_Text (iText *, int fontId, const char *fontSpecId);
146void setHeadingFont_Text (iText *, enum iTextFont font); 117void setDocumentFontSize_Text(iText *, float fontSizeFactor); /* affects all except `default*` fonts */
147void setContentFontSize_Text (iText *, float fontSizeFactor); /* affects all except `default*` fonts */
148void resetFonts_Text (iText *); 118void resetFonts_Text (iText *);
149 119
150int lineHeight_Text (int fontId); 120int lineHeight_Text (int fontId);