Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arcade (pyglet?) improperly rendering text #2484

Open
elegantiron opened this issue Jan 7, 2025 · 7 comments
Open

Arcade (pyglet?) improperly rendering text #2484

elegantiron opened this issue Jan 7, 2025 · 7 comments

Comments

@elegantiron
Copy link

elegantiron commented Jan 7, 2025

Bug Report

Letters in arcade.Text objects are cut off if they overlap other letters. This is possibly a regression of #937.

System Info

Arcade 3.0.0.dev40
------------------
vendor: Intel
renderer: Intel(R) Arc(TM) A580 Graphics
version: (3, 3)
python: 3.12.8 (tags/v3.12.8:2dc476b, Dec  3 2024, 19:30:04) [MSC v.1942 64 bit (AMD64)]
platform: win32
pyglet version: 2.1.rc1
PIL version: 11.0.0

Actual behavior:

python_Moawih5Rsh

Expected behavior:

Letters are not cut off

Steps to reproduce/example code:

I'm not sure how to attach the font in question, but it can be obtained from dafont.com (direct link) with a 100% free license.

self.title_text = arcade.Text(
    Strings.TITLE,
    self.width // 2,
    self.height - 10,
    arcade.color.RUBINE_RED,
    50,
    anchor_x="center",
    anchor_y="top",
    batch=self.batch,
    font_name="FairydustB"
)
@pushfoo
Copy link
Member

pushfoo commented Jan 8, 2025

I can't replicate this on Linux. This may be a Windows-specific issue.

@elegantiron Can you try adding pyglet.options.win32_gdi_font = False to the top of the file after importing pyglet?

The code for the GDI+ font renderer in the "fix" PR does not look pretty (pyglet/pyglet#459), so it's worth checking if you're using the DirectWrite.

@DigiDuncan Can you give this a try? I get the following under 3.12 for both:

  1. pyglet on both the release candidate of the reported Arcade version and the 2.1.0 tag
  2. Arcade (tip of development and in a fresh venv with arcade==3.0.0.dev50)
    image

Here's the code:

@elegantiron
Copy link
Author

Can you try adding pyglet.options.win32_gdi_font = False to the top of the file after importing pyglet?

I added this to the file that defines and calls my main() and I get the same results. I have added the import and option line after the __future__, built-in, and arcade imports. Should it be in the file where I define the text object and batch?

Here's the code

I am not knowledgeable enough to know if

label_instances = []

    shared_data = dict(
        font_name="FairydustB",
        color=arcade.color.RUBINE_RED,
        font_size=40,
        width=window.width,
        x=window.height // 2,
        batch=batch,
        align="center",
        anchor_x="center",
        anchor_y="top",
    )

    # Create labels, re-used from an old pyglet thing I did
    label_data = [
        (pyglet.text.Label,     ("Such's Life With Big Letter Serifs",), shared_data),
    ]

    for label_class, args, kwargs in label_data:
        current_y = (window.height // 2) - (len(label_data) // 2) * 20
        label = label_class(*args, y=current_y, **kwargs)
        label_instances.append(label)

Is equivalent to the code I'm using, which uses arcade.Text instead of pyglet labels.

@pushfoo
Copy link
Member

pushfoo commented Jan 8, 2025

I have added the import and option line after the future, built-in, and arcade imports. Should it be in the file where I define the text object and batch?

I've updated both gists to be simpler and include the pyglet options line. You're right, the paste I uploaded was both not quite right and too complicated.

@pushfoo
Copy link
Member

pushfoo commented Jan 9, 2025

At least one user on the pyglet Discord claims they can replicate it on the pyglet-only file. @elegantiron do you have any other similar fonts you can replicate this issue with?

@elegantiron
Copy link
Author

@elegantiron do you have any other similar fonts you can replicate this issue with?

I do not. I'm sure I could find more if I went looking, as it seems the elongated serifs aren't too rare a style.

I took a look at the updated gist, and it seems like some old code got included. There are multiple definitions for main() in the arcade file.

I will be able to test this in a few hours and will provide another update with results.

@elegantiron
Copy link
Author

I rearranged the imports thusly:

import pyglet
pyglet.options.win32_gdi_font = False
import arcade

And I am still getting cut-off serifs on the font.

I tried executing the pyglet example verbatim and still have cut-off serifs.

I have found some more fonts which seem to exhibit the same issue (Note that the licenses for the below fonts vary):

@pushfoo
Copy link
Member

pushfoo commented Jan 10, 2025

Ty for the extra font info. Here's an outline of what I understand the current situation to be:

  • pyglet merged a fix into master, the branch for their 2.0.X releases
  • pyglet will release a 2.0.X package with the fix
  • pyglet will merge changes from their master branch into development, the 2.1.X branch
  • pyglet will make a 2.1.X point release
  • Arcade updates development branch with pyglet 2.1.0 (see Upgrade to pyglet==2.1.0 #2487)
  • Arcade will update either our 3.0.0 release candidate or full release to include the fix from the pyglet 2.1.X branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants