The font manager now has default fonts for bold/fixed as well - these are now used
in the DesktopSettings as defaults, too (but can be changed there). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14804 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -56,7 +56,9 @@ class FontManager : public BLooper {
|
|||||||
FontStyle *GetStyle(uint16 familyID, uint16 styleID) const;
|
FontStyle *GetStyle(uint16 familyID, uint16 styleID) const;
|
||||||
FontStyle* FindStyleMatchingFace(uint16 face) const;
|
FontStyle* FindStyleMatchingFace(uint16 face) const;
|
||||||
|
|
||||||
const ServerFont* DefaultFont() const;
|
const ServerFont* DefaultPlainFont() const;
|
||||||
|
const ServerFont* DefaultBoldFont() const;
|
||||||
|
const ServerFont* DefaultFixedFont() const;
|
||||||
|
|
||||||
void AttachUser(uid_t userID);
|
void AttachUser(uid_t userID);
|
||||||
void DetachUser(uid_t userID);
|
void DetachUser(uid_t userID);
|
||||||
@@ -66,7 +68,10 @@ class FontManager : public BLooper {
|
|||||||
struct font_mapping;
|
struct font_mapping;
|
||||||
|
|
||||||
bool _LoadRecentFontMappings();
|
bool _LoadRecentFontMappings();
|
||||||
status_t _SetDefaultFont();
|
FontStyle* _GetDefaultStyle(const char *familyName, const char *styleName,
|
||||||
|
const char *fallbackFamily, const char *fallbackStyle,
|
||||||
|
uint16 fallbackFace);
|
||||||
|
status_t _SetDefaultFonts();
|
||||||
void _AddSystemPaths();
|
void _AddSystemPaths();
|
||||||
status_t _AddPath(const char* path);
|
status_t _AddPath(const char* path);
|
||||||
status_t _AddPath(BEntry& entry, font_directory** _newDirectory = NULL);
|
status_t _AddPath(BEntry& entry, font_directory** _newDirectory = NULL);
|
||||||
@@ -87,7 +92,9 @@ class FontManager : public BLooper {
|
|||||||
BObjectList<font_mapping> fMappings;
|
BObjectList<font_mapping> fMappings;
|
||||||
BObjectList<FontFamily> fFamilies;
|
BObjectList<FontFamily> fFamilies;
|
||||||
HashTable fStyleHashTable;
|
HashTable fStyleHashTable;
|
||||||
ServerFont *fDefaultFont;
|
ServerFont* fDefaultPlainFont;
|
||||||
|
ServerFont* fDefaultBoldFont;
|
||||||
|
ServerFont* fDefaultFixedFont;
|
||||||
bool fScanned;
|
bool fScanned;
|
||||||
int32 fNextID;
|
int32 fNextID;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,16 +32,9 @@ DesktopSettings::Private::~Private()
|
|||||||
void
|
void
|
||||||
DesktopSettings::Private::_SetDefaults()
|
DesktopSettings::Private::_SetDefaults()
|
||||||
{
|
{
|
||||||
_SetFont(fPlainFont, DEFAULT_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE,
|
fPlainFont = *gFontManager->DefaultPlainFont();
|
||||||
DEFAULT_PLAIN_FONT_SIZE, FALLBACK_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE,
|
fBoldFont = *gFontManager->DefaultBoldFont();
|
||||||
B_REGULAR_FACE);
|
fFixedFont = *gFontManager->DefaultFixedFont();
|
||||||
_SetFont(fBoldFont, DEFAULT_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE,
|
|
||||||
DEFAULT_BOLD_FONT_SIZE, FALLBACK_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE,
|
|
||||||
B_BOLD_FACE);
|
|
||||||
_SetFont(fFixedFont, DEFAULT_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,
|
|
||||||
DEFAULT_FIXED_FONT_SIZE, FALLBACK_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,
|
|
||||||
B_REGULAR_FACE);
|
|
||||||
fFixedFont.SetSpacing(B_FIXED_SPACING);
|
|
||||||
|
|
||||||
fMouseMode = B_NORMAL_MOUSE;
|
fMouseMode = B_NORMAL_MOUSE;
|
||||||
|
|
||||||
@@ -67,28 +60,6 @@ DesktopSettings::Private::_SetDefaults()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
DesktopSettings::Private::_SetFont(ServerFont &font, const char *familyName,
|
|
||||||
const char *styleName, float size, const char *fallbackFamily,
|
|
||||||
const char *fallbackStyle, uint16 fallbackFace)
|
|
||||||
{
|
|
||||||
BAutolock locker(gFontManager);
|
|
||||||
|
|
||||||
// try to find a matching font
|
|
||||||
|
|
||||||
FontStyle* style = gFontManager->GetStyle(familyName, styleName);
|
|
||||||
if (style == NULL) {
|
|
||||||
style = gFontManager->GetStyle(fallbackFamily, fallbackStyle);
|
|
||||||
if (style == NULL) {
|
|
||||||
style = gFontManager->FindStyleMatchingFace(fallbackFace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (style != NULL)
|
|
||||||
font.SetStyle(*style);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DesktopSettings::Private::_Load()
|
DesktopSettings::Private::_Load()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,9 +49,6 @@ class DesktopSettings::Private : public BLocker {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _SetDefaults();
|
void _SetDefaults();
|
||||||
void _SetFont(ServerFont& font, const char* family, const char* style,
|
|
||||||
float size, const char *fallbackFamily,
|
|
||||||
const char* fallbackStyle, uint16 fallbackFace);
|
|
||||||
status_t _Load();
|
status_t _Load();
|
||||||
|
|
||||||
ServerFont fPlainFont;
|
ServerFont fPlainFont;
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ struct FontManager::font_mapping {
|
|||||||
FontManager::FontManager()
|
FontManager::FontManager()
|
||||||
: BLooper("Font Manager"),
|
: BLooper("Font Manager"),
|
||||||
fFamilies(20),
|
fFamilies(20),
|
||||||
fDefaultFont(NULL),
|
|
||||||
fScanned(false),
|
fScanned(false),
|
||||||
fNextID(0)
|
fNextID(0)
|
||||||
{
|
{
|
||||||
@@ -68,7 +67,7 @@ FontManager::FontManager()
|
|||||||
_AddSystemPaths();
|
_AddSystemPaths();
|
||||||
_LoadRecentFontMappings();
|
_LoadRecentFontMappings();
|
||||||
|
|
||||||
fInitStatus = _SetDefaultFont();
|
fInitStatus = _SetDefaultFonts();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -141,30 +140,61 @@ FontManager::_RemoveFamily(const char *familyName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
FontStyle*
|
||||||
\brief Sets the font that will be used when you create an empty
|
FontManager::_GetDefaultStyle(const char *familyName, const char *styleName,
|
||||||
ServerFont without specifying a style.
|
const char *fallbackFamily, const char *fallbackStyle,
|
||||||
*/
|
uint16 fallbackFace)
|
||||||
status_t
|
|
||||||
FontManager::_SetDefaultFont()
|
|
||||||
{
|
{
|
||||||
FontStyle* style = GetStyle(DEFAULT_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE);
|
// try to find a matching font
|
||||||
|
|
||||||
|
FontStyle* style = GetStyle(familyName, styleName);
|
||||||
if (style == NULL) {
|
if (style == NULL) {
|
||||||
style = GetStyle(FALLBACK_PLAIN_FONT_FAMILY, DEFAULT_PLAIN_FONT_STYLE);
|
style = GetStyle(fallbackFamily, fallbackStyle);
|
||||||
if (style == NULL) {
|
if (style == NULL) {
|
||||||
style = FindStyleMatchingFace(B_REGULAR_FACE);
|
style = FindStyleMatchingFace(fallbackFace);
|
||||||
if (style == NULL && fFamilies.CountItems() != 0)
|
if (style == NULL && FamilyAt(0) != NULL)
|
||||||
style = FamilyAt(0)->StyleAt(0);
|
style = FamilyAt(0)->StyleAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Sets the fonts that will be used when you create an empty
|
||||||
|
ServerFont without specifying a style, as well as the default
|
||||||
|
Desktop fonts if there are no settings available.
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
FontManager::_SetDefaultFonts()
|
||||||
|
{
|
||||||
|
FontStyle* style = _GetDefaultStyle(DEFAULT_PLAIN_FONT_FAMILY,
|
||||||
|
DEFAULT_PLAIN_FONT_STYLE, FALLBACK_PLAIN_FONT_FAMILY,
|
||||||
|
DEFAULT_PLAIN_FONT_STYLE,
|
||||||
|
B_REGULAR_FACE);
|
||||||
if (style == NULL)
|
if (style == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
fDefaultFont = new (nothrow) ServerFont(*style, DEFAULT_PLAIN_FONT_SIZE);
|
fDefaultPlainFont = new (nothrow) ServerFont(*style, DEFAULT_PLAIN_FONT_SIZE);
|
||||||
if (fDefaultFont == NULL)
|
if (fDefaultPlainFont == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
style = _GetDefaultStyle(DEFAULT_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE,
|
||||||
|
FALLBACK_BOLD_FONT_FAMILY, DEFAULT_BOLD_FONT_STYLE, B_BOLD_FACE);
|
||||||
|
|
||||||
|
fDefaultBoldFont = new (nothrow) ServerFont(*style, DEFAULT_BOLD_FONT_SIZE);
|
||||||
|
if (fDefaultBoldFont == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
style = _GetDefaultStyle(DEFAULT_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE,
|
||||||
|
FALLBACK_FIXED_FONT_FAMILY, DEFAULT_FIXED_FONT_STYLE, B_REGULAR_FACE);
|
||||||
|
|
||||||
|
fDefaultFixedFont = new (nothrow) ServerFont(*style, DEFAULT_FIXED_FONT_SIZE);
|
||||||
|
if (fDefaultFixedFont == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
fDefaultFixedFont->SetSpacing(B_FIXED_SPACING);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -631,9 +661,23 @@ FontManager::FindStyleMatchingFace(uint16 face) const
|
|||||||
|
|
||||||
|
|
||||||
const ServerFont*
|
const ServerFont*
|
||||||
FontManager::DefaultFont() const
|
FontManager::DefaultPlainFont() const
|
||||||
{
|
{
|
||||||
return fDefaultFont;
|
return fDefaultPlainFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const ServerFont*
|
||||||
|
FontManager::DefaultBoldFont() const
|
||||||
|
{
|
||||||
|
return fDefaultBoldFont;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const ServerFont*
|
||||||
|
FontManager::DefaultFixedFont() const
|
||||||
|
{
|
||||||
|
return fDefaultFixedFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ ServerFont::ServerFont()
|
|||||||
:
|
:
|
||||||
fStyle(NULL)
|
fStyle(NULL)
|
||||||
{
|
{
|
||||||
*this = *gFontManager->DefaultFont();
|
*this = *gFontManager->DefaultPlainFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user