[6241] in java-interest

home help back first fref pref prev next nref lref last post

Re: Rotate Text?

daemon@ATHENA.MIT.EDU (Brian D. Elliott)
Tue Mar 26 21:57:15 1996

Date:         Mon, 25 Mar 1996 13:45:25 -0800
Reply-To: Java Interest <JAVA-INTEREST@JAVASOFT.COM>
From: "Brian D. Elliott" <belliott@WORLD.NAD.NORTHROP.COM>
To: Multiple recipients of list JAVA-INTEREST
              <JAVA-INTEREST@JAVASOFT.COM>
In-Reply-To:  <31567B53.4F3C@impltd.com>

I have not solved this problem but several people are interested in
a solution. I don't have time to pursue a solution at this time but
here is some information from the X Window System FAQ that may be
helpful(see the bottom for refs to ftp source code sites):

**************************************************************************

   Your only choice, if you want to stay within the core X protocol, is to
render the text into a pixmap, read it back via XGetImage(), rotate it "by
hand" with whatever matrices you want, and put it back to the server via
XPutImage(); more specifically:
   1) create a bitmap B and write your text to it.
   2) create an XYBitmap image I from B (via XGetImage).
   3) create an XYBitmap Image I2 big enough to handle the transformation.
   4) for each x,y in I2, I2(x,y) = I(a,b) where
      a = x * cos(theta) - y * sin(theta)
      b = x * sin(theta) + y * cos(theta)
   5) render I2
   Note that you should be careful how you implement this not to lose
bits; an algorithm based on shear transformations may in fact be better.
   The high-level server-extensions and graphics packages available for X
also permit rendering of rotated text: Display PostScript, PEX, PHiGS,
and GKS,
although most are not capable of arbitrary rotation and probably do not
use the
same fonts that would be found on a printer.
   In addition, if you have enough access to the server to install a font
on it, you can create a font which consists of letters rotated at some
predefined angle. Your application can then itself figure out placement
of each
glyph.

[courtesy der Mouse (mouse@larry.mcrcim.mcgill.edu), Eric Taylor
(etaylor@wilkins.bmc.tmc.edu), and Ken Lee (now kenton@esd.sgi.com), 11/90;
Liam Quin (lee@sq.com), 12/90; Dave Wiggins (dpw@x.org), 5/94.]

   InterViews (C++ UI toolkit, in the X contrib software) has support for
rendering rotated fonts in X.  It could be one source of example code.
[Brian R. Smith (brsmith@cs.umn.edu), 3/91]
   Another possibility is to use the Hershey Fonts; they are
stroke-rendered and can be used by X by converting them into XDrawLine
requests. [eric@pencom.com, 10/91]

   The xrotfont program by Alan Richardson (mppa3@syma.sussex.ac.uk)
(posted to comp.sources.x July 14 1992) paints a rotated font by implementing
the method above and by using an outline (Hershey) font.
   The xvertext package by Alan Richardson (mppa3@syma.sussex.ac.uk) is a
set of functions to facilitate the writing of text at any angle.  It is on
ftp.x.org as contrib/xvertext.5.0.shar.Z.

   O'Reilly's X Resource issue 3 includes information from HP about
modifications to the X fonts server which provide for rotated and scaled
text.
The modifications are on ftp.x.org in contrib/hp_xlfd_enhancements.


******************************************************************

If anyone finds or writes some Java code to resolve this I would be
interested.

Brian Elliott

=========================================================================
Brian Elliott                          | 310-948-6863
Northrop Grumman Corp.                 |
belliott@world.northgrum.com           |
=========================================================================

On Mon, 25 Mar 1996, Kevin Conner wrote:

> Brian Elliott wrote:
> >
> > How do I rotate text? I want to use g.drawString
> > to draw text at an angle.
> >
> > Do I have to write my own? Or has someone else
> > already done it? I am considering using some
> > X Window rotate font code and translating it
> > into Java or using the Hershey vector font set.
> >
>
> Can you summarise any responses you get?
>
> I implemented a generic class which would rotate an image and used
> this to spin text.  I was not very happy with it's performance but,
> as this was my introduction to Image manipulation, I didn't go back
> to modify the code.
>
> Thanks,
>       Kev
>
> -----------------------------------------------------------------------
> Kevin Conner          knrc@impltd.com        Integrated Micro Products
> Software Engineer     +44 1207 585533        Consett, County Durham, UK
>

-----
This message has been forwarded via the JAVA-INTEREST
mailing list.  In order to unsubscribe from this list, send a message to
listserv@javasoft.com with the command 'signoff JAVA-INTEREST' in
the message body (not in the subject line).

home help back first fref pref prev next nref lref last post