mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
160 stars 91 forks source link

Can't render text with pycairo #172

Open oliverbienert opened 6 years ago

oliverbienert commented 6 years ago

I successfully built python-mapnik using the mason build, according to instructions. However, pycairo test fails as already mentioned in #168. I am able to create svg as long as I don't use a TextSymbolizer. If I try to render text, then the same error occurs, no matter which font-face I declare:

python: ../../../../src/cairo-scaled-font.c:459: _cairo_scaled_glyph_page_destroy: Assertion `!scaled_font->cache_frozen' failed.

In #2675 the problem was apparently solved, but then it reappears now. This is a real show stopper and I can reproduce it on different systems.

Importing mapnik before cairo, as mentioned in #2675 also does not help.

talaj commented 6 years ago

It is just an idea, but when I was playing with color fonts I was getting this error on some systems only when I was using these color fonts. Maybe there is some font which causes this. You can list all fonts Mapnik can see by

list(mapnik.FontEngine.face_names())

Mapnik automatically imports fonts from some system font paths. You can override it by MAPNIK_FONT_DIRECTORY:

export MAPNIK_FONT_DIRECTORY=/home/user/dev/mapnik/fonts/dejavu-fonts-ttf-2.37
oliverbienert commented 6 years ago

No, unfortunately, it doesn't matter what font I use. I registered my font folder like so:

from mapnik import register_fonts, FontEngine
custom_fonts_dir = '/usr/share/fonts/truetype'
register_fonts(custom_fonts_dir)

and tried quite a number of fonts. But it always crashes and does not render.

I'll try to compile myself and see if it works if I comment those 2 Assertion lines. But it feels like a hack.

oliverbienert commented 6 years ago

I've set up a debian stretch in a lxc container (using lxd) and did the following (in short):

Now I have a working solution, the fonts are rendered as expected. However, I still think that this is a hack for those assertions are there for a reason. And I still want to know why those assertions fail in the first place.

avillagran-geo commented 6 years ago

Hi everyone!, has anyone had success regarding the problem? I have tried different paths and I can not render text. I tried to comment the lines as indicated by @oliverbienert , but I ended up in another error. (sorry by strange english)