From c9cba998dcff95e3a9453d8062f71262d507652f Mon Sep 17 00:00:00 2001 From: my Date: Tue, 19 Nov 2019 13:27:18 +0100 Subject: [PATCH] String Umsetzung und DriiteFont finished. --- CMakeLists.txt | 2 +- main/main.cpp | 63 ++++++++++++----- res/font3.bmp | Bin 0 -> 458442 bytes res/font3.ppm | 22 ------ res/font3.toml | 18 +++-- src/Block.cpp | 65 ----------------- src/Block.h | 35 ---------- src/Config.cpp | 66 ------------------ src/Config.h | 42 ----------- src/DritteFont.cpp | 162 ------------------------------------------- src/DritteFont.h | 42 ----------- src/Font.cpp | 100 +++++++++++++++++++++++++- src/Font.h | 46 ++++++++++-- src/MainFont.cpp | 91 ------------------------ src/MainFont.h | 53 -------------- src/TextRenderer.cpp | 100 ++++++++++++++++++++++++++ src/TextRenderer.h | 49 +++++++++++++ 17 files changed, 346 insertions(+), 610 deletions(-) create mode 100644 res/font3.bmp delete mode 100644 res/font3.ppm delete mode 100644 src/Block.cpp delete mode 100644 src/Block.h delete mode 100644 src/Config.cpp delete mode 100644 src/Config.h delete mode 100644 src/DritteFont.cpp delete mode 100644 src/DritteFont.h delete mode 100644 src/MainFont.cpp delete mode 100644 src/MainFont.h create mode 100644 src/TextRenderer.cpp create mode 100644 src/TextRenderer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 60d47c8..1594915 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ include_directories(lib/toml) set(LIB_PATH "${CMAKE_SOURCE_DIR}/../library") include_directories(${LIB_PATH}/include) -add_executable(TextRenderer ${SOURCES} ${HEADERS} main/main.cpp src/Font.cpp src/Font.h src/DritteFont.cpp src/DritteFont.h src/Config.cpp src/Config.h src/Block.cpp src/Block.h) +add_executable(TextRenderer ${SOURCES} ${HEADERS} main/main.cpp src/TextRenderer.cpp src/TextRenderer.h) target_link_libraries(TextRenderer ${LIB_PATH}/lib/liblibrary.a) diff --git a/main/main.cpp b/main/main.cpp index 033a82a..c3474ee 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1,9 +1,11 @@ //#include "add.h" #include "Bitmap.h" -#include "MainFont.h" +#include "Font.h" #include +bool isQuit(std::string command); + /** * @author: Julian Hinxlage * @since: v0.0.0 @@ -11,26 +13,55 @@ * A string is converted and displayed in the console. * Currently only to test. */ + +#include "TextRenderer.h" + int main() { - MainFont font("../res/font2.bmp", "../res/font2.toml"); + Font font("../res/font1.bmp", "../res/font1.toml"); - std::string str; - std::cout << "string to draw: "; - std::getline(std::cin, str); + std::string oldText; + std::string currentText; + TextRenderer textRenderer(vkvm::Color(255, 255, 255), vkvm::Color(0, 0, 0)); - for (int i = 0; i < font.height(); i++) { - for (char c : str) { - for (int j = 0; j < font.width(); j++) { - if (font.getPixel(c,j,i)) { - std::cout << "█"; - } else { - std::cout << " "; - } - } - std::cout << " "; + std::string command; + + std::cout << "TextRender: " << std::endl; + std::getline(std::cin, command); + while(!isQuit(command)) { + if(command.compare("update")) { + currentText = vkvm::getText(); + textRenderer.update(currentText); } - std::cout << std::endl; + std::cout << "TextRender: " << std::endl; + std::getline(std::cin, command); } + std::cout << "TextRender finished." << std::endl; + return 0; } + + +// std::string str; +// std::cout << "string to draw: "; +// std::getline(std::cin, str); +// +// for (int i = 0; i < font.height(); i++) { +// for (char c : str) { +// for (int j = 0; j < font.width(); j++) { +// if (font.getPixel(c,j,i)) { +// std::cout << "█"; +// } else { +// std::cout << " "; +// } +// } +// std::cout << " "; +// } +// std::cout << std::endl; +// } +// +// return 0; + +bool isQuit(std::string command) { + return command.compare("quit") == 0; +} diff --git a/res/font3.bmp b/res/font3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..609d2668e6a8824d1b7a8ee7b1c01b249fb66f55 GIT binary patch literal 458442 zcmeHvL9Q%Km(vGAtbygAo-kshbduo;?wgDfi?C+b8*W>r>Q|LVWm>9BoH zIP2c`T57$2`Op9JfB*Y`{_lVOd;9NyYybTp|Ms7M{#X0o|K^|n&_4h9=Rf}c^Z)mN zkAMB=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18%?#xB)ld2Hb!fa070@4Y&a};0D})8*l?|zzw(o WH{b@`fE#cFZomz=0XOh74g4RBoKZ&r literal 0 HcmV?d00001 diff --git a/res/font3.ppm b/res/font3.ppm deleted file mode 100644 index f5a99ac..0000000 --- a/res/font3.ppm +++ /dev/null @@ -1,22 +0,0 @@ -P6 -777 307 -255 -111111111111jjjqqq111111111111VVVWWW VVV\\\111111111111]]]bbbVVVWWWVVVWWWVVVVVV111VVVVVVVVV\\\111111111111===111VVV======WWWAAAPPPVVV===111111111111wwweeeXXXhhhVVV===IIIWWWVVV======WWWVVV======VVV111VVV===VVV>>>===VVV++++++444<<<vvv111111111"""++++++444000DDDJJJSSSmmm111!!!111111XXXXXX !!!VVV===hhh+++^^^...444///IIIDDD 111+++...^^^===mmm111111111111mmm======mmmXXX+++...vvvOOOrrr111+++......BBB111111===XXX===XXX111111BBBBBBVVV000...iiiuuu 111+++//////BBB111111BBBBBB===XXX+++kkk^^^......///111JJJwww111+++//////===mmm111111mmm======mmm++++++###///000111000 +++///000!!! !!!++++++000...mmmmmmmmmyyyEEE|||+++000000VVV======VVVAAAAAAVVV===000...111111111111 ---VVVBBB===VVV000111VVV======VVVVVV======VVVVVV======VVVVVV===>>>VVVJJJJJJ000111000111111111111mmmmmmyyy@@@111JJJJJJVVVVVV VVV^^^111FFF111111111111VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV111111111111<<<111111111111999dddaaaVVVWWW000111000VVVWWWVVVWWW}}}VVVVVVWWWWWWVVVWWW 111VVVWWWVVVVVVWWWVVVVVVWWW///000000/// 111VVV======WWW...//////...VVV======WWWVVV======WWW??????~~~===VVVVVV======WWW===WWWVVV======WWW 111VVV======WWW===VVVVVV======WWW===VVVVVV======WWW............ 111111111111111111mmmmmmmmmmmm------------555??????~~~!!!111111!!!??????111111111111,,,,,,,,,,,,...^^^555===mmm111111===WWW===mmmVVV===111111111111mmmmmmmmmmmm++++++++++++///...??????BBB111111BBBXXX??????111111VVV===++++++++++++000///BBB111WWWBBBVVV111111,,,,,,,,,,,,111000666555===mmm111===mmm===XXX??????111111111111VVV------------111777444!!!!!!111111111111mmmmmmmmmmmm............+++??????111111111111===VVV .../////////VVV======VVVVVV======VVV===VVVVVV======VVVVVV======VVVVVV======VVVVVV???,,,+++GGGWWWVVV======VVVVVV======VVV mmmmmmmmm///000000///JJJJJJ?????? VVV000111000JJJJJJVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV(((VVVVVVVVVVVV ---)))+++}}}ddd|||NNN+++++++++@@@lll++++++WWWJJJJJJJJJJJJlll++++++JJJJJJJJJJJJ???lllNNN++++++WWW===IIIllllll+++III>>>ooolllVVVXXXXXXXXXVVVVVVXXXVVVXXX111111XXX$$$VVVVVVXXXXXXVVV$$$VVVuuu((( 111111111111III - - -lll111111RRRRRR111111111111111111111111III===VVV======XXXXXX======XXXVVV===VVV======XXXVVV======XXX111111===XXXGGG___===VVVVVV======XXX===XXXVVV===GGG___===VVVfffDDD??????111111111111111111111111III111111fffDDD111111111111111111III<<<111111(((ttt??????111111III!!!111111111uuu((( 111111III:::111111111GGGbbb?????? 111111111111%%%VVV===___HHH===VVVXXX===VVV===VVV===VVV===111111VVV======VVV===VVVVVV===GGGbbbVVV===VVV===___HHHZZZwwwwwwttttttZZZ111111111111999OOO111111OOO??????iiiiii111111111111)))VVV$$$VVVXXXVVVVVVVVV111VVVVVVVVVVVV (((tttVVVVVV$$$$$$@@@???$$$888...<<<WWW<<<WWW888kkkWWWWWWLLLLLLVVVVVVbbb999======999VVVXXX===VVVVVV===VVVXXXIIIJJJJJJVVV======XXX......JJJJJJJJJJJJWWWIIIWWWIIIVVV======XXX111111qqqJJJJJJ......JJJJJJJJJJJJVVV===111111IIIzzz//////CCC綶>>>CCC綶>>>111222[[[//////{{{VVV{{{VVV======WWW```333vvv///XXXXXXBBBBBBaaa///000vvv???vvv???EEE{{{111===??????===vvv222еBBB,,,,,,BBBaaa111000000000vvvIII栠栠vvvIIIVVVWWWqqq111111iiiiii555vvvXXX======XXX,,,,,,aaa111000000111}}}bbb}}}bbbmmmmmm111111iiiiii000vvvaaa111000JJJ111111===??????===aaa111///vvvIII888888zzzmmmmmm111111aaa111///vvv@@@666666 㯯)))111111111aaa111...}}}666666000VVV===111111XXX===000```,,,,,,aaa111...DDD綶@@@888888...111======111BBB,,,,,,BBBaaaVVVXXX```BBBBBBaaaVVV===WWWIII}}}bbb}}}bbbVVVWWWbbb桡桡<<<WWW999===<<<999VVVccccccWWWLLLLLLdddVVVXXXvvv///JJJJJJJJJJJJvvvvvvJJJJJJJJJJJJJJJJJJJJJJJJCCC - - -ZZZvvv///JJJJJJJJJJJJ}}}}}}vvv222еJJJJJJJJJJJJvvvvvv}}}JJJJJJJJJJJJ}}}JJJJJJJJJJJJZZZ """}}}vvv222еJJJJJJJJJJJJVVV======XXX||||||555vvv||||||```|||555vvv 000vvv   (((cccKKK  000vvv JJJJJJ}}}}}}???;;;}}}}}}wwwwwwVVVVVVWWW!!!VVVVVVVVVVVVPPPSSSVVVWWWVVVWWWVVVWWWVVV======VVVJJJJJJ ***(((??????~~~??????~~~??????~~~??????~~~??????~~~??????VVV===VVV======WWWVVV======VVVVVV======VVV}}}======|||VVV======WWWVVV======WWWVVV===IIIWWWVVVVVVVVV))))))111000??????~~~??????~~~??????~~~??????~~~??????~~~??????VVV111000111VVV111+++bbb}}}bbb}}}///000????????????????????????????????????VVV111+++...///VVV111+++888888^^^...VVV111+++666666+++666666+++888888VVV======VVVVVV======VVVVVV======VVVVVV======VVVVVV======VVVVVV======VVVVVV======VVVVVVBBB===VVVVVV======VVVbbb}}}bbb}}}VVVVVVVVVVVV333333333333VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVccccccdddJJJJJJJJJJJJJJJJJJJJJJJJ111XXX111111111111111111vvv///vvvvvv111111111111111111111111111111111111vvv///111111111111111111vvv///111111 111111222111111111222vvv222еvvvvvv111222111111111222111222111111111222vvv222е111222111111111222vvv222е111222߽߼111111===XXX222333111222111111111333555vvvJJJJJJJJJJJJ222333111222111111111333JJJJJJJJJJJJ222333111222111111111333JJJJJJJJJJJJ555vvv222333111222111111111333555vvvJJJJJJJJJJJJ222333111333333ccc```333```333333ccc000vvvJJJJJJJJJJJJ333ccc```333```333333cccJJJJJJJJJJJJ333ccc```333```333333cccJJJJJJJJJJJJ000vvv333ccc```333```333333ccc000vvvJJJJJJJJJJJJ333ccc___111vvvvvvJJJJJJFFFXXXvvvvvvJJJJJJeeeVVVVVVVVVVVVVVVVVVVVVXXXXXXXXXVVVXXXVVVXXXVVVXXXVVVXXX$$$VVVVVVXXXVVVXXXVVVXXXVVVXXXVVVXXXVVVXXX RRRVVV===VVV===VVV===VVV===VVV===VVV===VVV======XXXXXX======XXXVVV======XXXVVV======XXXVVV======XXXVVV======XXXGGG___===VVVVVV======XXXVVV======XXXVVV======XXXVVV======XXXVVV======XXXVVV==='''XXXXXX---&&&MMM[[[,,,+++++++++JJJJJJ###+++VVV======VVVVVV======VVVVVV======VVV===VVVVVV===___HHHVVV===___HHHVVV===___HHHVVV===___HHHVVV===___HHHVVV===___HHHVVV===WWW===VVV===VVV===VVV===VVV===VVV======VVVVVV======VVVVVV======VVVVVV======VVVVVV======VVVJJJJJJVVV%%%===VVVVVV===___HHHOOOOOOOOOOOOOOOOOOOOOVVVVVVVVVVVVVVVVVVVVVVVV$$$VVV$$$VVV$$$VVV$$$VVV$$$VVV$$$VVVWWWVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV$$$ccccccdddJJJJJJJJJJJJWWWJJJJJJJJJJJJ111111FFFFFFWWW===111111<<<$$$MMM111gggvvv///www - - -BBB"""111111FFFHHH111222BBB"""UUUppp...LLL>>>]]]vvv222еxxx - - -BBB###111222FFFIIIJJJJJJJJJJJJJJJJJJJJJJJJVVV111111111333BBBTTT @@@,,,222555vvv~~~ - - -BBB$$$VVVWWW```333FFFHHHJJJJJJJJJJJJJJJJJJJJJJJJ```333333cccBBBRRRaaaNNNOOO222000vvvxxx$$$VVV===OOO]]]VVV======WWW@@@,,,ggg??????vvvvvvvvvvvvvvv111111111111??????111111111111??????111111111111??????111111??????ZZZOOOUUU\\\??????ttt??????%%%VVV===___HHHVVV===___HHHVVV===___HHHVVV===VVV===??????======OOOOOOOOOvvvvvvvvvVVV$$$VVV$$$VVV$$$VVVVVVvvvtttvvvvvvVVVWWW<<<WWW<<<WWWccccccWWWWWWeeeWWW'''WWW===KKK~~~KKK~~~KKK~~~ZZZlll333;;;ggg@@@VVVWWW111111---uuuuuu---ӌ+++;;;&&&@@@@@@111111ccc---......---*********IIIIII>>>...~~~&&&```zzzVVV======WWW111111ccc--- ,,,......,,,;;;*********lllAAA??????111111??????ccc333 ,,,...---,,,;;;JJJ333+++333333333333ttt111cccvvvvvvvvvvvvvvv+++...---+++vvvvvv;;;~~~KKK~~~KKK~~~KKKIIIIII###栠===***QQQ222%%%??????ccc000lllvvvvvvvvvvvvHHHHHHvvvvvv;;;;;;$$$}}}bbbbbb}}}===333??????cccmmmmmm $$$IIIIII;;;;;;<<<333??????cccUUU,,,qqq$$$IIIIII;;;IIIIIIDDDllllll'''888888<<<LLLZZZOOOUUU\\\??????cccmmmmmm::: vvvvvvvvvvvvIIIIIIvvvvvv;;;666666;;;333+++333333333333pppttt'''??????ccc---)))wwwvvvvvvvvvvvvvvvXXXXXXvvvvvv;;;777+++666666[[[AAA%%%??????ccc&&& ;;;IIIIIIZZZllllll'''888888@@@~~~&&&ZZZ###bbb:::===VVV??????ccc||| +++;;;JJJJJJJJJJJJJJJJJJ&&&vvvvvvccc*********JJJJJJJJJJJJJJJJJJ'''%%%}}}bbbbbb}}}gggGGGvvvvvv\\\VVV桡~~~KKK~~~KKK~~~KKK<<<WWWWWWpppFFF mmm___aaaaaa<<<888sssUUU - - -ddd555ppp...ppp...111111eeekkkPPPjjjiii000ZZZuuu888'''vvveee$$$ \ No newline at end of file diff --git a/res/font3.toml b/res/font3.toml index 0132316..f6596a2 100644 --- a/res/font3.toml +++ b/res/font3.toml @@ -1,7 +1,11 @@ -border_color=192 192 192 -backgroud_color=255 255 255 -font_color=0 0 0 -border_width=2 -row=8 -column=32 -columnOfFinalRow=6 \ No newline at end of file +xOffset = 0 +yOffset = 0 +xSize = 22 +ySize = 31 +xCount = 32 +yCount = 7 +xStart = 0 +yStart = 0 +fillValue = 0xffffff +firstChar = 20 +pixelSize = 4 diff --git a/src/Block.cpp b/src/Block.cpp deleted file mode 100644 index ee07787..0000000 --- a/src/Block.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// -// Created by my on 2019/11/14. -// - -#include "Block.h" - -void Block::clear() { - -} - -void Block::addString(std::string str) { - -} - -void Block::addChar(unsigned char character) { - -} - -void Block::newLine() { - -} - -void Block::setBackgroundWithSingleColor(Color color) { - -} - -void Block::setBackground(Color *) { - -} - -void Block::setBackgroundWithSlowChangedColor(Color color1, Color color2, int modul) { - -} - -void Block::setNowX() { - -} - -void Block::setNowY() { - -} - -void Block::addNowX() { - -} - -void Block::addNowY() { - -} - -int Block::getNowx() { - return 0; -} - -int Block::getNowY() { - return 0; -} - -void Block::addString(std::string str, Font font) { - -} - -unsigned char *Block::getDisplayColor() { - return nullptr; -} diff --git a/src/Block.h b/src/Block.h deleted file mode 100644 index c0c9fc3..0000000 --- a/src/Block.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// Created by my on 2019/11/13. -// - -#ifndef TRE_BLOCK_H -#define TRE_BLOCK_H - -#include -#include -#include "Font.h" - -class Block { -public: - virtual void clear(); - virtual void addString(std::string str); - virtual void addString(std::string str, Font font); - virtual void addChar(unsigned char character); - virtual void newLine(); - virtual unsigned char * getDisplayColor(); - - - virtual void setBackgroundWithSingleColor(Color color); - virtual void setBackground(Color[]); - virtual void setBackgroundWithSlowChangedColor(Color color1, Color color2, int modul); - - - virtual void setNowX(); - virtual void setNowY(); - virtual void addNowX(); - virtual void addNowY(); - virtual int getNowx(); - virtual int getNowY(); -}; - -#endif //TRE_BLOCK_H diff --git a/src/Config.cpp b/src/Config.cpp deleted file mode 100644 index adfbc26..0000000 --- a/src/Config.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// -// Created by my on 2019/11/12. -// - -#include "Config.h" - - -Config::Config() { - init(); -} - -void Config::init() { - std::ifstream infile(CONFIG_FILE_PATH); - std::string line; - - std::getline(infile, line); - line = line.substr(BORDER_COLOR_STARTPOSITION); - border_color = readColor(line); - - std::getline(infile, line); - line = line.substr(BACKGROUND_COLOR_STARTPOSITION); - background_color = readColor(line); - - std::getline(infile, line); - line = line.substr(FONT_COLOR_STARTPOSITION); - font_color = readColor(line); - - std::getline(infile, line); - line = line.substr(BORDER_WIDTH_STARTPOSITION); - border_width = readInteger(line); - - std::getline(infile, line); - line = line.substr(ROW_STARTPOSITION); - row = readInteger(line); - - std::getline(infile, line); - line = line.substr(COLUMN_STARTPOSITION); - column = readInteger(line); - - std::getline(infile, line); - line = line.substr(COLUMN_OF_FINAL_ROW_STARTPOSITION); - column_of_finalRow = readInteger(line); -} - -int Config::readInteger(std::string line) { - int value; - std::istringstream iss(line); - - if(!(iss >> value)) { - std::cout << "failed when read interger from config" << std::endl; - } - - return value; -} - -Color Config::readColor(std::string line) { - int red, green, blue; - std::istringstream iss(line); - - if(!(iss >> red >> green >> blue)) { - std::cout << "failed when read color from config" << std::endl; - } - - Color color(red, green, blue); - return color; -} diff --git a/src/Config.h b/src/Config.h deleted file mode 100644 index a890ae4..0000000 --- a/src/Config.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// Created by my on 2019/11/13. -// - -#ifndef TRE_CONFIG_H -#define TRE_CONFIG_H - -#include -#include -#include -#include "Color.h" - -#define CONFIG_FILE_PATH "../res/font4.config" -#define BORDER_COLOR_STARTPOSITION 13 -#define BACKGROUND_COLOR_STARTPOSITION 16 -#define FONT_COLOR_STARTPOSITION 11 -#define BORDER_WIDTH_STARTPOSITION 13 -#define ROW_STARTPOSITION 4 -#define COLUMN_STARTPOSITION 7 -#define COLUMN_OF_FINAL_ROW_STARTPOSITION 17 - -class Config { -public: - Color border_color = Color(0, 0, 0); - Color background_color = Color(0, 0, 0); - Color font_color = Color(0, 0, 0); - int border_width; - int row; - int column; - int column_of_finalRow; - - Config(); - -private: - void init(); - - Color readColor(std::string line); - int readInteger(std::string line); -}; - - -#endif //TRE_CONFIG_H diff --git a/src/DritteFont.cpp b/src/DritteFont.cpp deleted file mode 100644 index 5b2466b..0000000 --- a/src/DritteFont.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// -// Created by my on 2019/11/11. -// - -#include "DritteFont.h" - -DritteFont::DritteFont(){ - readFont(); -} - -std::vector DritteFont::test() { - return loadBitmap(); -} - -std::vector> DritteFont::getCharacter(unsigned char character) { - return characters[character - FIRST_CHARACTER_INDEX]; -} - -void DritteFont::readFont() { - std::vector data = loadBitmap(); - Config config; - - int offset = DATA_OFFSET; - int row; - int column; - int i; - int j; - int size = getBitmapSize(data); // size = width * 10000 + height - int width = size / 10000; - int characterSize = getCharacterSize(data, config, width); // characterSize = width * 10000 + height - int characterWidth = characterSize / 10000; - int characterHeight = characterSize % 10000; - -// characters->resize(NUMBER_OF_CHARACTERS); - - for(i = 0; i < NUMBER_OF_CHARACTERS; i++) { - characters[i].resize(characterHeight); - for(j = 0; j < characterHeight; j++) { - characters[i][j].resize(characterWidth); - } - } - - offset = findNextStartOffset(data, offset, config); - for(row = 0; row < config.row - 1; row++) { - for(column = 0; column < config.column; column++) { - for(i = 0; i < characterHeight; i++) { - for(j = 0; j < characterWidth; j++) { - characters[row * config.column + column][i][j] = - data[offset + (i * width + j) * PIXEL_SIZE] != (char)config.background_color.red; - } - } - offset = findNextStartOffset(data, offset, config); - } - offset += characterHeight * width * PIXEL_SIZE; - offset = findNextStartOffset(data, offset, config); - } - - for(column = 0; column < config.column_of_finalRow; column++) { - for(i = 0; i < characterHeight; i++) { - for(j = 0; j < characterWidth; j++) { - characters[config.row * config.column + column][i][j] = - data[offset + (i * width + j) * PIXEL_SIZE] != (char)config.background_color.red; - } - } - offset = findNextStartOffset(data, offset, config); - } -} - -std::vector DritteFont::loadBitmap() { - std::ifstream ifstream; - ifstream.open(PATH_OF_FONT_BITMAP); - if(ifstream.is_open()) { - std::string str((std::istreambuf_iterator(ifstream)), std::istreambuf_iterator()); - std::vector data; - data.resize(str.size()); - for(int i = 0; i < str.size(); i++){ - data[i] = str[i]; - } - return data; - } - - std::cout << "read failed" << std::endl; - return std::vector(); -} - -int DritteFont::getBitmapSize(std::vector data) { - int width = 0; - int height = 0; - int offset = WIDTH_OFFSET; - - while(data[offset] != WIDTH_END_SIGNAL) { - width = width * 10 + data[offset++] - '0'; - } - offset++; - - while(data[offset] != HEIGHT_END_SIGNAL) { - height = height * 10 + data[offset++] - '0'; - } - - return width * 10000 + height; -} - -int DritteFont::getCharacterSize(std::vector data, Config config, int width) { - int characterWidth = 0; - int characterHeight = 0; - int tempOffset; - - int offset = DATA_OFFSET; - int counter = 0; - - // because the red green blue values of border color is equal, - // so i simple the method, falls the values is different, - // the method must be modified - for(; offset < data.size(); offset++) { - - if(((unsigned int)data[offset] & 0xff) == config.border_color.red) // only use red value because the red, green and blue values are equal. - counter++; - - if(((unsigned int)data[offset] & 0xff) != config.border_color.red) { - if(counter > 0 && counter < config.border_width * 3 + DEVIATION_NUMBER) { // mal 3 because color has 3 values, red, green and blue values. - tempOffset = offset; - while (((unsigned int)data[tempOffset++] & 0xff) != config.border_color.red) { - characterWidth++; - } - tempOffset = offset; - while (((unsigned int)data[tempOffset] & 0xff) != config.border_color.red) { - characterHeight++; - tempOffset += width * PIXEL_SIZE; - } - - return characterWidth / PIXEL_SIZE * 10000 + characterHeight; - } - - counter = 0; - } - } - - std::cout << "not get chacter size\n" << std::endl; - return 0; -} - - -int DritteFont::findNextStartOffset(std::vector data, int offset, Config config) { - - int counter = 0; - - for(; offset < data.size(); offset += PIXEL_SIZE) { - - if(((unsigned int)data[offset] & 0xff) == config.border_color.red) // only use red value because the red, green and blue values are equal. - counter++; - - if(((unsigned int)data[offset] & 0xff) != config.border_color.red) { - if(counter > 0 && counter < config.border_width + DEVIATION_NUMBER) { // mal 3 because color has 3 values, red, green and blue values. - return offset; - } - - counter = 0; - } - } - std::cout << "not find offset\n" << std::endl; - return 0; -} \ No newline at end of file diff --git a/src/DritteFont.h b/src/DritteFont.h deleted file mode 100644 index 4d61b66..0000000 --- a/src/DritteFont.h +++ /dev/null @@ -1,42 +0,0 @@ -// -// Created by my on 2019/11/13. -// - -#ifndef TRE_DRITTEFONT_H -#define TRE_DRITTEFONT_H - - -#include -#include -#include -#include "Config.h" -#include "Font.h" - -#define FIRST_CHARACTER_INDEX 25 -#define NUMBER_OF_CHARACTERS 262 -#define DATA_OFFSET 0xf; -#define WIDTH_OFFSET 3; -#define WIDTH_END_SIGNAL 0x20 -#define HEIGHT_END_SIGNAL 0x0A -#define PATH_OF_FONT_BITMAP "../res/font4.ppm" -#define DEVIATION_NUMBER 10 -#define PIXEL_SIZE 3 - -class DritteFont : public Font{ -public: - DritteFont(); - - std::vector test(); - std::vector> getCharacter(unsigned char character) override; - std::vector> characters[NUMBER_OF_CHARACTERS]; - -private: - void readFont(); - - std::vector loadBitmap(); - int getBitmapSize(std::vector data); - int getCharacterSize(std::vector data, Config config, int width); - int findNextStartOffset(std::vector data, int offset, Config config); -}; - -#endif //TRE_DRITTEFONT_H diff --git a/src/Font.cpp b/src/Font.cpp index f5b302c..14a6b72 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -1,9 +1,103 @@ // -// Created by my on 2019/11/14. +// Copyright (c) 2019 Julian Hinxlage. All rights reserved. // #include "Font.h" +#include -std::vector> Font::getCharacter(unsigned char character) { - return std::vector>(); +Font::Font() { + xOffset = 0; + yOffset = 0; + xSize = 0; + ySize = 0; + xCount = 0; + yCount = 0; + xStart = 0; + yStart = 0; + fillValue = 0; + firstChar = ' '; } + +Font::Font(const std::string &file, const std::string &configFile) : Font() { + load(file, configFile); +// std::vector tempString; + +// if(std::regex_match(file, std::regex("(.+)\\.ppm$"))) { +// loadPPMFile(file, configFile); +// } else { +// std::cout << "heloo1" << std::endl; +// load(file, configFile); +// } + +} + +void Font::load(const std::string &file, const std::string &configFile) { + bitmap.load(file); + auto config = cpptoml::parse_file(configFile); + xOffset = config->get_as("xOffset").value_or(0); + yOffset = config->get_as("yOffset").value_or(0); + xSize = config->get_as("xSize").value_or(0); + ySize = config->get_as("ySize").value_or(0); + xCount = config->get_as("xCount").value_or(0); + yCount = config->get_as("yOffset").value_or(0); + xStart = config->get_as("xStart").value_or(0); + yStart = config->get_as("yStart").value_or(0); + fillValue = config->get_as("fillValue").value_or(0); + firstChar = (char)config->get_as("firstChar").value_or(0); + pixelSize = config->get_as("pixelSize").value_or(0); + gap = config->get_as("gap").value_or(-1); +} + +int Font::width() { + return xSize; +} + +int Font::height() { + return ySize; +} + +bool Font::getPixel(char character, int x, int y) { + //index of character(x and y) + int index = (character - firstChar); + + if(gap != -1){ + if (index >= gap){ + index++; + } + } + + int xIndex = index % xCount; + int yIndex = index / xCount; + + if(index < 0){ + yIndex--; + xIndex += xCount; + } + + //character index to pixel index conversion + int xPos = xIndex * (xSize + xOffset) + xStart; + int yPos = yIndex * (ySize + yOffset) + yStart; + + return bitmap.getPixel((xPos + x) * pixelSize, (yPos + y) * pixelSize) == fillValue; +} + +bool** Font::getCharacter(unsigned char character) { + int fontHeight = height(); + int fontWidth = width(); + bool **bitmap_character; + + bitmap_character = (bool**)malloc(fontHeight * sizeof(bool*)); + for (int i = 0; i < fontHeight; i++) { + bitmap_character[i] = (bool*)malloc(fontWidth * sizeof(bool)); + for (int j = 0; j < fontWidth; j++) { + bitmap_character[i][j] = getPixel(character, j, i); + } + } + + return bitmap_character; +} + +void Font::loadPPMFile(const std::string &file, const std::string &configFile) { + +} + diff --git a/src/Font.h b/src/Font.h index 9f00af6..71e5e17 100644 --- a/src/Font.h +++ b/src/Font.h @@ -1,16 +1,52 @@ // -// Created by my on 2019/11/14. +// Copyright (c) 2019 Julian Hinxlage. All rights reserved. // #ifndef TEXTRENDERER_FONT_H #define TEXTRENDERER_FONT_H +#include "Bitmap.h" -#include - -class Font { +/** + * @author: Julian Hinxlage + * @since: v0.0.0 + * @brief: this class provides pixel access based on characters + */ +class Font{ public: - virtual std::vector> getCharacter(unsigned char character); + Bitmap bitmap; + + //space between characters + int xOffset; + int yOffset; + + //size of a character + int xSize; + int ySize; + + //count of characters per row + int xCount; + //count of rows + int yCount; + + //pixel offset of first character + int xStart; + int yStart; + + unsigned int fillValue; + char firstChar; + int pixelSize; + int gap; + + Font(); + explicit Font(const std::string &file, const std::string &configFile); + void load(const std::string &file, const std::string &configFile); + void loadPPMFile(const std::string &file, const std::string &configFile); + bool** getCharacter(unsigned char character); + + int width(); + int height(); + bool getPixel(char character, int x, int y); }; diff --git a/src/MainFont.cpp b/src/MainFont.cpp deleted file mode 100644 index a10ef3b..0000000 --- a/src/MainFont.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// -// Copyright (c) 2019 Julian Hinxlage. All rights reserved. -// - -#include "MainFont.h" -#include - -MainFont::MainFont() { - xOffset = 0; - yOffset = 0; - xSize = 0; - ySize = 0; - xCount = 0; - yCount = 0; - xStart = 0; - yStart = 0; - fillValue = 0; - firstChar = ' '; -} - -MainFont::MainFont(const std::string &file, const std::string &configFile) : MainFont() { - load(file, configFile); -} - -void MainFont::load(const std::string &file, const std::string &configFile) { - bitmap.load(file); - auto config = cpptoml::parse_file(configFile); - xOffset = config->get_as("xOffset").value_or(0); - yOffset = config->get_as("yOffset").value_or(0); - xSize = config->get_as("xSize").value_or(0); - ySize = config->get_as("ySize").value_or(0); - xCount = config->get_as("xCount").value_or(0); - yCount = config->get_as("yOffset").value_or(0); - xStart = config->get_as("xStart").value_or(0); - yStart = config->get_as("yStart").value_or(0); - fillValue = config->get_as("fillValue").value_or(0); - firstChar = (char)config->get_as("firstChar").value_or(0); - pixelSize = config->get_as("pixelSize").value_or(0); - gap = config->get_as("gap").value_or(-1); -} - -int MainFont::width() { - return xSize; -} - -int MainFont::height() { - return ySize; -} - -bool MainFont::getPixel(char character, int x, int y) { - //index of character(x and y) - int index = (character - firstChar); - - if(gap != -1){ - if (index >= gap){ - index++; - } - } - - int xIndex = index % xCount; - int yIndex = index / xCount; - - if(index < 0){ - yIndex--; - xIndex += xCount; - } - - //character index to pixel index conversion - int xPos = xIndex * (xSize + xOffset) + xStart; - int yPos = yIndex * (ySize + yOffset) + yStart; - - return bitmap.getPixel((xPos + x) * pixelSize, (yPos + y) * pixelSize) == fillValue; -} - -std::vector> MainFont::getCharacter(unsigned char character) { - - std::vector> bitmap_character; - int fontHeight = height(); - int fontWidth = width(); - - bitmap_character.resize(fontHeight); - for (int i = 0; i < fontHeight; i++) { - bitmap_character.resize(fontWidth); - for (int j = 0; j < fontWidth; j++) { - bitmap_character[i][j] = getPixel(character, j, i); - } - } - - return bitmap_character; -} - diff --git a/src/MainFont.h b/src/MainFont.h deleted file mode 100644 index b30ad94..0000000 --- a/src/MainFont.h +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) 2019 Julian Hinxlage. All rights reserved. -// - -#ifndef TEXTRENDERER_MAINFONT_H -#define TEXTRENDERER_MAINFONT_H - -#include "Bitmap.h" -#include "Font.h" - -/** - * @author: Julian Hinxlage - * @since: v0.0.0 - * @brief: this class provides pixel access based on characters - */ -class MainFont : public Font{ -public: - Bitmap bitmap; - - //space between characters - int xOffset; - int yOffset; - - //size of a character - int xSize; - int ySize; - - //count of characters per row - int xCount; - //count of rows - int yCount; - - //pixel offset of first character - int xStart; - int yStart; - - unsigned int fillValue; - char firstChar; - int pixelSize; - int gap; - - MainFont(); - explicit MainFont(const std::string &file, const std::string &configFile); - void load(const std::string &file, const std::string &configFile); - std::vector> getCharacter(unsigned char character) override; - - int width(); - int height(); - bool getPixel(char character, int x, int y); -}; - - -#endif //TEXTRENDERER_MAINFONT_H diff --git a/src/TextRenderer.cpp b/src/TextRenderer.cpp new file mode 100644 index 0000000..c662dc4 --- /dev/null +++ b/src/TextRenderer.cpp @@ -0,0 +1,100 @@ +// +// Created by my on 2019/11/16. +// +#include "TextRenderer.h" + +TextRenderer::TextRenderer(vkvm::Color backgroundColor, vkvm::Color fontColor) + : backgroundColor(backgroundColor), fontColor(fontColor) { + windowWidth = vkvm::getWidth(); + fontWidth = font.width(); + fontHeight = font.height(); +} + +void TextRenderer::update(std::string text) { + int startX; + int startY; + int i; + int fontNumbersInOneLine = windowWidth / fontWidth; + bool** characterBitmap; + + std::cout << "get window's width from shared memery: (" << windowWidth << ")" << std::endl; + + std::string newText = vkvm::getText(); + + std::cout << "get text:" << newText << std::endl; + + for(i = 0; i < newText.size(); i++) { + if(i > oldText.size() || oldText[i] != newText[i]) { + startX = i % fontNumbersInOneLine * fontWidth; + startY = i / fontNumbersInOneLine * fontHeight; + characterBitmap = getCharacter(newText[i], font); + fontProcessing(characterBitmap); + translateToSharedMemory(characterBitmap, startX, startY); + } + } +} + +void TextRenderer::setOldText(std::string text) { + +} + +bool** TextRenderer::getCharacter(unsigned char character, Font font) { + int fontHeight = font.height(); + int fontWidth = font.width(); + bool **bitmap_character; + + bitmap_character = (bool**)malloc(fontHeight * sizeof(bool*)); + for (int i = 0; i < fontHeight; i++) { + bitmap_character[i] = (bool*)malloc(fontWidth * sizeof(bool)); + for (int j = 0; j < fontWidth; j++) { + bitmap_character[i][j] = font.getPixel(character, j, i); + } + } + + return bitmap_character; +} + +void TextRenderer::fontProcessing(bool **characterBitmap) { + if(isBold()) { + + } + + if(isItalics()) { + + } + + if(isUnderline()) { + + } +} + +bool TextRenderer::isBold() { + return type & BOLD != 0; +} + +bool TextRenderer::isItalics() { + return type & ITALICS != 0; +} + +bool TextRenderer::isUnderline() { + return type & UNDERLINE != 0; +} + +void TextRenderer::translateToSharedMemory(bool **characterBitmap, int startX, int startY) { + int x, y; + int currentX = startX; + int currentY = startY; + + for(y = 0; y < fontHeight; y++) { + for(x = 0; x < fontWidth; x++) { + if(characterBitmap[y + startY][x + startX]) + setPixel(currentX, currentY, fontColor); + else + setPixel(currentX, currentY, backgroundColor); + currentX++; + } + currentX = startX; + currentY++; + } +} + diff --git a/src/TextRenderer.h b/src/TextRenderer.h new file mode 100644 index 0000000..8d3679b --- /dev/null +++ b/src/TextRenderer.h @@ -0,0 +1,49 @@ +// +// Created by my on 2019/11/16. +// + +#ifndef TEXTRENDERER_TEXTRENDERER_H +#define TEXTRENDERER_TEXTRENDERER_H + +#define BOLD 0b001 +#define ITALICS 0b010 +#define UNDERLINE 0b100 + +#include +#include +#include +#include +#include "Font.h" + +/** + * @author: Yajie Qi, Shaohua Tong + * @since: v0.0.0 + * @brief: gets a string from the Shared Memory and converts the text into a bitmap-array. + */ +class TextRenderer { +public: + TextRenderer(vkvm::Color defaultBackgroundColor, vkvm::Color fontColor); + + void update(std::string text); + void setOldText(std::string text); + bool** getCharacter(unsigned char character, Font font); + +private: + std::string oldText; + vkvm::Color backgroundColor; + vkvm::Color fontColor; + vkvm::FontType fontType = vkvm::getFont(); + Font font = Font(fontType.getName(), "../res/font3.toml"); + int type; + int windowWidth; + int fontWidth; + int fontHeight; + bool isBold(); + bool isItalics(); + bool isUnderline(); + void fontProcessing(bool **characterBitmap); + void translateToSharedMemory(bool **characterBitmap, int startX, int startY); +}; + + +#endif //TEXTRENDERER_TEXTRENDERER_H