Skip to content

Commit

Permalink
Ready v2.0.14 release
Browse files Browse the repository at this point in the history
  • Loading branch information
benmoran56 committed Mar 8, 2024
1 parent bb1b654 commit ea87564
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 10 deletions.
8 changes: 7 additions & 1 deletion RELEASE_NOTES
@@ -1,11 +1,12 @@
pyglet 2.0.13
pyglet 2.0.14

Changes and Improvements
------------------------
- shapes: Add new MultiLine shape. (#1057)
- font: Enhance UserDefinedFonts to allow using custom font mapping functions (#1067)
- typing: Improve Xaudio2 COM type hints (#1062)
- text: Raise Exception when attempting to change IncrementalTextLayout.rotation, as it's not supported.
- tests.integration: Add simple sanity tests for creation of all Label, Document, and Layout objects.

Bugfixes
--------
Expand All @@ -28,6 +29,11 @@ Bugfixes
- text.layout: Anchor bottom fix for Scrollable/Incremental.


pyglet 2.0.13

Withdrawn due to Label creation bug.


pyglet 2.0.12

Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion pyglet/__init__.py
Expand Up @@ -9,7 +9,7 @@
from typing import TYPE_CHECKING

#: The release version
version = '2.0.13'
version = '2.0.14'
__version__ = version

MIN_PYTHON_VERSION = 3, 8
Expand Down
4 changes: 2 additions & 2 deletions pyglet/text/__init__.py
Expand Up @@ -445,7 +445,7 @@ def __init__(self, text='',
"""
doc = decode_text(text)
super().__init__(doc, width, height, x, y, z, anchor_x, anchor_y, rotation,
super().__init__(doc, x, y, z, width, height, anchor_x, anchor_y, rotation,
multiline, dpi, batch, group, program, init_document=False)

self.document.set_style(0, len(self.document.text), {
Expand Down Expand Up @@ -514,7 +514,7 @@ def __init__(self, text='', location=None,
self._text = text
self._location = location
doc = decode_html(text, location)
super().__init__(doc, width, height, x, y, z, anchor_x, anchor_y, rotation,
super().__init__(doc, x, y, z, width, height, anchor_x, anchor_y, rotation,
multiline, dpi, batch, group, program, init_document=False)

@property
Expand Down
10 changes: 4 additions & 6 deletions tests/integration/text/test_empty_document.py
Expand Up @@ -7,18 +7,17 @@
from pyglet import window



@pytest.fixture(params=[document.UnformattedDocument,
document.FormattedDocument])
@pytest.fixture(params=[document.UnformattedDocument, document.FormattedDocument])
def text_window(request):

class _TestWindow(window.Window):
def __init__(self, doctype, *args, **kwargs):
super(_TestWindow, self).__init__(*args, **kwargs)

self.batch = graphics.Batch()
self.document = doctype()
self.layout = layout.IncrementalTextLayout(self.document,
self.width, self.height, batch=self.batch)
self.layout = layout.IncrementalTextLayout(
self.document, self.width, self.height, batch=self.batch)

def on_draw(self):
gl.glClearColor(1, 1, 1, 1)
Expand All @@ -42,4 +41,3 @@ def test_empty_document_bold(text_window):
text_window.set_bold()
text_window.dispatch_events()
text_window.close()

37 changes: 37 additions & 0 deletions tests/integration/text/test_label_creation.py
@@ -0,0 +1,37 @@
"""Test creation of all Label classes and decoders"""
import random

import pytest


from pyglet.text import decode_text, decode_attributed, decode_html
from pyglet.text import Label, DocumentLabel, HTMLLabel

WIDTH = 500
HEIGHT = 100
X = random.randint(0, 900)
Y = random.randint(0, 600)
Z = random.randint(-10, 10)


@pytest.mark.parametrize('label_class', [Label, HTMLLabel])
def test_label_creation(label_class):
label = label_class("This is a test", x=X, y=Y, z=Z)
assert label.x == X
assert label.y == Y
assert label.z == Z


@pytest.fixture(params=[(decode_text, "This is a string of regular text."),
(decode_html, "<font color=green>This is html text.</font>"),
(decode_attributed, "This is {bold True}attributed{bold False} text.")])
def document(request):
decoder, string = request.param
return decoder(string)


def test_documentlabel_creation(document):
label = DocumentLabel(document=document, x=X, y=Y, z=Z)
assert label.x == X
assert label.y == Y
assert label.z == Z
46 changes: 46 additions & 0 deletions tests/integration/text/test_layout_creation.py
@@ -0,0 +1,46 @@
"""Test creation of all Layout classes"""
import random
import itertools


import pytest

from pyglet.text import document
from pyglet.text import layout

WIDTH = 500
HEIGHT = 100
X = random.randint(0, 900)
Y = random.randint(0, 600)
Z = random.randint(-10, 10)


# Create combination of all Layout and Document types
document_classes = [document.UnformattedDocument, document.FormattedDocument]
layout_classes = [layout.TextLayout, layout.ScrollableTextLayout, layout.IncrementalTextLayout]
all_combinations = list(itertools.product(document_classes, layout_classes))


@pytest.mark.parametrize('doctype, layouttype', all_combinations)
def test_layout_creation_keyword(doctype, layouttype):
_doc = doctype("This is a test")
_layout = layouttype(document=_doc, width=WIDTH, height=HEIGHT, x=X, y=Y, z=Z)
assert _layout.width == WIDTH
assert _layout.height == HEIGHT
assert _layout.x == X
assert _layout.y == Y
assert _layout.z == Z
assert _layout.position == (X, Y, Z)


@pytest.mark.parametrize('doctype, layouttype', all_combinations)
def test_layout_creation_positional(doctype, layouttype):
_doc = doctype("This is a test")
_layout = layouttype(_doc, WIDTH, HEIGHT, X, Y, Z)
# Make sure the arguments were in order:
assert _layout.width == WIDTH
assert _layout.height == HEIGHT
assert _layout.x == X
assert _layout.y == Y
assert _layout.z == Z
assert _layout.position == (X, Y, Z)

0 comments on commit ea87564

Please sign in to comment.