+ second font
This commit is contained in:
parent
4b1afac94d
commit
566bfee91e
|
@ -12,7 +12,7 @@
|
||||||
* Currently only to test.
|
* Currently only to test.
|
||||||
*/
|
*/
|
||||||
int main() {
|
int main() {
|
||||||
Font font("../res/font.bmp","../res/font.toml");
|
Font font("../res/font1.bmp","../res/font1.toml");
|
||||||
|
|
||||||
std::string str;
|
std::string str;
|
||||||
std::cout << "string to draw: ";
|
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
|
yCount = 4
|
||||||
xStart = 1
|
xStart = 1
|
||||||
yStart = 2
|
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++){
|
for(int i = 0; i < getBitsPerPixel() / 8;i++){
|
||||||
*((char*)&pixel+i) = ptr[i];
|
*((char*)&pixel+i) = ptr[i];
|
||||||
}
|
}
|
||||||
|
if(pixel != 0){
|
||||||
|
return pixel;
|
||||||
|
}
|
||||||
return pixel;
|
return pixel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ Font::Font() {
|
||||||
xStart = 0;
|
xStart = 0;
|
||||||
yStart = 0;
|
yStart = 0;
|
||||||
fillValue = 0;
|
fillValue = 0;
|
||||||
|
firstChar = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
Font::Font(const std::string &file, const std::string &configFile) : Font() {
|
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);
|
xStart = config->get_as<int>("xStart").value_or(0);
|
||||||
yStart = config->get_as<int>("yStart").value_or(0);
|
yStart = config->get_as<int>("yStart").value_or(0);
|
||||||
fillValue = config->get_as<unsigned int>("fillValue").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() {
|
int Font::width() {
|
||||||
|
@ -45,7 +47,7 @@ int Font::height() {
|
||||||
|
|
||||||
bool Font::getPixel(char character, int x, int y) {
|
bool Font::getPixel(char character, int x, int y) {
|
||||||
//index of character(x and y)
|
//index of character(x and y)
|
||||||
int index = (character - ' ');
|
int index = (character - firstChar);
|
||||||
int xIndex = index % xCount;
|
int xIndex = index % xCount;
|
||||||
int yIndex = index / xCount;
|
int yIndex = index / xCount;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ public:
|
||||||
int yStart;
|
int yStart;
|
||||||
|
|
||||||
unsigned int fillValue;
|
unsigned int fillValue;
|
||||||
|
char firstChar;
|
||||||
|
|
||||||
Font();
|
Font();
|
||||||
explicit Font(const std::string &file, const std::string &configFile);
|
explicit Font(const std::string &file, const std::string &configFile);
|
||||||
|
|
Loading…
Reference in New Issue