Menu

#205 Fix incorrect text height calculation

open
6
2007-11-12
2005-09-09
m17n
No

Currently Tk_MeasureChars () calculate only the width of
characters, and callers of that function
(Tk_DrawTextLayout in tkFont.c and MeasureChars in
tkTextDisp.c) assumes that the ascent and descent and the
same as those of Tk_Font. But, implementations of
Tk_MeasureChars (e.g. in tkUnixRFont.c) may use different
fonts (subfonts of Tk_Font).

This leads to in incorrect text line height.

My patch fixes this problem by introducing a new structure
Tk_TextMetrics (members are ascent, descent, and width)
and using a pointer to that structure instead of a pointer
to (int). Could you please consider this change?

Once the patch is accepted, I'll post another patch (yet
another implementation of tkUnixRfont) that utilizes the
m17n-lib <http:/www.m17n.org/m17n-lib> to provide
multilingual rendering facility to tk. The attached image
is an example of using that for rendering multilingual
text by Tcl/Tk.

The attached tar.gz file contains these files:

tk.diff -- patch to the current CVS code of tk
sample.png -- the sample image file mentioned above

Discussion

  • m17n

    m17n - 2005-09-09

    tar.gz contains a patch and sample image

     
  • Nobody/Anonymous

    Logged In: NO

    All sounds sensible to me, although far outside my area of
    expertise. I'm wondering if you have a simple sample script
    (e.g. a new test case for Tk's test suite) which illustrates
    the problem?

     
  • m17n

    m17n - 2005-09-20

    Logged In: YES
    user_id=1341974

    > All sounds sensible to me, although far outside my area of
    > expertise. I'm wondering if you have a simple sample script
    > (e.g. a new test case for Tk's test suite) which illustrates
    > the problem?

    Thank you for the response, but I don't know how to
    write a test suite. Instead, I'll show a sample.

    The attached file sample.tar.gz contains these files:
    Ac.ttf -- TTF font
    temp1.png, temp2.png -- screen dumps

    At first, please install Ac.ttf whose family name is
    "Electrik". You have to put that font in some
    directory that fontconfig searches.

    Then, run the following script with "wish" that is
    configured with --enable-xft.

    #!/bin/sh
    # the next line restarts using wish \ exec wish "$0" "$@"
    text .t -font {Electrik 24} -width 20 -height 3
    # U+9F8D is a chinese character whose meaning is "dragon".
    .t insert end "dragon \u9F8D"
    pack .t

    The screen dump of the result is temp1.png. You'll see
    that the top few pixels of U+9F8D is not drawn.

    With my patch, the same script displays that character
    correctly as temp2.png.

     
  • m17n

    m17n - 2005-09-20

    TrueType font and screen dumps

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2007-11-12
    • priority: 5 --> 6
    • assigned_to: hobbs --> 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.