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

set_char_size() fails with float parameter #113

Open
buzmeg opened this issue Jul 9, 2019 · 4 comments
Open

set_char_size() fails with float parameter #113

buzmeg opened this issue Jul 9, 2019 · 4 comments
Labels
good first issue good for first-time contributors

Comments

@buzmeg
Copy link

buzmeg commented Jul 9, 2019

set_char_size() claims to take floats as parameters in the documentation. However, if you feed it a float, freetype-py crashes.

face.set_char_size(128, 128, 128, 128) works fine

face.set_char_size(128.0, 128, 128, 128) crashes with:

Traceback (most recent call last):
  File "main.py", line 517, in <module>
    sys.exit(main())
  File "main.py", line 483, in main
    initialize_freetype()
  File "main.py", line 24, in initialize_freetype
    face.set_char_size(128.0, 128, 128, 128)  # Render directly to correct bitmap size
  File "/Users/andrewl/python/triangles/venv/lib/python3.7/site-packages/freetype/__init__.py", line 1081, in set_char_size
    error = FT_Set_Char_Size( self._FT_Face, width, height, hres, vres )
ctypes.ArgumentError: argument 2: <class 'TypeError'>: Don't know how to convert parameter 2
@HinTak
Copy link
Collaborator

HinTak commented Jul 9, 2019

I think the documentation is mis-worded - width and height are both 26.6 fractional numbers . It is a special type of integer to mean x / 64, when you write x. (I.e. 128 means 2 , 96 means 1.5). Hres and vres are just integers, not floats. They are passed directly to freetype as documented in freetype's documentation.

@buzmeg
Copy link
Author

buzmeg commented Jul 15, 2024

Closing.

@buzmeg buzmeg closed this as completed Jul 15, 2024
@HinTak
Copy link
Collaborator

HinTak commented Jul 15, 2024

The crash probably should be avoided. Again, this is a good and somewhat easy to fix first issue for new contributors.

@HinTak HinTak reopened this Jul 15, 2024
@HinTak
Copy link
Collaborator

HinTak commented Jul 15, 2024

There are code elsewhere checking the type of inputs (e.g. file names are byte arrays, what freetype c expects, and python 3 strings are converted to byte arrays) and convert if mismatch to what freetype expects. This is a good new contributor issue to add such.

@HinTak HinTak added the good first issue good for first-time contributors label Jul 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue good for first-time contributors
Projects
None yet
Development

No branches or pull requests

2 participants