| 1 | ' Classes/System/Drawing/FontFamily.ab | 
|---|
| 2 |  | 
|---|
| 3 | Namespace System | 
|---|
| 4 | Namespace Drawing | 
|---|
| 5 |  | 
|---|
| 6 | Class FontFamily | 
|---|
| 7 | Implements IDisposable, ICloneable | 
|---|
| 8 | Public | 
|---|
| 9 | Sub FontFamily(native As *GpFontFamily) | 
|---|
| 10 | nativeFamily = native | 
|---|
| 11 | End Sub | 
|---|
| 12 |  | 
|---|
| 13 | Sub FontFamily(/*IN const*/ name As PCWSTR, fontCollection As FontCollection) | 
|---|
| 14 | SetStatus(GdipCreateFontFamilyFromName(name, getNativeCollection(fontCollection), nativeFamily)) | 
|---|
| 15 | End Sub | 
|---|
| 16 |  | 
|---|
| 17 | Static Function GenericSansSerif() As FontFamily | 
|---|
| 18 | If ActiveBasic.IsNothing(GenericSansSerifFontFamily) Then | 
|---|
| 19 | Dim native As *GpFontFamily | 
|---|
| 20 | SetStatus(GdipGetGenericFontFamilySansSerif(native)) | 
|---|
| 21 | GenericSansSerifFontFamily = New FontFamily(native) | 
|---|
| 22 | End If | 
|---|
| 23 | GenericSansSerif = GenericSansSerifFontFamily | 
|---|
| 24 | End Function | 
|---|
| 25 |  | 
|---|
| 26 | Static Function GenericSerif() As FontFamily | 
|---|
| 27 | If ActiveBasic.IsNothing(GenericSerifFontFamily) Then | 
|---|
| 28 | Dim native As *GpFontFamily | 
|---|
| 29 | SetStatus(GdipGetGenericFontFamilySerif(native)) | 
|---|
| 30 | GenericSerifFontFamily = New FontFamily(native) | 
|---|
| 31 | End If | 
|---|
| 32 | GenericSerif = GenericSerifFontFamily | 
|---|
| 33 | End Function | 
|---|
| 34 |  | 
|---|
| 35 | Static Function GenericMonospace() As FontFamily | 
|---|
| 36 | If ActiveBasic.IsNothing(GenericMonospaceFontFamily) Then | 
|---|
| 37 | Dim native As *GpFontFamily | 
|---|
| 38 | SetStatus(GdipGetGenericFontFamilyMonospace(native)) | 
|---|
| 39 | GenericMonospaceFontFamily = New FontFamily(native) | 
|---|
| 40 | End If | 
|---|
| 41 | GenericMonospace = GenericMonospaceFontFamily | 
|---|
| 42 | End Function | 
|---|
| 43 |  | 
|---|
| 44 | Sub Dispose() | 
|---|
| 45 | If nativeFamily <> 0 Then | 
|---|
| 46 | GdipDeleteFontFamily(nativeFamily) | 
|---|
| 47 | End If | 
|---|
| 48 | nativeFamily = 0 | 
|---|
| 49 | End Sub | 
|---|
| 50 |  | 
|---|
| 51 | Sub ~FontFamily() | 
|---|
| 52 | Dispose() | 
|---|
| 53 | End Sub | 
|---|
| 54 |  | 
|---|
| 55 | Function Clone() As FontFamily | 
|---|
| 56 | Dim cloned As *GpFontFamily | 
|---|
| 57 | SetStatus(GdipCloneFontFamily(nativeFamily, cloned)) | 
|---|
| 58 | Clone = New FontFamily(cloned) | 
|---|
| 59 | End Function | 
|---|
| 60 |  | 
|---|
| 61 | Function GetName(language As LANGID) As String | 
|---|
| 62 | Dim name[ELM(LF_FACESIZE)] As WCHAR | 
|---|
| 63 | SetStatus(GdipGetFamilyName(nativeFamily, name, language)) | 
|---|
| 64 | Dim p = name As PCWSTR | 
|---|
| 65 | GetName = New String(p) | 
|---|
| 66 | End Function | 
|---|
| 67 |  | 
|---|
| 68 | Function IsStyleAvailable(style As FontStyle) As Boolean | 
|---|
| 69 | Dim StyleAvailable As BOOL | 
|---|
| 70 | SetStatus(GdipIsStyleAvailable(nativeFamily, style, StyleAvailable)) | 
|---|
| 71 | IsStyleAvailable = StyleAvailable As Boolean | 
|---|
| 72 | End Function | 
|---|
| 73 |  | 
|---|
| 74 | Function GetEmHeight(style As FontStyle) As Word | 
|---|
| 75 | SetStatus(GdipGetEmHeight(nativeFamily, style, GetEmHeight)) | 
|---|
| 76 | End Function | 
|---|
| 77 | /* | 
|---|
| 78 | Function GetCellAscent(style As FontStyle) As Word | 
|---|
| 79 | SetStatus(GdipGetCellAscent(nativeFamily, style, GetEmHeight)) | 
|---|
| 80 | End Function | 
|---|
| 81 |  | 
|---|
| 82 | Function GetCellDescent(style As FontStyle) As Word | 
|---|
| 83 | SetStatus(GdipGetCellDescent(nativeFamily, style, GetEmHeight)) | 
|---|
| 84 | End Function | 
|---|
| 85 |  | 
|---|
| 86 |  | 
|---|
| 87 | Function GetLineSpacing(style As FontStyle) As Word | 
|---|
| 88 | SetStatus(GdipGetLineSpacing(nativeFamily, style, GetEmHeight)) | 
|---|
| 89 | End Function | 
|---|
| 90 | */ | 
|---|
| 91 | ' Familes | 
|---|
| 92 |  | 
|---|
| 93 | Function NativeFamily() As *GpFontFamily | 
|---|
| 94 | NativeFamily = nativeFamily | 
|---|
| 95 | End Function | 
|---|
| 96 |  | 
|---|
| 97 | Private | 
|---|
| 98 |  | 
|---|
| 99 | nativeFamily As *GpFontFamily | 
|---|
| 100 |  | 
|---|
| 101 | Static Function getNativeCollection(fc As FontCollection) As *GpFontCollection | 
|---|
| 102 | If ActiveBasic.IsNothing(fc) Then | 
|---|
| 103 | getNativeCollection = 0 | 
|---|
| 104 | Else | 
|---|
| 105 | getNativeCollection = fc.nativeCollection | 
|---|
| 106 | End If | 
|---|
| 107 | End Function | 
|---|
| 108 |  | 
|---|
| 109 | Static GenericSansSerifFontFamily = Nothing As FontFamily | 
|---|
| 110 | Static GenericSerifFontFamily = Nothing As FontFamily | 
|---|
| 111 | Static GenericMonospaceFontFamily = Nothing As FontFamily | 
|---|
| 112 |  | 
|---|
| 113 | End Class | 
|---|
| 114 |  | 
|---|
| 115 |  | 
|---|
| 116 |  | 
|---|
| 117 | End Namespace | 
|---|
| 118 | End Namespace | 
|---|