* style and family IDs are no longer just the index in their parent's lists (as

they can disappear and IDs should stay persistent at least as long as the
  system runs).
* destroying a FontStyle discards its FT_Face again.
* the font style and family names are now truncated to the appropriate length,
  so that they can always be used via the Be API.
* (char *) == (char *) hardly compares the string (but was probably introduced
  by me when I stopped FontFamily from accessing FontStyle privates
* removed FontServer::SaveList() - made no particular sense to me.
* removed superfluous "inline" keyword in the FontStyle definition.
* more cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14619 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-01 17:49:01 +00:00
parent b8cde4497e
commit b4f34cfb95
5 changed files with 134 additions and 224 deletions
+37 -41
View File
@@ -84,85 +84,81 @@ typedef struct {
*/
class FontStyle : public SharedObject, public BLocker {
public:
FontStyle(const char* filepath,
FT_Face face);
virtual ~FontStyle();
FontStyle(const char* path, 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
*/
inline bool IsFixedWidth() const
{ return fFTFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; }
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
*/
inline bool IsScalable() const
{ return fFTFace->face_flags & FT_FACE_FLAG_SCALABLE; }
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
*/
inline bool HasKerning() const
{ return fFTFace->face_flags & FT_FACE_FLAG_KERNING; }
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
*/
inline bool HasTuned() const
{ return fFTFace->num_fixed_sizes > 0; }
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
*/
inline int32 TunedCount() const
{ return fFTFace->num_fixed_sizes; }
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
*/
inline uint16 GlyphCount() const
{ return fFTFace->num_glyphs; }
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
*/
inline uint16 CharMapCount() const
{ return fFTFace->num_charmaps; }
uint16 CharMapCount() const
{ return fFTFace->num_charmaps; }
const char* Name() const;
inline FontFamily* Family() const
{ return fFontFamily; }
inline uint16 ID() const
{ return fID; }
int32 Flags() const;
const char* Name() const;
FontFamily* Family() const
{ return fFontFamily; }
uint16 ID() const
{ return fID; }
int32 Flags() const;
inline uint16 Face() const
{ return fFace; }
uint16 PreservedFace(uint16) const;
uint16 Face() const
{ return fFace; }
uint16 PreservedFace(uint16) const;
const char* Path() const;
font_height GetHeight(const float& size) const;
font_direction Direction() const
{ return B_FONT_LEFT_TO_RIGHT; }
const char* Path() const;
font_height GetHeight(const float& size) const;
font_direction Direction() const
{ return B_FONT_LEFT_TO_RIGHT; }
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);
FT_Face GetFTFace() const
{ return fFTFace; }
void AttachedToFamily(FontFamily* family);
void DetachedFromFamily();
// TODO: Re-enable when I understand how the FT2 Cache system changed from
// 2.1.4 to 2.1.8
// int16 ConvertToUnicode(uint16 c);
private:
friend class FontFamily;
@@ -198,8 +194,7 @@ class FontStyle : public SharedObject, public BLocker {
*/
class FontFamily : public SharedObject {
public:
FontFamily(const char* namestr,
const uint16& index);
FontFamily(const char* name, uint16 id);
virtual ~FontFamily();
const char* Name() const;
@@ -220,10 +215,11 @@ class FontFamily : public SharedObject {
int32 CountStyles() const;
FontStyle* StyleAt(int32 index) const;
protected:
private:
BString fName;
BObjectList<FontStyle> fStyles;
uint16 fID;
uint16 fNextID;
int32 fFlags;
};
+5 -3
View File
@@ -20,6 +20,8 @@
#include FT_FREETYPE_H
#include FT_CACHE_H
class BPath;
class FontFamily;
class FontStyle;
class ServerFont;
@@ -41,7 +43,6 @@ class FontServer : public BLocker {
void RemoveFamily(const char *family);
void ScanSystemFolders();
status_t ScanDirectory(const char *path);
void SaveList();
FontFamily* GetFamilyByIndex(int32 index) const;
FontFamily *GetFamily(uint16 familyID) const;
@@ -67,8 +68,8 @@ class FontServer : public BLocker {
*/
void FontsUpdated() { fNeedUpdate = false; }
protected:
uint16 TranslateStyleToFace(const char *name) const;
private:
void _AddFont(BPath &path);
FT_CharMap _GetSupportedCharmap(const FT_Face &face);
@@ -77,6 +78,7 @@ class FontServer : public BLocker {
BObjectList<FontFamily> fFamilies;
ServerFont *fPlain, *fBold, *fFixed;
bool fNeedUpdate;
int32 fNextID;
};
extern FTC_Manager ftmanager;