call Q_INIT_RESOURCE statically from Font constructor

This commit is contained in:
Stephen Birarda 2015-02-06 15:17:53 -08:00
parent 6a58d8b0a3
commit 961b5b5346

View file

@ -88,6 +88,9 @@ const float DEFAULT_POINT_SIZE = 12;
class Font {
public:
Font();
using TexturePtr = QSharedPointer < QOpenGLTexture >;
using VertexArrayPtr = QSharedPointer< QOpenGLVertexArrayObject >;
using ProgramPtr = QSharedPointer < QOpenGLShaderProgram >;
@ -183,6 +186,14 @@ Font* loadFont(const QString& family) {
return LOADED_FONTS[family];
}
Font::Font() {
static bool fontResourceInitComplete = false;
if (!fontResourceInitComplete) {
Q_INIT_RESOURCE(font);
fontResourceInitComplete = true;
}
}
// NERD RAGE: why doesn't QHash have a 'const T & operator[] const' member
const Glyph & Font::getGlyph(const QChar & c) const {
if (!_glyphs.contains(c)) {