* cleaned up and applied coding style to FontStyle
* got rid of bogus member variables in FontStyle (which were already flags in the underlying FT_Face structure) * disabled using the FreeType font cache -> I think from my earlier tests, I can conclude that the cache was not actually working. At least not giving any speed improvements. The AGG engine contains a caching system, for now, it works ok. I have no idea if this has anything to do with crashes in the freetype code, but at least I have not seen any since this change. But I have not tested much... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14448 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -53,14 +53,14 @@ enum font_format
|
||||
FONT_WINFONT,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
//! data structure used by the FreeType cache manager
|
||||
typedef struct CachedFaceRec_
|
||||
{
|
||||
BString file_path;
|
||||
int face_index;
|
||||
} CachedFaceRec, *CachedFace;
|
||||
|
||||
*/
|
||||
/*!
|
||||
\brief Private structure to store font height values
|
||||
|
||||
@@ -83,85 +83,104 @@ typedef struct
|
||||
FontStyle objects help abstract a lot of the font engine details while
|
||||
still offering plenty of information the style in question.
|
||||
*/
|
||||
class FontStyle : public SharedObject
|
||||
{
|
||||
public:
|
||||
FontStyle(const char *filepath, FT_Face face);
|
||||
~FontStyle();
|
||||
class FontStyle : public SharedObject {
|
||||
public:
|
||||
FontStyle(const char* filepath,
|
||||
FT_Face face);
|
||||
virtual ~FontStyle();
|
||||
|
||||
/*!
|
||||
\fn bool FontStyle::IsFixedWidth(void)
|
||||
\brief Determines whether the font's character width is fixed
|
||||
\return true if fixed, false if not
|
||||
*/
|
||||
bool IsFixedWidth() const { return is_fixedwidth; }
|
||||
inline bool IsFixedWidth() const
|
||||
{ return fFTFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; }
|
||||
/*!
|
||||
\fn bool FontStyle::IsScalable(void)
|
||||
\brief Determines whether the font can be scaled to any size
|
||||
\return true if scalable, false if not
|
||||
*/
|
||||
bool IsScalable() const { return is_scalable; }
|
||||
inline bool IsScalable() const
|
||||
{ return fFTFace->face_flags & FT_FACE_FLAG_SCALABLE; }
|
||||
/*!
|
||||
\fn bool FontStyle::HasKerning(void)
|
||||
\brief Determines whether the font has kerning information
|
||||
\return true if kerning info is available, false if not
|
||||
*/
|
||||
bool HasKerning() const { return has_kerning; }
|
||||
inline bool HasKerning() const
|
||||
{ return fFTFace->face_flags & FT_FACE_FLAG_KERNING; }
|
||||
/*!
|
||||
\fn bool FontStyle::HasTuned(void)
|
||||
\brief Determines whether the font contains strikes
|
||||
\return true if it has strikes included, false if not
|
||||
*/
|
||||
bool HasTuned() const { return has_bitmaps; }
|
||||
inline bool HasTuned() const
|
||||
{ return fFTFace->num_fixed_sizes > 0; }
|
||||
/*!
|
||||
\fn bool FontStyle::TunedCount(void)
|
||||
\brief Returns the number of strikes the style contains
|
||||
\return The number of strikes the style contains
|
||||
*/
|
||||
int32 TunedCount() const { return tunedcount; }
|
||||
inline int32 TunedCount() const
|
||||
{ return fFTFace->num_fixed_sizes; }
|
||||
/*!
|
||||
\fn bool FontStyle::GlyphCount(void)
|
||||
\brief Returns the number of glyphs in the style
|
||||
\return The number of glyphs the style contains
|
||||
*/
|
||||
uint16 GlyphCount() const { return glyphcount; }
|
||||
inline uint16 GlyphCount() const
|
||||
{ return fFTFace->num_glyphs; }
|
||||
/*!
|
||||
\fn bool FontStyle::CharMapCount(void)
|
||||
\brief Returns the number of character maps the style contains
|
||||
\return The number of character maps the style contains
|
||||
*/
|
||||
uint16 CharMapCount(void) const { return charmapcount; }
|
||||
const char *Name() const;
|
||||
FontFamily *Family() const { return family; }
|
||||
uint16 GetID() const { return fID; }
|
||||
int32 GetFlags() const;
|
||||
inline uint16 CharMapCount() const
|
||||
{ return fFTFace->num_charmaps; }
|
||||
|
||||
uint16 GetFace() const { return fFace; }
|
||||
const char* Name() const;
|
||||
inline FontFamily* Family() const
|
||||
{ return fFontFamily; }
|
||||
inline uint16 GetID() const
|
||||
{ return fID; }
|
||||
int32 GetFlags() const;
|
||||
|
||||
const char *GetPath() const;
|
||||
font_height GetHeight(const float &size) const;
|
||||
inline uint16 GetFace() const
|
||||
{ return fFace; }
|
||||
|
||||
const char* GetPath() const;
|
||||
font_height GetHeight(const float& size) const;
|
||||
|
||||
FT_Face GetFTFace() const { return fFTFace; }
|
||||
inline 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);
|
||||
// int16 ConvertToUnicode(uint16 c);
|
||||
|
||||
void AttachedToFamily(FontFamily* family);
|
||||
void DetachedFromFamily();
|
||||
|
||||
protected:
|
||||
uint16 TranslateStyleToFace(const char *name) const;
|
||||
uint16 TranslateStyleToFace(const char *name) const;
|
||||
|
||||
friend class FontFamily;
|
||||
FontFamily *family;
|
||||
uint16 glyphcount, charmapcount;
|
||||
BString fName, fPath;
|
||||
bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps;
|
||||
int32 tunedcount;
|
||||
CachedFace cachedface;
|
||||
FT_Face fFTFace;
|
||||
uint8 format;
|
||||
BRect fbounds;
|
||||
uint16 fID;
|
||||
uint16 fFace;
|
||||
FontStyleHeight fHeight;
|
||||
|
||||
FT_Face fFTFace;
|
||||
// CachedFace cachedface;
|
||||
|
||||
FontFamily* fFontFamily;
|
||||
|
||||
BString fName;
|
||||
BString fPath;
|
||||
|
||||
BRect fBounds;
|
||||
|
||||
uint16 fID;
|
||||
uint16 fFace;
|
||||
|
||||
FontStyleHeight fHeight;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -171,31 +190,33 @@ protected:
|
||||
FontFamily objects bring together many styles of the same face, such as
|
||||
Arial Roman, Arial Italic, Arial Bold, etc.
|
||||
*/
|
||||
class FontFamily : public SharedObject
|
||||
{
|
||||
public:
|
||||
FontFamily(const char *namestr, const uint16 &index);
|
||||
~FontFamily();
|
||||
const char *Name();
|
||||
class FontFamily : public SharedObject {
|
||||
public:
|
||||
FontFamily(const char* namestr,
|
||||
const uint16& index);
|
||||
virtual ~FontFamily();
|
||||
|
||||
const char* Name() const;
|
||||
|
||||
bool AddStyle(FontStyle *style);
|
||||
void RemoveStyle(const char *style);
|
||||
void RemoveStyle(FontStyle *style);
|
||||
|
||||
FontStyle *GetStyle(int32 index) const;
|
||||
FontStyle *GetStyle(const char *style) const;
|
||||
|
||||
uint16 GetID() const { return fID; }
|
||||
|
||||
bool HasStyle(const char *style) const;
|
||||
int32 CountStyles() const;
|
||||
int32 GetFlags();
|
||||
bool AddStyle(FontStyle* style);
|
||||
void RemoveStyle(const char* style);
|
||||
void RemoveStyle(FontStyle* style);
|
||||
|
||||
FontStyle* GetStyle(int32 index) const;
|
||||
FontStyle* GetStyle(const char* style) const;
|
||||
|
||||
uint16 GetID() const
|
||||
{ return fID; }
|
||||
|
||||
bool HasStyle(const char* style) const;
|
||||
int32 CountStyles() const;
|
||||
int32 GetFlags();
|
||||
|
||||
protected:
|
||||
BString fName;
|
||||
BList fStyles;
|
||||
uint16 fID;
|
||||
int32 fFlags;
|
||||
BString fName;
|
||||
BList fStyles;
|
||||
uint16 fID;
|
||||
int32 fFlags;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user