diff --git a/main/main.cpp b/main/main.cpp index 057c501..6e06b4e 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -12,7 +12,7 @@ * Currently only to test. */ int main() { - Font font("../res/font.bmp","../res/font.toml"); + Font font("../res/font1.bmp","../res/font1.toml"); std::string str; std::cout << "string to draw: "; diff --git a/res/font.bmp b/res/font1.bmp similarity index 100% rename from res/font.bmp rename to res/font1.bmp diff --git a/res/font.toml b/res/font1.toml similarity index 71% rename from res/font.toml rename to res/font1.toml index b56bd8a..f0eabc5 100644 --- a/res/font.toml +++ b/res/font1.toml @@ -6,4 +6,5 @@ xCount = 18 yCount = 4 xStart = 1 yStart = 2 -fillValue = 0xffffff \ No newline at end of file +fillValue = 0xffffff +firstChar = 32 diff --git a/res/font2.bmp b/res/font2.bmp new file mode 100644 index 0000000..1962db2 Binary files /dev/null and b/res/font2.bmp differ diff --git a/res/font2.toml b/res/font2.toml new file mode 100644 index 0000000..4720c41 --- /dev/null +++ b/res/font2.toml @@ -0,0 +1,10 @@ +xOffset = 2 +yOffset = 16 +xSize = 6 +ySize = 6 +xCount = 16 +yCount = 6 +xStart = 1 +yStart = 2 +fillValue = 0xffffff +firstChar = 33 diff --git a/src/Bitmap.cpp b/src/Bitmap.cpp index a7fc8e8..49968c1 100644 --- a/src/Bitmap.cpp +++ b/src/Bitmap.cpp @@ -56,5 +56,8 @@ unsigned int Bitmap::getPixel(int x, int y) { for(int i = 0; i < getBitsPerPixel() / 8;i++){ *((char*)&pixel+i) = ptr[i]; } + if(pixel != 0){ + return pixel; + } return pixel; } diff --git a/src/Font.cpp b/src/Font.cpp index 9674f4a..83d7dc7 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -15,6 +15,7 @@ Font::Font() { xStart = 0; yStart = 0; fillValue = 0; + firstChar = ' '; } Font::Font(const std::string &file, const std::string &configFile) : Font() { @@ -33,6 +34,7 @@ void Font::load(const std::string &file, const std::string &configFile) { 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); } int Font::width() { @@ -45,7 +47,7 @@ int Font::height() { bool Font::getPixel(char character, int x, int y) { //index of character(x and y) - int index = (character - ' '); + int index = (character - firstChar); int xIndex = index % xCount; int yIndex = index / xCount; diff --git a/src/Font.h b/src/Font.h index 8a7d3f9..3a1a482 100644 --- a/src/Font.h +++ b/src/Font.h @@ -29,6 +29,7 @@ public: int yStart; unsigned int fillValue; + char firstChar; Font(); explicit Font(const std::string &file, const std::string &configFile);