From 0f23a86b9d351d04769e3c60e65d55858cdcea6f Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Sun, 21 Feb 2021 10:55:50 +1100 Subject: More consistent line height in headings and preformatted blocks Also updates help.gemini to reflect changes --- src/about/help.gemini | 4 ++-- src/documentstyle.cpp | 2 +- src/renderers/geminirenderer.cpp | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/about/help.gemini b/src/about/help.gemini index dd204a5..98c74fa 100644 --- a/src/about/help.gemini +++ b/src/about/help.gemini @@ -1,5 +1,5 @@ # Kristall Help -This is the manual for the Kristall small-internet browser. It contains explanations on how to use the program, what each setting means and +This is the manual for the Kristall small-internet browser. It contains explanations on how to use the program, what each setting means and other information about the browser. ## The Mission Kristall tries to fill the hole of graphical browsers for alternative internet protocols with a high usability and feature richness. @@ -197,7 +197,7 @@ Most items in the *Style* category have either a [Font], [Color] or both buttons [Line height (paragraph)] is an additional spacing between paragraph text lines. By default this is set to 5px, and can help with readability. (Gemtext-only feature) -[Line height (header)] is an additional spacing between header text lines. By default this is set to 0px. Pages will usually look better when this is set to a low value, or else headings will appear too far from paragraph text. (Gemtext-only feature) +[Line height (header)] is an additional spacing between header text lines. By default this is set to 5px. (Gemtext-only feature) [Indentation] is a set of options that control the level of indent in certain text parts in Gemini pages. diff --git a/src/documentstyle.cpp b/src/documentstyle.cpp index 6023075..815a647 100644 --- a/src/documentstyle.cpp +++ b/src/documentstyle.cpp @@ -146,7 +146,7 @@ DocumentStyle::DocumentStyle(bool do_init) : theme(Fixed), justify_text(true), text_width_enabled(true), line_height_p(5.0), - line_height_h(0.0), + line_height_h(5.0), indent_bq(1), indent_p(1), indent_h(0), indent_l(2), indent_size(15.0), list_symbol(QTextListFormat::ListDisc) diff --git a/src/renderers/geminirenderer.cpp b/src/renderers/geminirenderer.cpp index 09ff494..be702e4 100644 --- a/src/renderers/geminirenderer.cpp +++ b/src/renderers/geminirenderer.cpp @@ -66,6 +66,15 @@ std::unique_ptr GeminiRenderer::render( { if (line.startsWith("```")) { + // Set the last line of the preformatted block to have + // standard line height. + QTextBlockFormat fmt = text_style.preformatted_format; + fmt.setLineHeight(themed_style.line_height_p, + QTextBlockFormat::LineDistanceHeight); + cursor.movePosition(QTextCursor::PreviousBlock); + cursor.setBlockFormat(fmt); + + cursor.movePosition(QTextCursor::NextBlock); cursor.setBlockFormat(text_style.standard_format); verbatim = false; } -- cgit v1.2.3