automatically get correct float size for curve buffer
This commit is contained in:
parent
ee47b7649a
commit
5d3dbc075c
1 changed files with 9 additions and 6 deletions
|
@ -337,7 +337,6 @@ class Font {
|
|||
continue;
|
||||
}
|
||||
if(glyphs.count(charcode) != 0){
|
||||
//cout << "but count is not 0?" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -426,7 +425,7 @@ class Font {
|
|||
glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
GL_RG32F,
|
||||
bufferCurvesSize * 2,
|
||||
bufferCurvesSize * sizeof(glm::highp_f32),
|
||||
1,
|
||||
0,
|
||||
GL_RG,
|
||||
|
@ -918,23 +917,24 @@ class Font {
|
|||
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;
|
||||
FT_Face face = Font::loadFace(library, filename, error);
|
||||
if(error != ""){
|
||||
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,
|
||||
const std::string & filename,
|
||||
const string & mainText,
|
||||
unique_ptr <Font> & mainFont,
|
||||
shared_ptr <Font> & mainFont,
|
||||
Font::BoundingBox & bb){
|
||||
{
|
||||
cout << "tryUpdateMainFont" << endl;
|
||||
auto font = loadFont(library, filename, 0.05f);
|
||||
if(!font){
|
||||
return;
|
||||
|
@ -946,6 +946,9 @@ static void tryUpdateMainFont(FT_Library & library,
|
|||
|
||||
mainFont = std::move(font);
|
||||
bb = mainFont->measure(0, 0, mainText);
|
||||
cout << "tryUpdateMainFont loaded font" << endl;
|
||||
cout << "mainText: " << mainText << endl;
|
||||
cout << bb.minX << "-" << bb.maxX << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue