Browse Source

If font face uses mutable glyphs, reacquire all glyphs before constructing text batch.

Lasse Öörni 12 years ago
parent
commit
694e41c42a
2 changed files with 10 additions and 0 deletions
  1. 2 0
      Source/Engine/UI/Font.h
  2. 8 0
      Source/Engine/UI/Text.cpp

+ 2 - 0
Source/Engine/UI/Font.h

@@ -115,6 +115,8 @@ public:
     int GetRowHeight() const { return rowHeight_; }
     /// Return textures.
     const Vector<SharedPtr<Texture2D> >& GetTextures() const { return textures_; }
+    /// Return if font face uses mutable glyphs.
+    bool HasMutableGlyphs() const { return !mutableGlyphs_.Empty(); }
     
 private:
     /// Render all glyphs of the face into a single texture. Return true if could fit them. Called by Font.

+ 8 - 0
Source/Engine/UI/Text.cpp

@@ -161,8 +161,16 @@ void Text::GetBatches(PODVector<UIBatch>& batches, PODVector<float>& vertexData,
         FontFace* face = font_->GetFace(fontSize_);
         if (!face)
             return;
+        
+        // If face has changed or char positions are not valid anymore, update before rendering
         if (charPositionsDirty_ || !fontFace_ || face != fontFace_)
             UpdateCharPositions();
+        // If face uses mutable glyphs mechanism, reacquire glyphs before rendering to make sure they are in the texture
+        else if (face->HasMutableGlyphs())
+        {
+            for (unsigned i = 0; i < printText_.Size(); ++i)
+                face->GetGlyph(printText_[i]);
+        }
         
         const Vector<SharedPtr<Texture2D> >& textures = face->GetTextures();
         for (unsigned n = 0; n < textures.Size() && n < pageGlyphLocations_.Size(); ++n)