-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgdiplusfontcollection.go
91 lines (72 loc) · 2.33 KB
/
gdiplusfontcollection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package gdiplus
import (
. "github.com/tryor/winapi"
)
type IFontCollection interface {
GetNativeFontCollection() *GpFontCollection
GetFamilyCount() (numFound INT)
GetFamilies(numSought INT, gpfamilies []*FontFamily) Status
Release()
}
type FontCollection struct {
GdiplusBase
nativeFontCollection *GpFontCollection
}
func (this *FontCollection) GetNativeFontCollection() *GpFontCollection {
return this.nativeFontCollection
}
func (this *FontCollection) Release() {
}
func (this *FontCollection) GetFamilyCount() (numFound INT) {
this.setStatus(GdipGetFontCollectionFamilyCount(this.nativeFontCollection, &numFound))
return
}
func (this *FontCollection) GetFamilies(numSought INT, gpfamilies []*FontFamily) Status {
if numSought <= 0 || gpfamilies == nil || len(gpfamilies) == 0 {
return this.setStatus(InvalidParameter, nil)
}
numFound := INT(0)
//GpFontFamily **nativeFamilyList = new GpFontFamily*[numSought];
nativeFamilyList := make([]*GpFontFamily, numSought)
this.setStatus(GdipGetFontCollectionFamilyList(
this.nativeFontCollection,
numSought,
nativeFamilyList,
&numFound))
if this.LastResult == Ok {
for i := INT(0); i < numFound; i++ {
GdipCloneFontFamily(nativeFamilyList[i], &gpfamilies[i].nativeFamily)
}
}
return this.LastResult
}
type InstalledFontCollection struct {
FontCollection
}
func NewInstalledFontCollection() (*InstalledFontCollection, error) {
fc := &InstalledFontCollection{}
fc.setStatus(GdipNewInstalledFontCollection(&fc.nativeFontCollection))
return fc, fc.LastError
}
func (this *InstalledFontCollection) Release() {
}
type PrivateFontCollection struct {
FontCollection
}
func NewPrivateFontCollection() (*PrivateFontCollection, error) {
fc := &PrivateFontCollection{}
fc.setStatus(GdipNewPrivateFontCollection(&fc.nativeFontCollection))
return fc, fc.LastError
}
func (this *PrivateFontCollection) Release() {
if this.nativeFontCollection != nil {
this.setStatus(GdipDeletePrivateFontCollection(&this.nativeFontCollection))
this.nativeFontCollection = nil
}
}
func (this *PrivateFontCollection) AddFontFile(filename string) Status {
return this.setStatus(GdipPrivateAddFontFile(this.nativeFontCollection, filename))
}
func (this *PrivateFontCollection) AddMemoryFont(memory []byte) Status {
return this.setStatus(GdipPrivateAddMemoryFont(this.nativeFontCollection, memory))
}