implemented font reader

This commit is contained in:
devZoGok
2022-03-02 20:24:04 +02:00
parent 77e00b0a64
commit 35ccac66b9
8 changed files with 104 additions and 17 deletions
+40
View File
@@ -0,0 +1,40 @@
#include "fontReader.h"
#include "fontAsset.h"
#include <iostream>
#include "glad.h"
#include <glfw3.h>
using namespace std;
namespace vb01{
FontReader *fontReader = nullptr;
FontReader* FontReader::getSingleton(){
if(!fontReader)
fontReader = new FontReader();
return fontReader;
}
FontReader::FontReader() : AbstractAssetReader(){
if(FT_Init_FreeType(&ft))
cout << "Couldn't init Freetype\n";
}
Asset* FontReader::readAsset(string path){
if(FT_New_Face(ft, path.c_str(), 0, &face))
cout << "Could not load font\n";
FT_Set_Pixel_Sizes(face, pixelWidth, pixelHeight);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
FontAsset *font = new FontAsset;
font->path = path;
font->face = face;
return font;
}
}