Retooled the server-side font API to make it work better

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10788 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2005-01-17 02:04:21 +00:00
parent 76bf6f57d7
commit c1d0331e5b
3 changed files with 63 additions and 26 deletions
+36 -21
View File
@@ -73,70 +73,75 @@ class FontStyle : public SharedObject
public: public:
FontStyle(const char *filepath, FT_Face face); FontStyle(const char *filepath, FT_Face face);
~FontStyle(void); ~FontStyle(void);
ServerFont *Instantiate(float size, float rotation=0.0, float shear=90.0);
/*! /*!
\fn bool FontStyle::IsFixedWidth(void) \fn bool FontStyle::IsFixedWidth(void)
\brief Determines whether the font's character width is fixed \brief Determines whether the font's character width is fixed
\return true if fixed, false if not \return true if fixed, false if not
*/ */
bool IsFixedWidth(void) { return is_fixedwidth; } bool IsFixedWidth(void) const { return is_fixedwidth; }
/*! /*!
\fn bool FontStyle::IsScalable(void) \fn bool FontStyle::IsScalable(void)
\brief Determines whether the font can be scaled to any size \brief Determines whether the font can be scaled to any size
\return true if scalable, false if not \return true if scalable, false if not
*/ */
bool IsScalable(void) { return is_scalable; } bool IsScalable(void) const { return is_scalable; }
/*! /*!
\fn bool FontStyle::HasKerning(void) \fn bool FontStyle::HasKerning(void)
\brief Determines whether the font has kerning information \brief Determines whether the font has kerning information
\return true if kerning info is available, false if not \return true if kerning info is available, false if not
*/ */
bool HasKerning(void) { return has_kerning; } bool HasKerning(void) const { return has_kerning; }
/*! /*!
\fn bool FontStyle::HasTuned(void) \fn bool FontStyle::HasTuned(void)
\brief Determines whether the font contains strikes \brief Determines whether the font contains strikes
\return true if it has strikes included, false if not \return true if it has strikes included, false if not
*/ */
bool HasTuned(void) { return has_bitmaps; } bool HasTuned(void) const { return has_bitmaps; }
/*! /*!
\fn bool FontStyle::TunedCount(void) \fn bool FontStyle::TunedCount(void)
\brief Returns the number of strikes the style contains \brief Returns the number of strikes the style contains
\return The number of strikes the style contains \return The number of strikes the style contains
*/ */
int32 TunedCount(void) { return tunedcount; } int32 TunedCount(void) const { return tunedcount; }
/*! /*!
\fn bool FontStyle::GlyphCount(void) \fn bool FontStyle::GlyphCount(void)
\brief Returns the number of glyphs in the style \brief Returns the number of glyphs in the style
\return The number of glyphs the style contains \return The number of glyphs the style contains
*/ */
uint16 GlyphCount(void) { return glyphcount; } uint16 GlyphCount(void) const { return glyphcount; }
/*! /*!
\fn bool FontStyle::CharMapCount(void) \fn bool FontStyle::CharMapCount(void)
\brief Returns the number of character maps the style contains \brief Returns the number of character maps the style contains
\return The number of character maps the style contains \return The number of character maps the style contains
*/ */
uint16 CharMapCount(void) { return charmapcount; } uint16 CharMapCount(void) const { return charmapcount; }
const char *Name(void); const char *Name(void) const;
FontFamily *Family(void) { return family; } FontFamily *Family(void) const { return family; }
uint16 GetID(void) const { return fID; }
int32 GetFlags(void) const;
FT_Face GetFace(void); uint16 GetFace(void) const { return fFace; }
const char *GetPath(void); const char *GetPath(void);
int16 ConvertToUnicode(uint16 c); // TODO: Re-enable when I understand how the FT2 Cache system changed from
// 2.1.4 to 2.1.8
// int16 ConvertToUnicode(uint16 c);
protected: protected:
uint16 TranslateStyleToFace(const char *name) const;
friend class FontFamily; friend class FontFamily;
FontFamily *family; FontFamily *family;
uint16 glyphcount, charmapcount; uint16 glyphcount, charmapcount;
BString *name, *path; BString fName, fPath;
BList *instances;
bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps; bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps;
int32 tunedcount; int32 tunedcount;
CachedFace cachedface; CachedFace cachedface;
uint8 format; uint8 format;
BRect fbounds; BRect fbounds;
uint16 fID;
uint16 fFace;
}; };
/*! /*!
@@ -149,18 +154,28 @@ protected:
class FontFamily : public SharedObject class FontFamily : public SharedObject
{ {
public: public:
FontFamily(const char *namestr); FontFamily(const char *namestr, const uint16 &index);
~FontFamily(void); ~FontFamily(void);
const char *Name(void); const char *Name(void);
void AddStyle(const char *path, FT_Face face);
bool AddStyle(FontStyle *style);
void RemoveStyle(const char *style); void RemoveStyle(const char *style);
void RemoveStyle(FontStyle *style);
FontStyle *GetStyle(int32 index);
FontStyle *GetStyle(const char *style);
uint16 GetID(void) const { return fID; }
bool HasStyle(const char *style); bool HasStyle(const char *style);
int32 CountStyles(void); int32 CountStyles(void);
const char *GetStyle(int32 index); int32 GetFlags(void);
FontStyle *GetStyle(const char *style);
protected: protected:
BString *name; BString fName;
BList *styles; BList fStyles;
uint16 fID;
int32 fFlags;
}; };
#endif #endif
+14 -2
View File
@@ -61,20 +61,32 @@ public:
void RemoveFamily(const char *family); void RemoveFamily(const char *family);
status_t ScanDirectory(const char *path); status_t ScanDirectory(const char *path);
void SaveList(void); void SaveList(void);
FontStyle *GetStyle(font_family family, font_style face);
const char *GetFamilyName(uint16 id) const;
const char *GetStyleName(const char *family, uint16 id) const;
FontStyle *GetStyle(const char *family, const char *face);
FontStyle *GetStyle(const char *family, uint16 id) const;
FontStyle *GetStyle(const uint16 &familyid, const uint16 &styleid);
FontFamily *GetFamily(const uint16 &familyid);
ServerFont *GetSystemPlain(void); ServerFont *GetSystemPlain(void);
ServerFont *GetSystemBold(void); ServerFont *GetSystemBold(void);
ServerFont *GetSystemFixed(void); ServerFont *GetSystemFixed(void);
bool SetSystemPlain(const char *family, const char *style, float size); bool SetSystemPlain(const char *family, const char *style, float size);
bool SetSystemBold(const char *family, const char *style, float size); bool SetSystemBold(const char *family, const char *style, float size);
bool SetSystemFixed(const char *family, const char *style, float size); bool SetSystemFixed(const char *family, const char *style, float size);
bool FontsNeedUpdated(void) { return need_update; } bool FontsNeedUpdated(void) { return need_update; }
/*! /*!
\brief Called when the fonts list has been updated \brief Called when the fonts list has been updated
*/ */
void FontsUpdated(void) { need_update=false; } void FontsUpdated(void) { need_update=false; }
protected: protected:
FontFamily *_FindFamily(const char *name); FontFamily *_FindFamily(const char *name) const;
uint16 TranslateStyleToFace(const char *name) const;
FT_CharMap _GetSupportedCharmap(const FT_Face &face); FT_CharMap _GetSupportedCharmap(const FT_Face &face);
bool init; bool init;
sem_id lock; sem_id lock;
+13 -3
View File
@@ -29,8 +29,7 @@
#include <Rect.h> #include <Rect.h>
#include <Font.h> #include <Font.h>
#include "FontFamily.h"
class FontStyle;
class ServerFont class ServerFont
{ {
@@ -52,7 +51,6 @@ public:
uint32 CountGlyphs(void); uint32 CountGlyphs(void);
int32 CountTuned(void); int32 CountTuned(void);
font_file_format FileFormat(void); font_file_format FileFormat(void);
FontStyle *Style(void) const { return fstyle; }
void SetDirection(const font_direction &dir) { fdirection=dir; } void SetDirection(const font_direction &dir) { fdirection=dir; }
void SetEdges(const edge_info &info) { fedges=info; } void SetEdges(const edge_info &info) { fedges=info; }
@@ -64,6 +62,18 @@ public:
void SetRotation(const float &value) { frotation=value; } void SetRotation(const float &value) { frotation=value; }
void SetFace(const uint32 &value) { fface=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(); }
const char *GetStyle(void) const;
const char *GetFamily(void) const;
const char *GetPath(void) const { return fstyle->GetPath(); }
BRect BoundingBox(void); BRect BoundingBox(void);
void Height(font_height *fh); void Height(font_height *fh);