[mapguide-trac] #271: Consider adding bidi support for text rendering

MapGuide Open Source trac_mapguide at osgeo.org
Thu Jun 11 00:34:17 EDT 2009


#271: Consider adding bidi support for text rendering
-------------------------------+--------------------------------------------
 Reporter:  traianstanev       |         Owner:  waltweltonlair
     Type:  enhancement        |        Status:  assigned      
 Priority:  medium             |     Milestone:  2.1           
Component:  Rendering Service  |       Version:  2.1.0         
 Severity:  minor              |    Resolution:                
 Keywords:                     |   External_id:                
-------------------------------+--------------------------------------------
Comment (by waltweltonlair):

 Fix #271 (Consider adding bidi support for text rendering)

 This submission r3936 adds BIDI support for text rendering.  Labels and
 symbols containing bi-directional
 character sequences will now render correctly.

 A new BIDIConverter class is added to the Stylization project.  It takes a
 bi-directional unicode
 string as input and creates a LTR ordering of that string for display
 purposes.  The class was
 written by Troy, and here are some additional notes he provided regarding
 it:

   It is a complete solution include glyph shaping.  I took special care in
 making
   sure the code is stable.  I’ve run through millions of string
 conversions without
   a problem and have just completed a 30 million string test with randomly
   constructed strings ranging from 1-100 characters.  (We’re also free of
 any memory
   leaks although I can’t really take credit for that since I use mostly
 std stuff
   which does the memory management).  In release mode it can process
 roughly 20,000
   reasonably sized (in my test case about 55 characters and 3 language
 swaps)
   strings a second.

 Integration of the converter primarily happens in the MapGuide renderer
 implementations of !MeasureString
 and !DrawString: before measuring or drawing a string we convert it to LTR
 format.  Labels for
 point and polygon features are then rendered correctly, as well as symbols
 containing text elements.
 However this is not sufficient for path labels - labels which follow the
 contours of polyline
 features.  Path labels are handled by splitting them into individual
 characters and positioning
 each character along the feature (RSFontEngine.!LayoutPathText performs
 this work).  To support
 BIDI strings, the path label therefore needs to be converted before
 !LayoutPathText is called.  This
 is done in the !LabelRenderer and !LabelRendererLocal classes in
 Stylization.

 I did some performance testing of the updated code, and a couple of
 factors will affect the results:
  * the number of labels in your map
  * the type of labels in your map (path labels or point/polygon labels)
  * whether the labels actually contain bi-directional character sequences

 Test 1: On a tiled map that had not-too-dense path labels containing bi-
 directional strings, the
 performance impact was about 5%.

 Test 2: The server rendering unit test has a map with very dense labels on
 a polygon layer.  It's more
 of an extreme case.  I temporarily changed the test so that all labels
 contained bi-directional strings,
 and also made it render the map 100 times to increase measurement
 precision.  The overall time increased
 by 17% (from 58 seconds to 68 seconds).  I then reran the test with the
 labels changed back to their
 default English strings, and the increase was only 9% (63 seconds vs. 58
 seconds).

 For the majority of maps with labels I expect the performance impact to be
 5% or less.  Of course
 if you have no labels then there is no impact.

-- 
Ticket URL: <https://trac.osgeo.org/mapguide/ticket/271#comment:5>
MapGuide Open Source <http://mapguide.osgeo.org/>
MapGuide Open Source Internals


More information about the mapguide-trac mailing list