Tk::Text text width with non-fixed fonts 
Author Message
 Tk::Text text width with non-fixed fonts

Hi,

wrapping lines in Tk::Text-widgets does a good job, as long as the
font is a fixed one (e.g. curier). It seems to get confused, if
a non-fixed font is used (e.g. times). Specifying e.g. -width => 40
what does this mean for a non-fixed font?

Is it possible to specify the width of a text-widget in pixel?
Does line breaking obey that specification?

Greetings

Jrgen

--
Dr.rer.nat. Juergen Vollmer, Viktoriastrasse 15, D-76133 Karlsruhe

            www.informatik-vollmer.de Tel: +49(721) 9204871 Fax: +49(721) 24874



Sun, 29 Jun 2003 16:12:55 GMT  
 Tk::Text text width with non-fixed fonts

Quote:

> wrapping lines in Tk::Text-widgets does a good job, as long as the
> font is a fixed one (e.g. curier). It seems to get confused, if
> a non-fixed font is used (e.g. times). Specifying e.g. -width => 40
> what does this mean for a non-fixed font?

According to the Tk::Text man page:

        Specifies the desired width for the window in units of
        characters in the font given by the -font option.  If
        the font doesn't have a uniform width then the width
        of the character "0" is used in translating from
        character units to screen units.

Quote:
> Is it possible to specify the width of a text-widget in pixel?
> Does line breaking obey that specification?

--
Marc Dashevsky  (remove "_" from address to reply by e-mail)


Sun, 29 Jun 2003 20:43:03 GMT  
 Tk::Text text width with non-fixed fonts

Quote:


> > wrapping lines in Tk::Text-widgets does a good job, as long as the
> > font is a fixed one (e.g. curier). It seems to get confused, if
> > a non-fixed font is used (e.g. times). Specifying e.g. -width => 40
> > what does this mean for a non-fixed font?

> According to the Tk::Text man page:

>    Specifies the desired width for the window in units of
>    characters in the font given by the -font option.  If
>    the font doesn't have a uniform width then the width
>    of the character "0" is used in translating from
>    character units to screen units.

> > Is it possible to specify the width of a text-widget in pixel?
> > Does line breaking obey that specification?

With the above, you can set the approximate width with

$text->configure(-width => $width_in_pixels /
                           $text->fontMeasure("fontname", "0"));

Regards,
        Slaven

--
use Tk;$c=tkinit->Canvas(-he,20)->grid;$x=5;map{s!\n!!g;map{create$c 'line'=>
map{$a=-43+ord;($x+($a>>3)*2=>5+($a&7)*2)}split''}split"!";$x+=12}split/_/=>'K
PI1_+09IPK_K;-OA1_+K!;A__1;Q!7G_1+QK_3CLPI90,_+K!;A_+1!KQ!.N_K+1Q!.F_1+KN.Q__1+
KN._K+1Q!.F_1+KN.Q_+1Q__+1!KQ!.N_1;Q!7G_K3,09Q_+1!K.Q_K+1Q!.F_1+KN.Q_';MainLoop



Mon, 30 Jun 2003 14:35:55 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. fixed width text files

2. Tk::Dialog "text width" Please Ignore

3. Tk::Dialog "text width"

4. Color Coding Text in a Tk::Text Widget

5. scrollbars, Tk::Text, large text

6. Help with pulling text out of a Tk::Text

7. TK::Text - Inserting text

8. Tag for all new text in Tk::Text

9. Perl/Tk and Fonts (Tk::Fonts) Question

10. width of text in canvas

11. Pod Problems (using =pod, nesting fonts, and Pod::Text)

12. Extracting font size ONLY from text widget with -cget

 

 
Powered by phpBB® Forum Software