parent
b920c95c8c
commit
f9aa3e35b0
|
@ -17,6 +17,8 @@ bool isQuit(std::string command);
|
||||||
#include "TextRenderer.h"
|
#include "TextRenderer.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
vkvm::initialize(0);
|
||||||
|
|
||||||
Font font("../res/font1.bmp", "../res/font1.toml");
|
Font font("../res/font1.bmp", "../res/font1.toml");
|
||||||
|
|
||||||
std::string oldText;
|
std::string oldText;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
xOffset = 0
|
xOffset = 6
|
||||||
yOffset = 0
|
yOffset = 6
|
||||||
xSize = 22
|
xSize = 18
|
||||||
ySize = 31
|
ySize = 27
|
||||||
xCount = 32
|
xCount = 32
|
||||||
yCount = 7
|
yCount = 9
|
||||||
xStart = 0
|
xStart = 7
|
||||||
yStart = 0
|
yStart = 9
|
||||||
fillValue = 0xffffff
|
fillValue = 4294967295
|
||||||
firstChar = 20
|
firstChar = 25
|
||||||
pixelSize = 4
|
pixelSize = 1
|
||||||
|
invertedColors = 1
|
||||||
|
|
35
src/Font.cpp
35
src/Font.cpp
|
@ -20,15 +20,6 @@ Font::Font() {
|
||||||
|
|
||||||
Font::Font(const std::string &file, const std::string &configFile) : Font() {
|
Font::Font(const std::string &file, const std::string &configFile) : Font() {
|
||||||
load(file, configFile);
|
load(file, configFile);
|
||||||
// std::vector<std::string> 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) {
|
void Font::load(const std::string &file, const std::string &configFile) {
|
||||||
|
@ -46,6 +37,7 @@ void Font::load(const std::string &file, const std::string &configFile) {
|
||||||
firstChar = (char)config->get_as<int>("firstChar").value_or(0);
|
firstChar = (char)config->get_as<int>("firstChar").value_or(0);
|
||||||
pixelSize = config->get_as<int>("pixelSize").value_or(0);
|
pixelSize = config->get_as<int>("pixelSize").value_or(0);
|
||||||
gap = config->get_as<int>("gap").value_or(-1);
|
gap = config->get_as<int>("gap").value_or(-1);
|
||||||
|
invertedColors = config->get_as<int>("invertedColors").value_or(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Font::width() {
|
int Font::width() {
|
||||||
|
@ -78,26 +70,11 @@ bool Font::getPixel(char character, int x, int y) {
|
||||||
int xPos = xIndex * (xSize + xOffset) + xStart;
|
int xPos = xIndex * (xSize + xOffset) + xStart;
|
||||||
int yPos = yIndex * (ySize + yOffset) + yStart;
|
int yPos = yIndex * (ySize + yOffset) + yStart;
|
||||||
|
|
||||||
return bitmap.getPixel((xPos + x) * pixelSize, (yPos + y) * pixelSize) == fillValue;
|
bool value = bitmap.getPixel((xPos + x) * pixelSize, (yPos + y) * pixelSize) == fillValue;
|
||||||
}
|
if(invertedColors){
|
||||||
|
return !value;
|
||||||
bool** Font::getCharacter(unsigned char character) {
|
}else{
|
||||||
int fontHeight = height();
|
return value;
|
||||||
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) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,11 @@ public:
|
||||||
int pixelSize;
|
int pixelSize;
|
||||||
int gap;
|
int gap;
|
||||||
|
|
||||||
|
bool invertedColors;
|
||||||
|
|
||||||
Font();
|
Font();
|
||||||
explicit Font(const std::string &file, const std::string &configFile);
|
explicit Font(const std::string &file, const std::string &configFile);
|
||||||
void load(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 width();
|
||||||
int height();
|
int height();
|
||||||
|
|
Loading…
Reference in New Issue