[PD-dev] [ pure-data-Patches-3289212 ] Move text drawing routine to tcl

SourceForge.net noreply at sourceforge.net
Sun May 1 06:20:05 CEST 2011


Patches item #3289212, was opened at 2011-04-18 23:39
Message generated for change (Comment added) made by eighthave
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=478072&aid=3289212&group_id=55736

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: puredata
Group: bugfix
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Kan-Ru Chen (kanru)
Assigned to: Nobody/Anonymous (nobody)
Summary: Move text drawing routine to tcl

Initial Comment:
It's best let tcl to figure out how to draw text and the border box. This should fix non-latin text drawing like Chinese.

----------------------------------------------------------------------

>Comment By: Hans-Christoph Steiner (eighthave)
Date: 2011-05-01 00:20

Message:
In the long run, this patch is the right approach.  But it'll take some
major overhaul of the guts to get there.  Basically, currently the core C
'pd' process receives the mouse motion from the Tcl 'pd-gui' process, and
then 'pd' determines when something like an object or slider is clicked. 
That means with the current code, if Tcl sizes the boxes, then Pd will
still think they are the original size.  

The current box width is determined by using the width of the latin
capital M. It seems that chinese characters are much wider than a latin
capital M.  I attached an image that shows what happens if the current Pd
code uses a chinese character as the baseline for the character width. 
Basically, chinese characters fit, but latin characters become oddly
small.

If you want to try this yourself, check out tcl/pd-gui.tcl, in the proc
fit_font_into_metrics:

        while {[font measure $myfont M] > $width || \


----------------------------------------------------------------------

Comment By: Kan-Ru Chen (kanru)
Date: 2011-04-19 03:03

Message:
                                                                    As for
the bug with the
    Chinese text not fitting in the boxes, my guess is that its related to
the
    UTF-8 code, something like each chinese character is made up of
multiple
    bytes, and some piece of code is still measuring one character equals
one

Right, currently `text_getrect' count the bytes in the string as the
column numbers. After this patch
the only reference to `text_getrect' is `gatom_getwherelabel'. I'm not
familiar with pd enough so I left
this untouched.

----------------------------------------------------------------------

Comment By: Hans-Christoph Steiner (eighthave)
Date: 2011-04-19 00:35

Message:
This patch is definitely the right approach going forward (instead of
generating Tcl commands on the C-side, calling Tcl procs from C).  Part of
the problem though is that the mouse tracking is still handled on the
C-side, and this patch makes the boxes smaller than the original size. 
Therefore if you clikc just above or below the box, Pd still uses the old
measurements (now in pd-gui.tcl) as the basis for determining what was
clicked on, and you'll get the menu for that object that was just below
where the mouse clicked rather than the menu for the canvas that was just
clicked. 

I think this patch could be useful now if it used the box measurements in
pd-gui.tcl, and then fit the font into them.  As for the bug with the
Chinese text not fitting in the boxes, my guess is that its related to the
UTF-8 code, something like each chinese character is made up of multiple
bytes, and some piece of code is still measuring one character equals one
byte.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=478072&aid=3289212&group_id=55736



More information about the Pd-dev mailing list