Closed UserLeeZJ closed 4 years ago
Hi, could you give cocos, pyglet and windows version info?
cocos: if it is a github checkout the commit sha1, else the cocos.version
pyglet: if it is an hg clone, the commit sha1, else the pyglet.__version__
windows: 7? 10? which stepping of win10?
It would help if you can run the following pure pyglet script and report if it crashes or does something unexpected.
expected = """
You should see a pyglet window with black background
and the text 'Alakazam' rising from the bottom to some height,
then repeating the movement.
Should look similar to reference_image.png, attached in
the github issue or included in the .zip, see below.
Expected directory layout:
top/
data/
edunline.ttf -> from cocos/samples/tetrico/data/
font_problem.py -> this file
reference.png -> optional, the reference image in github issue
example run command, adjust as needed
cd top
py -3.6 font_problem.py
a .zip with all the files can be get from
https://github.com/los-cocos/cocos/issues/317
"""
print(expected)
import pyglet
pyglet.resource.path.append('data')
pyglet.resource.reindex()
pyglet.font.add_directory('data')
window = pyglet.window.Window(640, 480)
x0 = window.width // 2
y0 = 10
t=0.0
# yes, the internal name is that silly
font_name = 'Edit Undo Line BRK'
label = pyglet.text.Label('Alakazam',
font_name = font_name,
font_size=72,
x=x0, y=y0,
anchor_x='center')
@window.event
def on_key_press(symbol, modifiers):
if symbol == pyglet.window.key.ESCAPE:
window.has_exit = True
@window.event
def on_draw():
window.clear()
label.draw()
def update(dt):
global t
label.y = int(y0 + (t % 2) * 50)
t += dt
pyglet.clock.schedule_interval(update, 1 / 30.)
pyglet.app.run()
You can make the desired directory layout as shown in the 'expect' string or dowload cocos_#317_pure_pyglet_probe.zip which have all the necesary files in the intended layout.
A reference screenshot:
Hi, could you give cocos, pyglet and windows version info?
cocos: if it is a github checkout the commit sha1, else the cocos.version
pyglet: if it is an hg clone, the commit sha1, else the
pyglet.__version__
windows: 7? 10? which stepping of win10?
cocos.version = '0.6.5' pyglet.version= '1.3.2' window10,64bit
It would help if you can run the following pure pyglet script and report if it crashes or does something unexpected.
expected = """ You should see a pyglet window with black background and the text 'Alakazam' rising from the bottom to some height, then repeating the movement. Should look similar to reference_image.png, attached in the github issue or included in the .zip, see below. Expected directory layout: top/ data/ edunline.ttf -> from cocos/samples/tetrico/data/ font_problem.py -> this file reference.png -> optional, the reference image in github issue example run command, adjust as needed cd top py -3.6 font_problem.py a .zip with all the files can be get from https://github.com/los-cocos/cocos/issues/317 """ print(expected) import pyglet pyglet.resource.path.append('data') pyglet.resource.reindex() pyglet.font.add_directory('data') window = pyglet.window.Window(640, 480) x0 = window.width // 2 y0 = 10 t=0.0 # yes, the internal name is that silly font_name = 'Edit Undo Line BRK' label = pyglet.text.Label('Alakazam', font_name = font_name, font_size=72, x=x0, y=y0, anchor_x='center') @window.event def on_key_press(symbol, modifiers): if symbol == pyglet.window.key.ESCAPE: window.has_exit = True @window.event def on_draw(): window.clear() label.draw() def update(dt): global t label.y = int(y0 + (t % 2) * 50) t += dt pyglet.clock.schedule_interval(update, 1 / 30.) pyglet.app.run()
You can make the desired directory layout as shown in the 'expect' string or dowload cocos_#317_pure_pyglet_probe.zip which have all the necesary files in the intended layout.
A reference screenshot:
As you described, there is no error output .
Ok, I can confirm it is a pyglet behavoir change beetween diferent windows version.
The bugdemo is a slight modification on the previous script, where a tuple of font names is passed instead of a font name.
expected = """
You should see a pyglet window with black background
and the text 'Alakazam' rising from the bottom to some height,
then repeating the movement.
Should look similar to reference_image.png, attached in
the github issue or included in the .zip, see below.
Expected directory layout:
top/
data/
edunline.ttf -> from cocos/samples/tetrico/data/
font_problem.py -> this file
reference.png -> optional, the reference image in github issue
example run command, adjust as needed
cd top
py -3.6 font_problem.py
a .zip with all the files can be get from
https://github.com/los-cocos/cocos/issues/317
"""
print(expected)
import pyglet
pyglet.resource.path.append('data')
pyglet.resource.reindex()
pyglet.font.add_directory('data')
window = pyglet.window.Window(640, 480)
x0 = window.width // 2
y0 = 10
t=0.0
# yes, the internal name is that silly
##font_name = 'Edit Undo Line BRK' # no problem
font_name = ('Edit Undo Line BRK',) # traceback
fo = pyglet.font.load(font_name, 72)
label = pyglet.text.Label('Alakazam',
font_name = font_name,
font_size=72,
x=x0, y=y0,
anchor_x='center')
@window.event
def on_key_press(symbol, modifiers):
if symbol == pyglet.window.key.ESCAPE:
window.has_exit = True
@window.event
def on_draw():
window.clear()
label.draw()
def update(dt):
global t
label.y = int(y0 + (t % 2) * 50)
t += dt
pyglet.clock.schedule_interval(update, 1 / 30.)
pyglet.app.run()
The script runs fine on win7, python 3.6, pyglet 1.3.2 from pypi
With win10, version 1809 (OS build 17763.379), english, with py 3.7.2 , pyglet 1.3.2 it tracebacks similar to the OP
Traceback (most recent call last):
File "font_problem2.py", line 43, in <module>
fo = pyglet.font.load(font_name, 72)
File "C:\Python37\lib\site-packages\py_libs\pyglet\font\__init__.py", line 138, in load
if _font_class.have_font(n):
File "C:\Python37\lib\site-packages\py_libs\pyglet\font\win32.py", line 563, in have_font
gdiplus.GdipGetFamilyName(gpfamily, font_name, '\0')
ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert
Note: pyglet line numers have some offset because some print added
New zip: cocos_#317_pure_pyglet_probe_2.zip
Can you confirm if it also happens on your machine?
Opened a pyglet issue at https://bitbucket.org/pyglet/pyglet/issues/255/traceback-in-pygletfontload-win10
pyglet dev here. Unfortunately I wasn't able to reproduce this in my Windows VM, but it's a newer build. It's possible that this was a Windows bug. I'll try again on another Windows machine when I get the chance.
A fix has been pushed to pyglet master in github, should be published on next release 1.4.2
Meanwhile, @UserLeeZJ , you can patch manualy your local pyglet instalation by editing the file pyglet/image/codecs/gdiplus.py ; replace the line
gdiplus.GdipGetFamilyName.argtypes = [c_void_p, c_wchar_p, c_wchar]
with
gdiplus.GdipGetFamilyName.argtypes = [LONG_PTR, c_wchar_p, c_wchar]
Thanks for your report.
Just to add: if you prefer to use pip, you can install the latest version directly from the repository. For example:
pip install --upgrade https://github.com/pyglet/pyglet/archive/master.zip --user
Fixed in pyglet - Recommended pyglet 1.4.3 Closing
Traceback (most recent call last): File "E:\github_storage\cocos-master\samples\tetrico\tetrico.py", line 250, in
MainMenu(),
File "E:\github_storage\cocos-master\samples\tetrico\tetrico.py", line 224, in init
self.create_menu( items, shake(), shake_back() )
File "E:\github_storage\cocos-master\samples\tetrico../..\cocos\menu.py", line 294, in create_menu
self._build_items(layout_strategy)
File "E:\github_storage\cocos-master\samples\tetrico../..\cocos\menu.py", line 230, in _build_items
layout_strategy(self)
File "E:\github_storage\cocos-master\samples\tetrico../..\cocos\menu.py", line 97, in verticalMenuLayout
fo = font.load(menu.font_item['font_name'], menu.font_item['font_size'])
File "D:\Program Files\Python36\lib\site-packages\pyglet\font__init__.py", line 135, in load
if _font_class.have_font(n):
File "D:\Program Files\Python36\lib\site-packages\pyglet\font\win32.py", line 560, in have_font
gdiplus.GdipGetFamilyName(gpfamily, font_name, '\0')
ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert