xref: /haiku/src/servers/app/font/AppFontManager.h (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
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 APP_FONT_MANAGER_H
10 #define APP_FONT_MANAGER_H
11 
12 
13 #include "FontManager.h"
14 
15 #include <Locker.h>
16 
17 
18 #include <ft2build.h>
19 #include FT_FREETYPE_H
20 
21 struct node_ref;
22 
23 
24 // font areas should be less than 20MB
25 #define MAX_FONT_DATA_SIZE_BYTES	20 * 1024 * 1024
26 #define MAX_USER_FONTS				128
27 
28 /*!
29 	\class AppFontManager AppFontManager.h
30 	\brief Manager for application-added fonts in the font subsystem
31 */
32 class AppFontManager : public FontManager, BLocker {
33 public:
34 								AppFontManager();
35 
36 			bool				Lock() { return BLocker::Lock(); }
37 			void				Unlock() { BLocker::Unlock(); }
38 			bool				IsLocked() const { return BLocker::IsLocked(); }
39 
40 			status_t			AddUserFontFromFile(const char* path,
41 									uint16& familyID, uint16& styleID);
42 			status_t			AddUserFontFromMemory(const FT_Byte* fontAddress,
43 									size_t size, uint16& familyID, uint16& styleID);
44 			status_t			RemoveUserFont(uint16 familyID, uint16 styleID);
45 
46 private:
47 			uint16				_NextID();
48 
49 private:
50 			uint16				fNextID;
51 };
52 
53 
54 #endif	/* APP_FONT_MANAGER_H */
55