summaryrefslogtreecommitdiff
path: root/meta/3rd/love2d/library/love/font.lua
blob: 53c36fb7d9a303b0e1135ccf9d365f714a7bdb65 (plain)
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
---@meta

---
---Allows you to work with fonts.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font)
---
---@class love.font
love.font = {}

---
---Creates a new BMFont Rasterizer.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font.newBMFontRasterizer)
---
---@overload fun(fileName: string, glyphs: string, dpiscale?: number):love.Rasterizer
---@param imageData love.ImageData # The image data containing the drawable pictures of font glyphs.
---@param glyphs string # The sequence of glyphs in the ImageData.
---@param dpiscale? number # DPI scale.
---@return love.Rasterizer rasterizer # The rasterizer.
function love.font.newBMFontRasterizer(imageData, glyphs, dpiscale) end

---
---Creates a new GlyphData.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font.newGlyphData)
---
---@param rasterizer love.Rasterizer # The Rasterizer containing the font.
---@param glyph number # The character code of the glyph.
function love.font.newGlyphData(rasterizer, glyph) end

---
---Creates a new Image Rasterizer.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font.newImageRasterizer)
---
---@param imageData love.ImageData # Font image data.
---@param glyphs string # String containing font glyphs.
---@param extraSpacing? number # Font extra spacing.
---@param dpiscale? number # Font DPI scale.
---@return love.Rasterizer rasterizer # The rasterizer.
function love.font.newImageRasterizer(imageData, glyphs, extraSpacing, dpiscale) end

---
---Creates a new Rasterizer.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font.newRasterizer)
---
---@overload fun(data: love.FileData):love.Rasterizer
---@overload fun(size?: number, hinting?: love.HintingMode, dpiscale?: number):love.Rasterizer
---@overload fun(fileName: string, size?: number, hinting?: love.HintingMode, dpiscale?: number):love.Rasterizer
---@overload fun(fileData: love.FileData, size?: number, hinting?: love.HintingMode, dpiscale?: number):love.Rasterizer
---@overload fun(imageData: love.ImageData, glyphs: string, dpiscale?: number):love.Rasterizer
---@overload fun(fileName: string, glyphs: string, dpiscale?: number):love.Rasterizer
---@param filename string # The font file.
---@return love.Rasterizer rasterizer # The rasterizer.
function love.font.newRasterizer(filename) end

---
---Creates a new TrueType Rasterizer.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font.newTrueTypeRasterizer)
---
---@overload fun(fileName: string, size?: number, hinting?: love.HintingMode, dpiscale?: number):love.Rasterizer
---@overload fun(fileData: love.FileData, size?: number, hinting?: love.HintingMode, dpiscale?: number):love.Rasterizer
---@param size? number # The font size.
---@param hinting? love.HintingMode # True Type hinting mode.
---@param dpiscale? number # The font DPI scale.
---@return love.Rasterizer rasterizer # The rasterizer.
function love.font.newTrueTypeRasterizer(size, hinting, dpiscale) end

---
---A GlyphData represents a drawable symbol of a font Rasterizer.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font)
---
---@class love.GlyphData: love.Data, love.Object
local GlyphData = {}

---
---Gets glyph advance.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getAdvance)
---
---@return number advance # Glyph advance.
function GlyphData:getAdvance() end

---
---Gets glyph bearing.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getBearing)
---
---@return number bx # Glyph bearing X.
---@return number by # Glyph bearing Y.
function GlyphData:getBearing() end

---
---Gets glyph bounding box.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getBoundingBox)
---
---@return number x # Glyph position x.
---@return number y # Glyph position y.
---@return number width # Glyph width.
---@return number height # Glyph height.
function GlyphData:getBoundingBox() end

---
---Gets glyph dimensions.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getDimensions)
---
---@return number width # Glyph width.
---@return number height # Glyph height.
function GlyphData:getDimensions() end

---
---Gets glyph pixel format.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getFormat)
---
---@return love.PixelFormat format # Glyph pixel format.
function GlyphData:getFormat() end

---
---Gets glyph number.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getGlyph)
---
---@return number glyph # Glyph number.
function GlyphData:getGlyph() end

---
---Gets glyph string.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getGlyphString)
---
---@return string glyph # Glyph string.
function GlyphData:getGlyphString() end

---
---Gets glyph height.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getHeight)
---
---@return number height # Glyph height.
function GlyphData:getHeight() end

---
---Gets glyph width.
---
---
---[Open in Browser](https://love2d.org/wiki/GlyphData:getWidth)
---
---@return number width # Glyph width.
function GlyphData:getWidth() end

---
---A Rasterizer handles font rendering, containing the font data (image or TrueType font) and drawable glyphs.
---
---
---[Open in Browser](https://love2d.org/wiki/love.font)
---
---@class love.Rasterizer: love.Object
local Rasterizer = {}

---
---Gets font advance.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getAdvance)
---
---@return number advance # Font advance.
function Rasterizer:getAdvance() end

---
---Gets ascent height.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getAscent)
---
---@return number height # Ascent height.
function Rasterizer:getAscent() end

---
---Gets descent height.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getDescent)
---
---@return number height # Descent height.
function Rasterizer:getDescent() end

---
---Gets number of glyphs in font.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getGlyphCount)
---
---@return number count # Glyphs count.
function Rasterizer:getGlyphCount() end

---
---Gets glyph data of a specified glyph.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getGlyphData)
---
---@overload fun(self: love.Rasterizer, glyphNumber: number):love.GlyphData
---@param glyph string # Glyph
---@return love.GlyphData glyphData # Glyph data
function Rasterizer:getGlyphData(glyph) end

---
---Gets font height.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getHeight)
---
---@return number height # Font height
function Rasterizer:getHeight() end

---
---Gets line height of a font.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:getLineHeight)
---
---@return number height # Line height of a font.
function Rasterizer:getLineHeight() end

---
---Checks if font contains specified glyphs.
---
---
---[Open in Browser](https://love2d.org/wiki/Rasterizer:hasGlyphs)
---
---@param glyph1 string|number # Glyph
---@param glyph2 string|number # Glyph
---@vararg string|number # Additional glyphs
---@return boolean hasGlyphs # Whatever font contains specified glyphs.
function Rasterizer:hasGlyphs(glyph1, glyph2, ...) end

---
---True Type hinting mode.
---
---
---[Open in Browser](https://love2d.org/wiki/HintingMode)
---
---@alias love.HintingMode
---
---Default hinting. Should be preferred for typical antialiased fonts.
---
---| "normal"
---
---Results in fuzzier text but can sometimes preserve the original glyph shapes of the text better than normal hinting.
---
---| "light"
---
---Results in aliased / unsmoothed text with either full opacity or completely transparent pixels. Should be used when antialiasing is not desired for the font.
---
---| "mono"
---
---Disables hinting for the font. Results in fuzzier text.
---
---| "none"