4 #if !defined(ECERE_VANILLA)
8 public class FontResource : Resource
11 property const char * faceName { set { delete faceName; faceName = CopyString(value); } get { return this ? faceName : null; } };
12 property float size { set { size = value; } get { return this ? size : 0; } };
13 property bool bold { set { flags.bold = value; } get { return this ? flags.bold : false; } };
14 property bool italic { set { flags.italic = value; } get { return this ? flags.italic : false; } };
15 property bool underline { set { flags.underline = value; } get { return this ? flags.underline : false; } };
16 property Font font { get { return this ? font : null; } };
17 property Window window { set { if(value) { value.RemoveResource(this); value.AddResource(this); } } };
18 property float outlineSize { set { outlineSize = value; } get { return this ? outlineSize : 0; } };
19 property float outlineFade { set { outlineFade = value; } get { return this ? outlineFade : 0; } };
20 #if !defined(ECERE_VANILLA)
21 property FMFont fmFont { get { return this ? fmFont : null; } };
29 DisplaySystem displaySystem;
30 float outlineSize, outlineFade;
31 #if !defined(ECERE_VANILLA)
36 void Load(FontResource copy, DisplaySystem displaySystem)
39 faceName = *&CopyString(copy.faceName);
41 *&flags = *©.flags;
42 *&outlineSize = *©.outlineSize;
43 *&outlineFade = *©.outlineFade;
44 if(faceName && displaySystem)
46 this.displaySystem = displaySystem;
47 font = displaySystem.LoadOutlineFont(faceName, size, flags, outlineSize, outlineFade);
51 #if !defined(ECERE_VANILLA)
52 void LoadFM(FontResource copy, DisplaySystem displaySystem, FontManager fm)
54 Load(copy, displaySystem);
58 fmFont = fm.getFont(this);
63 void Reference(FontResource reference)
66 faceName = *&CopyString(reference.faceName);
67 *&size = *&reference.size;
68 *&flags = *&reference.flags;
69 *&outlineSize = *&reference.outlineSize;
70 *&outlineFade = *&reference.outlineFade;
71 font = reference.font;
72 #if !defined(ECERE_VANILLA)
73 fmFont = reference.fmFont;
80 #if !defined(ECERE_VANILLA)
87 if(font && displaySystem)
88 displaySystem.UnloadFont(font);
89 #if !defined(ECERE_VANILLA)
91 fm.removeFont(fmFont);
96 void OnCopy(FontResource newData)
98 property::size = newData.size;
99 property::faceName = newData.faceName;
100 property::bold = newData.bold;
101 property::outlineSize = newData.outlineSize;
102 property::outlineFade = newData.outlineFade;
106 Window OnEdit(Window window, Window master, int x, int y, int w, int h, void * userData)
108 Window editData = class::OnEdit(window, master, x + 24,y,w - 48,h, userData);
111 window, master = editData, inactive = true, text = "...", hotKey = F2,
112 position = { Max(x + 24, x + w - 24), y }, size = { 24, h }
118 void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags flags)
120 char * string = this ? faceName : null;
121 Font font = this ? font : null;
122 if(!string) string = "(none)";
123 surface.WriteTextDots(alignment, x + 24, y + 1, width - 24, string, strlen(string));
124 surface.SetBackground(White);
125 surface.Area(x - 4, y, x + 20, y + 15);
127 surface.SetForeground(Black);
128 surface.Rectangle(x-1, y + 1, x + 18, y + 14);
131 int OnCompare(FontResource font2)
136 char * string1 = faceName;
137 char * string2 = font2.faceName;
138 if(string1 && string2)
139 result = strcmpi(string1, string2);
144 const char * OnGetString(char * string, void * fieldDat, bool * needClass)
148 char * fileName = faceName;
150 strcpy(string, fileName);
158 bool OnGetDataFromString(const char * string)
160 this = (string && string[0]) ? FontResource { } : null;