mirror of
https://github.com/ApfelTeeSaft/vb01.git
synced 2026-08-26 19:33:45 +00:00
41 lines
768 B
C++
41 lines
768 B
C++
#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;
|
|
}
|
|
}
|