mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
loading only a subset of characters from fonts
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user