large cleanup, should have fixed some memory leaks too
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12942 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -87,59 +87,59 @@ class FontStyle : public SharedObject
|
||||
{
|
||||
public:
|
||||
FontStyle(const char *filepath, FT_Face face);
|
||||
~FontStyle(void);
|
||||
~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(void) const { return is_fixedwidth; }
|
||||
bool IsFixedWidth() const { return is_fixedwidth; }
|
||||
/*!
|
||||
\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(void) const { return is_scalable; }
|
||||
bool IsScalable() const { return is_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(void) const { return has_kerning; }
|
||||
bool HasKerning() const { return has_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(void) const { return has_bitmaps; }
|
||||
bool HasTuned() const { return has_bitmaps; }
|
||||
/*!
|
||||
\fn bool FontStyle::TunedCount(void)
|
||||
\brief Returns the number of strikes the style contains
|
||||
\return The number of strikes the style contains
|
||||
*/
|
||||
int32 TunedCount(void) const { return tunedcount; }
|
||||
int32 TunedCount() const { return tunedcount; }
|
||||
/*!
|
||||
\fn bool FontStyle::GlyphCount(void)
|
||||
\brief Returns the number of glyphs in the style
|
||||
\return The number of glyphs the style contains
|
||||
*/
|
||||
uint16 GlyphCount(void) const { return glyphcount; }
|
||||
uint16 GlyphCount() const { return glyphcount; }
|
||||
/*!
|
||||
\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(void) const;
|
||||
FontFamily *Family(void) const { return family; }
|
||||
uint16 GetID(void) const { return fID; }
|
||||
int32 GetFlags(void) const;
|
||||
const char *Name() const;
|
||||
FontFamily *Family() const { return family; }
|
||||
uint16 GetID() const { return fID; }
|
||||
int32 GetFlags() const;
|
||||
|
||||
uint16 GetFace(void) const { return fFace; }
|
||||
uint16 GetFace() const { return fFace; }
|
||||
|
||||
const char *GetPath(void);
|
||||
font_height GetHeight(const float &size);
|
||||
const char *GetPath() const;
|
||||
font_height GetHeight(const float &size) const;
|
||||
|
||||
FT_Face GetFTFace() const { return fFTFace; }
|
||||
|
||||
@@ -175,21 +175,21 @@ class FontFamily : public SharedObject
|
||||
{
|
||||
public:
|
||||
FontFamily(const char *namestr, const uint16 &index);
|
||||
~FontFamily(void);
|
||||
const char *Name(void);
|
||||
~FontFamily();
|
||||
const char *Name();
|
||||
|
||||
bool AddStyle(FontStyle *style);
|
||||
void RemoveStyle(const char *style);
|
||||
void RemoveStyle(FontStyle *style);
|
||||
|
||||
FontStyle *GetStyle(int32 index);
|
||||
FontStyle *GetStyle(const char *style);
|
||||
FontStyle *GetStyle(int32 index) const;
|
||||
FontStyle *GetStyle(const char *style) const;
|
||||
|
||||
uint16 GetID(void) const { return fID; }
|
||||
uint16 GetID() const { return fID; }
|
||||
|
||||
bool HasStyle(const char *style);
|
||||
int32 CountStyles(void);
|
||||
int32 GetFlags(void);
|
||||
bool HasStyle(const char *style) const;
|
||||
int32 CountStyles() const;
|
||||
int32 GetFlags();
|
||||
|
||||
protected:
|
||||
BString fName;
|
||||
|
||||
@@ -72,7 +72,7 @@ FontStyle::FontStyle(const char *filepath, FT_Face face)
|
||||
This is done because a FontStyle should be deleted only when it no longer has any
|
||||
dependencies.
|
||||
*/
|
||||
FontStyle::~FontStyle(void)
|
||||
FontStyle::~FontStyle()
|
||||
{
|
||||
delete cachedface;
|
||||
}
|
||||
@@ -81,12 +81,14 @@ FontStyle::~FontStyle(void)
|
||||
\brief Returns the name of the style as a string
|
||||
\return The style's name
|
||||
*/
|
||||
const char *FontStyle::Name(void) const
|
||||
const char*
|
||||
FontStyle::Name() const
|
||||
{
|
||||
return fName.String();
|
||||
}
|
||||
|
||||
font_height FontStyle::GetHeight(const float &size)
|
||||
font_height
|
||||
FontStyle::GetHeight(const float &size) const
|
||||
{
|
||||
font_height fh = { 0, 0, 0 };
|
||||
|
||||
@@ -105,12 +107,14 @@ font_height FontStyle::GetHeight(const float &size)
|
||||
\brief Returns the path to the style's font file
|
||||
\return The style's font file path
|
||||
*/
|
||||
const char *FontStyle::GetPath(void)
|
||||
const char*
|
||||
FontStyle::GetPath() const
|
||||
{
|
||||
return fPath.String();
|
||||
}
|
||||
|
||||
int32 FontStyle::GetFlags(void) const
|
||||
int32
|
||||
FontStyle::GetFlags() const
|
||||
{
|
||||
int32 flags=0;
|
||||
if(IsFixedWidth())
|
||||
@@ -141,7 +145,8 @@ int16 FontStyle::ConvertToUnicode(uint16 c)
|
||||
}
|
||||
*/
|
||||
|
||||
uint16 FontStyle::TranslateStyleToFace(const char *name) const
|
||||
uint16
|
||||
FontStyle::TranslateStyleToFace(const char *name) const
|
||||
{
|
||||
if(!name)
|
||||
return 0;
|
||||
@@ -180,21 +185,19 @@ FontFamily::FontFamily(const char *namestr, const uint16 &index)
|
||||
its styles have no dependencies or some other really good reason, such as
|
||||
system shutdown.
|
||||
*/
|
||||
FontFamily::~FontFamily(void)
|
||||
FontFamily::~FontFamily()
|
||||
{
|
||||
FontStyle *style;
|
||||
for(int32 i=0; i<fStyles.CountItems(); i++)
|
||||
{
|
||||
style=(FontStyle *)fStyles.RemoveItem(i);
|
||||
delete style;
|
||||
}
|
||||
int32 count = fStyles.CountItems();
|
||||
for (int32 i = 0; i < count; i++)
|
||||
delete (FontStyle*)fStyles.ItemAt(i);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the name of the family
|
||||
\return The family's name
|
||||
*/
|
||||
const char *FontFamily::Name(void)
|
||||
const char*
|
||||
FontFamily::Name()
|
||||
{
|
||||
return fName.String();
|
||||
}
|
||||
@@ -204,7 +207,8 @@ const char *FontFamily::Name(void)
|
||||
\param path full path to the style's font file
|
||||
\param face FreeType face handle used to obtain info about the font
|
||||
*/
|
||||
bool FontFamily::AddStyle(FontStyle *style)
|
||||
bool
|
||||
FontFamily::AddStyle(FontStyle *style)
|
||||
{
|
||||
if (!style)
|
||||
return false;
|
||||
@@ -213,8 +217,7 @@ bool FontFamily::AddStyle(FontStyle *style)
|
||||
|
||||
// Don't add if it already is in the family.
|
||||
int32 count = fStyles.CountItems();
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
for(int32 i = 0; i < count; i++) {
|
||||
item = (FontStyle*)fStyles.ItemAt(i);
|
||||
if (item->fName == style->fName)
|
||||
return false;
|
||||
@@ -222,13 +225,12 @@ bool FontFamily::AddStyle(FontStyle *style)
|
||||
|
||||
style->family=this;
|
||||
|
||||
if(fStyles.CountItems()>0)
|
||||
{
|
||||
if (fStyles.CountItems() > 0) {
|
||||
item = (FontStyle*)fStyles.ItemAt(fStyles.CountItems() - 1);
|
||||
style->fID = item->fID + 1;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
style->fID = 0;
|
||||
}
|
||||
|
||||
fStyles.AddItem(style);
|
||||
AddDependent();
|
||||
@@ -243,7 +245,8 @@ bool FontFamily::AddStyle(FontStyle *style)
|
||||
\brief Removes a style from the family and deletes it
|
||||
\param style Name of the style to be removed from the family
|
||||
*/
|
||||
void FontFamily::RemoveStyle(const char *style)
|
||||
void
|
||||
FontFamily::RemoveStyle(const char *style)
|
||||
{
|
||||
int32 count=fStyles.CountItems();
|
||||
if(!style || count<1)
|
||||
@@ -272,10 +275,10 @@ void FontFamily::RemoveStyle(const char *style)
|
||||
\brief Removes a style from the family. The caller is responsible for freeing the object
|
||||
\param style The style to be removed from the family
|
||||
*/
|
||||
void FontFamily::RemoveStyle(FontStyle *style)
|
||||
{
|
||||
if(fStyles.HasItem(style))
|
||||
void
|
||||
FontFamily::RemoveStyle(FontStyle *style)
|
||||
{
|
||||
if (fStyles.HasItem(style)) {
|
||||
fStyles.RemoveItem(style);
|
||||
RemoveDependent();
|
||||
|
||||
@@ -288,7 +291,8 @@ void FontFamily::RemoveStyle(FontStyle *style)
|
||||
\brief Returns the number of styles in the family
|
||||
\return The number of styles in the family
|
||||
*/
|
||||
int32 FontFamily::CountStyles(void)
|
||||
int32
|
||||
FontFamily::CountStyles() const
|
||||
{
|
||||
return fStyles.CountItems();
|
||||
}
|
||||
@@ -298,7 +302,8 @@ int32 FontFamily::CountStyles(void)
|
||||
\param style Name of the style being checked
|
||||
\return True if it belongs, false if not
|
||||
*/
|
||||
bool FontFamily::HasStyle(const char *style)
|
||||
bool
|
||||
FontFamily::HasStyle(const char *style) const
|
||||
{
|
||||
int32 count = fStyles.CountItems();
|
||||
|
||||
@@ -306,8 +311,7 @@ bool FontFamily::HasStyle(const char *style)
|
||||
return false;
|
||||
|
||||
FontStyle *fs;
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
fs = (FontStyle*)fStyles.ItemAt(i);
|
||||
if( fs && fs->fName.Compare(style) == 0)
|
||||
return true;
|
||||
@@ -320,7 +324,8 @@ bool FontFamily::HasStyle(const char *style)
|
||||
\param index list index of the style to be found
|
||||
\return name of the style or NULL if the index is not valid
|
||||
*/
|
||||
FontStyle *FontFamily::GetStyle(int32 index)
|
||||
FontStyle*
|
||||
FontFamily::GetStyle(int32 index) const
|
||||
{
|
||||
return (FontStyle*)fStyles.ItemAt(index);
|
||||
}
|
||||
@@ -332,14 +337,15 @@ FontStyle *FontFamily::GetStyle(int32 index)
|
||||
|
||||
The object returned belongs to the family and must not be deleted.
|
||||
*/
|
||||
FontStyle *FontFamily::GetStyle(const char *style)
|
||||
FontStyle*
|
||||
FontFamily::GetStyle(const char *style) const
|
||||
{
|
||||
int32 count=fStyles.CountItems();
|
||||
if (!style || count < 1)
|
||||
return NULL;
|
||||
|
||||
FontStyle *fs;
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
fs = (FontStyle*)fStyles.ItemAt(i);
|
||||
if (fs && fs->fName.Compare(style) == 0)
|
||||
return fs;
|
||||
@@ -347,17 +353,15 @@ FontStyle *FontFamily::GetStyle(const char *style)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32 FontFamily::GetFlags(void)
|
||||
{
|
||||
if(fFlags==-1)
|
||||
int32
|
||||
FontFamily::GetFlags()
|
||||
{
|
||||
if (fFlags == -1) {
|
||||
fFlags = 0;
|
||||
|
||||
for(int32 i=0; i<fStyles.CountItems(); i++)
|
||||
{
|
||||
for (int32 i = 0; i < fStyles.CountItems(); i++) {
|
||||
FontStyle* style = (FontStyle*)fStyles.ItemAt(i);
|
||||
if(style)
|
||||
{
|
||||
if (style) {
|
||||
if (style->IsFixedWidth())
|
||||
fFlags |= B_IS_FIXED;
|
||||
if (style->TunedCount() > 0)
|
||||
@@ -367,5 +371,4 @@ int32 FontFamily::GetFlags(void)
|
||||
}
|
||||
|
||||
return fFlags;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user