1 type Font
2 {
3 uint hFont
4 }
5
6 type FontManager <inherit=hash>
7 {
8 }
9
10 method Font FontManager.GetFont( str name )
11 {
12 return this[name]->Font
13 }
14
15 method FontManager.AddFont( str name, uint hFont )
16 {
17 uint f as .GetFont( name )
18 if &f
19 {
20 DeleteObject( f.hFont )
21 }
22 else
23 {
24 f as new( Font )->Font
25 this[name] = &f
26 }
27 //print( " \(&f) \(name) \(hFont )\n" )
28 f.hFont = hFont
29 }
30
31 method FontManager FontManager.Default()
32 {
33 uint hfont
34 int cur
35 LOGFONT lf
36 GetObject( GetStockObject( $DEFAULT_GUI_FONT ), sizeof( LOGFONT ), &lf )
37 .AddFont( "default", CreateFontIndirect( lf ) )
38
39 cur = lf.lfUnderline
40 lf.lfUnderline = 1
41 .AddFont( "default_underline", CreateFontIndirect( lf ) )
42 lf.lfUnderline = cur
43
44 cur = lf.lfWeight
45 lf.lfWeight = 800
46 .AddFont( "default_bold", CreateFontIndirect( lf ) )
47 lf.lfWeight = cur
48
49 cur = lf.lfHeight
50 lf.lfHeight = int( double(cur) * 1.5 )
51 .AddFont( "default_big", CreateFontIndirect( lf ) )
52 lf.lfHeight = cur
53
54 return this
55 }
Редактировать