Message1020

Author ptaney
Recipients
Date 2005-08-16.18:55:01
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Frank Wierzbicki wrote:
>> ...but this jython only posts the hex string:
>> 
>>     box.add(swing.JButton("\u0F00"))
>> or
>>     box.add(swing.JButton(unicode("\u0F00")))
>> 
>> Similar problem with the textpane.
>> 
>> How do I inform widgets about the font, or what's up?
>> I am on a Mac running 10.4.2 and jython2.2a1
>Does this work if you do it in regular Java?  Does in work in Jython 
>2.1?

>There is very new support for more CPython-like unicode behavior 
for
>strings like u"xxx".  There could be some problems with it.  If this
>works in either or both Java and Jython 2.1 please submit a bug
>report.

I have tried various workarounds to no avail, so here are test 
programs in java and jython.  The java works fine; the jython posts 
garbage.


import java.awt.*; 
import java.awt.font.*; 
import javax.swing.JButton;
import javax.swing.JFrame;
import java.io.*; 

public class TibFontTest extends Canvas { 
    // pick up the font at 
    // http://cvs.sourceforge.net/viewcvs.py/thdltools/Fonts/
TibetanMachineUni and put it in the local dir
    // see what they look like: http://www.unicode.org/charts/PDF/
U0F00.pdf

    JFrame f; 
    File fh1;
    FileInputStream fis;
    Font myfont; 

    public TibFontTest(String title) { 
        f = new JFrame(title); 
        setSize(500, 400); 

        try { 
            fh1 = new File("TibetanMachineUniAlphaVolt.ttf");
            fis = new FileInputStream(fh1);
            myfont = Font.createFont(Font.TRUETYPE_FONT, fis);
            myfont = myfont.deriveFont(Font.PLAIN, 20);
        } 
        catch (Exception e) { 
            System.out.println("Font problem.  Exiting.");
            System.exit(0);
        }

        f.getContentPane().setLayout(new GridLayout(6, 3));
        f.getContentPane().add(new JButton("\u0F00"));
        f.getContentPane().add(new JButton("\u0F01"));
        f.getContentPane().add(new JButton("\u0F02"));
        f.getContentPane().add(new JButton("\u0F03"));
        f.getContentPane().add(new JButton("\u0F04"));
        f.getContentPane().add(new JButton("\u0F05"));

        f.getContentPane().add(new JButton("\u0F06"));
        f.getContentPane().add(new JButton("\u0F07"));
        f.getContentPane().add(new JButton("\u0F40"));
        f.getContentPane().add(new JButton("\u0F41"));
        f.getContentPane().add(new JButton("\u0F42"));
        f.getContentPane().add(new JButton("\u0F43"));

        f.getContentPane().add(new JButton("\u0F44"));
        f.getContentPane().add(new JButton("\u0F45"));
        f.getContentPane().add(new JButton("\u0F46"));
        f.getContentPane().add(new JButton("\u0F47"));
        f.getContentPane().add(new JButton("\u0F49"));
        f.getContentPane().add(new JButton("\u0F4A"));
        f.pack(); 
        f.setVisible(true); 
    } 

    public static void main(String args[]) { 
        TibFontTest f1 = new TibFontTest("Font Test Window"); 
    } 
} 

====

from pawt import swing
from java import awt
from java import io

class TibFontTest3(awt.Canvas):
    '''pick up the font at 
    http://cvs.sourceforge.net/viewcvs.py/thdltools/Fonts/
TibetanMachineUni/ and put it in the local dir
    see what they look like: http://www.unicode.org/charts/PDF/
U0F00.pdf'''  or look at the java buttons

    def __init__(self, title, 
fontfilename="TibetanMachineUniAlphaVolt.ttf"):
        f = swing.JFrame(title)
        self.setSize(500, 400)
        self.pointsize = 15

        fh1 = io.File(fontfilename)
        fis = io.FileInputStream(fh1)
        self.myfont = awt.Font.createFont
(awt.Font.TRUETYPE_FONT, fis)
        self.myfont = self.myfont.deriveFont(awt.Font.PLAIN, 
self.pointsize)

        f.contentPane.setLayout(awt.GridLayout(6, 3))
        f.contentPane.add(swing.JButton('\u0F00'.encode('utf-16')))
        f.contentPane.add(swing.JButton('\u0F01'.encode('utf-16')))
        f.contentPane.add(swing.JButton('\u0F02'.encode('utf-16')))
        f.contentPane.add(swing.JButton('\u0F03'.encode('utf-16')))
        f.contentPane.add(swing.JButton('\u0F04'.encode('utf-16')))
        f.contentPane.add(swing.JButton('\u0F05'.encode('utf-16')))
        # now with  u'\u
        f.contentPane.add(swing.JButton(u'\u0F06'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'\u0F07'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'\u0F40'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'\u0F41'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'\u0F42'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'\u0F43'.encode('utf-16')))
        # now with  u'
        f.contentPane.add(swing.JButton(u'0F44'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'0F45'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'0F46'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'0F47'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'0F49'.encode('utf-16')))
        f.contentPane.add(swing.JButton(u'0F4A'.encode('utf-16')))

        f.pack()
        f.setVisible(True)
    
if __name__ == "__main__":
    f3 = TibFontTest3("Font Test Window")

History
Date User Action Args
2008-02-20 17:17:24adminlinkissue1261231 messages
2008-02-20 17:17:24admincreate