# [cairo] scale with text

Tobias Ceglarek dev at ceglarek.org
Sat Feb 17 12:03:47 PST 2007

```Hello again,

thanks for your  guesses ;-) I will try to further specify my question.

How can I zoom the cairo surface with all its elements (text, paths, ..)
keeping the ratios of sizes?

For example: If there is a text with width=80 in a rectangular path with
width=100, after scaling with 2.0 i want to have the same ratio so that
the text has a width of 160 and the path a width of 200. The ratio is
80/100=160/200=0.8.

I have attached two pics again. The circle is always exactly in the
white area - the text not. Why? How can I just zoom the Text like the
circle?

Regards,

Prinz Igor

On Sat, 2007-02-17 at 11:11 -0800, Carl Worth wrote:
> On Sat, 17 Feb 2007 19:20:41 +0100, Tobias Ceglarek wrote:
> > I have attached two pics. You will see, that the text overlaps the white
> > area in the zoomed version.
>
> Thanks for the picture.
>
> I still don't understand what it is you are having trouble
> achieving. Here's what I understand so far:
>
> * You called cairo_scale to make the text get larger
>
> * The text got larger
>
> * Something about the white box
>
> I feel like there's a question in there, and I'd like to try to answer
> it. But I'm still not sure what the question is. Can you help some
> more?
>
> I can take some guesses as to what the question might be:
>
>     Question: How can I restrict the text to be clipped by a rectangle
>               the size of the white box?
>
>     Answer: Call the following before drawing the text:
>
> 		cairo_rectangle (cr, x, y, width, height);
> 		cairo_clip (cr);
>
>     Question: How can I measure the size of the text so that I can
>     	      draw a rectangle that will bound it?
>
>
>     etc.
>
> But I'm not sure that it's too productive for me to keep guessing
> until I get to the right question. :-)
>
> > cairo_text_path(str)
> > cairo_fill
> >
> >
> > cairo_show_text(str)
> >
> > The effect is the same.
>
> Good. That means that those functions or behaving exactly as intended.
>
> -Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_original.png
Type: image/png
Size: 16293 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070217/02ecc2b2/cairo_original-0001.png
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_zoomed.png
Type: image/png
Size: 17702 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20070217/02ecc2b2/cairo_zoomed-0001.png
```