automatically get correct float size for curve buffer

This commit is contained in:
jrkb 2023-04-12 13:57:44 +02:00
parent ee47b7649a
commit 5d3dbc075c

View file

@ -337,7 +337,6 @@ class Font {
continue; continue;
} }
if(glyphs.count(charcode) != 0){ if(glyphs.count(charcode) != 0){
//cout << "but count is not 0?" << endl;
continue; continue;
} }
@ -426,7 +425,7 @@ class Font {
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,
0, 0,
GL_RG32F, GL_RG32F,
bufferCurvesSize * 2, bufferCurvesSize * sizeof(glm::highp_f32),
1, 1,
0, 0,
GL_RG, GL_RG,
@ -918,23 +917,24 @@ class Font {
float dilation = 0; float dilation = 0;
}; };
static std::unique_ptr <Font> loadFont(FT_Library & library, const std::string & filename, float worldSize = 1.0f, bool hinting = false){ static std::shared_ptr <Font> loadFont(FT_Library & library, const std::string & filename, float worldSize = 1.0f, bool hinting = false){
std::string error; std::string error;
FT_Face face = Font::loadFace(library, filename, error); FT_Face face = Font::loadFace(library, filename, error);
if(error != ""){ if(error != ""){
std::cerr << "[font] failed to load " << filename << ": " << error << std::endl; std::cerr << "[font] failed to load " << filename << ": " << error << std::endl;
return std::unique_ptr <Font>{}; return std::shared_ptr <Font>{};
} }
return std::make_unique <Font>(face, worldSize, hinting); return std::make_shared <Font>(face, worldSize, hinting);
} }
static void tryUpdateMainFont(FT_Library & library, static void tryUpdateMainFont(FT_Library & library,
const std::string & filename, const std::string & filename,
const string & mainText, const string & mainText,
unique_ptr <Font> & mainFont, shared_ptr <Font> & mainFont,
Font::BoundingBox & bb){ Font::BoundingBox & bb){
{ {
cout << "tryUpdateMainFont" << endl;
auto font = loadFont(library, filename, 0.05f); auto font = loadFont(library, filename, 0.05f);
if(!font){ if(!font){
return; return;
@ -946,6 +946,9 @@ static void tryUpdateMainFont(FT_Library & library,
mainFont = std::move(font); mainFont = std::move(font);
bb = mainFont->measure(0, 0, mainText); bb = mainFont->measure(0, 0, mainText);
cout << "tryUpdateMainFont loaded font" << endl;
cout << "mainText: " << mainText << endl;
cout << bb.minX << "-" << bb.maxX << endl;
} }
} }
} }