upside down font
This commit is contained in:
parent
db047ef797
commit
3b96e1a726
|
@ -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[] {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
|
||||
|
||||
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());
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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:
|
||||
};
|
Loading…
Reference in New Issue