Re: font tweaking

Brent Welch <[email protected]> Wed, 27 Apr 2005 14:15:59 -0700
Newsgroups gmane.mail.exmh.devel
Message-ID <[email protected]>
This code:
 set tag [MimeSetCharset $tkw $part]
 $tkw tag add $tag insert end
is exmh trying to find a font that can display the character set
indicated by the content-type.
The 
 $tkw tag remove noteTag "insert -1line"  end
line has to do with the little "Charset" note that sometimes appears.

To test your change, you'd need to send yourself a text part in
some alternate character set and ensure that it is displayed right.
I don't think it will be.

The way to try your fix is to use a "tag raise" command so that
your tag for the *bold* annotation has higher precedence than the
other tags that apply to that range.  Just because the highlighting
is done after the charset stuff doesn't guarantee the tag order, which
is instead determined by the order the tags were created (not when
they were applied to the text).  I think what happens is that you
created the embolded text tag on message 1, which didn't have a
charset, then later displayed a message 2 that got a new tag created
for the charset.  That new tag has precedence, so you need to give your
embolded tag a boost in priority. Anyway, try the tag raise
as noted below

>>>John Beck said:
 > 
 > I thought it might be nice to extend the various text highlighting tricks
 > to include one which shows "starred" text (i.e., something between "*"
 > characters, often used for emphasis, like "I *really* mean it") as bold.
 > I added the following to Hook_MsgHighlight_jcl-beautify in msgShow.tcl
 > 
 >         if {[regexp {\*.+\*} $txt bolded]} {
 >             if {[regexp {^[^*]*\*} $txt beforefirststar]} {
 >                 set firstlen [expr [string length $beforefirststar]]
 >                 set endpos [expr $firstlen + [string length $bolded] - 2]
 >                 $t tag add embolded $idx.[expr $firstlen] $idx.[expr 
$endpos
     ]
 >             } else {
 >                 $t tag add embolded $idx.0 $idx.end
 >             }

$t tag raise embolded

 >             continue
 >         }
 > 
 > and put this in my default file:
 > 
 > *b_embolded:    -font 9x15bold
 > 
 > And it works, sometimes.  If I change the default file line to:
 > 
 > *b_embolded:    -foreground red
 > 
 > then it works all the time.  But if I try to change the font rather than
 > the color, it doesn't work if the message in question has a charset value
 > in its Content-Type: header.  I.e.:
 > 
 > Content-Type: text/plain
 > 
 > works and even:
 > 
 > Content-Type: text/plain; charset=
 > 
 > works, but
 > 
 > Content-Type: text/plain; charset=x
 > 
 > does not work, for any non-null value of x.
 > 
 > Looking at the code, the cause of the discrepancy appeared to be this 
chunk
 > of code from MimeParseSingle in mime.c:
 > 
 >             if [info exists mimeHdr($part,param,charset)] {
 >                 set tag [MimeSetCharset $tkw $part]
 >                 $tkw tag remove noteTag "insert -1line"  end
 >                 $tkw tag add $tag insert end
 >                 if [info exists firstLinePosition] {
 >                     seek $fileIO $firstLinePosition
 >                 }
 >                 Mime_SetFileEncoding $fileIO $part
 >                 if [info exists firstLinePosition] {
 >                     gets $fileIO firstLine
 >                 }
 >             }  else {
 >                 set tag {}
 >             }
 > 
 > and in fact, if I replace the first three lines of the if block with the 
one
 > line from the else block, then the problem goes away without any 
*apparent*
 > side-effects.  But as I only have the vaguest idea what this code is 
doing
 > and no idea why, I thought it would be wise to consult here before making
 > such a change.  Who has clues in this area?
 > 
 > Thanks.
 > -- John
 > 
 > _______________________________________________
 > Exmh-workers mailing list
 > [email protected]
 > https://www.redhat.com/mailman/listinfo/exmh-workers
 > 
 > 

--
Brent Welch
Software Architect, Panasas Inc
Accelerating Time to Results(tm) with Clustered Storage

www.panasas.com
[email protected]