2005-06-24 07:31:41 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2005, Haiku.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Handles the largest part of the font subsystem */
|
|
|
|
|
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
#include <Directory.h>
|
|
|
|
#include <Entry.h>
|
|
|
|
#include <File.h>
|
|
|
|
#include <Message.h>
|
2005-11-01 19:28:01 +03:00
|
|
|
#include <Path.h>
|
2003-01-19 00:43:30 +03:00
|
|
|
#include <String.h>
|
|
|
|
|
2005-11-02 16:25:39 +03:00
|
|
|
#include <FontManager.h>
|
2003-09-09 14:26:11 +04:00
|
|
|
#include <FontFamily.h>
|
|
|
|
#include <ServerFont.h>
|
2003-01-19 00:43:30 +03:00
|
|
|
#include "ServerConfig.h"
|
|
|
|
|
2005-11-01 20:49:01 +03:00
|
|
|
#include <new>
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2005-11-02 11:55:51 +03:00
|
|
|
static FTC_Manager ftmanager;
|
|
|
|
FT_Library gFreeTypeLibrary;
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager *gFontManager = NULL;
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2003-08-02 04:13:30 +04:00
|
|
|
//#define PRINT_FONT_LIST
|
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
|
|
|
|
#if 0
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Access function to request a face via the FreeType font cache
|
|
|
|
*/
|
2005-11-01 19:28:01 +03:00
|
|
|
static FT_Error
|
2005-06-24 07:31:41 +04:00
|
|
|
face_requester(FTC_FaceID face_id, FT_Library library,
|
2003-01-19 00:43:30 +03:00
|
|
|
FT_Pointer request_data, FT_Face *aface)
|
|
|
|
{
|
|
|
|
CachedFace face = (CachedFace) face_id;
|
2005-11-02 11:55:51 +03:00
|
|
|
return FT_New_Face(gFreeTypeLibrary, face->file_path.String(), face->face_index,aface);
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
2005-11-01 19:28:01 +03:00
|
|
|
#endif
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
//! Does basic set up so that directories can be scanned
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::FontManager()
|
2005-06-24 07:31:41 +04:00
|
|
|
: BLocker("font server lock"),
|
|
|
|
fFamilies(20),
|
|
|
|
fPlain(NULL),
|
|
|
|
fBold(NULL),
|
2005-11-01 20:49:01 +03:00
|
|
|
fFixed(NULL),
|
|
|
|
fNextID(0)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-11-02 11:55:51 +03:00
|
|
|
fInitStatus = FT_Init_FreeType(&gFreeTypeLibrary) == 0 ? B_OK : B_ERROR;
|
2003-01-19 00:43:30 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
Fire up the font caching subsystem.
|
|
|
|
The three zeros tell FreeType to use the defaults, which are 2 faces,
|
|
|
|
4 face sizes, and a maximum of 200000 bytes. I will probably change
|
|
|
|
these numbers in the future to maximize performance for your "average"
|
|
|
|
application.
|
|
|
|
*/
|
2005-11-02 11:55:51 +03:00
|
|
|
// if (FTC_Manager_New(gFreeTypeLibrary, 0, 0, 0, &face_requester, NULL, &ftmanager) != 0)
|
2005-10-20 14:01:49 +04:00
|
|
|
// fInit = false;
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
//! Frees items allocated in the constructor and shuts down FreeType
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::~FontManager()
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
|
|
|
FTC_Manager_Done(ftmanager);
|
2005-11-02 11:55:51 +03:00
|
|
|
FT_Done_FreeType(gFreeTypeLibrary);
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Counts the number of font families available
|
|
|
|
\return The number of unique font families currently available
|
|
|
|
*/
|
2005-11-01 19:28:01 +03:00
|
|
|
int32
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::CountFamilies(void)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-11-01 19:28:01 +03:00
|
|
|
return fFamilies.CountItems();
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Counts the number of styles available in a font family
|
|
|
|
\param family Name of the font family to scan
|
|
|
|
\return The number of font styles currently available for the font family
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
int32
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::CountStyles(const char *familyName)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontFamily *family = GetFamily(familyName);
|
|
|
|
if (family)
|
|
|
|
return family->CountStyles();
|
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Removes a font family from the font list
|
|
|
|
\param family The family to remove
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
void
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::RemoveFamily(const char *familyName)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontFamily *family = GetFamily(familyName);
|
|
|
|
if (family) {
|
|
|
|
fFamilies.RemoveItem(family);
|
|
|
|
delete family;
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2005-08-12 18:55:46 +04:00
|
|
|
//! Scans the four default system font folders
|
|
|
|
void
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::ScanSystemFolders(void)
|
2005-08-12 18:55:46 +04:00
|
|
|
{
|
|
|
|
ScanDirectory("/boot/beos/etc/fonts/ttfonts/");
|
|
|
|
|
|
|
|
// We don't scan these in test mode to help shave off some startup time
|
|
|
|
#if !TEST_MODE
|
|
|
|
ScanDirectory("/boot/beos/etc/fonts/PS-Type1/");
|
|
|
|
ScanDirectory("/boot/home/config/fonts/ttfonts/");
|
|
|
|
ScanDirectory("/boot/home/config/fonts/psfonts/");
|
|
|
|
#endif
|
|
|
|
}
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2005-11-01 20:49:01 +03:00
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Adds the FontFamily/FontStyle that is represented by this path.
|
|
|
|
*/
|
|
|
|
void
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::_AddFont(BPath &path)
|
2005-11-01 20:49:01 +03:00
|
|
|
{
|
|
|
|
FT_Face face;
|
2005-11-02 11:55:51 +03:00
|
|
|
FT_Error error = FT_New_Face(gFreeTypeLibrary, path.Path(), 0, &face);
|
2005-11-01 20:49:01 +03:00
|
|
|
if (error != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
FontFamily *family = GetFamily(face->family_name);
|
|
|
|
if (family != NULL && family->HasStyle(face->style_name)) {
|
|
|
|
// prevent adding the same style twice
|
|
|
|
// (this indicates a problem with the installed fonts maybe?)
|
|
|
|
FT_Done_Face(face);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (family == NULL) {
|
|
|
|
family = new (nothrow) FontFamily(face->family_name, fNextID++);
|
|
|
|
if (family == NULL
|
|
|
|
|| !fFamilies.AddItem(family)) {
|
|
|
|
delete family;
|
|
|
|
FT_Done_Face(face);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef PRINT_FONT_LIST
|
|
|
|
printf("\tFont Style: %s, %s\n", face->family_name, face->style_name);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// the FontStyle takes over ownership of the FT_Face object
|
|
|
|
FontStyle *style = new FontStyle(path.Path(), face);
|
|
|
|
if (!family->AddStyle(style))
|
|
|
|
delete style;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Scan a folder for all valid fonts
|
2005-11-01 20:49:01 +03:00
|
|
|
\param directoryPath Path of the folder to scan.
|
2003-01-20 02:04:58 +03:00
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
status_t
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::ScanDirectory(const char *directoryPath)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
|
|
|
// This bad boy does all the real work. It loads each entry in the
|
|
|
|
// directory. If a valid font file, it adds both the family and the style.
|
|
|
|
// Both family and style are stored internally as BStrings. Once everything
|
|
|
|
|
|
|
|
BDirectory dir;
|
2005-06-24 07:31:41 +04:00
|
|
|
status_t status = dir.SetTo(directoryPath);
|
|
|
|
if (status != B_OK)
|
|
|
|
return status;
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
BEntry entry;
|
|
|
|
while (dir.GetNextEntry(&entry) == B_OK) {
|
|
|
|
BPath path;
|
|
|
|
status = entry.GetPath(&path);
|
|
|
|
if (status < B_OK)
|
2003-01-19 00:43:30 +03:00
|
|
|
continue;
|
|
|
|
|
2005-06-03 23:50:30 +04:00
|
|
|
|
|
|
|
// TODO: Commenting this out makes my "Unicode glyph lookup"
|
|
|
|
// work with our default fonts. The real fix is to select the
|
|
|
|
// Unicode char map (if supported), and/or adjust the
|
|
|
|
// utf8 -> glyph-index mapping everywhere to handle other
|
|
|
|
// char maps. We could also ignore fonts that don't support
|
|
|
|
// the Unicode lookup as a temporary "solution".
|
2005-06-24 07:31:41 +04:00
|
|
|
#if 0
|
|
|
|
FT_CharMap charmap = _GetSupportedCharmap(face);
|
|
|
|
if (!charmap) {
|
2003-01-19 00:43:30 +03:00
|
|
|
FT_Done_Face(face);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
face->charmap = charmap;
|
|
|
|
#endif
|
|
|
|
|
2005-11-01 20:49:01 +03:00
|
|
|
_AddFont(path);
|
|
|
|
// takes over ownership of the FT_Face object
|
2005-06-24 07:31:41 +04:00
|
|
|
}
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
fNeedUpdate = true;
|
2003-01-19 00:43:30 +03:00
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Finds and returns the first valid charmap in a font
|
|
|
|
|
|
|
|
\param face Font handle obtained from FT_Load_Face()
|
|
|
|
\return An FT_CharMap or NULL if unsuccessful
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
FT_CharMap
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::_GetSupportedCharmap(const FT_Face& face)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
for (int32 i = 0; i < face->num_charmaps; i++) {
|
|
|
|
FT_CharMap charmap = face->charmaps[i];
|
|
|
|
|
|
|
|
switch (charmap->platform_id) {
|
2003-01-19 00:43:30 +03:00
|
|
|
case 3:
|
|
|
|
// if Windows Symbol or Windows Unicode
|
2005-06-24 07:31:41 +04:00
|
|
|
if (charmap->encoding_id == 0 || charmap->encoding_id == 1)
|
2003-01-19 00:43:30 +03:00
|
|
|
return charmap;
|
|
|
|
break;
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
case 1:
|
|
|
|
// if Apple Unicode
|
2005-06-24 07:31:41 +04:00
|
|
|
if (charmap->encoding_id == 0)
|
2003-01-19 00:43:30 +03:00
|
|
|
return charmap;
|
|
|
|
break;
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
case 0:
|
|
|
|
// if Apple Roman
|
2005-06-24 07:31:41 +04:00
|
|
|
if (charmap->encoding_id == 0)
|
2003-01-19 00:43:30 +03:00
|
|
|
return charmap;
|
|
|
|
break;
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
return NULL;
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
FontFamily*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetFamilyByIndex(int32 index) const
|
2005-11-01 19:28:01 +03:00
|
|
|
{
|
|
|
|
return fFamilies.ItemAt(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
2005-11-01 19:28:01 +03:00
|
|
|
\brief Locates a FontFamily object by name
|
|
|
|
\param name The family to find
|
|
|
|
\return Pointer to the specified family or NULL if not found.
|
2003-01-20 02:04:58 +03:00
|
|
|
*/
|
2005-11-01 19:28:01 +03:00
|
|
|
FontFamily*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetFamily(const char* name) const
|
2005-11-01 19:28:01 +03:00
|
|
|
{
|
|
|
|
if (name == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
int32 count = fFamilies.CountItems();
|
|
|
|
|
|
|
|
for (int32 i = 0; i < count; i++) {
|
|
|
|
FontFamily* family = fFamilies.ItemAt(i);
|
|
|
|
if (!strcmp(family->Name(), name))
|
|
|
|
return family;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FontFamily*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetFamily(uint16 familyID) const
|
2005-11-01 19:28:01 +03:00
|
|
|
{
|
|
|
|
for (int32 i = 0; i < fFamilies.CountItems(); i++) {
|
|
|
|
FontFamily *family = (FontFamily*)fFamilies.ItemAt(i);
|
|
|
|
if (family->ID() == familyID)
|
|
|
|
return family;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
FontStyle*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetStyleByIndex(const char* familyName, int32 index) const
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontFamily* family = GetFamily(familyName);
|
2005-11-01 19:28:01 +03:00
|
|
|
if (family != NULL)
|
|
|
|
return family->StyleAt(index);
|
2003-01-19 00:43:30 +03:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2005-11-01 19:28:01 +03:00
|
|
|
/*!
|
|
|
|
\brief Retrieves the FontStyle object that comes closest to the one specified
|
|
|
|
|
|
|
|
\param family The font's family or NULL in which case \a familyID is used
|
|
|
|
\param style The font's style or NULL in which case \a styleID is used
|
|
|
|
\param familyID will only be used if \a family is NULL (or empty)
|
|
|
|
\param styleID will only be used if \a style is NULL (or empty)
|
|
|
|
\param face is used to specify the style if both \a style is NULL or empty
|
|
|
|
and styleID is 0xffff.
|
|
|
|
|
|
|
|
\return The FontStyle having those attributes or NULL if not available
|
|
|
|
*/
|
|
|
|
FontStyle*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetStyle(const char* familyName, const char* styleName, uint16 familyID,
|
2005-11-01 19:28:01 +03:00
|
|
|
uint16 styleID, uint16 face)
|
|
|
|
{
|
|
|
|
FontFamily* family;
|
|
|
|
|
|
|
|
// find family
|
|
|
|
|
|
|
|
if (familyName != NULL && familyName[0])
|
|
|
|
family = GetFamily(familyName);
|
|
|
|
else
|
|
|
|
family = GetFamily(familyID);
|
|
|
|
|
|
|
|
if (family == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
// find style
|
|
|
|
|
|
|
|
if (styleName != NULL && styleName[0])
|
|
|
|
return family->GetStyle(styleName);
|
|
|
|
|
|
|
|
if (styleID != 0xffff)
|
|
|
|
return family->GetStyleByID(styleID);
|
|
|
|
|
|
|
|
// try to get from face
|
|
|
|
return family->GetStyleMatchingFace(face);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
/*!
|
|
|
|
\brief Retrieves the FontStyle object
|
|
|
|
\param family ID for the font's family
|
|
|
|
\param style ID of the font's style
|
|
|
|
\return The FontStyle having those attributes or NULL if not available
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
FontStyle*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetStyle(uint16 familyID, uint16 styleID)
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontFamily *family = GetFamily(familyID);
|
|
|
|
if (family)
|
2005-11-01 19:28:01 +03:00
|
|
|
return family->GetStyleByID(styleID);
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the current object used for the regular style
|
|
|
|
\return A ServerFont pointer which is the plain font.
|
|
|
|
|
|
|
|
Do NOT delete this object. If you access it, make a copy of it.
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
ServerFont*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetSystemPlain()
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
return fPlain;
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the current object used for the bold style
|
|
|
|
\return A ServerFont pointer which is the bold font.
|
|
|
|
|
|
|
|
Do NOT delete this object. If you access it, make a copy of it.
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
ServerFont*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetSystemBold()
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
return fBold;
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the current object used for the fixed style
|
|
|
|
\return A ServerFont pointer which is the fixed font.
|
|
|
|
|
|
|
|
Do NOT delete this object. If you access it, make a copy of it.
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
ServerFont*
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::GetSystemFixed()
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
return fFixed;
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Sets the system's plain font to the specified family and style
|
|
|
|
\param family Name of the font's family
|
|
|
|
\param style Name of the style desired
|
|
|
|
\param size Size desired
|
|
|
|
\return true if successful, false if not.
|
|
|
|
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
bool
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::SetSystemPlain(const char* familyName, const char* styleName, float size)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontStyle *style = GetStyle(familyName, styleName);
|
|
|
|
if (style == NULL)
|
2003-01-19 00:43:30 +03:00
|
|
|
return false;
|
2005-06-24 07:31:41 +04:00
|
|
|
|
|
|
|
delete fPlain;
|
2005-11-03 16:10:28 +03:00
|
|
|
fPlain = new ServerFont(*style, size);
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 20:31:44 +03:00
|
|
|
/*!
|
|
|
|
\brief Sets the system's bold font to the specified family and style
|
|
|
|
\param family Name of the font's family
|
|
|
|
\param style Name of the style desired
|
|
|
|
\param size Size desired
|
|
|
|
\return true if successful, false if not.
|
|
|
|
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
bool
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::SetSystemBold(const char* familyName, const char* styleName, float size)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontStyle *style = GetStyle(familyName, styleName);
|
|
|
|
if (style == NULL)
|
2003-01-19 00:43:30 +03:00
|
|
|
return false;
|
2005-06-24 07:31:41 +04:00
|
|
|
|
|
|
|
delete fBold;
|
2005-11-03 16:10:28 +03:00
|
|
|
fBold = new ServerFont(*style, size);
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-20 20:31:44 +03:00
|
|
|
/*!
|
|
|
|
\brief Sets the system's fixed font to the specified family and style
|
|
|
|
\param family Name of the font's family
|
|
|
|
\param style Name of the style desired
|
|
|
|
\param size Size desired
|
|
|
|
\return true if successful, false if not.
|
|
|
|
|
|
|
|
*/
|
2005-06-24 07:31:41 +04:00
|
|
|
bool
|
2005-11-02 16:25:39 +03:00
|
|
|
FontManager::SetSystemFixed(const char* familyName, const char* styleName, float size)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-06-24 07:31:41 +04:00
|
|
|
FontStyle *style = GetStyle(familyName, styleName);
|
|
|
|
if (style == NULL)
|
2003-01-19 00:43:30 +03:00
|
|
|
return false;
|
2005-01-17 05:05:50 +03:00
|
|
|
|
2005-06-24 07:31:41 +04:00
|
|
|
delete fFixed;
|
2005-11-03 16:10:28 +03:00
|
|
|
fFixed = new ServerFont(*style, size);
|
2005-06-24 07:31:41 +04:00
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|