//#include "add.h" #include "Bitmap.h" #include "Font.h" #include bool isQuit(std::string command); /** * @author: Julian Hinxlage * @since: v0.0.0 * @brief: An image is loaded and used as a font. * A string is converted and displayed in the console. * Currently only to test. */ #include "TextRenderer.h" int main() { vkvm::initialize(0); std::string currentText; /*************************set back to shared memory(only for test)********************************************/ vkvm::Color fontColor1(0, 0, 0); vkvm::Color backgroudColor1(255, 255, 255); Font font1("../res/font3.bmp", "../res/font3.toml"); vkvm::setFont(vkvm::FontType(3, "font", font1.height(), font1.width())); vkvm::setForegroundColor(fontColor1); vkvm::setBackgroundColor(backgroudColor1); /**************************get text and font from shared memory*******************************************/ std::string fontResourcePath = "../res/font" + std::to_string(vkvm::getFont().getId()) + ".bmp"; std::string fontConfigureFilePath = "../res/font" + std::to_string(vkvm::getFont().getId()) + ".toml"; Font font = Font(fontResourcePath, fontConfigureFilePath); TextRenderer textRenderer(vkvm::Color(255, 255, 255), vkvm::Color(0, 0, 0). font); vkvm::Color fontColor = vkvm::getForegroundColor(); vkvm::Color backgroundColor = vkvm::getBackgroundColor(); /*********************************************************************/ std::string command; std::cout << "TextRender: " << std::endl; std::getline(std::cin, command); while(!isQuit(command)) { if(command.compare("update")) { vkvm::setText("Hello World."); currentText = vkvm::getText(); textRenderer.update(currentText); } 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; }