From 6d495dfc269812d3a3dca05bbd0ca8abdfbb7e95 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 25 Mar 2005 21:02:40 +0000 Subject: [PATCH] FT_New_Face is a quite heavy function and shouldn't be called for every StringWidth, StringHeight and DrawString call. We now keep it open in FontStyle and destroy it there too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12006 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/servers/app/FontFamily.h | 5 ++++- headers/private/servers/app/ServerFont.h | 16 +++++++++------- src/servers/app/FontFamily.cpp | 3 ++- src/servers/app/FontServer.cpp | 4 +++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/headers/private/servers/app/FontFamily.h b/headers/private/servers/app/FontFamily.h index 23482ebafa..65e7508e0e 100644 --- a/headers/private/servers/app/FontFamily.h +++ b/headers/private/servers/app/FontFamily.h @@ -140,7 +140,9 @@ public: const char *GetPath(void); font_height GetHeight(const float &size); - + + FT_Face GetFTFace() const { return fFTFace; } + // TODO: Re-enable when I understand how the FT2 Cache system changed from // 2.1.4 to 2.1.8 // int16 ConvertToUnicode(uint16 c); @@ -154,6 +156,7 @@ protected: bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps; int32 tunedcount; CachedFace cachedface; + FT_Face fFTFace; uint8 format; BRect fbounds; uint16 fID; diff --git a/headers/private/servers/app/ServerFont.h b/headers/private/servers/app/ServerFont.h index 5a07ef6ddf..5c7925cdcf 100644 --- a/headers/private/servers/app/ServerFont.h +++ b/headers/private/servers/app/ServerFont.h @@ -64,13 +64,15 @@ public: void SetRotation(const float &value) { frotation=value; } void SetFace(const uint32 &value) { fFace=value; } - bool IsFixedWidth(void) { return fStyle->IsFixedWidth(); } - bool IsScalable(void) { return fStyle->IsScalable(); } - bool HasKerning(void) { return fStyle->HasKerning(); } - bool HasTuned(void) { return fStyle->HasTuned(); } - int32 TunedCount(void) { return fStyle->TunedCount(); } - uint16 GlyphCount(void) { return fStyle->GlyphCount(); } - uint16 CharMapCount(void) { return fStyle->CharMapCount(); } + bool IsFixedWidth(void) const { return fStyle->IsFixedWidth(); } + bool IsScalable(void) const { return fStyle->IsScalable(); } + bool HasKerning(void) const { return fStyle->HasKerning(); } + bool HasTuned(void) const { return fStyle->HasTuned(); } + int32 TunedCount(void) const { return fStyle->TunedCount(); } + uint16 GlyphCount(void) const { return fStyle->GlyphCount(); } + uint16 CharMapCount(void) const { return fStyle->CharMapCount(); } + + FT_Face GetFTFace() const { return fStyle->GetFTFace(); }; const char *GetStyle(void) const; const char *GetFamily(void) const; diff --git a/src/servers/app/FontFamily.cpp b/src/servers/app/FontFamily.cpp index 21ee78d962..1d266a833f 100644 --- a/src/servers/app/FontFamily.cpp +++ b/src/servers/app/FontFamily.cpp @@ -33,10 +33,11 @@ FTC_Manager ftmanager; /*! \brief Constructor \param filepath path to a font file - \param face FreeType handle for the font file after it is loaded - for its info only + \param face FreeType handle for the font file after it is loaded - it will be kept open until the FontStyle is destroied */ FontStyle::FontStyle(const char *filepath, FT_Face face) { + fFTFace = face; fName=face->style_name; cachedface=new CachedFaceRec; cachedface->file_path=filepath; diff --git a/src/servers/app/FontServer.cpp b/src/servers/app/FontServer.cpp index 338eef95dd..69b38017c6 100644 --- a/src/servers/app/FontServer.cpp +++ b/src/servers/app/FontServer.cpp @@ -286,7 +286,9 @@ status_t FontServer::ScanDirectory(const char *fontspath) else validcount++; - FT_Done_Face(face); + // FT_Face is kept open in FontStyle and will be unset in the + // FontStyle destructor + } // end for(i