Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Aligning TextLayout to the text baseline
Aligning TextLayout to the text baseline [message #1309703] Tue, 22 April 2014 21:25 Go to next message
Jim Mayer is currently offline Jim MayerFriend
Messages: 18
Registered: July 2009
Junior Member
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.
Re: Aligning TextLayout to the text baseline [message #1311392 is a reply to message #1309703] Wed, 23 April 2014 19:40 Go to previous message
Jim Mayer is currently offline Jim MayerFriend
Messages: 18
Registered: July 2009
Junior Member
OK... I've answered my own question. A usable set of metrics are returned by the TextLayout.getLineMetrics(line) method.

Jim
Previous Topic:Diffrent SWT browser IE versions during runtime
Next Topic:Gtk Error message when creating ExpandItems dynamically on linux
Goto Forum:
  


Current Time: Tue Apr 23 17:30:24 GMT 2024

Powered by FUDForum. Page generated in 0.04340 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top