Skip to main content



      Home
Home » Eclipse Projects » GEF » Problem with italic Text in Draw2D
Problem with italic Text in Draw2D [message #68479] Thu, 06 March 2003 03:40 Go to next message
Eclipse UserFriend
On Windows GetTextExtentPoint32 may return innacurate result and italic
strings represented incorrectly (see pictures attached).

Following hack in FigureUtilites fix this situation but may not work on
other platforms :(

protected static org.eclipse.swt.graphics.Point getStringDimension(String s,
Font f) {

setFont(f);

Point result = getGC().stringExtent(s);

if ((f.getFontData()[0].getStyle() & SWT.ITALIC) == SWT.ITALIC)

result.x += 1;

return result;

}





  • Attachment: image001.png
    (Size: 3.91KB, Downloaded 93 times)
  • Attachment: image003.png
    (Size: 4.01KB, Downloaded 88 times)
Re: Problem with italic Text in Draw2D [message #68491 is a reply to message #68479] Thu, 06 March 2003 04:04 Go to previous messageGo to next message
Eclipse UserFriend
Oops... Fonts may have different sizes...

protected static org.eclipse.swt.graphics.Point getStringDimension(String s,
Font f) {

setFont(f);

Point result = getGC().stringExtent(s);

if ((f.getFontData()[0].getStyle() & SWT.ITALIC) == SWT.ITALIC)

result.x += Math.max((int)(result.y * 0.04),1);

return result;

}


"Alex Selkov" <as@empproject.com> wrote in message
news:b471ol$4qe$1@rogue.oti.com...
> On Windows GetTextExtentPoint32 may return innacurate result and italic
> strings represented incorrectly (see pictures attached).
>
> Following hack in FigureUtilites fix this situation but may not work on
> other platforms :(
>
> protected static org.eclipse.swt.graphics.Point getStringDimension(String
s,
> Font f) {
>
> setFont(f);
>
> Point result = getGC().stringExtent(s);
>
> if ((f.getFontData()[0].getStyle() & SWT.ITALIC) == SWT.ITALIC)
>
> result.x += 1;
>
> return result;
>
> }
>
>
>
>
>
Re: Problem with italic Text in Draw2D [message #68642 is a reply to message #68491] Thu, 06 March 2003 08:42 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This looks like a problem with SWT's GC.
Please open a bugzilla against SWT.

"Alex Selkov" <as@empproject.com> wrote in message
news:b4736q$6cf$1@rogue.oti.com...
> Oops... Fonts may have different sizes...
>
> protected static org.eclipse.swt.graphics.Point getStringDimension(String
s,
> Font f) {
>
> setFont(f);
>
> Point result = getGC().stringExtent(s);
>
> if ((f.getFontData()[0].getStyle() & SWT.ITALIC) == SWT.ITALIC)
>
> result.x += Math.max((int)(result.y * 0.04),1);
>
> return result;
>
> }
>
>
> "Alex Selkov" <as@empproject.com> wrote in message
> news:b471ol$4qe$1@rogue.oti.com...
> > On Windows GetTextExtentPoint32 may return innacurate result and italic
> > strings represented incorrectly (see pictures attached).
> >
> > Following hack in FigureUtilites fix this situation but may not work on
> > other platforms :(
> >
> > protected static org.eclipse.swt.graphics.Point
getStringDimension(String
> s,
> > Font f) {
> >
> > setFont(f);
> >
> > Point result = getGC().stringExtent(s);
> >
> > if ((f.getFontData()[0].getStyle() & SWT.ITALIC) == SWT.ITALIC)
> >
> > result.x += 1;
> >
> > return result;
> >
> > }
> >
> >
> >
> >
> >
>
>
Previous Topic:Funny tab characters in Draw2d
Next Topic:GEF dependencies?
Goto Forum:
  


Current Time: Tue Jul 22 14:53:05 EDT 2025

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

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

Back to the top