bugGNU Octave - Bugs: bug #33118, FLTK and Qt: text rotation fails...


bug #33118: FLTK and Qt: text rotation fails for angles other than 90 degrees

Submitted by:  None
Submitted on:  Tue 19 Apr 2011 05:27:18 AM UTC  
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Dan Newman Originator Email:  -email is unavailable-
Open/Closed:  Open Release:  dev
Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Thu 22 Dec 2016 04:54:44 PM UTC, comment #13:

Understood. So this is really a much bigger project than just a rotation matrix. I suppose it might be possible to start with the ugly solution, just to get something working onscreen, and then figure out the correct solution with Freetype later.

Rik <rik5>
Project Administrator
Thu 22 Dec 2016 11:57:39 AM UTC, comment #12:

Just a note:
Almost 2 years ago I started a repo on github https://github.com/Andy1978/octave-debug-text-renderer for this issue. Perhaps it's worth a look...

Andreas Weber <andy1978>
Project Member
Thu 22 Dec 2016 09:53:30 AM UTC, comment #11:


>> It seems that as a first take, we could just calculate a rotation matrix (R) and then use ...

Yes, one could try this approach but I fear that the result would be of poor quality. Freetype initially applies antialiasing on glyphs so that they are rasterized smoothly on the original grid. After rotation one would have to interpolate pixels colors to make them fit into the output pixmap (see "imtransform" in the image package) and antialiasing would then be lost.

Freetype has tools to rotate/transform glyphs before rasterization but it would be a deeper change into txt-renderer.cc

Pantxo Diribarne <pantxo>
Project Member
Tue 20 Dec 2016 09:46:46 PM UTC, comment #10:

I'm adding Pantxo to the CC list for this 5-year old bug because he often has a good understanding of OpenGL. In this case, the issue seems to have been traced back to the function

which is in libinter/corefcn/ft-text-renderer.cc:1113.

It seems that as a first take, we could just calculate a rotation matrix (R) and then use

since the multiplication operator should be defined for uint8NDArray types.

Rik <rik5>
Project Administrator
Thu 08 Dec 2016 03:56:03 AM UTC, comment #9:

issue still exists in Octave 4.2.0 using comment #5 example in the qt and fltk toolkits, but not gnuplot (text is rotated in gnuplot). saved pdfs still have correct rotated text.

Nicholas Jankowski <nrjank>
Mon 13 Jun 2016 09:54:47 AM UTC, comment #8:

This issue still exists.

Tatsuro MATSUOKA <tmacchant>
Thu 05 Feb 2015 06:18:54 AM UTC, comment #7:

This is still present on the current development version, and affects both the FLTK and Qt toolkits. Updating version and summary.

Mike Miller <mtmiller>
Project Administrator
Sun 18 Sep 2011 03:26:21 PM UTC, comment #6:

I've changed the summary

Ben Abbott <bpabbott>
Project Member
Wed 20 Apr 2011 03:57:15 PM UTC, comment #5:

Confirmed that this is a rendering issue as printing works correctly.

Good work by Andreas in identifying the problem file and area. It looks to me like we are maintaining the pixels in an Octave uint8NDarray already. This means we could probably just use a rotation matrix in Octave rather than calling out to FreeType. I don't mess with the graphics area much, however, so someone else will have to do any coding in this area.

Rik <rik5>
Project Administrator
Wed 20 Apr 2011 12:18:47 PM UTC, comment #4:

I had now a deeper look on this. Please keep in mind that I am a beginner with the octave source code and some asumptions might be false.

hg id = f212ff846296

Since the text is rendered into a bitmap with freetype, fltk does not rotate the text. Rather in
which calls

int ft_render::rotation_to_mode (double rotation) const;
does only accept 0,90,180,270 deg, all values which does not mache are set to 0

The "rotation" is done in txt-eng-ft.cc, ft_render::render
with "pixels = pixels.permute (perm);"

I guess if instead the FreeType function FT_Set_Transform
is used, we can display arbitrary rotated text and can get rid of the "permute". (see http://www.freetype.org/freetype2/docs/tutorial/step1.html)


Andreas Weber <andy1978>
Project Member
Wed 20 Apr 2011 07:34:51 AM UTC, comment #3:

I think FLTK can draw rotated text with fl_rotate and fl_draw.

I stepped through the code and found in
txt-eng-ft.cc:394:ft_render::render (text_element* elt, Matrix& box, int rotation) a switch for ROTATION_0, ROTATION_90, ROTATION_180 and ROTATION_270

All values outside x*90 are mapped to ROTATION_0 in ft_render::rotation_to_mode (double rotation) const.

I'm really not familiar with the octave internals but it seems to me like the text gets rendered with freetype and the fltk functions only draw the resulting bitmap in
gl-render.cc:2992: glDrawPixels (bbox(2), bbox(3), GL_RGBA, GL_UNSIGNED_BYTE, pixels.data ());

btw: If I want to compile octave-dev with debugging symbols, what is the prefered way? Now I made a
../octave/configure --enable-shared --disable-static
make CFLAGS="-O0 -ggdb" CXXFLAGS="-O0 -ggdb"

is this sufficient?

Andreas Weber <andy1978>
Project Member
Wed 20 Apr 2011 02:27:03 AM UTC, comment #2:

I think this is a limitation of FLTK.


However, GL2PS does not have this limitation. Thus, output obtained using the print() function should be correct.

Ben Abbott <bpabbott>
Project Member
Tue 19 Apr 2011 06:35:25 PM UTC, comment #1:

Confirmed on a recent development tip (4/19/2011).

Rik <rik5>
Project Administrator
Tue 19 Apr 2011 05:27:18 AM UTC, original submission:

The "Rotation" property is not handled correctly by the text() function. For angles which are positive multiples of 90, the plotted result is correct. For other angles, the text is plotted at a rotation angle of 0.

This failure only occurs onder fltk. Gnuplot produces the correct result.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by rik5
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by tmacchant (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-12-20 rik5 Carbon-Copy- => Added pantxo
    2015-02-05 mtmiller Release3.4.0 => dev
        Operating SystemGNU/Linux => Any
        SummaryFLTK text rotation fails for angles other than 90 deg => FLTK and Qt: text rotation fails for angles other than 90 degrees
    2014-12-26 rik5 Dependencies- => bugs #32332 is dependent
    2011-09-18 bpabbott Summarytext rotation fails for angles other than 90 deg => FLTK text rotation fails for angles other than 90 deg
    2011-04-19 rik5 StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.3