upside down font

This commit is contained in:
mrbesen 2022-01-06 14:23:11 +01:00
parent db047ef797
commit 3b96e1a726
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
3 changed files with 44 additions and 1 deletions

View File

@ -5,6 +5,7 @@ using json = nlohmann::json;
#include "replacefont.h"
#include "rulefont.h"
#include "turnfont.h"
#include "phonefont.h"
#include "vectorfont.h"
@ -22,11 +23,12 @@ static const std::string nboxrepl[] {"🅰", "🅱", "🅲", "🅳", "🅴",
static const std::string widerepl[] {"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""};
FontBot::FontBot() {
fonts.reserve(14);
fonts.reserve(15);
fonts.push_back(new ReplaceFont("Fancy", fancyrepl));
fonts.push_back(new ReplaceFont("Fraktur", frakturrepl));
fonts.push_back(new ReplaceFont("Double", doublerepl));
fonts.push_back(new ReplaceFont("Cursed", cursedrepl));
fonts.push_back(new TurnFont());
fonts.push_back(new PhoneFont());
fonts.push_back(new ReplaceFont("monospace", monospacere));
fonts.push_back(new VectorFont());

28
src/turnfont.cpp Normal file
View File

@ -0,0 +1,28 @@
#include "turnfont.h"
const static std::string repl [] = {"ɐ", "q", "ɔ", "p", "ǝ", "ɟ", "ƃ", "ɥ", "ı", "ɾ", "ʞ", "ן", "ɯ", "u", "o", "d", "b", "ɹ", "s", "ʇ", "n", "ʌ", "ʍ", "x", "ʎ", "z", "", "q", "Ͻ", "", "Ǝ", "", "ƃ", "H", "I", "ſ", "ʞ", "˥", "W", "N", "O", "Ԁ", "", "", "S", "", "", "Λ", "M", "X", "ʎ", "Z"};
TurnFont::TurnFont() {}
void TurnFont::applyFont(const std::string& in, std::string& out) const {
out.reserve(in.size()*2);
for(size_t pos_in = 0; pos_in < in.size(); ++pos_in) {
char c = in[pos_in];
if(c >= 'a' && c <= 'z') {
out.insert(0, repl[c - 'a']);
} else if(c >= 'A' && c <= 'Z') {
out.insert(0, repl[c - 'A' + 26]);
} else {
out.insert(0, 1, c);
}
}
}
const std::string& TurnFont::getName() const {
const static std::string NAME = "UpsideDown";
return NAME;
}
bool TurnFont::canApply(const std::string& in) const {
return true;
}

13
src/turnfont.h Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include "font.h"
class TurnFont : public Font {
public:
TurnFont();
virtual void applyFont(const std::string& in, std::string& out) const override;
virtual const std::string& getName() const override;
virtual bool canApply(const std::string& in) const override;
private:
};