added Unifont

This commit is contained in:
Julian Hinxlage 2020-01-07 15:05:32 +01:00
parent ecdbb30d3e
commit 9b593ce231
4 changed files with 21 additions and 3 deletions

View File

@ -2,6 +2,7 @@
#include "internal.hpp" #include "internal.hpp"
#include "vkvm.hpp" #include "vkvm.hpp"
#include <thread> #include <thread>
#include <iostream>
int cursorPosX = 0; int cursorPosX = 0;
int cursorPosY = 0; int cursorPosY = 0;

BIN
res/font4.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

12
res/font4.toml Normal file
View File

@ -0,0 +1,12 @@
xOffset = 6
yOffset = 2
xSize = 10
ySize = 14
xCount = 255
yCount = 255
xStart = 33
yStart = 65
fillValue = 0
firstChar = 0
pixelSize = 1
invertedColors = 0

View File

@ -51,13 +51,18 @@ int Bitmap::getBitsPerPixel() {
unsigned int Bitmap::getPixel(int x, int y) { unsigned int Bitmap::getPixel(int x, int y) {
unsigned int pixel = 0; unsigned int pixel = 0;
if(bpp == 1){
int index = (getHeight() - 1 - y) * getWidth() + x;
char *ptr = getData() + (index / 8);
bool value = (ptr[0] >> (7 - (index % 8))) & 1u;
return (int)value;
}
char *ptr = getData() + ((getHeight() - 1 - y) * getWidth() + x) * (getBitsPerPixel() / 8); char *ptr = getData() + ((getHeight() - 1 - y) * getWidth() + x) * (getBitsPerPixel() / 8);
for(int i = 0; i < getBitsPerPixel() / 8;i++){ for(int i = 0; i < getBitsPerPixel() / 8;i++){
auto value = reinterpret_cast<char*>(&pixel)+i; auto value = reinterpret_cast<char*>(&pixel)+i;
*value = ptr[i]; *value = ptr[i];
} }
if(pixel != 0){
return pixel;
}
return pixel; return pixel;
} }