' Classes/System/Drawing/FontFamily.ab

Namespace System
Namespace Drawing

Class FontFamily
	Implements IDisposable, ICloneable
Public
	Sub FontFamily(native As *GpFontFamily)
		nativeFamily = native
	End Sub

	Sub FontFamily(/*IN const*/ name As PCWSTR, fontCollection As FontCollection)
		SetStatus(GdipCreateFontFamilyFromName(name, getNativeCollection(fontCollection), nativeFamily))
	End Sub

	Static Function GenericSansSerif() As FontFamily
		If ActiveBasic.IsNothing(GenericSansSerifFontFamily) Then
			Dim native As *GpFontFamily
			SetStatus(GdipGetGenericFontFamilySansSerif(native))
			GenericSansSerifFontFamily = New FontFamily(native)
		End If
		GenericSansSerif = GenericSansSerifFontFamily
	End Function

	Static Function GenericSerif() As FontFamily
		If ActiveBasic.IsNothing(GenericSerifFontFamily) Then
			Dim native As *GpFontFamily
			SetStatus(GdipGetGenericFontFamilySerif(native))
			GenericSerifFontFamily = New FontFamily(native)
		End If
		GenericSerif = GenericSerifFontFamily
	End Function

	Static Function GenericMonospace() As FontFamily
		If ActiveBasic.IsNothing(GenericMonospaceFontFamily) Then
			Dim native As *GpFontFamily
			SetStatus(GdipGetGenericFontFamilyMonospace(native))
			GenericMonospaceFontFamily = New FontFamily(native)
		End If
		GenericMonospace = GenericMonospaceFontFamily
	End Function

	Sub Dispose()
		If nativeFamily <> 0 Then
			GdipDeleteFontFamily(nativeFamily)
		End If
		nativeFamily = 0
	End Sub

	Sub ~FontFamily()
		Dispose()
	End Sub

	Function Clone() As FontFamily
		Dim cloned As *GpFontFamily
		SetStatus(GdipCloneFontFamily(nativeFamily, cloned))
		Clone = New FontFamily(cloned)
	End Function

	Function GetName(language As LANGID) As String
		Dim name[ELM(LF_FACESIZE)] As WCHAR
		SetStatus(GdipGetFamilyName(nativeFamily, name, language))
		Dim p = name As PCWSTR
		GetName = New String(p)
	End Function

	Function IsStyleAvailable(style As FontStyle) As Boolean
		Dim StyleAvailable As BOOL
		SetStatus(GdipIsStyleAvailable(nativeFamily, style, StyleAvailable))
		IsStyleAvailable = StyleAvailable As Boolean
	End Function

	Function GetEmHeight(style As FontStyle) As Word
		SetStatus(GdipGetEmHeight(nativeFamily, style, GetEmHeight))
	End Function
/*
	Function GetCellAscent(style As FontStyle) As Word
		SetStatus(GdipGetCellAscent(nativeFamily, style, GetEmHeight))
	End Function

	Function GetCellDescent(style As FontStyle) As Word
		SetStatus(GdipGetCellDescent(nativeFamily, style, GetEmHeight))
	End Function


	Function GetLineSpacing(style As FontStyle) As Word
		SetStatus(GdipGetLineSpacing(nativeFamily, style, GetEmHeight))
	End Function
*/
	' Familes

	Function NativeFamily() As *GpFontFamily
		NativeFamily = nativeFamily
	End Function

Private

	nativeFamily As *GpFontFamily

	Static Function getNativeCollection(fc As FontCollection) As *GpFontCollection
		If ActiveBasic.IsNothing(fc) Then
			getNativeCollection = 0
		Else
			getNativeCollection = fc.nativeCollection
		End If
	End Function

	Static GenericSansSerifFontFamily = Nothing As FontFamily
	Static GenericSerifFontFamily = Nothing As FontFamily
	Static GenericMonospaceFontFamily = Nothing As FontFamily

End Class



End Namespace
End Namespace
