|Aligning TextLayout to the text baseline [message #1309703]
||Tue, 22 April 2014 21:25
| Jim Mayer
Registered: July 2009
I'm using TextLayout to format and display text. My system is running Fedora 20 on a 64 bit Intel system, so SWT is running against GTK and Cairo. I'm using the version of SWT that ships with the Eclipse Kepler release.|
My problem is that I cannot find a way to orient the output of TextLayout.draw with a text baseline. For latin text (e.g., "abc") the TextLayout origin is the upper left corner of the block and those coordinates can be determined from the font metrics.
However, for Arabic text (for example, "العربية"), the height reported by TextLayout.getBounds() is larger than the height reported from the font metrics and the text, when rendered, appears visibly lower. The effect is most noticible when displaying a line containing mixed Arabic and Latin text, as the entire line will appear to shift down as soon as the first Arabic character appears.
I've seen this effect with both "Droid Arabic Naskh" and "Droid Sans Fallback" fonts. It is not present in all fonts, however.
I noticed that there is a method in the Pango libraries called "pango_layout_get_baseline" (https://developer.gnome.org/pango/stable/pango-Layout-Objects.html#pango-layout-get-baseline) that gets the Y position of the baseline of the first line in layout, and I wonder if TextLayout should either expose this capability or use it internally.
Does anyone have experience with this issue or know how to handle this sort of layout issue? I thought I'd ask here before posting a bug report.
Powered by FUDForum
. Page generated in 0.38835 seconds