reading nonlatin characters

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent 406d9b9f2b
commit 75d6273219
2 changed files with 16 additions and 16 deletions
+11 -11
View File
@@ -13,7 +13,7 @@
using namespace std;
namespace vb01{
Text::Text(string fontPath, string entry){
Text::Text(string fontPath, wstring entry){
initFont(fontPath);
setText(entry);
}
@@ -69,7 +69,11 @@ namespace vb01{
float advanceOffset = 0;
for(int i = 0; i < entry.length(); i++){
Glyph glyph = getGlyph(entry[i]);
Glyph *glyphPtr = getGlyph(entry[i]);
if(!glyphPtr)
continue;
Glyph glyph = *glyphPtr;
prepareGlyphs(glyph, advanceOffset);
advanceOffset += glyph.size.x + glyph.bearing.x;
}
@@ -101,7 +105,7 @@ namespace vb01{
glDrawArrays(GL_TRIANGLES, 0, 6);
}
void Text::setText(string text){
void Text::setText(wstring text){
this->entry = text;
glGenVertexArrays(1, &VAO);
@@ -115,15 +119,11 @@ namespace vb01{
glBindVertexArray(0);
}
Text::Glyph Text::getGlyph(char ch){
Glyph glyph;
for(Glyph g : characters)
Text::Glyph* Text::getGlyph(u16 ch){
Glyph *glyph = nullptr;
for(Glyph &g : characters)
if(g.ch == ch)
glyph = g;
glyph = &g;
return glyph;
}
float Text::getCharWidth(char c){
return getGlyph(c).size.x * scale;
}
}