2003-01-19 00:43:30 +03:00
|
|
|
//------------------------------------------------------------------------------
|
2004-09-21 02:50:02 +04:00
|
|
|
// Copyright (c) 2001-2002, Haiku, Inc.
|
2003-01-19 00:43:30 +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: FontServer.cpp
|
|
|
|
// Author: DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
// Description: Handles the largest part of the font subsystem
|
|
|
|
//
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
#include <String.h>
|
|
|
|
#include <Directory.h>
|
|
|
|
#include <Entry.h>
|
2003-07-14 00:56:00 +04:00
|
|
|
#include <storage/Path.h> // specified to be able to build under Dano
|
2003-01-19 00:43:30 +03:00
|
|
|
#include <File.h>
|
|
|
|
#include <Message.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2003-09-09 14:26:11 +04:00
|
|
|
#include <FontServer.h>
|
|
|
|
#include <FontFamily.h>
|
|
|
|
#include <ServerFont.h>
|
2003-01-19 00:43:30 +03:00
|
|
|
#include "ServerConfig.h"
|
|
|
|
|
2003-07-24 23:38:24 +04:00
|
|
|
extern FTC_Manager ftmanager;
|
|
|
|
FT_Library ftlib;
|
2003-10-05 21:39:12 +04:00
|
|
|
FontServer *fontserver=NULL;
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2003-08-02 04:13:30 +04:00
|
|
|
//#define PRINT_FONT_LIST
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Access function to request a face via the FreeType font cache
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
static FT_Error face_requester(FTC_FaceID face_id, FT_Library library,
|
|
|
|
FT_Pointer request_data, FT_Face *aface)
|
|
|
|
{
|
|
|
|
CachedFace face = (CachedFace) face_id;
|
|
|
|
return FT_New_Face(ftlib,face->file_path.String(),face->face_index,aface);
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
//! Does basic set up so that directories can be scanned
|
2003-01-19 00:43:30 +03:00
|
|
|
FontServer::FontServer(void)
|
|
|
|
{
|
|
|
|
lock=create_sem(1,"fontserver_lock");
|
|
|
|
init=(FT_Init_FreeType(&ftlib)==0)?true:false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
if(FTC_Manager_New(ftlib,0,0,0,&face_requester,NULL,&ftmanager)!=0
|
|
|
|
&& init)
|
|
|
|
init=false;
|
|
|
|
|
|
|
|
families=new BList(0);
|
|
|
|
plain=NULL;
|
|
|
|
bold=NULL;
|
|
|
|
fixed=NULL;
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
//! Frees items allocated in the constructor and shuts down FreeType
|
2003-01-19 00:43:30 +03:00
|
|
|
FontServer::~FontServer(void)
|
|
|
|
{
|
|
|
|
delete_sem(lock);
|
|
|
|
delete families;
|
|
|
|
FTC_Manager_Done(ftmanager);
|
|
|
|
FT_Done_FreeType(ftlib);
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
//! Locks access to the font server
|
2003-01-19 00:43:30 +03:00
|
|
|
void FontServer::Lock(void)
|
|
|
|
{
|
|
|
|
acquire_sem(lock);
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
//! Unlocks access to the font server
|
2003-01-19 00:43:30 +03:00
|
|
|
void FontServer::Unlock(void)
|
|
|
|
{
|
|
|
|
release_sem(lock);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
int32 FontServer::CountFamilies(void)
|
|
|
|
{
|
|
|
|
if(init)
|
|
|
|
return families->CountItems();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
int32 FontServer::CountStyles(const char *family)
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *f=GetFamily(family);
|
2003-01-19 00:43:30 +03:00
|
|
|
if(f)
|
|
|
|
{
|
|
|
|
return f->CountStyles();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Removes a font family from the font list
|
|
|
|
\param family The family to remove
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
void FontServer::RemoveFamily(const char *family)
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *f=GetFamily(family);
|
2003-01-19 00:43:30 +03:00
|
|
|
if(f)
|
|
|
|
{
|
|
|
|
families->RemoveItem(f);
|
|
|
|
delete f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
const char *FontServer::GetFamilyName(uint16 id) const
|
|
|
|
{
|
|
|
|
FontFamily *fam;
|
|
|
|
for(int32 i=0; i<families->CountItems(); i++)
|
|
|
|
{
|
|
|
|
fam=(FontFamily*)families->ItemAt(i);
|
|
|
|
if(fam && fam->GetID()==id)
|
|
|
|
return fam->Name();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *FontServer::GetStyleName(const char *family, uint16 id) const
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *fam=GetFamily(family);
|
2005-01-17 05:05:50 +03:00
|
|
|
FontStyle *sty;
|
|
|
|
for(int32 i=0; i<families->CountItems(); i++)
|
|
|
|
{
|
|
|
|
sty=fam->GetStyle(i);
|
|
|
|
if(sty && sty->GetID()==id)
|
|
|
|
return sty->Name();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
FontStyle *FontServer::GetStyle(const char *family, uint16 id) const
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *fam=GetFamily(family);
|
2005-01-17 05:05:50 +03:00
|
|
|
FontStyle *sty;
|
|
|
|
for(int32 i=0; i<families->CountItems(); i++)
|
|
|
|
{
|
|
|
|
sty=fam->GetStyle(i);
|
|
|
|
if(sty && sty->GetID()==id)
|
|
|
|
return sty;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Protected function which locates a FontFamily object
|
|
|
|
\param name The family to find
|
|
|
|
\return Pointer to the specified family or NULL if not found.
|
|
|
|
|
|
|
|
Do NOT delete the FontFamily returned by this function.
|
|
|
|
*/
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *FontServer::GetFamily(const char *name) const
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
|
|
|
if(!init)
|
|
|
|
return NULL;
|
|
|
|
int32 count=families->CountItems(), i;
|
|
|
|
FontFamily *family;
|
|
|
|
for(i=0; i<count; i++)
|
|
|
|
{
|
|
|
|
family=(FontFamily*)families->ItemAt(i);
|
|
|
|
if(strcmp(family->Name(),name)==0)
|
|
|
|
return family;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Scan a folder for all valid fonts
|
|
|
|
\param fontspath Path of the folder to scan.
|
|
|
|
\return
|
|
|
|
- \c B_OK Success
|
|
|
|
- \c B_NAME_TOO_LONG The path specified is too long
|
|
|
|
- \c B_ENTRY_NOT_FOUND The path does not exist
|
|
|
|
- \c B_LINK_LIMIT A cyclic loop was detected in the file system
|
|
|
|
- \c B_BAD_VALUE Invalid input specified
|
|
|
|
- \c B_NO_MEMORY Insufficient memory to open the folder for reading
|
|
|
|
- \c B_BUSY A busy node could not be accessed
|
|
|
|
- \c B_FILE_ERROR An invalid file prevented the operation.
|
|
|
|
- \c B_NO_MORE_FDS All file descriptors are in use (too many open files).
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
status_t FontServer::ScanDirectory(const char *fontspath)
|
|
|
|
{
|
|
|
|
// 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;
|
|
|
|
BEntry entry;
|
|
|
|
BPath path;
|
|
|
|
entry_ref ref;
|
|
|
|
status_t stat;
|
|
|
|
int32 refcount,i, validcount=0;
|
|
|
|
FT_Face face;
|
|
|
|
FT_Error error;
|
|
|
|
FT_CharMap charmap;
|
|
|
|
FontFamily *family;
|
2005-01-17 05:05:50 +03:00
|
|
|
FontStyle *style;
|
2003-01-19 00:43:30 +03:00
|
|
|
|
|
|
|
stat=dir.SetTo(fontspath);
|
|
|
|
if(stat!=B_OK)
|
|
|
|
return stat;
|
|
|
|
|
|
|
|
refcount=dir.CountEntries();
|
|
|
|
|
|
|
|
for(i=0;i<refcount;i++)
|
|
|
|
{
|
|
|
|
if(dir.GetNextEntry(&entry)==B_ENTRY_NOT_FOUND)
|
|
|
|
break;
|
|
|
|
|
|
|
|
stat=entry.GetPath(&path);
|
|
|
|
if(stat!=B_OK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
error=FT_New_Face(ftlib,path.Path(),0,&face);
|
|
|
|
|
|
|
|
if (error!=0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
charmap=_GetSupportedCharmap(face);
|
|
|
|
if(!charmap)
|
|
|
|
{
|
|
|
|
FT_Done_Face(face);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
face->charmap=charmap;
|
|
|
|
|
2005-01-17 23:08:40 +03:00
|
|
|
family=GetFamily(face->family_name);
|
2003-01-19 00:43:30 +03:00
|
|
|
|
|
|
|
if(!family)
|
|
|
|
{
|
2003-08-02 04:13:30 +04:00
|
|
|
#ifdef PRINT_FONT_LIST
|
|
|
|
printf("Font Family: %s\n",face->family_name);
|
|
|
|
#endif
|
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
family=new FontFamily(face->family_name,families->CountItems());
|
2003-01-19 00:43:30 +03:00
|
|
|
families->AddItem(family);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(family->HasStyle(face->style_name))
|
|
|
|
{
|
|
|
|
FT_Done_Face(face);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-08-02 04:13:30 +04:00
|
|
|
#ifdef PRINT_FONT_LIST
|
|
|
|
printf("\tFont Style: %s\n",face->style_name);
|
|
|
|
#endif
|
|
|
|
|
2005-01-17 05:05:50 +03:00
|
|
|
style=new FontStyle(path.Path(),face);
|
|
|
|
if(!family->AddStyle(style))
|
|
|
|
delete style;
|
|
|
|
else
|
|
|
|
validcount++;
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2005-03-26 00:02:40 +03:00
|
|
|
// FT_Face is kept open in FontStyle and will be unset in the
|
|
|
|
// FontStyle destructor
|
|
|
|
|
2003-01-19 00:43:30 +03:00
|
|
|
} // end for(i<refcount)
|
|
|
|
|
|
|
|
dir.Unset();
|
|
|
|
|
|
|
|
need_update=true;
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
FT_CharMap FontServer::_GetSupportedCharmap(const FT_Face &face)
|
|
|
|
{
|
|
|
|
int32 i;
|
|
|
|
FT_CharMap charmap;
|
|
|
|
for(i=0; i< face->num_charmaps; i++)
|
|
|
|
{
|
|
|
|
charmap=face->charmaps[i];
|
|
|
|
switch(charmap->platform_id)
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
// if Windows Symbol or Windows Unicode
|
|
|
|
if(charmap->encoding_id==0 || charmap->encoding_id==1)
|
|
|
|
return charmap;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
// if Apple Unicode
|
|
|
|
if(charmap->encoding_id==0)
|
|
|
|
return charmap;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
// if Apple Roman
|
|
|
|
if(charmap->encoding_id==0)
|
|
|
|
return charmap;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief This saves all family names and styles to the file specified in
|
|
|
|
ServerConfig.h as SERVER_FONT_LIST as a flattened BMessage.
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
This operation is not done very often because the access to disk adds a significant
|
|
|
|
performance hit.
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
The format for storage consists of two things: an array of strings with the name 'family'
|
|
|
|
and a number of small string arrays which have the name of the font family. These are
|
|
|
|
the style lists.
|
2003-01-19 00:43:30 +03:00
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
Additionally, any fonts which have bitmap strikes contained in them or any fonts which
|
|
|
|
are fixed-width are named in the arrays 'tuned' and 'fixed'.
|
2003-01-19 00:43:30 +03:00
|
|
|
*/
|
|
|
|
void FontServer::SaveList(void)
|
|
|
|
{
|
2005-01-17 05:05:50 +03:00
|
|
|
/* int32 famcount=0, stycount=0,i=0,j=0;
|
2003-01-19 00:43:30 +03:00
|
|
|
FontFamily *fam;
|
|
|
|
FontStyle *sty;
|
|
|
|
BMessage fontmsg, familymsg('FONT');
|
|
|
|
BString famname, styname, extraname;
|
|
|
|
bool fixed,tuned;
|
|
|
|
|
|
|
|
famcount=families->CountItems();
|
|
|
|
for(i=0; i<famcount; i++)
|
|
|
|
{
|
|
|
|
fam=(FontFamily*)families->ItemAt(i);
|
|
|
|
fixed=false;
|
|
|
|
tuned=false;
|
|
|
|
if(!fam)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
famname=fam->Name();
|
|
|
|
|
|
|
|
// Add the family to the message
|
|
|
|
familymsg.AddString("name",famname);
|
|
|
|
|
|
|
|
stycount=fam->CountStyles();
|
|
|
|
for(j=0;j<stycount;j++)
|
|
|
|
{
|
|
|
|
styname.SetTo(fam->GetStyle(j));
|
|
|
|
if(styname.CountChars()>0)
|
|
|
|
{
|
|
|
|
// Add to list
|
|
|
|
familymsg.AddString("styles", styname);
|
|
|
|
|
|
|
|
// Check to see if it has prerendered strikes (has "tuned" fonts)
|
|
|
|
sty=fam->GetStyle(styname.String());
|
|
|
|
if(!sty)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(sty->HasTuned() && sty->IsScalable())
|
|
|
|
tuned=true;
|
|
|
|
|
|
|
|
// Check to see if it is fixed-width
|
|
|
|
if(sty->IsFixedWidth())
|
|
|
|
fixed=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(tuned)
|
|
|
|
familymsg.AddBool("tuned",true);
|
|
|
|
if(fixed)
|
|
|
|
familymsg.AddBool("fixed",true);
|
|
|
|
|
|
|
|
fontmsg.AddMessage("family",&familymsg);
|
|
|
|
familymsg.MakeEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
BFile file(SERVER_FONT_LIST,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
|
|
|
if(file.InitCheck()==B_OK)
|
|
|
|
fontmsg.Flatten(&file);
|
2005-01-17 05:05:50 +03:00
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
}
|
|
|
|
|
2003-01-20 02:04:58 +03:00
|
|
|
/*!
|
|
|
|
\brief Retrieves the FontStyle object
|
|
|
|
\param family The font's family
|
2005-01-17 05:05:50 +03:00
|
|
|
\param style The font's style
|
2003-01-20 02:04:58 +03:00
|
|
|
\return The FontStyle having those attributes or NULL if not available
|
|
|
|
*/
|
2005-01-17 05:05:50 +03:00
|
|
|
FontStyle *FontServer::GetStyle(const char *family, const char *style)
|
2003-01-19 00:43:30 +03:00
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *ffam=GetFamily(family);
|
2003-01-19 00:43:30 +03:00
|
|
|
|
|
|
|
if(ffam)
|
|
|
|
{
|
2005-01-17 05:05:50 +03:00
|
|
|
FontStyle *fsty=ffam->GetStyle(style);
|
2003-01-19 00:43:30 +03:00
|
|
|
return fsty;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
FontStyle *FontServer::GetStyle(const uint16 &familyid, const uint16 &styleid)
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *fam=GetFamily(familyid);
|
|
|
|
if(fam)
|
|
|
|
{
|
|
|
|
FontStyle *sty=fam->GetStyle(styleid);
|
|
|
|
return sty;
|
|
|
|
}
|
2005-01-17 05:05:50 +03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *FontServer::GetFamily(const uint16 &familyid) const
|
2005-01-17 05:05:50 +03:00
|
|
|
{
|
|
|
|
for(int32 i=0; i<families->CountItems(); i++)
|
|
|
|
{
|
|
|
|
FontFamily *fam=(FontFamily*)families->ItemAt(i);
|
|
|
|
if(fam->GetID()==familyid)
|
|
|
|
return fam;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
ServerFont *FontServer::GetSystemPlain(void)
|
|
|
|
{
|
2005-02-02 02:23:45 +03:00
|
|
|
return plain;
|
2003-01-19 00:43:30 +03: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.
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
ServerFont *FontServer::GetSystemBold(void)
|
|
|
|
{
|
2005-02-02 02:23:45 +03:00
|
|
|
return bold;
|
2003-01-19 00:43:30 +03: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.
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
ServerFont *FontServer::GetSystemFixed(void)
|
|
|
|
{
|
2005-02-02 02:23:45 +03:00
|
|
|
return fixed;
|
2003-01-19 00:43:30 +03: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.
|
|
|
|
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
bool FontServer::SetSystemPlain(const char *family, const char *style, float size)
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *fam=GetFamily(family);
|
2003-01-19 00:43:30 +03:00
|
|
|
if(!fam)
|
|
|
|
return false;
|
|
|
|
FontStyle *sty=fam->GetStyle(style);
|
|
|
|
if(!sty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(plain)
|
|
|
|
delete plain;
|
2005-01-17 05:05:50 +03:00
|
|
|
|
|
|
|
plain=new ServerFont(sty,size);
|
2003-01-19 00:43:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
bool FontServer::SetSystemBold(const char *family, const char *style, float size)
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *fam=GetFamily(family);
|
2003-01-19 00:43:30 +03:00
|
|
|
if(!fam)
|
|
|
|
return false;
|
|
|
|
FontStyle *sty=fam->GetStyle(style);
|
|
|
|
if(!sty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(bold)
|
|
|
|
delete bold;
|
2005-01-17 05:05:50 +03:00
|
|
|
|
|
|
|
bold=new ServerFont(sty,size);
|
2003-01-19 00:43:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2003-01-19 00:43:30 +03:00
|
|
|
bool FontServer::SetSystemFixed(const char *family, const char *style, float size)
|
|
|
|
{
|
2005-01-17 23:08:40 +03:00
|
|
|
FontFamily *fam=GetFamily(family);
|
2003-01-19 00:43:30 +03:00
|
|
|
if(!fam)
|
|
|
|
return false;
|
|
|
|
FontStyle *sty=fam->GetStyle(style);
|
|
|
|
if(!sty)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(fixed)
|
|
|
|
delete fixed;
|
2005-01-17 05:05:50 +03:00
|
|
|
|
|
|
|
fixed=new ServerFont(sty,size);
|
2003-01-19 00:43:30 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|