aster2013 10 years ago
parent
commit
897b1e6acc
2 changed files with 5 additions and 4 deletions
  1. 4 3
      Source/Urho3D/UI/FontFaceFreeType.cpp
  2. 1 1
      Source/Urho3D/UI/FontFaceFreeType.h

+ 4 - 3
Source/Urho3D/UI/FontFaceFreeType.cpp

@@ -164,7 +164,7 @@ bool FontFaceFreeType::Load(const unsigned char* fontData, unsigned fontDataSize
 
     int textureWidth = maxTextureSize;
     int textureHeight = maxTextureSize;
-    bool loadAllGlyphs = CanLoadAllGlyphs(numGlyphs, loadMode, textureWidth, textureHeight);
+    bool loadAllGlyphs = CanLoadAllGlyphs(numGlyphs, indexToCharMapping, loadMode, textureWidth, textureHeight);
 
     SharedPtr<Image> image(new Image(font_->GetContext()));
     image->SetSize(textureWidth, textureHeight, 1);
@@ -296,7 +296,7 @@ const FontGlyph* FontFaceFreeType::GetGlyph(unsigned c)
     return 0;
 }
 
-bool FontFaceFreeType::CanLoadAllGlyphs(unsigned numGlyphs, int loadMode, int& textureWidth, int& textureHeight) const
+bool FontFaceFreeType::CanLoadAllGlyphs(unsigned numGlyphs, HashMap<unsigned, unsigned>& indexToCharMapping, int loadMode, int& textureWidth, int& textureHeight) const
 {
     FT_Face face = (FT_Face)face_;
     FT_GlyphSlot slot = face->glyph;
@@ -304,7 +304,8 @@ bool FontFaceFreeType::CanLoadAllGlyphs(unsigned numGlyphs, int loadMode, int& t
 
     for (unsigned i = 0; i < numGlyphs; ++i)
     {
-        FT_Error error = FT_Load_Glyph(face, i, loadMode);
+        unsigned charCode = indexToCharMapping[i];
+        FT_Error error = FT_Load_Char(face, charCode, loadMode);
         if (!error)
         {
             int width = Max(slot->metrics.width >> 6, slot->bitmap.width);

+ 1 - 1
Source/Urho3D/UI/FontFaceFreeType.h

@@ -48,7 +48,7 @@ public:
 
 private:
     /// Check can load all glyph in one texture, return true and texture size if can load.
-    bool CanLoadAllGlyphs(unsigned numGlyphs, int loadMode, int& textureWidth, int& textureHeight) const;
+    bool CanLoadAllGlyphs(unsigned numGlyphs, HashMap<unsigned, unsigned>& indexToCharMapping, int loadMode, int& textureWidth, int& textureHeight) const;
     /// Setup next texture.
     bool SetupNextTexture(int textureWidth, int textureHeight);
     /// Load char glyph.