mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge pull request #4303 from sethalves/font-load-failed
Font load failed
This commit is contained in:
commit
d7664718ee
2 changed files with 12 additions and 3 deletions
|
@ -40,7 +40,7 @@ if (WIN32)
|
|||
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fno-strict-aliasing -ggdb")
|
||||
endif(WIN32)
|
||||
|
||||
if (NOT MSVC12)
|
||||
|
|
|
@ -511,6 +511,10 @@ TextRenderer::TextRenderer(const char* family, float pointSize, int weight,
|
|||
bool italic, EffectType effect, int effectThickness,
|
||||
const QColor& color) :
|
||||
_effectType(effect), _effectThickness(effectThickness), _pointSize(pointSize), _color(color), _font(loadFont(family)) {
|
||||
if (!_font) {
|
||||
qWarning() << "Unable to load font with family " << family;
|
||||
_font = loadFont("Courier");
|
||||
}
|
||||
if (1 != _effectThickness) {
|
||||
qWarning() << "Effect thickness not current supported";
|
||||
}
|
||||
|
@ -524,7 +528,10 @@ TextRenderer::~TextRenderer() {
|
|||
|
||||
glm::vec2 TextRenderer::computeExtent(const QString & str) const {
|
||||
float scale = (_pointSize / DEFAULT_POINT_SIZE) * 0.25f;
|
||||
return _font->computeExtent(str) * scale;
|
||||
if (_font) {
|
||||
return _font->computeExtent(str) * scale;
|
||||
}
|
||||
return glm::vec2(0.1f,0.1f);
|
||||
}
|
||||
|
||||
float TextRenderer::draw(float x, float y, const QString & str,
|
||||
|
@ -544,7 +551,9 @@ float TextRenderer::draw(float x, float y, const QString & str,
|
|||
// scale at all.
|
||||
mv.translate(glm::vec2(x, y)).scale(glm::vec3(scale, -scale, scale));
|
||||
// The font does all the OpenGL work
|
||||
result = _font->drawString(x, y, str, actualColor, _effectType, bounds / scale);
|
||||
if (_font) {
|
||||
result = _font->drawString(x, y, str, actualColor, _effectType, bounds / scale);
|
||||
}
|
||||
});
|
||||
return result.x;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue