added profont-IIx font

This commit is contained in:
Julian Hinxlage 2019-11-19 13:28:48 +01:00
parent 69ed7aea40
commit 26c7fa69c4
5 changed files with 23 additions and 3 deletions

View File

@ -1,4 +1,3 @@
#include "add.h"
#include "Bitmap.h"
#include "Font.h"
@ -12,7 +11,8 @@
* Currently only to test.
*/
int main() {
Font font("../res/font2.bmp","../res/font2.toml");
Font font("../res/profont-IIx.bmp","../res/profont-IIx.toml");
//Font font("../res/font2.bmp","../res/font2.toml");
std::string str;
std::cout << "string to draw: ";

BIN
res/profont-IIx.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 KiB

12
res/profont-IIx.toml Normal file
View File

@ -0,0 +1,12 @@
xOffset = 6
yOffset = 6
xSize = 18
ySize = 27
xCount = 32
yCount = 9
xStart = 7
yStart = 9
fillValue = 4294967295
firstChar = 25
pixelSize = 1
invertedColors = 1

View File

@ -37,6 +37,7 @@ void Font::load(const std::string &file, const std::string &configFile) {
firstChar = (char)config->get_as<int>("firstChar").value_or(0);
pixelSize = config->get_as<int>("pixelSize").value_or(0);
gap = config->get_as<int>("gap").value_or(-1);
invertedColors = config->get_as<int>("invertedColors").value_or(0);
}
int Font::width() {
@ -69,6 +70,11 @@ bool Font::getPixel(char character, int x, int y) {
int xPos = xIndex * (xSize + xOffset) + xStart;
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;
}else{
return value;
}
}

View File

@ -38,6 +38,8 @@ public:
int pixelSize;
int gap;
bool invertedColors;
Font();
explicit Font(const std::string &file, const std::string &configFile);
void load(const std::string &file, const std::string &configFile);