loading only a subset of characters from fonts

This commit is contained in:
devZoGok
2021-11-01 19:51:47 +02:00
parent c8d0fd11f0
commit 2adbb4b5e4
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -15,8 +15,8 @@
using namespace std;
namespace vb01{
Text::Text(string fontPath, wstring entry){
initFont(fontPath);
Text::Text(string fontPath, wstring entry, u16 firstChar, u16 lastChar){
initFont(fontPath, firstChar, lastChar);
setText(entry);
}
@@ -25,7 +25,7 @@ namespace vb01{
glDeleteBuffers(1, &VBO);
}
void Text::initFont(string fontPath){
void Text::initFont(string fontPath, u16 firstChar, u16 lastChar){
FT_Library ft;
FT_Face face;
if(FT_Init_FreeType(&ft))
@@ -37,7 +37,7 @@ namespace vb01{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
for(u16 i = 0; i < u16(0 - 1); i++){
for(u16 i = firstChar; i < lastChar; i++){
if(FT_Load_Char(face, i, FT_LOAD_RENDER)){
cout << "Could not load glyph\n";
continue;
+2 -2
View File
@@ -21,7 +21,7 @@ namespace vb01{
Vector2 size, bearing;
};
Text(std::string, std::wstring);
Text(std::string, std::wstring, u16 = 0, u16 = 256);
~Text();
void update();
void setText(std::wstring);
@@ -38,7 +38,7 @@ namespace vb01{
inline void setMaterial(Material *mat){this->material = mat;}
Glyph* getGlyph(u16);
private:
void initFont(std::string);
void initFont(std::string, u16, u16);
void prepareGlyphs(Glyph, Vector2);
void renderGlyphs(Glyph, float[], u32);