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

package provided via pip is outdated #147

Open
Axel1492 opened this issue Apr 16, 2018 · 5 comments
Open

package provided via pip is outdated #147

Axel1492 opened this issue Apr 16, 2018 · 5 comments

Comments

@Axel1492
Copy link
Contributor

Error when trying to run font-sdf.py

[i] Using GLFW (GL 4.3)
[i] Requesting "OpenSans-Regular.ttf" from remote server
[w] Data not available on remote server
[w] Falling back to default font
Traceback (most recent call last):
  File "C:\...\font-sdf.py", line 26, in <module>
    labels.append(text, regular, origin = (x,y,z), scale=scale, anchor_x="left")
  File "C:\Program Files\Python36\lib\site-packages\glumpy\graphics\collections\sdf_glyph_collection.py", line 76, in append
    V, I = self.bake(text, font, anchor_x, anchor_y)
  File "C:\Program Files\Python36\lib\site-packages\glumpy\graphics\collections\sdf_glyph_collection.py", line 128, in bake
    glyph = font[charcode]
  File "C:\Program Files\Python36\lib\site-packages\glumpy\graphics\text\sdf_font.py", line 75, in __getitem__
    self.load('%c' % charcode)
  File "C:\Program Files\Python36\lib\site-packages\glumpy\graphics\text\sdf_font.py", line 130, in load
    data,offset,advance = self.load_glyph(face, charcode)
  File "C:\Program Files\Python36\lib\site-packages\glumpy\graphics\text\sdf_font.py", line 102, in load_glyph
    hires_data = np.zeros( (hires_height,hires_width), np.double)
TypeError: 'float' object cannot be interpreted as an integer
@rougier
Copy link
Member

rougier commented Apr 16, 2018

It's probably because of hires_data = np.zeros( (hires_height,hires_width), np.double)
This should help: hires_data = np.zeros( (int(hires_height),int(hires_width)), np.double)

@Axel1492
Copy link
Contributor Author

Axel1492 commented Apr 16, 2018

so I basically fixed it in that file:

        # Pad high resolution glyph with a blank border and normalize values
        # between 0 and 1
        hires_width  = int((1+2*self._padding)*width)
        hires_height = int((1+2*self._padding)*height)
        hires_data = np.zeros( (hires_height,hires_width), np.double)
        ox,oy = int(self._padding*width), int(self._padding*height)
        hires_data[oy:oy+height, ox:ox+width] = G/255.0

problem continues:

  File "C:\Program Files\Python36\lib\site-packages\glumpy\graphics\collections\base_collection.py", line 517, in _update
    texture = texture.reshape(shape[0],shape[1],4)
TypeError: 'float' object cannot be interpreted as an integer

solved:

            # shape[2] = float count is only used in vertex shader code
            texture = texture.reshape(int(shape[0]),int(shape[1]),4)
            self._uniforms_texture = texture.view(Texture2D)
            self._uniforms_texture.interpolation = gl.GL_NEAREST

After this the position (origin) in labels.append(text, regular, origin = (x,y,z), scale=scale, anchor_x="left") used to render the text in font-sdf.py has no effect on the rendering position...

grafik

@Axel1492
Copy link
Contributor Author

so ...from what I have seen so far this seems to be a general issue with Python 3 and glumpy. As an example (int)/(int)=(float) in newer versions of python and not anymore (int)/(int)=(int) ....to maintain old behaviour all integer divisions have to be done with // operator (python>=2.2) or int().

@Axel1492 Axel1492 reopened this Apr 16, 2018
@Axel1492 Axel1492 changed the title Example font-sdf.py gives TypeError in sdf_font.py package provided via pip is outdated Apr 16, 2018
@Axel1492
Copy link
Contributor Author

OK ....I figured my problem out. I used pip install glumpy but that does give me an outdated version wich simply does not work. I recommend you update the package.

@rougier
Copy link
Member

rougier commented Apr 23, 2018

Thanks for the report . There is a bunch of PR waiting to be merge and after that I can make a new release. I leave this issue opened until I make the release.

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