[Gambas-user] Cairo library - printing text
Rolf-Werner Eilert
eilert-sprachen at ...221...
Wed Aug 14 12:30:37 CEST 2013
Am 14.08.2013 12:26, schrieb Rolf-Werner Eilert:
>
>
> Am 14.08.2013 10:11, schrieb Benoît Minisini:
>> Le 14/08/2013 09:22, Rolf-Werner Eilert a écrit :
>>> Hi all,
>>>
>>> Found the gb.cairo class, and I hope it will make PDFs from command line.
>>>
>>> The task is not too ambitious, just 2 pages, but there is a lot of text
>>> (4 paragraphs) on one of them.
>>>
>>> Due to documentation, the DrawText function in Cairo just prints a
>>> single line, and I have to move to the starting point before, is that
>>> correct? Is there another function that has as much comfort as the
>>> DrawText function of the Paint class? And what is the difference between
>>> DrawText and Text?
>>>
>>> In the documentation, it says Begin only starts printing on an image by
>>> now, but how with PDF? (A simple example of how to start and end
>>> printing with Cairo would be nice here, e. g. on the first Cairo page.)
>>>
>>> Thanks for your advice.
>>>
>>> Rolf
>>>
>>
>> The documentation is not up to date. Now gb.cairo can draws on any of
>> its "Surface" classes (you can read the Cairo documentation and Cairo
>> examples, as gb.cairo has almost exactly the same interface, usually
>> simplyfing it).
>>
>> It works like that :
>>
>> Dim hCairoPdfSurface As CairoPdfSurface
>>
>> hCairoPdfSurface = New CairoPdfSurface ( Path As String, Width As Float,
>> Height As Float )
>>
>> Cairo.Begin(hCairoPdfSurface)
>>
>> ...
>>
>> Cairo.ShowPage() ' Go to the next page
>>
>> ...
>>
>> Cairo.End()
>>
>> As for drawing text : Cairo implements just a "toy" API. That means if
>> you want full unicode text handling, you need to use gb.qt4 or gb.gtk.
>>
>> Cairo.Text() adds text glyphs to the current path (cairo_text_path()
>> cairo function), while Cairo.DrawText() draws them directly
>> (cairo_show_text() cairo function)
>>
>> Regards,
>>
>
> Just tried it, this runs well, but how to set font-name and font-size
> for .Text and .DrawText?
>
> Rolf
Sorry, rubbish, I found it... :-)
More information about the User
mailing list