xref: /haiku/src/servers/app/font/AppFontManager.h (revision dd2a1e350b303b855a50fd64e6cb55618be1ae6a)
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, uint16 index, uint16 instance,
41 									uint16& familyID, uint16& styleID);
42 			status_t			AddUserFontFromMemory(const FT_Byte* fontAddress, size_t size,
43 									uint16 index, uint16 instance,
44 									uint16& familyID, uint16& styleID);
45 			status_t			RemoveUserFont(uint16 familyID, uint16 styleID);
46 
47 private:
48 			uint16				_NextID();
49 
50 private:
51 			uint16				fNextID;
52 };
53 
54 
55 #endif	/* APP_FONT_MANAGER_H */
56