Summary: | setting font fails to retain the font and later fail | ||
---|---|---|---|
Product: | cairo | Reporter: | Pierre Baillargeon <pierrebai> |
Component: | quartz font backend | Assignee: | Vladimir Vukicevic <vladimir> |
Status: | RESOLVED FIXED | QA Contact: | cairo-bugs mailing list <cairo-bugs> |
Severity: | normal | ||
Priority: | medium | CC: | freedesktop, jmuizelaar, ranma42 |
Version: | 1.9.1 | ||
Hardware: | x86 (IA32) | ||
OS: | Mac OS X (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: |
Test case reproducing the bug on MacOSX / Quartz
C code reproducing teh bug on MacOSX 10.5.8 with Quartz font backend |
Description
Pierre Baillargeon
2009-11-02 14:03:44 UTC
A small test case would be useful. Its not clear to me if you are describing a pycairo problem, a cairo problem, or a cairo/quartz problem (there is no pycairo/Quartz implementation). Why should the font reference be increased. The functions cairo_select_font_face and cairo_set_font_size do not even return a cairo_font_face_t which you would need to call cairo_font_face_reference. You are correct, this is a cairo problem, not a pycairo problem. The test case is the tutorial I pointed to in the original bug report. It's a pycairo tutorial and it crashes on MacOSX / Quartz. I must have assumed the cairo and pycairo teams were closer than they really are. > From: bugzilla-daemon@freedesktop.org > To: pierrebai@hotmail.com > Subject: [Bug 24862] setting font fails to retain the font and later fail > Date: Mon, 16 Nov 2009 04:34:04 -0800 > > http://bugs.freedesktop.org/show_bug.cgi?id=24862 > > --- Comment #1 from Steve Chaplin <stevech1097@yahoo.com.au> 2009-11-16 04:34:04 PST --- > A small test case would be useful. > Its not clear to me if you are describing a pycairo problem, a cairo problem, > or a cairo/quartz problem (there is no pycairo/Quartz implementation). > > Why should the font reference be increased. The functions > cairo_select_font_face and cairo_set_font_size do not even return a > cairo_font_face_t which you would need to call cairo_font_face_reference. > > > -- > Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email > ------- You are receiving this mail because: ------- > You reported the bug. _________________________________________________________________ Windows Live : vos amis voient plus facilement ce que vous faites sur Facebook. http://go.microsoft.com/?linkid=9691826 BTW, the original "fix" I did was to add: { cairo_font_face_t* ff = cairo_get_font_face (o->ctx); if (ff) cairo_font_face_reference (ff); } Around line 826 of pycairo_select_font_face(). This avoids the crash but permanently hold the font in memory, I think. It is unfortunate that the Cairo API forces one to explicitly add that code when using a font in pycairo. (i.e, after each select_font_face(), one has to get_font_face() and add a reference to it. Here's a small pycairo program that reproduce the bug: #! /usr/bin/env pythonimport cairo class Diagram(object): def __init__(self, filename, width, height): self.surface = cairo.SVGSurface(filename + '.svg', width, height) cr = self.cr = cairo.Context(self.surface) cr.scale(width, height) # Note: bug doesn't show up if no save/restore. cr.save() self.draw_dest(self.cr) cr.restore() cr.show_page() self.surface.finish() def draw_dest(self, cr): cr.set_source_rgb(1, 1, 1) cr.rectangle(0, 0, 1, 1) cr.fill() class BugText(Diagram): def draw_dest(self, cr): Diagram.draw_dest(self, cr) cr.set_source_rgb(0.0, 0.0, 0.0) cr.select_font_face("Arial", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD) cr.set_font_size(1.2) # Uncomment to fix bug! #self.ff = cr.get_font_face() x_bearing, y_bearing, width, height = cr.text_extents("a")[:4] cr.move_to(0.5 - width / 2 - x_bearing, 0.5 - height / 2 - y_bearing) cr.show_text("a") if __name__ == '__main__': BugText('showtext', 300, 200) -- Pierre _________________________________________________________________ Windows Live : vos amis reçoivent vos nouveautés Facebook, Twitter et MySpace lorsqu'ils vous envoient un message électronique. http://go.microsoft.com/?linkid=9691827 Created attachment 31240 [details]
Test case reproducing the bug on MacOSX / Quartz
Move from pycairo to cairo bug list. Reassign. This doesn't make any sense. A simple C test case is appreciated. Created attachment 31259 [details]
C code reproducing teh bug on MacOSX 10.5.8 with Quartz font backend
This is a translation of the Python code in C. It crashes with a bus error on MacOSX 10.5.8 because the font is freed when the rendering is done. Adding an explicit reference to teh font by hand avoids the problem, but it should not be needed, I believe.
This looks to have been fixed at some point. I'm not able to reproduce the crash on OS X 10.11 with cairo 1.14.6 |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.