Re: Using Pango and TrueType Fonts

Olaf Schmidt <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
Am 26.02.2015 um 19:42 schrieb Michael Gerbracht:

>>> I would like to use Pango with Cairo to display data in graphs.[...] ..
>>>
...
> My problem is, that the resulting svg does not use the Wingdings font to
> display the text.

The Toy-API seems to work well enough for such simple purposes...

Using the Windows-Download from:
http://www.dynaset.org/dogusanh/luacairo
(on a Win-8-VM) and a slight adaption of example #2, to an SVG-Surface:

------------------------

local cairo = require"lcairo"
local CAIRO = cairo

w = 480
h = 240
cs = cairo.svg_surface_create('cairo_test.svg', w, h)
cr = cairo.create(cs)

cairo.select_font_face(cr, "WingDings", CAIRO.FONT_SLANT_NORMAL,
                                         CAIRO.FONT_WEIGHT_NORMAL)
cairo.set_font_size(cr, w/8)
cairo.move_to(cr, 0, 3*h/4)
cairo.text_path (cr, "LUA-lua")
cairo.set_source_rgb (cr, 0.5, 0.5, 1)
cairo.fill_preserve (cr)
cairo.set_source_rgb (cr, 0, 0, 0)
cairo.set_line_width (cr, w/200)
cairo.stroke (cr)

cairo.destroy (cr)
cairo.surface_destroy (cs)

-----------------------

The following SVG-Output was produced:
http://vbRichClient.com/Downloads/cairo_test.svg

... which looks quite "WingDingish" to me...

Aside from that, you seem to prefer the generation (and positioning)
of different "Point-Types" in your Graphs per Font-Rendering, ...
a better alternative would be (IMO), to write your own little LUA-
function, to construct a regular polygon around a given center-point:
http://en.wikipedia.org/wiki/Regular_polygon

Using only 5 Parameters (cx, cy, rInner, rOuter, nSides) you can
produce a lot of different "Point-Shapes" all with the same function
(which shouldn't take much more than 15-20 lines of code - then
generating a less voluminous SVG-output along the way as well).

Olaf

-- 
cairo mailing list
[email protected]
http://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.