Compare commits

...

2 Commits

Author SHA1 Message Date
mrbesen 034977d53f
vector font, canApply 2021-07-22 20:51:57 +02:00
mrbesen e10c407867
monospacefont 2021-07-22 20:42:05 +02:00
8 changed files with 55 additions and 1 deletions

View File

@ -5,19 +5,23 @@ using json = nlohmann::json;
#include "replacefont.h"
#include "phonefont.h"
#include "vectorfont.h"
static const std::string fancyrepl[] {"𝓪","𝓫","𝓬","𝓭","𝓮","𝓯","𝓰","𝓱","𝓲","𝓳","𝓴","𝓵","𝓶","𝓷","𝓸","𝓹","𝓺","𝓻","𝓼","𝓽","𝓾","𝓿","𝔀","𝔁","𝔂","𝔃","𝓐","𝓑","𝓒","𝓓","𝓔","𝓕","𝓖","𝓗","𝓘","𝓙","𝓚","𝓛","𝓜","𝓝","𝓞","𝓟","𝓠","𝓡","𝓢","𝓣","𝓤","𝓥","𝓦","𝓧","𝓨","𝓩"};
static const std::string frakturrepl[] {"𝖆","𝖇","𝖈","𝖉","𝖊","𝖋","𝖌","𝖍","𝖎","𝖏","𝖐","𝖑","𝖒","𝖓","𝖔","𝖕","𝖖","𝖗","𝖘","𝖙","𝖚","𝖛","𝖜","𝖝","𝖞","𝖟","𝕬","𝕭","𝕮","𝕯","𝕰","𝕱","𝕲","𝕳","𝕴","𝕵","𝕶","𝕷","𝕸","𝕹","𝕺","𝕻","𝕼","𝕽","𝕾","𝕿","𝖀","𝖁","𝖂","𝖃","𝖄","𝖅"};
static const std::string doublerepl[] {"𝕒","𝕓","𝕔","𝕕","𝕖","𝕗","𝕘","𝕙","𝕚","𝕛","𝕜","𝕝","𝕞","𝕟","𝕠","𝕡","𝕢","𝕣","𝕤","𝕥","𝕦","𝕧","𝕨","𝕩","𝕪","𝕫","𝔸","𝔹","","𝔻","𝔼","𝔽","𝔾","","𝕀","𝕁","𝕂","𝕃","𝕄","","𝕆","","","","𝕊","𝕋","𝕌","𝕍","𝕎","𝕏","𝕐",""};
static const std::string cursedrepl[] {"ǻ̵͙͇̘͕͔̥̣̇̚", "b̶̛͕͔̦̏̈̏͆̚", "̴̛̻̯̬̟̺̂̀̔̈́́̅̐̽͑͜ç̴̢̮̯̭̘̗̘̄̉̕", "̴̺͎̩͎̣̯̯̮̭̾̐́̅͑͜d̶̢̝̠̳̤͚͙͖͔̬̿̔͗͌̓̈̈̿̽͋̓́̌̎̐͠ͅ", "̴̨̝̯͕̪͕̲̤̯͎̭̺̳̩̯̘̜̖͂̀̈́̑̓͊̐͛̈́͐̈́̆͋̔̀̓̚͠ȩ̷͈̟̠̣̗̣̭̖̟̀̈́̀͐͆͆̍̀̈́͋̈́͋̎̊̑̈͌͐̏̚", "̷̟͖̺̖̺͍̼͖̣̺͊̄̐f̶̟̪̤̰̘̈́͐̈́́͗̓̒̌̅́̈́͛̄̎̔͑̚̚͜͝͝", "̵̡̢̧͓̩̬̳̭̲͕͈̲̟͚̭̟̮̓͑̌g̷̹̝̘̥̉͐́̓̄̊̔̓̌̆̊͒͊̔̑͘͝͠ͅ", "̷͈͂̔̔̎̉͝h̸̢͓͇̯͚̼͓̋̆͑͜", "̵̧̛̻̼̳̪͉̰͕̝͎̼̈͆̉͛̑̋̒̈̚i̶̡͚̱̟̘̠͙̪̽̆̎̊̓̂̐̂́̌̃̈́̔͋͋͝", "̶͎̻͎͇͛̕ĵ̷̡̧̧̞̬̩̰̩̘͔͈̟̭̩̻̣̣̰̐͑̀̇̀̂͌̾̽̕͜ͅ", "̸͎̥̒͂̐̾͋̔͗́̊̒̽̈̑̌̅̿̀͘k̵̡͈̠̙̖̙̖͖̝̭̘̺̠̺͓̻͎̟̼̇͛", "̵̡̧̢̨̼̳̩̣͚̠̠͎̘̳̻̱̳̥̳̽͐̊͗̍͝ͅl̴̡̨̗͍͕̦̲̝͚̼͎̤̱͍̈̌̃̇͋̌̕͝͝͝", "̵̻̐̒̍͋͂̎̉̚͠͠m̴̤̪͍̲̤̪̺̟̦̠̗͎̎̑̂̅̄͋͛̒̿͛͘͝ͅ", "̶̡̡̝̥̱̬͓̜̖͙̥̰̣͉͇͒̔͜n̶̡̺͔̱̱̤̗̅͌̈́̈́̑̃͗̏̃̈̈́͆̈́̅̒͝", "̶̡̨̮̭̩̘̲͚͚̩̝̙̩̟̞͈͔̟͓̇̾͂̑̿̅̐͝ơ̵̛̜̯̜̾͑͐̍͌̓̅̚̕͠", "̴̪̪̍̅̈̉͂̆̕̕͠p̸̖͉̗̝͚̍̀̑̾̓̍̍̈̍̐̎͛͌̀̈́̓͝ͅ", "̴̨̧̠̹̩̘̦̹̱̌͛̋̕͝͠ͅq̷̡̛͔͙̼͕̲̥̲̪̭̻͈̦̻͈̳͒͂̈́̈́̓̈́͊̈͘̕͜͜ͅ", "̵̛̺̼̔̒̑̽̈̈́͋͒̀͊̀́͊ŗ̸̪̼̹͂̉̒̂̒͑͆̂̽̉̀̃", "̷̰̭̗̻̼̭̰̐̈́̔̑̂̈́̍̈́̌̚͜͠s̸̝̠̦̔̓͛̽̉̃͝͠", "̸͎̙̣͚̯̝̙̜̱̼͕̔̀t̷̹̯͗͂͑̇̉̎̒͌̒͑̋͆̽̀͘͝", "̶̧̪̼̘̙̣̹̩̣̲̥̘͎̣̄̊͠ų̶̭̟̫̩̦̞̱̥̟̗̬̥̦͛̄̈́̉̿̓̇̾͋͑̄́̈́̂͛̏̌͜͠͝ͅ", "̴̢̡̛̠̙̤̹͔̜͈͍̖͖̰̮̬̝̳̀̽̍̽̑̒͆̿̒͗͊͋͋̍̌ͅv̶̢̝̼̰̤͉̙̯͕̣̬͚̮̘̝̱͔̉̽̄̀̾̿̔͊̃͑̒̾̇̊̀͒͘͜͜͝͠͝ͅ", "̷̧̡̛͓̯̥̳͈̭̣̘̐̋́́̀̅̈́̈́̎̈́̿͛̒̒͘͝͝w̶̨͇̞̖̠̣̮̥̻̞̪͚͕͙͎͎̐̄̀͒̍́̽̔̑̌̄̽̐̑̈́̚͜͝", "̷͎̮͍͝x̷̥͕͙̳̦̬̗͉̝͉̺̞̏̌̂͊͊̈́̈̍͘͜", "̸͉̘̺͉̩̗̼̥̯̩̻̟̽̑́͂̎͐̔̂̄̉̐͛̅̍̽́̚͝y̸̨̤̺͎͓̰̠̲̺̰̟͕͉̝̣̻̬͍̼͛͐̑̎͒̀̔͆̀̀̓̽͊̌̒͘", "̶̨͖̘̭̮̤̫͎̹̫̺̗̿͊̅͒́̀̈́̾́̿̔̅̋̑̀͋́͑̚͝z̶͍̀̒̐͐̎͛̃̄́̈́̏̀́̎̎̃̄̕̕", "A̵̡͖͙̟̯̯̐͑̄̾͗̓͝", "̵̦̗̘̣̓̾̐̑̃͌̂͂̂̈̏̈́̍̈́̚͠͠ͅB̴̨̨̢̭̱̳̳͕͓̗̦͔̥͊̌̂̊͌̀̎̇̍́͒͊̑̂͜͠", "̴̘͇̩̮̺͒́̾̒́͗͒͋̎̔̅̀̀̆͜͝C̶͓̹̮̟͓͎̳͈̻̻̿̅̎̊̽̀͐̅͘͜͝͝͝͠", "̶̧̛̞͓̹̺͖̣̜̮̼̥̠̣̖͈͍̜̯͓̀͊̈͐͒ͅD̴̡̡̅͠", "̴̨͕̺̝̙̰̭̫̈̀͛͑͐͒̀̕Ȩ̴̢̛͔̦͇̬̱̰̙̮̬̗̥̦̄̿̒̎̉͋̃̓́̐̉́̍̿͘", "̸͈̻̮̟̅̔̇̈͐͛̍̐̄̒̓̌̑͑̔̎͘͜ͅF̵̛̞̬͎̳̖̥̈̓̓", "̷̡̜̼̝̩̣̙͙̫̜͕̬̻̈̇̄͗̓̇͘͜͜G̵̛̳͈̥̼̣̾͛̉̋͐̐̑̅̅͝", "̴̛̮̖̼̞͉̩̩͔̤̣̿́͗͋͋̚͜͜Ḥ̵̡̨̩͎̦̲̦̗̮̲̳͈̦̦̙͉̓̇̊́͊͗̚ͅ", "̴̠̠̝̲̹̮̖̳̹̫̘̇̀͝", "̶̨͓̥͉̝̘̝̮̼͙͍͒͆̆̉̓́̔̋̽̾̈̏̾̕I̸̢̢̙̲̲̣̩̻̣̓͌͂̏̂̅̈́̈́́̊̏̒̌͝͝ͅ", "̶̛̼̳̮̂͂̅͌̒̌͊̉͂͑̑́̇̃̕͝͝J̵̺̫̝͍̹̪͉̪̽͌̓̿͂̿͗̎̚̚͝", "̵̛̞͓̪̦̮͙̘͙͖̥̻͓̗̮̦̞̻͓̦̓̃̂͑̾͑̚Ǩ̵̡̡͍̪͔͉͔̠̻̗̝̹̥̤̺͎͋̀̀̓̐͑̽͐̒̍͘͜", "̵̞̹̳͉̮͖̫̪͂̾̓̑̀̄̐͊L̵̛͎̺̝͔̠͇͈͇̰͚͓̊͑̓̐̽͆̉͛̇̌͛̅͊͝͠͝͠", "̵̡̨̨͔̺̫̬̰̈́͊̿̃̚͠M̴̧͔̗̤̝̲̝̹̤͙̺̿̅̔͋̒̎̓̓̈́̇͑̈́̚̕͝͠", "̵̙̠͈͈̖͕̣͕̲̖̄̈́̀̽͂͋̑̃͋͜ͅŅ̷̢͈̜̦̑̓̓̓̒", "̵̨̛͉̭͓̟̼̹̥̖̥̖̼̥̠̩͉͓̟̔̃͐̇̉̅̂͒̍̏̃Ò̷̡̟̭͈̜̼̳̤̪͖̰͎̘̩̜̰̫̱̹͎̓", "̷̘͕͉̲̯̊̔̒̏͌̈͐̅̾͒͆̾̄́̂̑̚͝P̸̺̫̆̍͌̇͛̀̏", "̶̢͍̹͔̦̟̣͔̠͇̯͓̎̇̀͋̓̉̈́̓͘͜͜Q̷̨̧̛̛̻͕̬͖̘̳̤̎̎̀̑͑̃̔͒̇̈́̌́̀̂̋͘̕", "̷͖̥̺͙̯͉͋̐Ŕ̷̡̨̡̬̥̳͎̭̮̬̩̫̈͑̒̔̔́̌̍͌͋̽̈͌̚͜͝", "̸̛͉̰̫̈́̄͂̿̄̈́͆́̽͝͠S̷͔̱̝̘̭̘̮̮̦̣̟̼̊̀̏̄̆̏̾̋́̾͗̏͝ͅ", "̸̧̛͍̝̭̫̙̫͖͕͉͇͌̔̀̈̓̊̅̅̚T̵̛͍͉͉̥̞̞͚̮̺̜͓̲̥̽̈́͗̌͗͗͊̓̄̽͂͆̿́̉̚͜", "̶̯̣͉̦̰̗̝̩̭̜̘̦̫̖̟͈̜̥̃̿̀͊̔͜U̶̦͚͕̰̻̺̙̙͕̔̿͂̌̏̀͆̉", "̶̜̳̯̫̖̘̦̜̘̤̘͓͔͕̞̦͖̀̈̐͋̾̀̆̾̇̋̕͝͠V̷̡̻͎̞̼̤̫̫̲̳̜̪͙͓̰͇͌̀͋́͛͗̍̓͘͜", "̶̡̢̝̺͕͈̬͓̹͇̩̻̖͕̪̞̿̑̐̓̄̊̊̾͘W̶̜̰̗̬̄̂͗̀̅̔̊̍̆͗̓̑̐̕", "̴̡̡̛̘͓̱͕͚͚̲̱̺̰͈̫̹̒̐́͆̄̔͆̈́̀͂͘͘͠ͅX̷̰̿͒̎̎̍̀̚", "̶̞͖̜̘̬͉̗͚̝͔̤̲̣͗̑̈́͆̉̋̑̆̊́̓̀̄̊̈Y̶̢̢̝̻̞̖̤̰͇̐̆͋̅͆̍̀͜͜", "̴͎̼̠͕̬̰̯̲̬͔̖̦͖̜͕̙͋̏͂͜͠Z̷̢̡̛͖̩̟̬͔̝̫̭̼͐́̈́̉́̎̍͠"};
static const std::string monospacere[] {"𝚊", "𝚋", "𝚌", "𝚍", "𝚎", "𝚏", "𝚐", "𝚑", "𝚒", "𝚓", "𝚔", "𝚕", "𝚖", "𝚗", "𝚘", "𝚙", "𝚚", "𝚛", "𝚜", "𝚝", "𝚞", "𝚟", "𝚠", "𝚡", "𝚢", "𝚣", "𝙰", "𝙱", "𝙲", "𝙳", "𝙴", "𝙵", "𝙶", "𝙷", "𝙸", "𝙹", "𝙺", "𝙻", "𝙼", "𝙽", "𝙾", "𝙿", "𝚀", "𝚁", "𝚂", "𝚃", "𝚄", "𝚅", "𝚆", "𝚇", "𝚈", "𝚉"};
FontBot::FontBot() {
fonts.reserve(5);
fonts.reserve(7);
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 PhoneFont());
fonts.push_back(new ReplaceFont("monospace", monospacere));
fonts.push_back(new VectorFont());
}
FontBot::~FontBot() {
@ -27,10 +31,17 @@ FontBot::~FontBot() {
}
bool FontBot::handleInline(TelegramAPI::Manager* api, TelegramAPI::InlineQuery& q) {
if(q.query.empty()) return true;
// awnser
json arr = {};
uint8_t id = 1;
for(const Font* f : fonts) {
// skip font if it can not be applied
if(!f->canApply(q.query)) continue;
// apply font
std::string fontized;
json j;

View File

@ -7,4 +7,5 @@ public:
virtual ~Font() {}
virtual void applyFont(const std::string& in, std::string& out) const = 0;
virtual const std::string& getName() const = 0;
virtual bool canApply(const std::string& in) const = 0;
};

View File

@ -29,4 +29,8 @@ void PhoneFont::applyFont(const std::string& in, std::string& out) const {
const std::string& PhoneFont::getName() const {
static const std::string name = "Old Phone";
return name;
}
bool PhoneFont::canApply(const std::string& in) const {
return true;
}

View File

@ -8,6 +8,7 @@ public:
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:
static const std::string phonePad[];
};

View File

@ -19,4 +19,8 @@ void ReplaceFont::applyFont(const std::string& in, std::string& out) const {
const std::string& ReplaceFont::getName() const {
return name;
}
bool ReplaceFont::canApply(const std::string& in) const {
return true;
}

View File

@ -8,6 +8,7 @@ public:
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:
const std::string name;
const std::string* repl; //pointer (array)

18
src/vectorfont.cpp Normal file
View File

@ -0,0 +1,18 @@
#include "vectorfont.h"
const std::string VectorFont::vectorSymbol = "";
VectorFont::VectorFont() {}
void VectorFont::applyFont(const std::string& in, std::string& out) const {
out = in[0] + vectorSymbol;
}
const std::string& VectorFont::getName() const {
static const std::string name = "Vector";
return name;
}
bool VectorFont::canApply(const std::string& in) const {
return in.length() == 1;
}

14
src/vectorfont.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include "font.h"
class VectorFont : public Font {
public:
VectorFont();
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:
static const std::string vectorSymbol;
};