EV_MODEL_TEXT.is_rotatable ?

14 views
Skip to first unread message

jjj

unread,
Nov 9, 2018, 10:01:32 PM11/9/18
to Eiffel Users
The comment for EV_MODEL_TEXT.is_rotatable says "Not yet."  Are plans in the works to make text rotatable any time soon?

jjj

Finnian Reilly

unread,
Nov 10, 2018, 5:58:44 AM11/10/18
to Eiffel Users
Hello jjjj,
Eiffel-Loop has an implementation of rotated text in class EL_DRAWABLE_PIXEL_BUFFER that is based on an Eiffel wrapper for the Cairo and Pangocairo library. See routine `draw_rotated_text_top_left'. The class is part of a library of extensions for Vision2.

The rotation works very well on Linux as you can see from this screeshot. On Windows I had some difficulties because the Cairo library calls a text rotation function in the Windows classic graphics API, and the results look very pixelated. As a workaround I came up with the idea of making a temporary transparent bitmap with Cairo, rotating the bitmap and then patching it on to the base layer. The results while not quite as good as the Linux implementation are still a big improvement on the Windows Graphics API.

However using the EL extensions for Vision2 has a number of caveats you should be aware of
  1. The Eiffel-Loop library is only confirmed to work with version 16.05 of the compiler and needs some work to make it compatible with the latest compiler. In particular I need to see if it's possible to remove some over-rides to the standard Vision2 library.
  2. For Windows you need to distribute about 29 mb of DLL's with your application These are needed to make Cairo and Pangocairo work.
  3. The Cairo and Pangocairo DLLs are not binary compatible with the latest version of the MSVC compiler as they are compiled with mingw. However they are confirmed to work with the MS 7.1 SDK and possibly some later versions but I haven't tested.
  4. Eiffel-Loop is void-safe aware but not void-safe, so if you are planning on making your apps void-safe then you may not be able to use Eiffel-Loop.
regards
Finnian

Finnian Reilly

unread,
Nov 10, 2018, 6:15:50 AM11/10/18
to Eiffel Users
A correction to my earlier post. Actually both Linux and Windows use the temporary bitmap rotation as shown in this routine. A better screenshot of the results on Linux.
class EL_DRAWABLE_PIXEL_BUFFER_I

   draw_rotated_text_top_left
(x, y: INTEGER; angle: DOUBLE; a_text: READABLE_STRING_GENERAL)
     
require
         locked_for_24_rgb_format
: is_rgb_24_bit implies is_locked
     
local
         text_rect
: EL_RECTANGLE; text_pixel_buffer: EL_DRAWABLE_PIXEL_BUFFER
         l_x
, l_y, hyphen_width: INTEGER
     
do
         create text_rect
.make_for_text (a_text, font)
         create text_pixel_buffer
.make_with_size (text_rect.width, text_rect.height)

         text_pixel_buffer
.set_color (color.twin)
         text_pixel_buffer
.set_antialias_best
         text_pixel_buffer
.set_font (font)
         text_pixel_buffer
.draw_text_top_left (0, 0, a_text)

         
-- Make last hyphen more prominent
         
if a_text [a_text.count] = '-' then
            l_x
:= font.string_width (a_text.substring (1, a_text.count - 1))
            l_y
:= font.ascent - font.descent + 1
            hyphen_width
:= font.string_width (once "-") - 1
            text_pixel_buffer
.set_line_width (1)
            text_pixel_buffer
.draw_line (l_x + 1, l_y, l_x + hyphen_width, l_y)
         
end

         save
         translate
(x, y); rotate (angle)
         draw_pixel_buffer
(0, 0, text_pixel_buffer.implementation)
         restore
     
end


jjj

unread,
Dec 9, 2018, 12:44:02 AM12/9/18
to Eiffel Users
Finnian,

Thanks for the reply.  Looks interesting, but all the caveats make the EL extensions a bit heavy handed for my application.  Is it possible to draw the EV_MODEL_TEXT (with the correct background color, if not transparent or no background), capture that as an EV_MODEL_PIXMAP, then rotate the pixmap?  But will it scale to an arbitrary size like other EV_MODELs?

So, I guess the answer to my original question is, "No".

jjj


Reply all
Reply to author
Forward
0 new messages