rougier / freetype-py

Python binding for the freetype library
Other
298 stars 88 forks source link

Fix bug: Glyph bounding box does not work #117

Closed fpagyu closed 4 years ago

fpagyu commented 4 years ago

see issue: https://github.com/rougier/freetype-py/issues/35

FT_Glyph_Get_CBox function in c (freetype: src/base/ftglyph.c):

 FT_Glyph_Get_CBox( FT_Glyph  glyph,
                     FT_UInt   bbox_mode,
                     FT_BBox  *acbox )
{
    // ...
}

receive glyph with FT_Glyph type, but you send byref(self._FT_Glyph) with *FT_Glyph type.

AppVeyorBot commented 4 years ago

:white_check_mark: Build freetype-py 1.0.128 completed (commit https://github.com/rougier/freetype-py/commit/a215145392 by @)

rougier commented 4 years ago

Thanks

fpagyu commented 4 years ago

There are some other problems. It works well on my ubuntu. But running on macos, it raise FT_Exception:

import freetype

face = freetype.Face("msyh.ttf")
face.set_pixel_sizes(0, 30)
slot = face.glyph 
glyph = slot.get_glyph()
glyph.get_cbox(freetype.FT_GLYPH_BBOX_SUBPIXELS)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/yufpga/proj/venv/lib/python3.6/site-packages/freetype/__init__.py", line 793, in get_cbox
    if error: raise FT_Exception(error)
freetype.ft_errors.FT_Exception: FT_Exception:  (unknown file format)
rougier commented 4 years ago

Is it specific for this font ?

fpagyu commented 4 years ago

I tried different font, get the same result.

rougier commented 4 years ago

Did you install the latest version because get_cbox shoudl be defined on line 822 (not 793)