Menu

#60 Text. Underline/overstrike & non-latin font

open
6
2003-10-31
2002-02-11
No

If a text item is requested to be underlined or
overstruck, then this is not reflected in the
generated postscript.

Additionally, if a font such as ZapfDingbats is used,
that does not have a Latin encoding, this is not shown
when the postscript is displayed.

I have made some changes to the text handling that
appears to resolve these problems, and I
enclose 'diff' output for the files I have changed
from the 8.4a3 distribution.

diff tkCanvPs.c tkCanvPs.c.orig
210,215d209
< % First test the encoding for this font.\n\ < % If this is a Latin font at position 65 will be
the encoding for\n\ < % the letter \"A\".\n\ < % If it isn't a latin font, don't re-encode it.\n\ < dup /Encoding get 65 get (A) eq {\n\ < % Yes, this is a Latin font, re-encode it...\n\ 227d220
< }if\n\ 359,360d351
< /overstrike exch def\n\ < /underline exch def\n\ 407,410c398
< % Get the width of the characters to be
displayed in case we need\n\ < % to underline or overstrike them.\n\ < dup stringwidth pop dup /strwid exch def\n\ < \n\ ---
> dup stringwidth pop\n\ 433,478d420
< \n\ < overstrike {\n\ < newpath\n\ < currentfont /FontInfo get /fontinfo exch
def % get current font info\n\ < currentfont /FontMatrix get /fontmatrix
exch def % and the font transformation matrix\n\ < \n\ < fontinfo /UnderlineThickness
get % get the underline thickness\n\ < 0
exch % put
in a dummy x value for dtransform\n\ < fontmatrix
dtransform % scale
according to font size\n\ < 2
mul % make
a bit thicker...\n\ < /overstrikethickness exch
def % and save\n\ <
pop % pop
the dummy x
< \n\ < 0 0
moveto % step
back to the start of the chars we drew\n\ < 0 baseline height 2 div sub
rmoveto % move to half-way up the
characters\n\ <
currentlinewidth %
save the current line width\n\ < overstrikethickness
setlinewidth % set the desired
underline thickness\n\ < strwid 0
rlineto % underline
the characters\n\ < stroke\n\ <
setlinewidth %
restore the original line width\n\ < } if\n\ < \n\ < underline {\n\ < newpath\n\ < currentfont /FontInfo get /fontinfo exch
def % get current font info\n\ < currentfont /FontMatrix get /fontmatrix
exch def % and the font transformation matrix\n\ < \n\ < fontinfo /UnderlinePosition
get % get the underline position\n\ < 0
exch % put
in a dummy x value for dtransform\n\ < fontmatrix dtransform /underlinepos exch
def % scale according to font size\n\ <
pop % pop
the dummy x
< \n\ < fontinfo /UnderlineThickness
get % and get the underline
thickness\n\ < 0 exch\n\ < fontmatrix dtransform /underlinethickness
exch def\n\ < pop\n\ < \n\ < 0 0
moveto % step
back to the start of the chars we drew\n\ < 0 0 underlinepos add
rmoveto % move down a bit\n\ <
currentlinewidth %
save the current line width\n\ < underlinethickness
setlinewidth % set the desired
underline thickness\n\ < strwid 0
rlineto % underline
the characters\n\ < stroke\n\ <
setlinewidth %
restore the original line width\n\ < } if\n\ < \n\

diff tkCanvText.c tkCanvText.c.orig
20d19
< #include "tkFont.h"
1507c1506
< sprintf(buffer, "] %d %g %g %s %s %s %s
DrawText\n",
---
> sprintf(buffer, "] %d %g %g %s %s DrawText\n",
1509,1511c1508
< ((stipple == None) ? "false" : "true"),
< ((((TkFont *) textPtr->tkfont)-
>fa.underline) ? "true" : "false"),
< ((((TkFont *) textPtr->tkfont)-
>fa.overstrike) ? "true" : "false") );
---
> ((stipple == None) ? "false" : "true"));

Discussion

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-02-26

    Logged In: YES
    user_id=72656

    can I get that as an attached file, with diff -u settings?
    That will make it much easier to apply. thanks.

     
  • Andy Lennard

    Andy Lennard - 2002-02-26
    • summary: Text. Underline/overstrike & non-latin f --> Text. Underline/overstrike & non-latin font
     
  • Andy Lennard

    Andy Lennard - 2002-02-26

    gzip of tar of original and modified files from 8.4a3 distribution

     
  • Andy Lennard

    Andy Lennard - 2002-02-26

    Logged In: YES
    user_id=35092

    Rather than a file of differences, I've attached a gzipped
    tar of the original files from the 8.4a3 distribution, and
    my modified versions. I hope that is more useful. Of
    course, I may be wrong, and often am...

    thanks.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2002-07-25
    • milestone: 102483 -->
    • assigned_to: hobbs --> nobody
    • priority: 5 --> 6
    • labels: 104345 -->
     
  • Donal K. Fellows

    • labels: --> 06. Canvas PostScript
     
  • Donal K. Fellows

    • assigned_to: nobody --> jenglish
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.