Autore Topic: Stampare del testo con il componente Cairo  (Letto 291 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.303
  • Ne mors quidem nos iunget
    • Mostra profilo
Stampare del testo con il componente Cairo
« il: 14 Agosto 2013, 10:31:04 »
Vi riporto di seguito una discussione apparsa sulla M.L.I.:


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

Codice: gambas [Seleziona]

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,
--
Benoît Minisini
"


" > The documentation is not up to date. Now gb.cairo can draws on any of

---> "can draw"

> its "Surface" classes (you can read the Cairo documentation and Cairo
> examples, as gb.cairo has almost exactly the same interface, usually
> simplyfing it).


---> "simplifying it"

--
Benoît Minisini
"
« Ultima modifica: 14 Agosto 2013, 10:34:54 da vuott »
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »