pyglet 2.1.3__py3-none-any.whl → 2.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyglet/__init__.py +21 -9
- pyglet/__init__.pyi +3 -1
- pyglet/app/cocoa.py +6 -3
- pyglet/display/win32.py +14 -15
- pyglet/display/xlib_vidmoderestore.py +1 -1
- pyglet/extlibs/earcut.py +2 -2
- pyglet/font/__init__.py +3 -3
- pyglet/font/base.py +118 -51
- pyglet/font/dwrite/__init__.py +1381 -0
- pyglet/font/dwrite/d2d1_lib.py +637 -0
- pyglet/font/dwrite/d2d1_types_lib.py +60 -0
- pyglet/font/dwrite/dwrite_lib.py +1577 -0
- pyglet/font/fontconfig.py +79 -16
- pyglet/font/freetype.py +252 -77
- pyglet/font/freetype_lib.py +234 -125
- pyglet/font/harfbuzz/__init__.py +275 -0
- pyglet/font/harfbuzz/harfbuzz_lib.py +212 -0
- pyglet/font/quartz.py +432 -112
- pyglet/font/user.py +18 -11
- pyglet/font/win32.py +9 -1
- pyglet/gl/wgl.py +94 -87
- pyglet/gl/wglext_arb.py +472 -218
- pyglet/gl/wglext_nv.py +410 -188
- pyglet/gui/widgets.py +6 -1
- pyglet/image/codecs/bmp.py +3 -5
- pyglet/image/codecs/gdiplus.py +28 -9
- pyglet/image/codecs/wic.py +198 -489
- pyglet/image/codecs/wincodec_lib.py +413 -0
- pyglet/input/base.py +3 -2
- pyglet/input/macos/darwin_hid.py +28 -2
- pyglet/input/win32/directinput.py +2 -1
- pyglet/input/win32/xinput.py +10 -9
- pyglet/lib.py +14 -2
- pyglet/libs/darwin/cocoapy/cocoalibs.py +74 -3
- pyglet/libs/darwin/coreaudio.py +0 -2
- pyglet/libs/win32/__init__.py +4 -2
- pyglet/libs/win32/com.py +65 -12
- pyglet/libs/win32/constants.py +1 -0
- pyglet/libs/win32/dinput.py +1 -9
- pyglet/libs/win32/types.py +72 -8
- pyglet/media/codecs/coreaudio.py +1 -0
- pyglet/media/codecs/wmf.py +93 -72
- pyglet/media/devices/win32.py +5 -4
- pyglet/media/drivers/directsound/lib_dsound.py +4 -4
- pyglet/media/drivers/xaudio2/interface.py +21 -17
- pyglet/media/drivers/xaudio2/lib_xaudio2.py +42 -25
- pyglet/shapes.py +1 -1
- pyglet/text/document.py +7 -53
- pyglet/text/formats/attributed.py +3 -1
- pyglet/text/formats/plaintext.py +1 -1
- pyglet/text/formats/structured.py +1 -1
- pyglet/text/layout/base.py +76 -68
- pyglet/text/layout/incremental.py +38 -8
- pyglet/text/layout/scrolling.py +1 -1
- pyglet/text/runlist.py +2 -114
- pyglet/window/win32/__init__.py +1 -3
- {pyglet-2.1.3.dist-info → pyglet-2.1.4.dist-info}/METADATA +1 -1
- {pyglet-2.1.3.dist-info → pyglet-2.1.4.dist-info}/RECORD +60 -54
- pyglet/font/directwrite.py +0 -2798
- {pyglet-2.1.3.dist-info → pyglet-2.1.4.dist-info}/LICENSE +0 -0
- {pyglet-2.1.3.dist-info → pyglet-2.1.4.dist-info}/WHEEL +0 -0
pyglet/font/user.py
CHANGED
|
@@ -73,7 +73,7 @@ except ImportError:
|
|
|
73
73
|
pass
|
|
74
74
|
|
|
75
75
|
if TYPE_CHECKING:
|
|
76
|
-
from pyglet.font.base import Glyph
|
|
76
|
+
from pyglet.font.base import Glyph, GlyphPosition
|
|
77
77
|
from pyglet.image import ImageData
|
|
78
78
|
|
|
79
79
|
|
|
@@ -158,11 +158,18 @@ class UserDefinedFontBase(base.Font):
|
|
|
158
158
|
def enable_scaling(self, base_size: int) -> None:
|
|
159
159
|
if not SCALING_ENABLED:
|
|
160
160
|
msg = "PIL is not installed. User Font Scaling requires PIL."
|
|
161
|
-
raise
|
|
161
|
+
raise ImportError(msg)
|
|
162
162
|
|
|
163
163
|
self._base_size = base_size
|
|
164
164
|
self._scaling = True
|
|
165
165
|
|
|
166
|
+
def _initialize_renderer(self) -> None:
|
|
167
|
+
"""Initialize the glyph renderer and cache it on the Font.
|
|
168
|
+
|
|
169
|
+
This way renderers for fonts that have been loaded but not used will not have unnecessary loaders.
|
|
170
|
+
"""
|
|
171
|
+
if not self._glyph_renderer:
|
|
172
|
+
self._glyph_renderer = self.glyph_renderer_class(self)
|
|
166
173
|
|
|
167
174
|
class UserDefinedFontException(Exception): # noqa: N818
|
|
168
175
|
"""An exception related to user font creation."""
|
|
@@ -175,9 +182,10 @@ class DictLikeObject(Protocol):
|
|
|
175
182
|
|
|
176
183
|
class UserDefinedMappingFont(UserDefinedFontBase):
|
|
177
184
|
"""The class allows the creation of user defined fonts from a set of mappings.
|
|
178
|
-
|
|
185
|
+
|
|
179
186
|
.. versionadded:: 2.0.15
|
|
180
187
|
"""
|
|
188
|
+
_glyph_renderer: UserDefinedGlyphRenderer
|
|
181
189
|
|
|
182
190
|
def __init__(self, name: str, default_char: str, size: int, mappings: DictLikeObject,
|
|
183
191
|
ascent: int | None = None, descent: int | None = None, weight: str = "normal", italic: bool = False,
|
|
@@ -233,17 +241,18 @@ class UserDefinedMappingFont(UserDefinedFontBase):
|
|
|
233
241
|
The base size is used to calculate the ratio between new sizes and the original.
|
|
234
242
|
"""
|
|
235
243
|
super().enable_scaling(base_size)
|
|
236
|
-
glyphs = self.get_glyphs(self.default_char)
|
|
244
|
+
glyphs, offsets = self.get_glyphs(self.default_char)
|
|
237
245
|
self.ascent = glyphs[0].height
|
|
238
246
|
self.descent = 0
|
|
239
247
|
|
|
240
|
-
def get_glyphs(self, text: str) -> list[Glyph]:
|
|
248
|
+
def get_glyphs(self, text: str) -> tuple[list[Glyph], list[GlyphPosition]]:
|
|
241
249
|
"""Create and return a list of Glyphs for `text`.
|
|
242
250
|
|
|
243
251
|
If any characters do not have a known glyph representation in this font, a substitution will be made with
|
|
244
252
|
the ``default_char``.
|
|
245
253
|
"""
|
|
246
|
-
|
|
254
|
+
self._initialize_renderer()
|
|
255
|
+
offsets = []
|
|
247
256
|
glyphs = [] # glyphs that are committed.
|
|
248
257
|
for c in base.get_grapheme_clusters(text):
|
|
249
258
|
# Get the glyph for 'c'. Hide tabs (Windows and Linux render
|
|
@@ -251,16 +260,14 @@ class UserDefinedMappingFont(UserDefinedFontBase):
|
|
|
251
260
|
if c == "\t":
|
|
252
261
|
c = " "
|
|
253
262
|
if c not in self.glyphs:
|
|
254
|
-
if not glyph_renderer:
|
|
255
|
-
glyph_renderer = self.glyph_renderer_class(self)
|
|
256
|
-
|
|
257
263
|
image_data = self.mappings.get(c)
|
|
258
264
|
if not image_data:
|
|
259
265
|
c = self.default_char
|
|
260
266
|
else:
|
|
261
|
-
self.glyphs[c] =
|
|
267
|
+
self.glyphs[c] = self._glyph_renderer.render(image_data)
|
|
262
268
|
glyphs.append(self.glyphs[c])
|
|
263
|
-
|
|
269
|
+
offsets.append(base.GlyphPosition(0, 0, 0, 0))
|
|
270
|
+
return glyphs, offsets
|
|
264
271
|
|
|
265
272
|
|
|
266
273
|
def get_scaled_user_font(font_base: UserDefinedMappingFont, size: int) -> UserDefinedMappingFont:
|
pyglet/font/win32.py
CHANGED
|
@@ -22,9 +22,11 @@ if TYPE_CHECKING:
|
|
|
22
22
|
|
|
23
23
|
DriverStringOptionsCmapLookup = 1
|
|
24
24
|
DriverStringOptionsRealizedAdvance = 4
|
|
25
|
+
TextRenderingHintSingleBitPerPixelGridFit = 1
|
|
25
26
|
TextRenderingHintAntiAlias = 4
|
|
26
27
|
TextRenderingHintAntiAliasGridFit = 3
|
|
27
28
|
|
|
29
|
+
|
|
28
30
|
FontStyleBold = 1
|
|
29
31
|
FontStyleItalic = 2
|
|
30
32
|
UnitPixel = 2
|
|
@@ -55,7 +57,13 @@ class Rectf(ctypes.Structure):
|
|
|
55
57
|
]
|
|
56
58
|
|
|
57
59
|
|
|
60
|
+
_text_quality = {
|
|
61
|
+
True: TextRenderingHintAntiAliasGridFit,
|
|
62
|
+
False: TextRenderingHintSingleBitPerPixelGridFit,
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
class GDIPlusGlyphRenderer(base.GlyphRenderer):
|
|
66
|
+
|
|
59
67
|
def __init__(self, font: GDIPlusFont) -> None:
|
|
60
68
|
self._bitmap = None
|
|
61
69
|
self._dc = None
|
|
@@ -103,7 +111,7 @@ class GDIPlusGlyphRenderer(base.GlyphRenderer):
|
|
|
103
111
|
gdi32.SelectObject(self._dc, self.font.hfont)
|
|
104
112
|
|
|
105
113
|
gdiplus.GdipSetTextRenderingHint(self._graphics,
|
|
106
|
-
|
|
114
|
+
_text_quality[pyglet.options.text_antialiasing])
|
|
107
115
|
|
|
108
116
|
self._brush = ctypes.c_void_p()
|
|
109
117
|
gdiplus.GdipCreateSolidFill(0xffffffff, ctypes.byref(self._brush))
|
pyglet/gl/wgl.py
CHANGED
|
@@ -3,71 +3,23 @@
|
|
|
3
3
|
Generated by tools/gengl.py.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from ctypes import CFUNCTYPE, POINTER, Structure,
|
|
7
|
-
from ctypes import
|
|
6
|
+
from ctypes import CFUNCTYPE, POINTER, Structure, c_int
|
|
7
|
+
from ctypes.wintypes import DWORD, BOOL, FLOAT, LONG, UINT, HDC, WORD, HANDLE, LPCSTR
|
|
8
8
|
|
|
9
9
|
from pyglet.gl.lib import link_WGL as _link_function
|
|
10
|
+
from pyglet.libs.win32.types import BYTE
|
|
10
11
|
|
|
11
12
|
if not _link_function:
|
|
12
13
|
raise ImportError('opengl32.dll is not available.')
|
|
13
14
|
|
|
14
15
|
CONST = 0
|
|
15
|
-
|
|
16
|
-
GLboolean = c_ubyte
|
|
17
|
-
GLbitfield = c_uint
|
|
18
|
-
GLbyte = c_char
|
|
19
|
-
GLshort = c_short
|
|
20
|
-
GLint = c_int
|
|
21
|
-
GLsizei = c_int
|
|
22
|
-
GLubyte = c_ubyte
|
|
23
|
-
GLushort = c_ushort
|
|
24
|
-
GLuint = c_uint
|
|
25
|
-
GLfloat = c_float
|
|
26
|
-
GLclampf = c_float
|
|
27
|
-
GLdouble = c_double
|
|
28
|
-
GLclampd = c_double
|
|
29
|
-
GLvoid = None
|
|
30
|
-
INT8 = c_char
|
|
31
|
-
PINT8 = c_char_p
|
|
32
|
-
INT16 = c_short
|
|
33
|
-
PINT16 = POINTER(c_short)
|
|
34
|
-
INT32 = c_int
|
|
35
|
-
PINT32 = POINTER(c_int)
|
|
36
|
-
UINT8 = c_ubyte
|
|
37
|
-
PUINT8 = POINTER(c_ubyte)
|
|
38
|
-
UINT16 = c_ushort
|
|
39
|
-
PUINT16 = POINTER(c_ushort)
|
|
40
|
-
UINT32 = c_uint
|
|
41
|
-
PUINT32 = POINTER(c_uint)
|
|
42
|
-
LONG32 = c_int
|
|
43
|
-
PLONG32 = POINTER(c_int)
|
|
44
|
-
ULONG32 = c_uint
|
|
45
|
-
PULONG32 = POINTER(c_uint)
|
|
46
|
-
DWORD32 = c_uint
|
|
47
|
-
PDWORD32 = POINTER(c_uint)
|
|
48
|
-
INT64 = c_longlong
|
|
49
|
-
PINT64 = POINTER(c_longlong)
|
|
50
|
-
UINT64 = c_ulonglong
|
|
51
|
-
PUINT64 = POINTER(c_ulonglong)
|
|
52
|
-
VOID = None
|
|
53
|
-
LPVOID = POINTER(None)
|
|
54
|
-
LPCSTR = c_char_p
|
|
55
|
-
CHAR = c_char
|
|
56
|
-
BYTE = c_ubyte
|
|
57
|
-
WORD = c_ushort
|
|
58
|
-
USHORT = c_ushort
|
|
59
|
-
UINT = c_uint
|
|
60
|
-
INT = c_int
|
|
16
|
+
|
|
61
17
|
INT_PTR = POINTER(c_int)
|
|
62
|
-
|
|
63
|
-
LONG = c_long
|
|
64
|
-
DWORD = c_ulong
|
|
65
|
-
FLOAT = c_float
|
|
18
|
+
|
|
66
19
|
COLORREF = DWORD
|
|
67
20
|
LPCOLORREF = POINTER(DWORD)
|
|
68
|
-
HANDLE = POINTER(None)
|
|
69
21
|
HGLRC = HANDLE
|
|
70
|
-
|
|
22
|
+
|
|
71
23
|
PROC = CFUNCTYPE(INT_PTR)
|
|
72
24
|
|
|
73
25
|
wglCopyContext = _link_function('wglCopyContext', BOOL, [HGLRC, HGLRC, UINT], None)
|
|
@@ -279,36 +231,91 @@ PRECT = POINTER(struct_tagRECT)
|
|
|
279
231
|
NPRECT = POINTER(struct_tagRECT)
|
|
280
232
|
LPRECT = POINTER(struct_tagRECT)
|
|
281
233
|
|
|
282
|
-
__all__ = [
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
234
|
+
__all__ = [
|
|
235
|
+
'COLORREF',
|
|
236
|
+
'CONST',
|
|
237
|
+
'GLYPHMETRICSFLOAT',
|
|
238
|
+
'HGLRC',
|
|
239
|
+
'LAYERPLANEDESCRIPTOR',
|
|
240
|
+
'LPCOLORREF',
|
|
241
|
+
'LPD_DOUBLEBUFFER',
|
|
242
|
+
'LPD_SHARE_ACCUM',
|
|
243
|
+
'LPD_SHARE_DEPTH',
|
|
244
|
+
'LPD_SHARE_STENCIL',
|
|
245
|
+
'LPD_STEREO',
|
|
246
|
+
'LPD_SUPPORT_GDI',
|
|
247
|
+
'LPD_SUPPORT_OPENGL',
|
|
248
|
+
'LPD_SWAP_COPY',
|
|
249
|
+
'LPD_SWAP_EXCHANGE',
|
|
250
|
+
'LPD_TRANSPARENT',
|
|
251
|
+
'LPD_TYPE_COLORINDEX',
|
|
252
|
+
'LPD_TYPE_RGBA',
|
|
253
|
+
'LPGLYPHMETRICSFLOAT',
|
|
254
|
+
'LPLAYERPLANEDESCRIPTOR',
|
|
255
|
+
'LPRECT',
|
|
256
|
+
'LPWGLSWAP',
|
|
257
|
+
'NPRECT',
|
|
258
|
+
'PGLYPHMETRICSFLOAT',
|
|
259
|
+
'PLAYERPLANEDESCRIPTOR',
|
|
260
|
+
'POINTFLOAT',
|
|
261
|
+
'PPOINTFLOAT',
|
|
262
|
+
'PRECT',
|
|
263
|
+
'PROC',
|
|
264
|
+
'PWGLSWAP',
|
|
265
|
+
'RECT',
|
|
266
|
+
'WGLSWAP',
|
|
267
|
+
'WGL_FONT_LINES',
|
|
268
|
+
'WGL_FONT_POLYGONS',
|
|
269
|
+
'WGL_SWAPMULTIPLE_MAX',
|
|
270
|
+
'WGL_SWAP_MAIN_PLANE',
|
|
271
|
+
'WGL_SWAP_OVERLAY1',
|
|
272
|
+
'WGL_SWAP_OVERLAY2',
|
|
273
|
+
'WGL_SWAP_OVERLAY3',
|
|
274
|
+
'WGL_SWAP_OVERLAY4',
|
|
275
|
+
'WGL_SWAP_OVERLAY5',
|
|
276
|
+
'WGL_SWAP_OVERLAY6',
|
|
277
|
+
'WGL_SWAP_OVERLAY7',
|
|
278
|
+
'WGL_SWAP_OVERLAY8',
|
|
279
|
+
'WGL_SWAP_OVERLAY9',
|
|
280
|
+
'WGL_SWAP_OVERLAY10',
|
|
281
|
+
'WGL_SWAP_OVERLAY11',
|
|
282
|
+
'WGL_SWAP_OVERLAY12',
|
|
283
|
+
'WGL_SWAP_OVERLAY13',
|
|
284
|
+
'WGL_SWAP_OVERLAY14',
|
|
285
|
+
'WGL_SWAP_OVERLAY15',
|
|
286
|
+
'WGL_SWAP_UNDERLAY1',
|
|
287
|
+
'WGL_SWAP_UNDERLAY2',
|
|
288
|
+
'WGL_SWAP_UNDERLAY3',
|
|
289
|
+
'WGL_SWAP_UNDERLAY4',
|
|
290
|
+
'WGL_SWAP_UNDERLAY5',
|
|
291
|
+
'WGL_SWAP_UNDERLAY6',
|
|
292
|
+
'WGL_SWAP_UNDERLAY7',
|
|
293
|
+
'WGL_SWAP_UNDERLAY8',
|
|
294
|
+
'WGL_SWAP_UNDERLAY9',
|
|
295
|
+
'WGL_SWAP_UNDERLAY10',
|
|
296
|
+
'WGL_SWAP_UNDERLAY11',
|
|
297
|
+
'WGL_SWAP_UNDERLAY12',
|
|
298
|
+
'WGL_SWAP_UNDERLAY13',
|
|
299
|
+
'WGL_SWAP_UNDERLAY14',
|
|
300
|
+
'WGL_SWAP_UNDERLAY15',
|
|
301
|
+
'SwapBuffers',
|
|
302
|
+
'wglCopyContext',
|
|
303
|
+
'wglCreateContext',
|
|
304
|
+
'wglCreateLayerContext',
|
|
305
|
+
'wglDeleteContext',
|
|
306
|
+
'wglDescribeLayerPlane',
|
|
307
|
+
'wglGetCurrentContext',
|
|
308
|
+
'wglGetCurrentDC',
|
|
309
|
+
'wglGetLayerPaletteEntries',
|
|
310
|
+
'wglGetProcAddress',
|
|
311
|
+
'wglMakeCurrent',
|
|
312
|
+
'wglRealizeLayerPalette',
|
|
313
|
+
'wglSetLayerPaletteEntries',
|
|
314
|
+
'wglShareLists',
|
|
315
|
+
'wglSwapLayerBuffers',
|
|
316
|
+
'wglSwapMultipleBuffers',
|
|
317
|
+
'wglUseFontBitmapsA',
|
|
318
|
+
'wglUseFontBitmapsW',
|
|
319
|
+
'wglUseFontOutlinesA',
|
|
320
|
+
'wglUseFontOutlinesW',
|
|
321
|
+
]
|