help

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

help

pablo digonzelli
I create a TextEdit view and a StaticText view. My problem is this:
    I want to set the width in function of the text width.
    My font has a pixelSize of 15.
    My Text is 9 characters long.
    for The StaticText I do:
        view width: ( view value size ) ( 9 ) * (view actualFont pixelSize)
(15) . (Result = 135).
    BUT THE VIEW SHOW THE TEXT PLUS 3 BLANK CHARACTERS TO THE RIGTH OF THE
TEXT.
    If I resize the view to width: 90 (the equivalent to a 6 chars text)
then the view adjust to the text.
 Why is this.
 Can anyone help me?.
 It looks like the pixeSize of the font it's not 15 pixels. view actualFont
pixelsize did not tell me the width of each character?
 TIA.


Reply | Threaded
Open this post in threaded view
|

Re: help

Christopher J. Demers
smalltalk1 <[hidden email]> wrote in message
news:90r8ck$21jk0$[hidden email]...
> I create a TextEdit view and a StaticText view. My problem is this:
>     I want to set the width in function of the text width.
>     My font has a pixelSize of 15.
>     My Text is 9 characters long.

If you are using a proportional font all characters are not the same size.
I use Canvas<<textExtent: to get the width of a string relative to the
current font.

Chris


Reply | Threaded
Open this post in threaded view
|

Re: help

pablo digonzelli
Thanks Chris
"Christopher J. Demers" <[hidden email]> wrote in
message news:90rm5s$23hsm$[hidden email]...

> smalltalk1 <[hidden email]> wrote in message
> news:90r8ck$21jk0$[hidden email]...
> > I create a TextEdit view and a StaticText view. My problem is this:
> >     I want to set the width in function of the text width.
> >     My font has a pixelSize of 15.
> >     My Text is 9 characters long.
>
> If you are using a proportional font all characters are not the same size.
> I use Canvas<<textExtent: to get the width of a string relative to the
> current font.
>
> Chris
>
>