-
Notifications
You must be signed in to change notification settings - Fork 20
/
module.d.ts
219 lines (191 loc) · 4.48 KB
/
module.d.ts
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
export interface LoadFlags {
noScale?: boolean
noHinting?: boolean
render?: boolean
noBitmap?: boolean
verticalLayout?: boolean
forceAutohint?: boolean
pedantic?: boolean
noRecurse?: boolean
ignoreTransform?: boolean
monochrome?: boolean
linearDesign?: boolean
noAutohint?: boolean
loadTarget?: RenderMode
color?: boolean
computeMetrics?: boolean
bitmapMetricsOnly?: boolean
}
export const FreeTypeVersion: string;
export enum SizeRequestType {
NOMINAL,
REAL_DIM,
BBOX,
CELL,
SCALES
}
export interface SizeRequest {
type: SizeRequestType
width: number
height: number
horiResolution: number
vertResolution: number
}
export type Matrix = [ number, number, number, number ]
export type Vector = [ number, number ]
export interface Char {
charCode: number
glyphIndex: number
}
export interface FontFaceProperties {
numFaces: number
faceIndex: number
faceFlags: {
scalable: boolean
fixedSizes: boolean
fixedWidth: boolean
sfnt: boolean
horizontal: boolean
vertical: boolean
kerning: boolean
multipleMasters: boolean
glyphNames: boolean
externalStream: boolean
hinter: boolean
cidKeyed: boolean
tricky: boolean
color: boolean
variation: boolean
}
styleFlags: {
italic: boolean
bold: boolean
}
numGlyphs: number
familyName: string
styleName: string
availableSizes: Array<{
height: number
width: number
size: number
xppem: number
yppem: number
}>
bbox: {
xMin: number
yMin: number
xMax: number
yMax: number
}
unitsPerEM: number
ascender: number
descender: number
height: number
maxAdvanceWidth: number
maxAdvanceHeight: number
underlinePosition: number
underlineThickness: number
size: {
xppem: number
yppem: number
xScale: number
yScale: number
ascender: number
descender: number
height: number
maxAdvance: number
}
}
export enum RenderMode {
NORMAL,
LIGHT,
MONO,
LCD,
LCD_V
}
export enum PixelMode {
NONE,
MONO,
GRAY,
GRAY2,
GRAY4,
LCD,
LCD_V,
BGRA
}
export enum KerningMode {
DEFAULT,
UNFITTED,
UNSCALED
}
export interface GlyphBitmap {
bitmap: {
height: number
width: number
pitch: number
buffer: Buffer
pixelMode: PixelMode
numGrays: number | null
}
bitmapLeft: number
bitmapTop: number
}
export enum GlyphFormat {
NONE,
COMPOSITE,
BITMAP,
OUTLINE,
PLOTTER
}
export interface Glyph {
bitmap: {
height: number
width: number
pitch: number
buffer: Buffer
pixelMode: PixelMode
numGrays: number | null
} | null
bitmapLeft: number | null
bitmapTop: number | null
metrics: {
isFontUnits: boolean
width: number
height: number
horiBearingX: number
horiBearingY: number
horiAdvance: number
vertBearingX: number
vertBearingY: number
vertAdvance: number
}
format: GlyphFormat
lsbDelta: number
rsbDelta: number
}
export class FontFace {
properties(): FontFaceProperties
setCharSize(charWidth: number, charHeight: number, horzResolution: number, vertResolution: number): void
setPixelSizes(pixelWidth: number, pixelHeight: number): void
// requestSize(props: SizeRequest): void
selectSize(strikeIndex: number): void
setTransform(matrix?: Matrix, vector?: Vector): void
getCharIndex(charCode: number): number | null
getFirstChar(): Char | null
getNextChar(charCode: number): Char | null
// getNameIndex
loadGlyph(glyphIndex: number, loadFlags?: LoadFlags): Glyph
loadChar(charCode: number, loadFlags?: LoadFlags): Glyph
renderGlyph(renderMode: RenderMode): GlyphBitmap
getKerning(leftGlyphIndex: number, rightGlyphIndex: number, kerningMode: KerningMode): Vector
// getTrackKerning(pointSize: number, degree: number): number
// getGlyphName
// getPostscriptName
// selectCharmap
// setCharmap
// getCharmapIndex
// getFSTypeFlags
// getSubGlyphInfo
}
export function NewFace(filepath: string, faceIndex?: number): FontFace;
export function NewMemoryFace(buffer: Buffer, faceIndex?: number): FontFace;