2003-01-01 01:19:48 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
2003-01-01 01:19:48 +03:00
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
//
|
|
|
|
// File Name: FontFamily.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Description: classes to represent font styles and families
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
#include "FontFamily.h"
|
|
|
|
#include "ServerFont.h"
|
|
|
|
#include FT_CACHE_H
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
FTC_Manager ftmanager;
|
2003-01-01 01:19:48 +03:00
|
|
|
|
|
|
|
/*!
|
2003-01-18 23:32:45 +03:00
|
|
|
\brief Constructor
|
2003-01-20 02:04:58 +03:00
|
|
|
\param filepath path to a font file
|
2005-03-26 00:02:40 +03:00
|
|
|
\param face FreeType handle for the font file after it is loaded - it will be kept open until the FontStyle is destroied
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
|
|
|
FontStyle::FontStyle(const char *filepath, FT_Face face)
|
2005-11-01 02:21:36 +03:00
|
|
|
:
|
|
|
|
fFTFace(face),
|
|
|
|
fFontFamily(NULL),
|
|
|
|
fName(face->style_name),
|
|
|
|
fPath(filepath),
|
|
|
|
fBounds(0, 0, 0, 0),
|
|
|
|
fID(0),
|
|
|
|
fFace(_TranslateStyleToFace(face->style_name))
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-10-20 14:01:49 +04:00
|
|
|
// cachedface = new CachedFaceRec;
|
|
|
|
// cachedface->file_path = filepath;
|
|
|
|
|
2005-05-07 21:32:43 +04:00
|
|
|
fHeight.ascent = face->ascender;
|
|
|
|
// FT2's descent numbers are negative. Be's is positive
|
|
|
|
fHeight.descent = -face->descender;
|
2005-05-07 19:04:52 +04:00
|
|
|
|
|
|
|
// FT2 doesn't provide a linegap, but according to the docs, we can
|
|
|
|
// calculate it because height = ascending + descending + leading
|
2005-05-07 21:32:43 +04:00
|
|
|
fHeight.leading = face->height - (fHeight.ascent + fHeight.descent);
|
|
|
|
fHeight.units_per_em = face->units_per_EM;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:32:45 +03:00
|
|
|
\brief Destructor
|
2003-01-01 01:19:48 +03:00
|
|
|
|
|
|
|
Frees all data allocated on the heap. All child ServerFonts are marked as having
|
|
|
|
a NULL style so that each ServerFont knows that it is running on borrowed time.
|
|
|
|
This is done because a FontStyle should be deleted only when it no longer has any
|
|
|
|
dependencies.
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
FontStyle::~FontStyle()
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-10-20 14:01:49 +04:00
|
|
|
// TODO: what was the purpose of this?
|
|
|
|
// delete cachedface;
|
|
|
|
// TODO: figure out if it is safe to call this:
|
|
|
|
// FT_Done_Face(fFTFace);
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the name of the style as a string
|
|
|
|
\return The style's name
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
const char*
|
|
|
|
FontStyle::Name() const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-01-17 05:05:50 +03:00
|
|
|
return fName.String();
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-06-03 23:30:32 +04:00
|
|
|
font_height
|
|
|
|
FontStyle::GetHeight(const float &size) const
|
2005-01-17 23:08:40 +03:00
|
|
|
{
|
2005-06-03 23:30:32 +04:00
|
|
|
font_height fh = { 0, 0, 0 };
|
2005-01-17 23:08:40 +03:00
|
|
|
|
|
|
|
// font units are 26.6 format, so we get REALLY big numbers if
|
|
|
|
// we don't do some shifting.
|
2005-05-08 10:24:35 +04:00
|
|
|
// TODO: As it looks like that the "units_per_em" don't change
|
|
|
|
// for the lifetime of FontStyle, can't we apply these
|
|
|
|
// conversions in the constructor and get rid of "units_per_em" ?
|
2005-05-07 21:32:43 +04:00
|
|
|
fh.ascent = (fHeight.ascent * size) / fHeight.units_per_em;
|
|
|
|
fh.descent = (fHeight.descent * size) / fHeight.units_per_em;
|
|
|
|
fh.leading = (fHeight.leading * size) / fHeight.units_per_em;
|
2005-01-17 23:08:40 +03:00
|
|
|
return fh;
|
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the path to the style's font file
|
|
|
|
\return The style's font file path
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
const char*
|
2005-11-01 02:21:36 +03:00
|
|
|
FontStyle::Path() const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-01-17 05:05:50 +03:00
|
|
|
return fPath.String();
|
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-06-03 23:30:32 +04:00
|
|
|
int32
|
2005-11-01 02:21:36 +03:00
|
|
|
FontStyle::Flags() const
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
int32 flags = 0;
|
|
|
|
|
|
|
|
if (IsFixedWidth())
|
|
|
|
flags |= B_IS_FIXED;
|
|
|
|
if (TunedCount() > 0)
|
|
|
|
flags |= B_HAS_TUNED_FONT;
|
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
return flags;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
/*!
|
|
|
|
\brief Updates the given face to match the one from this style
|
|
|
|
|
|
|
|
The specified font face often doesn't match the exact face of
|
|
|
|
a style. This method will preserve the attributes of the face
|
|
|
|
that this style does not alter, and will only update the
|
|
|
|
attributes that matter to this style.
|
|
|
|
The font renderer could then emulate the other face attributes
|
|
|
|
taking this style as a base.
|
|
|
|
*/
|
|
|
|
uint16
|
|
|
|
FontStyle::PreservedFace(uint16 face) const
|
|
|
|
{
|
|
|
|
// TODO: make this better
|
|
|
|
face &= ~(B_REGULAR_FACE | B_BOLD_FACE | B_ITALIC_FACE);
|
|
|
|
face |= Face();
|
|
|
|
|
|
|
|
return face;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Converts an ASCII character to Unicode for the style
|
2003-01-20 02:04:58 +03:00
|
|
|
\param c An ASCII character
|
2003-01-01 01:19:48 +03:00
|
|
|
\return A Unicode value for the character
|
|
|
|
*/
|
2005-01-17 05:05:50 +03:00
|
|
|
|
|
|
|
// TODO: Re-enable when I understand how the FT2 Cache system changed from
|
|
|
|
// 2.1.4 to 2.1.8
|
|
|
|
/*
|
2005-11-01 02:21:36 +03:00
|
|
|
int16
|
|
|
|
FontStyle::ConvertToUnicode(uint16 c)
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
|
|
|
FT_Face f;
|
2005-01-19 02:18:37 +03:00
|
|
|
if(FTC_Manager_LookupFace(ftmanager,(FTC_FaceID)cachedface,&f)!=0)
|
2003-01-01 01:19:48 +03:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
return FT_Get_Char_Index(f,c);
|
|
|
|
}
|
|
|
|
*/
|
2005-01-17 05:05:50 +03:00
|
|
|
|
2005-06-03 23:30:32 +04:00
|
|
|
uint16
|
2005-11-01 02:21:36 +03:00
|
|
|
FontStyle::_TranslateStyleToFace(const char *name) const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
if (name == NULL)
|
2005-01-17 05:05:50 +03:00
|
|
|
return 0;
|
2005-11-01 02:21:36 +03:00
|
|
|
|
|
|
|
BString string(name);
|
|
|
|
uint16 face = 0;
|
|
|
|
|
|
|
|
if (string.IFindFirst("bold") >= 0)
|
|
|
|
face |= B_BOLD_FACE;
|
|
|
|
|
|
|
|
if (string.IFindFirst("italic") >= 0
|
|
|
|
|| string.IFindFirst("oblique") >= 0)
|
|
|
|
face |= B_ITALIC_FACE;
|
|
|
|
|
|
|
|
if (face == 0)
|
|
|
|
return B_REGULAR_FACE;
|
|
|
|
|
|
|
|
return face;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-04-01 11:00:32 +04:00
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Constructor
|
2003-01-20 02:04:58 +03:00
|
|
|
\param namestr Name of the family
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-11-01 02:21:36 +03:00
|
|
|
FontFamily::FontFamily(const char *name, const uint16 &index)
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
fName = name;
|
2005-06-03 23:30:32 +04:00
|
|
|
fID = index;
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// will stay uninitialized until needed
|
2005-06-03 23:30:32 +04:00
|
|
|
fFlags = -1;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Destructor
|
|
|
|
|
|
|
|
Deletes all child styles. Note that a FontFamily should not be deleted unless
|
|
|
|
its styles have no dependencies or some other really good reason, such as
|
|
|
|
system shutdown.
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
FontFamily::~FontFamily()
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-06-03 23:30:32 +04:00
|
|
|
int32 count = fStyles.CountItems();
|
|
|
|
for (int32 i = 0; i < count; i++)
|
|
|
|
delete (FontStyle*)fStyles.ItemAt(i);
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the name of the family
|
|
|
|
\return The family's name
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
const char*
|
2005-10-20 14:01:49 +04:00
|
|
|
FontFamily::Name() const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-01-17 05:05:50 +03:00
|
|
|
return fName.String();
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Adds the style to the family
|
2003-01-20 02:04:58 +03:00
|
|
|
\param face FreeType face handle used to obtain info about the font
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
bool
|
|
|
|
FontFamily::AddStyle(FontStyle *style)
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-06-03 23:30:32 +04:00
|
|
|
if (!style)
|
2005-01-17 05:05:50 +03:00
|
|
|
return false;
|
2003-01-01 01:19:48 +03:00
|
|
|
|
|
|
|
FontStyle *item;
|
|
|
|
|
|
|
|
// Don't add if it already is in the family.
|
2005-06-03 23:30:32 +04:00
|
|
|
int32 count = fStyles.CountItems();
|
2005-11-01 02:21:36 +03:00
|
|
|
for (int32 i = 0; i < count; i++) {
|
2005-06-03 23:30:32 +04:00
|
|
|
item = (FontStyle*)fStyles.ItemAt(i);
|
2005-11-01 02:21:36 +03:00
|
|
|
if (item->Name() == style->Name())
|
2005-01-17 05:05:50 +03:00
|
|
|
return false;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
2005-11-01 02:21:36 +03:00
|
|
|
|
|
|
|
style->_SetFontFamily(this);
|
|
|
|
|
2005-06-03 23:30:32 +04:00
|
|
|
if (fStyles.CountItems() > 0) {
|
|
|
|
item = (FontStyle*)fStyles.ItemAt(fStyles.CountItems() - 1);
|
2005-11-01 02:21:36 +03:00
|
|
|
style->_SetID(item->ID() + 1);
|
2005-06-03 23:30:32 +04:00
|
|
|
} else {
|
2005-11-01 02:21:36 +03:00
|
|
|
style->_SetID(0);
|
2005-01-17 05:05:50 +03:00
|
|
|
}
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
fStyles.AddItem(style);
|
2003-01-01 01:19:48 +03:00
|
|
|
AddDependent();
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// force a refresh if a request for font flags is needed
|
2005-11-01 02:21:36 +03:00
|
|
|
fFlags = -1;
|
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
return true;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Removes a style from the family and deletes it
|
2003-01-20 02:04:58 +03:00
|
|
|
\param style Name of the style to be removed from the family
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
void
|
2005-11-01 02:21:36 +03:00
|
|
|
FontFamily::RemoveStyle(const char* styleName)
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
FontStyle *style = GetStyle(styleName);
|
|
|
|
if (style == NULL)
|
2003-01-01 01:19:48 +03:00
|
|
|
return;
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
fStyles.RemoveItem(style);
|
|
|
|
delete style;
|
|
|
|
|
|
|
|
RemoveDependent();
|
|
|
|
|
|
|
|
// force a refresh if a request for font flags is needed
|
|
|
|
fFlags = -1;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
/*!
|
|
|
|
\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
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
void
|
2005-10-20 14:01:49 +04:00
|
|
|
FontFamily::RemoveStyle(FontStyle* style)
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
if (fStyles.RemoveItem(style)) {
|
2005-01-17 05:05:50 +03:00
|
|
|
RemoveDependent();
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
// force a refresh if a request for font flags is needed
|
2005-06-03 23:30:32 +04:00
|
|
|
fFlags = -1;
|
2005-01-17 05:05:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the number of styles in the family
|
|
|
|
\return The number of styles in the family
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
int32
|
|
|
|
FontFamily::CountStyles() const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-01-17 05:05:50 +03:00
|
|
|
return fStyles.CountItems();
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Determines whether the style belongs to the family
|
2003-01-20 02:04:58 +03:00
|
|
|
\param style Name of the style being checked
|
2003-01-01 01:19:48 +03:00
|
|
|
\return True if it belongs, false if not
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
bool
|
2005-11-01 02:21:36 +03:00
|
|
|
FontFamily::HasStyle(const char *styleName) const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
return GetStyle(styleName) != NULL;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the name of a style in the family
|
2003-01-20 02:04:58 +03:00
|
|
|
\param index list index of the style to be found
|
2003-01-01 01:19:48 +03:00
|
|
|
\return name of the style or NULL if the index is not valid
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
FontStyle*
|
2005-11-01 02:21:36 +03:00
|
|
|
FontFamily::StyleAt(int32 index) const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
return fStyles.ItemAt(index);
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
|
|
|
\brief Get the FontStyle object for the name given
|
2003-01-20 02:04:58 +03:00
|
|
|
\param style Name of the style to be obtained
|
2003-01-01 01:19:48 +03:00
|
|
|
\return The FontStyle object or NULL if none was found.
|
|
|
|
|
|
|
|
The object returned belongs to the family and must not be deleted.
|
|
|
|
*/
|
2005-06-03 23:30:32 +04:00
|
|
|
FontStyle*
|
2005-11-01 02:21:36 +03:00
|
|
|
FontFamily::GetStyle(const char *styleName) const
|
2003-01-01 01:19:48 +03:00
|
|
|
{
|
2005-11-01 02:21:36 +03:00
|
|
|
int32 count = fStyles.CountItems();
|
|
|
|
if (!styleName || count < 1)
|
2003-01-01 01:19:48 +03:00
|
|
|
return NULL;
|
2005-06-03 23:30:32 +04:00
|
|
|
|
|
|
|
for (int32 i = 0; i < count; i++) {
|
2005-11-01 02:21:36 +03:00
|
|
|
FontStyle *style = fStyles.ItemAt(i);
|
|
|
|
if (!strcmp(style->Name(), styleName))
|
|
|
|
return style;
|
2003-01-01 01:19:48 +03:00
|
|
|
}
|
2005-11-01 02:21:36 +03:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FontStyle*
|
2005-11-01 19:28:01 +03:00
|
|
|
FontFamily::GetStyleByID(uint16 id) const
|
2005-11-01 02:21:36 +03:00
|
|
|
{
|
|
|
|
for (int32 i = 0; i < fStyles.CountItems(); i++) {
|
|
|
|
FontStyle* style = fStyles.ItemAt(i);
|
|
|
|
if (style->ID() == id)
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
2005-01-17 05:05:50 +03:00
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
|
|
|
|
FontStyle*
|
2005-11-01 19:28:01 +03:00
|
|
|
FontFamily::GetStyleMatchingFace(uint16 face) const
|
2005-11-01 02:21:36 +03:00
|
|
|
{
|
2005-11-01 19:28:01 +03:00
|
|
|
// we currently only use bold/italic/regular faces
|
|
|
|
face &= B_BOLD_FACE | B_ITALIC_FACE | B_REGULAR_FACE;
|
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
for (int32 i = 0; i < fStyles.CountItems(); i++) {
|
|
|
|
FontStyle* style = fStyles.ItemAt(i);
|
2005-11-01 19:28:01 +03:00
|
|
|
|
2005-11-01 02:21:36 +03:00
|
|
|
if (style->Face() == face)
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-03 23:30:32 +04:00
|
|
|
int32
|
2005-11-01 02:21:36 +03:00
|
|
|
FontFamily::Flags()
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-06-03 23:30:32 +04:00
|
|
|
if (fFlags == -1) {
|
|
|
|
fFlags = 0;
|
2005-11-01 02:21:36 +03:00
|
|
|
|
2005-06-03 23:30:32 +04:00
|
|
|
for (int32 i = 0; i < fStyles.CountItems(); i++) {
|
|
|
|
FontStyle* style = (FontStyle*)fStyles.ItemAt(i);
|
|
|
|
if (style) {
|
|
|
|
if (style->IsFixedWidth())
|
|
|
|
fFlags |= B_IS_FIXED;
|
|
|
|
if (style->TunedCount() > 0)
|
|
|
|
fFlags |= B_HAS_TUNED_FONT;
|
2005-01-17 05:05:50 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return fFlags;
|
|
|
|
}
|