Patryk Konopka 10 年之前
父节点
当前提交
589b15b8ee
共有 2 个文件被更改,包括 8 次插入37 次删除
  1. 6 34
      Source/Core/BitmapFont/FontFaceHandle.cpp
  2. 2 3
      Source/Core/BitmapFont/FontFaceHandle.h

+ 6 - 34
Source/Core/BitmapFont/FontFaceHandle.cpp

@@ -65,11 +65,13 @@ FontFaceHandle::~FontFaceHandle()
 // Initialises the handle so it is able to render text.
 bool FontFaceHandle::Initialise(BitmapFontDefinitions *bm_face, const String& _charset, int _size)
 {
+    this->bm_face = bm_face;
     size = _size;
     TextureWidth = bm_face->CommonCharactersInfo.ScaleWidth;
     TextureHeight = bm_face->CommonCharactersInfo.ScaleHeight;
     raw_charset = _charset;
 
+    // Construct proper path to texture
     URL fnt_source = bm_face->Face.Source;
     URL bitmap_source = bm_face->Face.BitmapSource;
     if(bitmap_source.GetPath().Empty())
@@ -366,46 +368,16 @@ void Rocket::Core::BitmapFont::FontFaceHandle::BuildGlyph(FontGlyph& glyph, Char
     glyph.bitmap_data = NULL;
 }
 
-void Rocket::Core::BitmapFont::FontFaceHandle::BuildKerning(BitmapFontDefinitions *bm_face)
-{
-    // Compile the kerning information for this character if the font includes it.
-//    if ( bm_face->CommonCharactersInfo.KerningCount > 0 )
-//    {
-//        for (size_t i = 0; i < charset.size(); ++i)
-//        {
-//            for (word rhs = (word) (Math::Max< unsigned int >(charset[i].min_codepoint, 32)); rhs <= charset[i].max_codepoint; ++rhs)
-//            {
-//                GlyphKerningList& glyph_kerning = kerning.insert(FontKerningList::value_type(rhs, GlyphKerningList())).first->second;
-
-//                for (size_t j = 0; j < charset.size(); ++j)
-//                {
-//                    for (word lhs = (word) (Math::Max< unsigned int >(charset[j].min_codepoint, 32)); lhs <= charset[j].max_codepoint; ++lhs)
-//                    {
-//                        int kerning = bm_face->BM_Helper_GetXKerning( lhs, rhs );
-//                        if (kerning != 0)
-//                            glyph_kerning[lhs] = kerning;
-//                    }
-//                }
-//            }
-//        }
-//    }
-}
-
 int Rocket::Core::BitmapFont::FontFaceHandle::GetKerning(word lhs, word rhs) const
 {
-//    FontKerningMap::const_iterator rhs_iterator = kerning.find(rhs);
-//    if (rhs_iterator == kerning.end())
-//        return 0;
-
-//    GlyphKerningMap::const_iterator lhs_iterator = rhs_iterator->second.find(lhs);
-//    if (lhs_iterator == rhs_iterator->second.end())
-//        return 0;
+    if( bm_face != NULL)
+    {
+        return bm_face->BM_Helper_GetXKerning(lhs, rhs);
+    }
 
-//    return lhs_iterator->second;
     return 0;
 }
 
-
 // Generates (or shares) a layer derived from a font effect.
 Rocket::Core::FontFaceLayer* FontFaceHandle::GenerateLayer( FontEffect* font_effect)
 {

+ 2 - 3
Source/Core/BitmapFont/FontFaceHandle.h

@@ -57,7 +57,7 @@ public:
     /// @param[in] charset The comma-separated list of unicode ranges this handle must support.
     /// @param[in] size The size, in points, of the face this handle should render at.
     /// @return True if the handle initialised successfully and is ready for rendering, false if an error occured.
-    bool Initialise(BitmapFontDefinitions *ft_face, const String& charset, int size);
+    bool Initialise(BitmapFontDefinitions *bm_face, const String& charset, int size);
 
     /// Returns the width a string will take up if rendered with this handle.
     /// @param[in] string The string to measure.
@@ -117,13 +117,12 @@ private:
 
     void BuildGlyphMap(BitmapFontDefinitions *bm_face, const UnicodeRange& unicode_range);
     void BuildGlyph(FontGlyph& glyph, CharacterInfo *ft_glyph);
-
-    void BuildKerning(BitmapFontDefinitions *bm_face);
     int GetKerning(word lhs, word rhs) const;
 
     // Generates (or shares) a layer derived from a font effect.
     virtual FontFaceLayer* GenerateLayer(FontEffect* font_effect);
 
+    BitmapFontDefinitions * bm_face;
     String TextureSource;
     String TextureDirectory;
     unsigned int TextureWidth;