octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text properties and FTGL


From: Shai Ayal
Subject: Re: Text properties and FTGL
Date: Sun, 26 Oct 2008 06:31:40 +0200

On Sun, Oct 26, 2008 at 4:06 AM, John Swensen <address@hidden> wrote:
> So I have been messing around with FTGL today and it looks quite easy to
> use.  I was able to get the xlabel, ylabel, and zlabel working (kindof!) and
> have a few questions and comments.
>
> Comments
> FTGL is very easy to use.  I used their simple little singleton class
> example from the web page for getting fonts back to octave and then did a
> simple render of the label property in label sections of the
> opengl_renderer::draw() function in gl-render.cc.  I used the FTTextureFont,
> since it appears that it is the only one that is anti-aliased and allows
> difference colors.
>
> Problems
> 1) At first, I was trying the following command to draw a sample plot and
> xlabel:
> t=-pi:0.1:pi; plot(t,sin(t),'ro','LineWidth',2);
> xlabel('asdfASDFQWERqwerZXCVzxcvasdfASDF');
> The text was showing up very, very large even for a fontsize of 12 points
> with a 72 points per inch resolution.  When I tried to reduce the fontsize
> down below a out 5, the text simply disappeared and even at 6 it was huge.
>  Not even the first letter 'a' was visible in its entirety on the screen.  I
> was quite confused.
> Then, I tried the following command for plotting:
> t = -100:100; plot(t,100*sin(t),'r'); xlabel('asdfASDFqwerQWERzxcvZXCV');
> With this command, the text looked much more reasonably sized so I cam to
> the conclusion that the OpenGL render method is really plotting at the size
> of the signal values, rather than scaling up to some sort of default size.
>  I think we need to scale up the plots so that 12 points in text with a 72
> ppi screen is really 12 points.
> (BIG CAVEAT: I know next to nothing about OpenGL, so I am not a lot of help
> when having to do low level OpenGL stuff.)

You are right. For the way I did it in octplot, complete with
rotations and alignemnts, have a look at:
http://octplot.svn.sourceforge.net/viewvc/octplot/trunk/octplot/src/text.cpp?revision=468&view=markup
lines 182-218. Note line 208 which scales everything so that one unit
equals one pixel.

My main problem with implementing text in gl-render was not the actual
rendering -- as you say it is not very hard, but rather the problems
surrounding text:
1. Which fonts?
2. How to make it generic enough that in the future we can incorporate
some TeX parsing
3. How to report back to octave the size of the rendered text --
needed e.g. to determine the number of ticks
All of these (and maybe more) need to be determined before we even get
to the actual rendering, which , as you can see, is already almost
done in octplot -- just need to copy it.

> Also, I searched around on the internet a bit about fonts in OpenGL and it
> seems that FTGL using Freetype is in fact the "best" option out there.
>  However, it seemed that there is a general consensus that OpenGL doesn't do
> small font sizes well.  Things start to get fuzzy and then disappear (just
> like I was seeing when I thought just shrinking the fontsize property would
> fix things).  Since I don't know OpenGL I can' t appreciate why this
> happens, but I think that scaling the plots to match the text size should
> work, since I don't know of many situations where a font size smaller than 6
> pt is necessary anyway.

I think you are correct -- the problem Is twofold
1. freetype can't render small sizes as well as the font designers
intended since this portion of the truetype "standard" is patented
http://freetype.sourceforge.net/patents.html
2. OpenGL itself is based on single precision floating point, so you
can run into it's accuracy problems quite easily

However, I think this is not so much a problem since small fonts in
hardcopy which will hopefully be postscript, will look good.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]