summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-02 06:21:19 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-02 06:21:19 +0200
commit70e1c929cbf62ab38d08b6b03991cb00623a8264 (patch)
tree7f07cc9fda02741aecf9068d5b2c288c3259ee29 /src
parentb83c46a9d6670e324fcf8a0a8cbc7f2ae5ba24db (diff)
GmDocument: Monospace body isn't normalized
Diffstat (limited to 'src')
-rw-r--r--src/gmdocument.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 4e76a22a..f5ce90a1 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -264,6 +264,17 @@ static void linkContentLaidOut_GmDocument_(iGmDocument *d, const iGmMediaInfo *m
264 } 264 }
265} 265}
266 266
267static iBool isNormalized_GmDocument_(const iGmDocument *d) {
268 const iPrefs *prefs = prefs_App();
269 if (startsWithCase_String(&d->url, "gemini:") && prefs->monospaceGemini) {
270 return iFalse;
271 }
272 if (startsWithCase_String(&d->url, "gopher:") && prefs->monospaceGopher) {
273 return iFalse;
274 }
275 return iTrue;
276}
277
267static void doLayout_GmDocument_(iGmDocument *d) { 278static void doLayout_GmDocument_(iGmDocument *d) {
268 const iBool isMono = isForcedMonospace_GmDocument_(d); 279 const iBool isMono = isForcedMonospace_GmDocument_(d);
269 /* TODO: Collect these parameters into a GmTheme. */ 280 /* TODO: Collect these parameters into a GmTheme. */
@@ -324,6 +335,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
324 uint16_t preId = 0; 335 uint16_t preId = 0;
325 iBool enableIndents = iFalse; 336 iBool enableIndents = iFalse;
326 iBool addSiteBanner = d->bannerType != none_GmDocumentBanner; 337 iBool addSiteBanner = d->bannerType != none_GmDocumentBanner;
338 const iBool isNormalized = isNormalized_GmDocument_(d);
327 enum iGmLineType prevType = text_GmLineType; 339 enum iGmLineType prevType = text_GmLineType;
328 if (d->format == plainText_GmDocumentFormat) { 340 if (d->format == plainText_GmDocumentFormat) {
329 isPreformat = iTrue; 341 isPreformat = iTrue;
@@ -363,7 +375,9 @@ static void doLayout_GmDocument_(iGmDocument *d) {
363 type = text_GmLineType; 375 type = text_GmLineType;
364 } 376 }
365 } 377 }
366 trimLine_Rangecc_(&line, type); 378 if (isNormalized) {
379 trimLine_Rangecc_(&line, type);
380 }
367 run.font = fonts[type]; 381 run.font = fonts[type];
368 /* Remember headings for the document outline. */ 382 /* Remember headings for the document outline. */
369 if (type == heading1_GmLineType || type == heading2_GmLineType || type == heading3_GmLineType) { 383 if (type == heading1_GmLineType || type == heading2_GmLineType || type == heading3_GmLineType) {
@@ -1219,7 +1233,9 @@ void setUrl_GmDocument(iGmDocument *d, const iString *url) {
1219 1233
1220void setSource_GmDocument(iGmDocument *d, const iString *source, int width) { 1234void setSource_GmDocument(iGmDocument *d, const iString *source, int width) {
1221 set_String(&d->source, source); 1235 set_String(&d->source, source);
1222 normalize_GmDocument(d); 1236 if (isNormalized_GmDocument_(d)) {
1237 normalize_GmDocument(d);
1238 }
1223 setWidth_GmDocument(d, width); /* re-do layout */ 1239 setWidth_GmDocument(d, width); /* re-do layout */
1224} 1240}
1225 1241