Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: Maybe the wrong question to ask? Re: [platform-swt-dev] FontMetrics question about width?


I believe what you are looking for is GC.stringExtent or GC.textExtent.
Set your font into the GC and then ask the GC how big your string will be.
Hope this helps,
Carolyn



Jack Park <jackpark@xxxxxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

10/19/2003 04:44 PM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx
        cc:        
        Subject:        Maybe the wrong question to ask? Re: [platform-swt-dev] FontMetrics question about width?



Since nobody rose to the siren call for an explanation of how to do what
we can do in AWT, let me rephrase the question.

I want to draw an oval and put some text inside it.  How to I, when
given a String as a label inside the oval, know what bounding rectangle
to assign to the oval?  That is, the oval, or a rectangle, or any other
shape, needs to know how large it should be based on the text (font,
size, etc) that it will surround. Maybe FontMetrics is the wrong
metaphor. What is the right metaphor?

Thanks
Jack

Steve Northover wrote:

>
> Did I miss the discussion about fontMetrics.width()?
>
>
>
>
> In taking some awt stuff -- really cool stuff worth moving to SWT -- I
> am running into the fontMetrics.width() issue. Is there a graceful
> workaround?
>
> Thanks
> Jack
>



_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top