# [reportlab-users] How to draw text in a non-rectangular area?

Philip Douglass reportlab-users@reportlab.com
Fri, 27 Dec 2002 16:34:44 -0500

```Actually I did join the list -- I just used a plussed version of my

Anyway, here is a test program that demonstrates the best I could come up
with off the top of my head (please excuse me, I'm not the most skilled
programmer, and I am a brand new python user). This still doesn't really
help with justifying text or anything like that. Has anyone else tried to
do what I'm trying to do? Is there a better way to accomplish this?

# File: point_in_frame_test.py
# Coordinates for an irregular frame, in inches
# Note: Must be clockwise coordinates!
frame = [( 1.8125,  3.5000 ),
( 6.6875,  3.5000 ),
( 6.6875,  2.8125 ),
( 5.6875,  1.8125 ),
( 2.8125,  1.8125 ),
( 1.8125,  2.8125 )]

points = [( 0.8125,  3.5000 ), # x=outside, y=top border (false)
( 2.8125,  2.8125 ), # x=inside, y=inside      (true)
( 2.8125,  1.8125 ), # on bottom left corner   (false)
( 7.6875,  0.8125 )] # x=outside, y=outside    (false)

def areaOfTriangle(pointset):
"""Returns the area for a given set of three points."""

(x0, y0), (x1, y1), (x2,y2) = pointset
area=(.5)*(x1*y2 - y1*x2 - x0*y2 + y0*x2 + x0*y1 - y0*x1)
return area

def isInside(frame, point):
"""Returns true if the given frame contains the given point."""

for i in range(2, len(frame)+1):
pointset = frame[i-2:i]
pointset.append(point)
a = areaOfTriangle(pointset)
if a >= 0:
return False
return True

for point in points:
if isInside(frame, point):
print "Yes, point ", point, " is inside frame."
else:
print " No, point ", point, " is not inside frame."

## END: point_in_frame_test.py

----- Original Message -----
From: "Andy Robinson" <andy@reportlab.com>
To: <reportlab-users@reportlab.com>; <philipd@sirs.com>
Sent: Friday, December 27, 2002 3:17 AM
Subject: RE: [reportlab-users] How to draw text in a non-rectangular area?

Philip,

We don't have anything to do this at present, you'd have
to 'roll your own' container.

Also, normally you have to join our users list first,
otherwise posts get held pending review.
http://two.pairlist.net/mailman/listinfo/reportlab-users

- Andy Robinson

> -----Original Message-----
> [mailto:reportlab-users-admin@reportlab.com]On Behalf Of Philip Douglass
> Sent: 26 December 2002 18:35
> To: reportlab-users@reportlab.com
> Subject: [reportlab-users] How to draw text in a non-rectangular area?
>
>
> I've scanned the docs and FAQ and couldn't find out if there was an easy
> way to flow text into a non-square frame. For example, I have a long
> string that I would like to format into a triangle. How can I do this?
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users@reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
_______________________________________________
reportlab-users mailing list
reportlab-users@reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users

```