nanogui: Thread: Re: Fonts + rotation


[<<] [<] Page 1 of 1 [>] [>>]
Subject: RE: Fonts + rotation
From: Greg Haerr ####@####.####
Date: 13 Jan 2000 20:37:15 -0000
Message-Id: <C1962B36D9BBD311B0F80060083DFEFB040F93@SYS.CenSoft.COM>

: > If you want any rotation, it gets more complicated, since we
: > need to decide whether the "bounding box" for the text is also
: > rotated, etc.
: 
: Greg,
: 
: Unfortunately, we need support for *ANY* rotation angle. We have to
display
: street names on a city map ... So, yes, probably that the bounding box
will
: have to be rotated.
: 
: If you have any brilliant idea ... Meanwhile, I'll keep digging into that
: issue and see what I can do ...

Allright, here's a method that will work, but isn't ridiculously
complicated.

Both the low level driver routines gen_gettextsize and gen_gettextbits
get extended with an "orientation" parameter, which is an integer describing
the degrees rotation clockwise, say.

Now, if the value is zero, everything operates as today.  If the value
specifies rotation, then we assume that only a single character is
being passed, never a string.  This semantic can be enforced from
the upper Gd level.  Then, the gettextbits and/or gettextsize functions
get the normal bitmap, and perform 3 calculations:

	1. Create a new width/height box appropriate for the rotated 
character, assuming upper left/top is 0,0.  The new width/height
is the max required to hold all bits of the rotated glyph image.

	2. Clear all bits in the new box, and then sequentially
apply sin/cos math to each non-zero bit in the original bitmap,
and place them into the new, still square, bitmap.

	3. return this new bitmap.

The upper level can then use the following methods to get the text drawn:

	1. If non-zero orientation is requested, break up the text string
into single characters for the following

	2. turn off background drawing, so that bounding boxes aren't
displayed.

	3. Get each character bitmap (rotated), and use a bresenham-
like algorithm (stolen from GdLine) for determining the new x,y
location for each subsequent character based on the returned w/h
of the previous character.

;-) ?

Greg

Subject: RE: Fonts + rotation
From: "Darran D. Rimron" ####@####.####
Date: 13 Jan 2000 21:02:06 -0000
Message-Id: <NCBBLCEDENCINNMFNPBCCEELDKAA.darran@getreal.co.uk>

Greg,
> -----Original Message-----
>
> [....]
>
> [ elaborate description of how to draw fonts at
>   (x,y, degrees) snipped ]
>
> ;-) ?


Easy to use, a bugger to code, I think.  Sounds wonderful from userland
point of view and something I can see a use for in nanodesk at some
stage.

	-Darran
--
Darran D. Rimron -=- Madness takes it toll please have exact change
European Research & Development Manager - http://www.getreal.co.uk/
Phone:44-1708-70-44-33 Fax:44-1708-74-88-59 Mobile:44-7931-37-59-39
Beaten paths are for beaten men...     Bus Overflow Error Use Taxis

Subject: Re: Fonts + rotation
From: Martin Jolicoeur ####@####.####
Date: 14 Jan 2000 01:25:38 -0000
Message-Id: <387E78C1.227FAC8D@visuaide.com>

Greg Haerr wrote:

> Allright, here's a method that will work, but isn't ridiculously
> complicated.

...

>
> ;-) ?
>
> Greg

Thanks for the idea, a good starting point ... But I don't like the computing
intensive sin/cos/math stuff (SA-1100 doesn't have an FPU ...)

Anyway, I'll keep digging the freetype library for solutions ...

Thanks again,

Regards,

Martin Jolicoeur
GVT Project
####@####.####

Subject: Re: Fonts + rotation
From: "Greg Haerr" ####@####.####
Date: 14 Jan 2000 03:55:51 -0000
Message-Id: <003b01bf5e41$a3272500$15320cd0@gregh>

: Thanks for the idea, a good starting point ... But I don't like the computing
: intensive sin/cos/math stuff (SA-1100 doesn't have an FPU ...)
: 
: Anyway, I'll keep digging the freetype library for solutions ...

You can use precomputed integer values for, say, 24 rotations
around the circle (every 15 degrees) and not use floating
point.  Actually, now that I think about it, you can cut that
to 1/4 that number if you want to compute the sign of sin/cos...

Greg


Subject: Re: Fonts + rotation
From: Alan Cox ####@####.####
Date: 14 Jan 2000 14:12:54 -0000
Message-Id: <E1297HU-0000WS-00@the-village.bc.nu>

> Thanks for the idea, a good starting point ... But I don't like the computing
> intensive sin/cos/math stuff (SA-1100 doesn't have an FPU ...)

sin/cos is cheap. You build a lookup table

Alan

Subject: RE: Fonts + rotation
From: Joe deBlaquiere ####@####.####
Date: 14 Jan 2000 14:53:31 -0000
Message-Id: <80466C8694A9D211A82D0060972BED441ECF8A@rebel.wirespeed.com>

a look up table is definately the way to go... but do you really want to use
bitmap fonts ??? I would think they would look kinda jagged, especially at a
45 degree angle. GLUT ( the OpenGL Utility Toolkit ) draws characters very
nicely at arbitrary angles using stroke fonts. I would definately look at
the GLUT code before I implemented anything. 

see :
http://reality.sgi.com/mjk_asd/glut3/glut3.html

I would think this could be done within nanogui or on top of.

--Joe

> -----Original Message-----
> From: Alan Cox ####@####.####
> Sent: Friday, January 14, 2000 8:01 AM
> To: ####@####.####
> Cc: ####@####.#### ####@####.####
> Subject: Re: Fonts + rotation
> 
> 
> > Thanks for the idea, a good starting point ... But I don't 
> like the computing
> > intensive sin/cos/math stuff (SA-1100 doesn't have an FPU ...)
> 
> sin/cos is cheap. You build a lookup table
> 
> Alan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
> 
Subject: Re: Fonts + rotation
From: "Greg Haerr" ####@####.####
Date: 14 Jan 2000 16:04:20 -0000
Message-Id: <008201bf5ea7$666f9000$15320cd0@gregh>

: a look up table is definately the way to go... but do you really want to use
: bitmap fonts ??? I would think they would look kinda jagged, especially at a
: 45 degree angle. GLUT ( the OpenGL Utility Toolkit ) draws characters very
: nicely at arbitrary angles using stroke fonts. I would definately look at
: the GLUT code before I implemented anything. 
: 

Thanks for the GLUT reference.  The issue isn't that we should use
bitmap fonts or not, but rather, that ALL fonts need to be converted
to a bitmap just before display, because nanogui uses a bitmap
renderer to actually display the font.  So if the font is stroke-based,
then it would be converted to a monochrome bitmap before display,
and handed off to the std font display routine.

If actually "outputing" with stroking is desired, then the mid level
line draw routines could be called directly, but that's not directly
supported yet.

Greg


[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.