24
24
from jpype import JException , JArray , JString # noqa
25
25
26
26
from .shape import Py5Shape , _return_py5shape # noqa
27
+ from .type_decorators import _ret_str # noqa
27
28
28
29
29
30
def _return_py5font (f ):
@@ -68,16 +69,16 @@ class Py5Font:
68
69
-----
69
70
70
71
Py5Font is the font class for py5. To create a font to use with py5, use
71
- :doc:` create_font_file`. This will create a font in the format py5 requires. Py5
72
+ `` create_font_file()` `. This will create a font in the format py5 requires. Py5
72
73
displays fonts using the .vlw font format, which uses images for each letter,
73
- rather than defining them through vector data. The :doc:` load_font` function
74
- constructs a new font and :doc:` text_font` makes a font active. The
75
- :doc:`py5font_list` method creates a list of the fonts installed on the
76
- computer, which is useful information to use with the :doc:` create_font`
77
- function for dynamically converting fonts into a format to use with py5.
78
-
79
- To create a new font dynamically, use the :doc:` create_font` function. Do not
80
- use the syntax ``Py5Font()``.
74
+ rather than defining them through vector data. The `` load_font()` ` function
75
+ constructs a new font and `` text_font()` ` makes a font active. The
76
+ ``Py5Font.list()`` method creates a list of the fonts installed on the computer,
77
+ which is useful information to use with the `` create_font()`` function for
78
+ dynamically converting fonts into a format to use with py5.
79
+
80
+ To create a new font dynamically, use the `` create_font()`` function. Do not use
81
+ the syntax ``Py5Font()``.
81
82
"""
82
83
83
84
_cls = jpype .JClass ('processing.core.PFont' )
@@ -87,92 +88,90 @@ def __init__(self, pfont):
87
88
self ._instance = pfont
88
89
89
90
def ascent (self ) -> float :
90
- """The documentation for this field or method has not yet been written .
91
+ """Get the ascent of this font from the baseline .
91
92
92
93
Underlying Java method: PFont.ascent
93
94
94
95
Notes
95
96
-----
96
97
97
- The documentation for this field or method has not yet been written. If you know
98
- what it does, please help out with a pull request to the relevant file in
99
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
98
+ Get the ascent of this font from the baseline. The value is based on a font of
99
+ size 1. Multiply it by the font size to get the offset from the baseline.
100
100
"""
101
101
return self ._instance .ascent ()
102
102
103
103
def descent (self ) -> float :
104
- """The documentation for this field or method has not yet been written .
104
+ """Get the descent of this font from the baseline .
105
105
106
106
Underlying Java method: PFont.descent
107
107
108
108
Notes
109
109
-----
110
110
111
- The documentation for this field or method has not yet been written. If you know
112
- what it does, please help out with a pull request to the relevant file in
113
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
111
+ Get the descent of this font from the baseline. The value is based on a font of
112
+ size 1. Multiply it by the font size to get the offset from the baseline.
114
113
"""
115
114
return self ._instance .descent ()
116
115
117
116
def get_default_size (self ) -> int :
118
- """The documentation for this field or method has not yet been written .
117
+ """Get the font's size that will be used when ``text_font()`` is called .
119
118
120
119
Underlying Java method: PFont.getDefaultSize
121
120
122
121
Notes
123
122
-----
124
123
125
- The documentation for this field or method has not yet been written. If you know
126
- what it does, please help out with a pull request to the relevant file in
127
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
124
+ Get the font's size that will be used when ``text_font()`` is called. When
125
+ drawing with 2x pixel density, bitmap fonts in OpenGL need to be created at
126
+ double the requested size. This ensures that they're shown at half on displays
127
+ (so folks don't have to change their sketch code).
128
128
"""
129
129
return self ._instance .getDefaultSize ()
130
130
131
131
def get_glyph_count (self ) -> int :
132
- """The documentation for this field or method has not yet been written .
132
+ """Get the number of glyphs contained in the font .
133
133
134
134
Underlying Java method: PFont.getGlyphCount
135
135
136
136
Notes
137
137
-----
138
138
139
- The documentation for this field or method has not yet been written. If you know
140
- what it does, please help out with a pull request to the relevant file in
141
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
139
+ Get the number of glyphs contained in the font. This will be 0 if the font is a
140
+ "lazy font" that creates glyphs as they are needed by the Sketch. This will be
141
+ the case if the font was created with ``create_font()`` without using the
142
+ ``charset`` parameter.
142
143
"""
143
144
return self ._instance .getGlyphCount ()
144
145
146
+ @_ret_str
145
147
def get_name (self ) -> str :
146
- """The documentation for this field or method has not yet been written .
148
+ """Get the font's name .
147
149
148
150
Underlying Java method: PFont.getName
149
151
150
152
Notes
151
153
-----
152
154
153
- The documentation for this field or method has not yet been written. If you know
154
- what it does, please help out with a pull request to the relevant file in
155
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
155
+ Get the font's name.
156
156
"""
157
157
return self ._instance .getName ()
158
158
159
+ @_ret_str
159
160
def get_post_script_name (self ) -> str :
160
- """The documentation for this field or method has not yet been written .
161
+ """Get the font's postscript name .
161
162
162
163
Underlying Java method: PFont.getPostScriptName
163
164
164
165
Notes
165
166
-----
166
167
167
- The documentation for this field or method has not yet been written. If you know
168
- what it does, please help out with a pull request to the relevant file in
169
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
168
+ Get the font's postscript name.
170
169
"""
171
170
return self ._instance .getPostScriptName ()
172
171
173
172
@overload
174
173
def get_shape (self , ch : chr , / ) -> Py5Shape :
175
- """The documentation for this field or method has not yet been written .
174
+ """Get a single character as a ``Py5Shape`` object .
176
175
177
176
Underlying Java method: PFont.getShape
178
177
@@ -188,23 +187,27 @@ def get_shape(self, ch: chr, /) -> Py5Shape:
188
187
----------
189
188
190
189
ch: chr
191
- missing variable description
190
+ single character
192
191
193
192
detail: float
194
- missing variable description
193
+ level of shape detail
195
194
196
195
Notes
197
196
-----
198
197
199
- The documentation for this field or method has not yet been written. If you know
200
- what it does, please help out with a pull request to the relevant file in
201
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
198
+ Get a single character as a ``Py5Shape`` object. Use the ``detail`` parameter to
199
+ draw the shape with only straight line segments.
200
+
201
+ Calling ``Py5Shape.disable_style()`` on the returned ``Py5Shape`` object seems
202
+ to be necessary for these to be drawable.
203
+
204
+ This method only works on fonts loaded with ``create_font()``.
202
205
"""
203
206
pass
204
207
205
208
@overload
206
209
def get_shape (self , ch : chr , detail : float , / ) -> Py5Shape :
207
- """The documentation for this field or method has not yet been written .
210
+ """Get a single character as a ``Py5Shape`` object .
208
211
209
212
Underlying Java method: PFont.getShape
210
213
@@ -220,23 +223,27 @@ def get_shape(self, ch: chr, detail: float, /) -> Py5Shape:
220
223
----------
221
224
222
225
ch: chr
223
- missing variable description
226
+ single character
224
227
225
228
detail: float
226
- missing variable description
229
+ level of shape detail
227
230
228
231
Notes
229
232
-----
230
233
231
- The documentation for this field or method has not yet been written. If you know
232
- what it does, please help out with a pull request to the relevant file in
233
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
234
+ Get a single character as a ``Py5Shape`` object. Use the ``detail`` parameter to
235
+ draw the shape with only straight line segments.
236
+
237
+ Calling ``Py5Shape.disable_style()`` on the returned ``Py5Shape`` object seems
238
+ to be necessary for these to be drawable.
239
+
240
+ This method only works on fonts loaded with ``create_font()``.
234
241
"""
235
242
pass
236
243
237
244
@_return_py5shape
238
245
def get_shape (self , * args ):
239
- """The documentation for this field or method has not yet been written .
246
+ """Get a single character as a ``Py5Shape`` object .
240
247
241
248
Underlying Java method: PFont.getShape
242
249
@@ -252,62 +259,50 @@ def get_shape(self, *args):
252
259
----------
253
260
254
261
ch: chr
255
- missing variable description
262
+ single character
256
263
257
264
detail: float
258
- missing variable description
265
+ level of shape detail
259
266
260
267
Notes
261
268
-----
262
269
263
- The documentation for this field or method has not yet been written. If you know
264
- what it does, please help out with a pull request to the relevant file in
265
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
270
+ Get a single character as a ``Py5Shape`` object. Use the ``detail`` parameter to
271
+ draw the shape with only straight line segments.
272
+
273
+ Calling ``Py5Shape.disable_style()`` on the returned ``Py5Shape`` object seems
274
+ to be necessary for these to be drawable.
275
+
276
+ This method only works on fonts loaded with ``create_font()``.
266
277
"""
267
278
return self ._instance .getShape (* args )
268
279
269
280
def get_size (self ) -> int :
270
- """The documentation for this field or method has not yet been written .
281
+ """Get the font's size .
271
282
272
283
Underlying Java method: PFont.getSize
273
284
274
285
Notes
275
286
-----
276
287
277
- The documentation for this field or method has not yet been written. If you know
278
- what it does, please help out with a pull request to the relevant file in
279
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
288
+ Get the font's size.
280
289
"""
281
290
return self ._instance .getSize ()
282
291
283
292
def is_smooth (self ) -> bool :
284
- """The documentation for this field or method has not yet been written.
293
+ """Boolean value reflecting if smoothing (anti-aliasing) was used when the font was
294
+ created.
285
295
286
296
Underlying Java method: PFont.isSmooth
287
297
288
298
Notes
289
299
-----
290
300
291
- The documentation for this field or method has not yet been written. If you know
292
- what it does, please help out with a pull request to the relevant file in
293
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
301
+ Boolean value reflecting if smoothing (anti-aliasing) was used when the font was
302
+ created. By default, ``create_font()`` will use smoothing.
294
303
"""
295
304
return self ._instance .isSmooth ()
296
305
297
- def is_stream (self ) -> bool :
298
- """The documentation for this field or method has not yet been written.
299
-
300
- Underlying Java method: PFont.isStream
301
-
302
- Notes
303
- -----
304
-
305
- The documentation for this field or method has not yet been written. If you know
306
- what it does, please help out with a pull request to the relevant file in
307
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
308
- """
309
- return self ._instance .isStream ()
310
-
311
306
@classmethod
312
307
@_return_list_str
313
308
def list (cls ) -> List [str ]:
@@ -320,42 +315,29 @@ def list(cls) -> List[str]:
320
315
321
316
Gets a list of the fonts installed on the system. The data is returned as a list
322
317
of strings. This list provides the names of each font for input into
323
- :doc:` create_font`, which allows py5 to dynamically format fonts.
318
+ `` create_font()` `, which allows py5 to dynamically format fonts.
324
319
325
320
This works outside of a running Sketch.
326
321
"""
327
322
return cls ._cls .list ()
328
323
329
- def set_subsetting (self ) -> None :
330
- """The documentation for this field or method has not yet been written.
331
-
332
- Underlying Java method: PFont.setSubsetting
333
-
334
- Notes
335
- -----
336
-
337
- The documentation for this field or method has not yet been written. If you know
338
- what it does, please help out with a pull request to the relevant file in
339
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
340
- """
341
- return self ._instance .setSubsetting ()
342
-
343
324
def width (self , c : chr , / ) -> float :
344
- """The documentation for this field or method has not yet been written .
325
+ """Get the width of a character in this font .
345
326
346
327
Underlying Java method: PFont.width
347
328
348
329
Parameters
349
330
----------
350
331
351
332
c: chr
352
- missing variable description
333
+ single character
353
334
354
335
Notes
355
336
-----
356
337
357
- The documentation for this field or method has not yet been written. If you know
358
- what it does, please help out with a pull request to the relevant file in
359
- https://github.com/hx2A/py5generator/tree/master/py5_docs/Reference/api_en/.
338
+ Get the width of a character in this font. The value is based on a font of size
339
+ 1. Multiply it by the font size to get the horizontal space of the character.
340
+
341
+ This will return 0 if the character is not in the font's character set.
360
342
"""
361
343
return self ._instance .width (c )
0 commit comments