Re: Fw: bitrot of the python freetype example (Re: cairo Digest, Vol 141, Issue 29)

Hin-Tak Leung <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
 Date: Sat, 22 Apr 2017 10:21:22 +1200
 From: Lawrence D'Oliveiro <[email protected]>
 To: [email protected]
 Subject: Re: [cairo] Fw: bitrot of the
 python freetype example

 On Fri, 21 Apr 2017 16:41:06 +0000
 (UTC), Hin-Tak Leung wrote:
 
> > If I comment out the section added
 by Lawrence D'Oliveiro, (the whole
> > "if
 _cairo_so.cairo_font_face_get_user_data ... #endif" clause),
 then
> > it sgefault inside freetype ...
 
> PEBKAC.
 
That's perhaps the whole problem with that code. I need to google to find out what "PEBKAC" is. Sometimes it is trying to be too clever, and not clear enough as a customizable "cookbook" example.

For example, instead of using 20 lines, 10 which is a cryptic comment, and another 10 which sets up the automatic clean-up code, perhaps a couple of lines at the beginning of the main body to keep the reference, and another few lines towards the end to drop the refernce, both manually, would make the example easier to use and customize.

I am talking about re-organizing the code somewhat along the line of:

_freetype_so.FT_New_Face()
cr_face = _cairo_so.cairo_ft_font_face_create_for_ft_face()
... main body...
 _cairo_so.cairo_font_face_destroy(cr_face)
_freetype_so.FT_Done_Face(ft_face)


That's one way that code might be improved, at least in one direction; it would be shorter perhaps also... shorter is good, right?   
-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.