1 /* 2 * Copyright 2001-2009, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * DarkWyrm <bpmagic@columbus.rr.com> 7 * Axel Dörfler, axeld@pinc-software.de 8 */ 9 #ifndef GLOBAL_FONT_MANAGER_H 10 #define GLOBAL_FONT_MANAGER_H 11 12 13 #include "FontManager.h" 14 15 #include <AutoDeleter.h> 16 #include <Looper.h> 17 #include <ObjectList.h> 18 19 20 class BEntry; 21 class BPath; 22 struct node_ref; 23 24 25 class FontFamily; 26 class FontStyle; 27 class ServerFont; 28 29 30 /*! 31 \class GlobalFontManager GlobalFontManager.h 32 \brief Manager for system fonts within the font subsystem 33 */ 34 class GlobalFontManager : public FontManager, public BLooper { 35 public: 36 GlobalFontManager(); 37 virtual ~GlobalFontManager(); 38 39 bool Lock() { return BLooper::Lock(); } 40 void Unlock() { BLooper::Unlock(); } 41 bool IsLocked() const { return BLooper::IsLocked(); } 42 43 status_t InitCheck() { return fInitStatus; } 44 45 void SaveRecentFontMappings(); 46 47 virtual void MessageReceived(BMessage* message); 48 49 virtual int32 CountFamilies(); 50 51 virtual int32 CountStyles(const char* family); 52 virtual int32 CountStyles(uint16 familyID); 53 54 int32 CheckRevision(uid_t user); 55 56 const ServerFont* DefaultPlainFont() const; 57 const ServerFont* DefaultBoldFont() const; 58 const ServerFont* DefaultFixedFont() const; 59 60 void AttachUser(uid_t userID); 61 void DetachUser(uid_t userID); 62 63 virtual FontFamily* GetFamily(uint16 familyID) const; 64 virtual FontFamily* GetFamily(const char* name); 65 66 virtual FontStyle* GetStyle(uint16 familyID, uint16 styleID) const; 67 virtual FontStyle* GetStyle(const char* familyName, 68 const char* styleName, 69 uint16 familyID = 0xffff, 70 uint16 styleID = 0xffff, 71 uint16 face = 0); 72 73 private: 74 struct font_directory; 75 struct font_mapping; 76 77 void _AddDefaultMapping(const char* family, 78 const char* style, const char* path); 79 bool _LoadRecentFontMappings(); 80 status_t _AddMappedFont(const char* family, 81 const char* style = NULL); 82 void _PrecacheFontFile(const ServerFont* font); 83 void _AddSystemPaths(); 84 font_directory* _FindDirectory(node_ref& nodeRef); 85 void _RemoveDirectory(font_directory* directory); 86 status_t _CreateDirectories(const char* path); 87 status_t _AddPath(const char* path); 88 status_t _AddPath(BEntry& entry, 89 font_directory** _newDirectory = NULL); 90 91 void _ScanFontsIfNecessary(); 92 void _ScanFonts(); 93 status_t _ScanFontDirectory(font_directory& directory); 94 status_t _AddFont(font_directory& directory, 95 BEntry& entry); 96 void _RemoveStyle(font_directory& directory, 97 FontStyle* style); 98 void _RemoveStyle(dev_t device, uint64 directory, 99 uint64 node); 100 FontStyle* _GetDefaultStyle(const char* familyName, 101 const char* styleName, 102 const char* fallbackFamily, 103 const char* fallbackStyle, 104 uint16 fallbackFace); 105 status_t _SetDefaultFonts(); 106 107 private: 108 status_t fInitStatus; 109 110 typedef BObjectList<font_directory> DirectoryList; 111 typedef BObjectList<font_mapping> MappingList; 112 113 DirectoryList fDirectories; 114 MappingList fMappings; 115 116 ObjectDeleter<ServerFont> 117 fDefaultPlainFont; 118 ObjectDeleter<ServerFont> 119 fDefaultBoldFont; 120 ObjectDeleter<ServerFont> 121 fDefaultFixedFont; 122 123 bool fScanned; 124 125 }; 126 127 128 extern GlobalFontManager* gFontManager; 129 130 #endif /* GLOBAL_FONT_MANAGER_H */ 131