+ second font
This commit is contained in:
parent
4b1afac94d
commit
566bfee91e
|
@ -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: ";
|
||||
|
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
@ -6,4 +6,5 @@ xCount = 18
|
|||
yCount = 4
|
||||
xStart = 1
|
||||
yStart = 2
|
||||
fillValue = 0xffffff
|
||||
fillValue = 0xffffff
|
||||
firstChar = 32
|
Binary file not shown.
After Width: | Height: | Size: 384 KiB |
|
@ -0,0 +1,10 @@
|
|||
xOffset = 2
|
||||
yOffset = 16
|
||||
xSize = 6
|
||||
ySize = 6
|
||||
xCount = 16
|
||||
yCount = 6
|
||||
xStart = 1
|
||||
yStart = 2
|
||||
fillValue = 0xffffff
|
||||
firstChar = 33
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<int>("xStart").value_or(0);
|
||||
yStart = config->get_as<int>("yStart").value_or(0);
|
||||
fillValue = config->get_as<unsigned int>("fillValue").value_or(0);
|
||||
firstChar = (char)config->get_as<int>("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;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ public:
|
|||
int yStart;
|
||||
|
||||
unsigned int fillValue;
|
||||
char firstChar;
|
||||
|
||||
Font();
|
||||
explicit Font(const std::string &file, const std::string &configFile);
|
||||
|
|
Loading…
Reference in New Issue