haiku/headers/private/servers/app/FontServer.h
Axel Dörfler 9b1ad6f45e Fixed a bunch of bugs in the font sub-system:
* BFont::Face() was almost always wrong - also on the server side,
  _TranslateStyleToFace() was broken.
* a clean font was not correctly initialized to be_plain_font
* BFont::GetFamilyAndStyle() did not work correctly if either family
  or style was NULL - which is allowed, and shouldn't have let it abort
  its task.
* FontServer::GetStyle() by ID did not work reliably under certain
  circumstances (but those were not reached with the current server)
* BFont::SetFamilyAndStyle() did not work when family was NULL, and
  it also never set fFace correctly.
* Introduced a FontFamily::GetStyleWithFace()
* Renamed some FontFamily/FontStyle methods from ie. GetID() to ID()
  to match the style used everywhere else in BeOS.
* Removed AS_SET_FAMILY_NAME as its no longer in use.
* Lots of cleanup and simplification.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14602 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-31 23:21:36 +00:00

86 lines
2.1 KiB
C++

/*
* Copyright 2001-2005, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef FONTSERVER_H_
#define FONTSERVER_H_
#include <OS.h>
#include <List.h>
#include <SupportDefs.h>
#include <Font.h>
#include <Locker.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_CACHE_H
class FontFamily;
class FontStyle;
class ServerFont;
/*!
\class FontServer FontServer.h
\brief Manager for the largest part of the font subsystem
*/
class FontServer : public BLocker {
public:
FontServer();
~FontServer();
/*!
\brief Determines whether the font server has started up properly
\return true if so, false if not.
*/
bool IsInitialized() { return fInit; }
int32 CountFamilies();
int32 CountStyles(const char *family);
void RemoveFamily(const char *family);
void ScanSystemFolders();
status_t ScanDirectory(const char *path);
void SaveList();
const char *GetFamilyName(uint16 id) const;
const char *GetStyleName(const char *family, uint16 id) const;
FontStyle *GetStyle(const char *family, const char *style, uint16 face = 0);
FontStyle *GetStyle(const char *family, uint16 id) const;
FontStyle *GetStyle(uint16 familyID, uint16 styleID);
FontFamily *GetFamily(uint16 familyID) const;
FontFamily *GetFamily(const char *name) const;
ServerFont *GetSystemPlain();
ServerFont *GetSystemBold();
ServerFont *GetSystemFixed();
bool SetSystemPlain(const char *family, const char *style, float size);
bool SetSystemBold(const char *family, const char *style, float size);
bool SetSystemFixed(const char *family, const char *style, float size);
bool FontsNeedUpdated() { return fNeedUpdate; }
/*!
\brief Called when the fonts list has been updated
*/
void FontsUpdated() { fNeedUpdate = false; }
protected:
uint16 TranslateStyleToFace(const char *name) const;
FT_CharMap _GetSupportedCharmap(const FT_Face &face);
private:
bool fInit;
BList fFamilies;
ServerFont *fPlain, *fBold, *fFixed;
bool fNeedUpdate;
};
extern FTC_Manager ftmanager;
extern FT_Library ftlib;
extern FontServer *gFontServer;
#endif /* FONTSERVER_H_ */