diff --git a/src/glyphs.hpp b/src/glyphs.hpp index f324283..59ff42f 100644 --- a/src/glyphs.hpp +++ b/src/glyphs.hpp @@ -68,6 +68,8 @@ namespace Glyphs auto space = 0; + TTF_SetFontStyle(font, current_style); + TTF_GlyphMetrics(font, ' ', NULL, NULL, NULL, NULL, &space); for (auto i = 0; i < copy.length(); i++) @@ -90,6 +92,8 @@ namespace Glyphs { if (word) { + word = false; + auto subw = 0; auto sub = copy.substr(start, i - start); @@ -100,8 +104,6 @@ namespace Glyphs TTF_SizeText(font, sub.c_str(), &subw, NULL); - word = false; - if (x + subw > width) { x = subw; @@ -117,9 +119,16 @@ namespace Glyphs if (c == '\t' || c == ' ') { x += space; + + if (x > width) + { + x = 0; + + lines += 1; + } } - if (x > width || c == '\n' || c == '\r') + if (c == '\n' || c == '\r') { x = 0; @@ -198,8 +207,6 @@ namespace Glyphs TTF_SizeText(font, sub.c_str(), &subw, NULL); - word = false; - if (x + subw > width) { lines += 1; @@ -266,6 +273,8 @@ namespace Glyphs auto skip = TTF_FontLineSkip(font); + TTF_SetFontStyle(font, current_style); + TTF_GlyphMetrics(font, ' ', NULL, NULL, NULL, NULL, &space); auto closeBold = false; @@ -292,6 +301,8 @@ namespace Glyphs { if (word) { + word = false; + auto subw = 0; auto sub = copy.substr(start, i - start); @@ -302,8 +313,6 @@ namespace Glyphs TTF_SizeText(font, sub.c_str(), &subw, NULL); - word = false; - if (x + subw > width) { x = subw; @@ -323,9 +332,16 @@ namespace Glyphs if (c == '\t' || c == ' ') { x += space; + + if (x > width) + { + x = 0; + + lines += 1; + } } - if (x > width || c == '\n' || c == '\r') + if (c == '\n' || c == '\r') { x = 0; @@ -406,14 +422,8 @@ namespace Glyphs TTF_SizeText(font, sub.c_str(), &subw, NULL); - word = false; - if (x + subw > width) { - x = subw; - - x += space; - lines += 1; y = lines * skip; diff --git a/src/topics/book1.json b/src/topics/book1.json index 28fc35b..4ff45d4 100644 --- a/src/topics/book1.json +++ b/src/topics/book1.json @@ -145,7 +145,7 @@ }, { "title": "Spell List for Starting Characters", - "text": "Animal Speech (Adventure)\nYou are able to communicate using the secret speech of animals. The text will tell you when you can cast this spell.\nRecharge: 50 silver\n\nArmour of Heaven (Combat)\nGain a +3 bonus to one party member's Armour which lasts until the end of this battle.\nRecharge: 50 silver\n\nIce Bolt (Combat)\nYou conjure a great block of ice and hurl it at your foe with magical strength. Make an immediate attack with a Fighting score of 8 against any opponent.\nRecharge: 50 silver\n\nPoison Stream (Combat)\nA sickly green poison jets from your hands. Make two immediate attacks with a Fighting score of 5, against two different opponents.\nRecharge: 50 silver\n\nUnfailing Strike (Combat)\nA pillar of energy sizzles into a single foe. Choose an opponent to lose 3 Health.\nRecharge: 50 silver\n\nWolf Spirit (Adventure)\nYou summon the spirit of the wolf to help guide you from danger in the natural world. Cast this spell when you fail a Survival check. You gain an additional 3 automatic successes for this check only.\nRecharge: 75 silver\n\nMagic Cabinet (Adventure)\nYou summon a magic cabinet made of purple wood. You can use this cabinet to access The Vault, storing and/or taking out as many items as you wish. When you have done this, the cabinet will vanish, until summoned again.\nRecharge: 100 silver" + "text": "Animal Speech (Adventure)\nYou are able to communicate using the secret speech of animals. The text will tell you when you can cast this spell.\nRecharge: 50 silver\n\nArmour of Heaven (Combat)\nGain a +3 bonus to one party member's Armour which lasts until the end of this battle.\nRecharge: 50 silver\n\nIce Bolt (Combat)\nYou conjure a great block of ice and hurl it at your foe with magical strength. Make an immediate attack with a Fighting score of 8 against any opponent.\nRecharge: 50 silver\n\nPoison Stream (Combat)\nA sickly green poison jets from your hands. Make two immediate attacks with a Fighting score of 5, against two different opponents.\nRecharge: 50 silver\n\nUnfailing Strike (Combat)\nA pillar of energy sizzles into a single foe. Choose an opponent to lose 3 Health.\nRecharge: 50 silver\n\nWolf Spirit (Adventure)\nYou summon the spirit of the wolf to help guide you from danger in the natural world. Cast this spell when you fail a Survival check. You gain an additional 3 automatic successes for this check only.\nRecharge: 75 silver\n\nMagic Cabinet (Adventure)\nYou summon a magic cabinet made of purple wood. You can use this cabinet to access The Vault, storing and/or taking out as many items as you wish. When you have done this, the cabinet will vanish, until summoned again.\nRecharge: 100 silver" }, { "title": "Sea Combat",