Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-04

[patch][rfc] pangocairo bindings and some related questions

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Sucha

Hi,

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;
begin
  Result := Pgchar(UTF8Encode(str));
end;

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 :)

Thanks.

Best Regards,

Martin Sucha

Reply by email

Paul Ishenin
to Martin Sucha
Martin Sucha wrote 15 lines
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; begin Result := Pgchar(UTF8Encode(str)); end; 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.

This way you will break lazarus since lazarus stores utf8 encoded strings in 'string' type.

Best regards,
Paul Ishenin.

Reply by email

Michael Schnell
to Paul Ishenin
This way you will break lazarus since lazarus stores utf8 encoded strings in 'string' type.

Which seems to be caused by understandable reasons, but causes a lot of trouble.

Quite like Lazarus needs to change on that behalf once a more advanced Unicode support is implemented in FPC (may that be working along the Lines of Delphi 2009 or done differently).

-Michael

Reply by email

Martin Sucha
to Martin Sucha: I've translated some C header files to be able to use pangocairo in my application.…

Hi,

2009/4/29 Martin Sucha:

I've translated some C header files to be able to use pangocairo in my application.

I'm attaching a version of the patch that I consider final. I added package cairo as a dependency for package gtk2. Also changed external library name for cairo unit (see below/patch itsef).

I'm also attaching an example program for pangocairo usage. As I'm short of time it is a separate source file. Feel free to include it into sources if you like it. (Note: I made it without reading any docs for pango/pangocairo so there are no warranties. This example works fine on linux and throws a numeric exception on windows. I've traced it to cairo_fill_preserve call for 'World' path (only stroking that path works fine) -- I don't know if it is bug in the example program itself or in pango/cairo/pangocairo binaries I used and I've _not_ checked it with latest gtk binaries)

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

I assume yes.

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?

I've hacked the build system somehow (added cairo dependency). It built successfully on linux 64 bit and windows. Hopefully I have not broken anything :) . Please let me know if you spot any mistake.

Show quoted text 5 lines
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 [...] to a name with "2" included.

This version of the patch also includes a change for this.

Best Regards

Martin Sucha

Reply by email

Martin Sucha
to Martin Sucha

Hi,

2009/5/5 Martin Sucha:

2009/4/29 Martin Sucha: > I've translated some C header files to be able to use pangocairo in > my application. I'm attaching a version of the patch that I consider final.

My patch is still hanging around...
I'd be very happy if it gets applied ;) Or are there any comments/suggestions?

Thanks

Best regards

Martin Sucha

Reply by email

Florian Klaempfl
to Martin Sucha
Show quoted text 11 lines
Hi, 2009/5/5 Martin Sucha: > 2009/4/29 Martin Sucha: >> I've translated some C header files to be able to use pangocairo in >> my application. > I'm attaching a version of the patch that I consider final. My patch is still hanging around... I'd be very happy if it gets applied ;) Or are there any comments/suggestions?

Best is to attach it to an issue report, then it won't be forgotten.

Reply by email

Martin Sucha
to Paul Ishenin

Hi,

2009/5/12 Paul Ishenin :

Show quoted text 8 lines
Martin Sucha wrote: > My patch is still hanging around... > I'd be very happy if it gets applied ;) Or are there any > comments/suggestions? I can't apply your patch since it touches makefiles and adds depedencies between packages. I suppose Michael will apply it.

Thanks for info. I'll create an issue report as Florian suggested.

Best regards

Martin Sucha

Reply by email