From 773caa15c74719eeeb2775cdcad2ffb62845e689 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 10 Aug 2021 12:30:07 -0400 Subject: Fixed handling of titles --- sword.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'sword.cc') diff --git a/sword.cc b/sword.cc index ada3d6e..a693085 100644 --- a/sword.cc +++ b/sword.cc @@ -66,6 +66,9 @@ void Sword::fillBuffer(string ref, Glib::RefPtr buf) { auto verseScale = buf->create_tag(); verseScale->property_scale() = 0.8; + auto titleScale = buf->create_tag(); + titleScale->property_scale() = 1.5; + titleScale->property_weight() = 600; auto verseOffset = buf->create_tag(); verseOffset->property_rise() = 3000; auto indent = buf->create_tag(); @@ -81,6 +84,7 @@ void Sword::fillBuffer(string ref, Glib::RefPtr buf) { bool isParagraph = false; bool isIndent = false; bool isDivineName = false; + bool isPreverse = false; for(string modifier : tex.modifiers) { if(modifier == "paragraph") { isParagraph = true; @@ -90,6 +94,17 @@ void Sword::fillBuffer(string ref, Glib::RefPtr buf) { isDivineName = true; } else if (modifier == "wordsOfJesus") { tags.push_back(redletter); + } else if (modifier == "title") { + tags.push_back(titleScale); + // Ensure newline + if(tex.text.back() != '\n') { + tex.text.push_back('\n'); + } + } else if (modifier == "preverse") { + isPreverse = true; + } else if (modifier == "parallel") { + // We don't support this (yet) + tex.text = ""; } } if(isIndent) { @@ -101,13 +116,13 @@ void Sword::fillBuffer(string ref, Glib::RefPtr buf) { if(isParagraph) { iter = buf->insert_with_tags(iter, indentString, tags); } - if(tex.verse != verse) { + if(tex.verse != verse && ! isPreverse) { std::vector> verseTags(tags.begin(), tags.end()); verseTags.push_back(verseScale); verseTags.push_back(verseOffset); iter = buf->insert_with_tags(iter, " " + std::to_string(tex.verse), verseTags); + verse = tex.verse; } - verse = tex.verse; if(isDivineName) { // There's no small caps support. Sigh. We do fake small caps instead. // Because i lazy, first letter is normal caps and rest small caps, always. -- cgit v1.2.3