[fpc-devel] [patch][rfc] pangocairo bindings and some related questions

Martin Sucha anty.sk at gmail.com
Wed Apr 29 17:33:03 CEST 2009


I've translated some C header files to be able to use pangocairo in
my application. Preliminary patch that adds these bindings (and some
missing things in pango and glib) is attached. Please review it (
comments requested :) ).

My questions:

1. I've chosen to put pangocairo.pas into separate subdirectory
under packages/gtk2/src/, is this okay?

2. This unit needs to be included into build system. This is where I
need some help as I'm not familiar with build system yet. What needs
to be done to integrate this unit? Is somewhere a document that
describes how freepascal build system works?

As I have only old fpc 2.2.0 installed on my ubuntu hardy system (I
did not have time to set up newer version and build newest compiler
yet), I could not check if this patch builds as a whole, but it
should. I checked pangocairo.pas (with some minor modifications to
build without dependencies) and mods in pango and successfully used
them to display text on cairo surface.

Other related questions:

3. PGChar is defined as ^char, but string in PGchar is encoded using
UTF-8 and automatic conversion from (wide)string to pchar does not
use this encoding so I have to use conversion function like

function StringToGChar(str:WideString):Pgchar;
  Result := Pgchar(UTF8Encode(str));

for every string argument to be able to use non-ascii characters in
gtk/pango. Maybe we could add overloaded assignment operator that
would handle this conversion. That would, however, break backward
compatibility with programs using non-ascii characters that handle
this conversion on their own.

4. On Windows, my program requires cairo.dll to be present, but
there only exists libcairo-2.dll in windows gtk2 binaries (simple
renaming that to cairo.dll fixes it). Also there are two versions of
cairo in ubuntu hardy (libcairo.so and libcairo.so.2). Maybe we
could update the library name in cairo package (I'm willing to
provide the neccessary (two-line) patch if you think using new
library name is good idea ;) to a name with "2" included.

That's all for now :)


Best Regards,

Martin Sucha
-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_pangocairo.patch
Type: text/x-patch
Size: 9596 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20090429/c90f95a7/attachment.bin>

More information about the fpc-devel mailing list