附修改后的font.properties.zh文件内容:
# @(#)font.properties.zh 1.10 02/03/07
#
# Copyright 2002 Sun Microsystems, Inc. All rights reserved.
# Modified by Yue Feng. 11/24/2003# Component Font Mappings
#
dialog.plain.0=Arial,ANSI_CHARSET
dialog.plain.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.plain.2=WingDings,SYMBOL_CHARSET
dialog.plain.3=Symbol,SYMBOL_CHARSETdialog.bold.0=Arial Bold,ANSI_CHARSET
dialog.bold.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.bold.2=WingDings,SYMBOL_CHARSET
dialog.bold.3=Symbol,SYMBOL_CHARSETdialog.italic.0=Arial Italic,ANSI_CHARSET
dialog.italic.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.italic.2=WingDings,SYMBOL_CHARSET
dialog.italic.3=Symbol,SYMBOL_CHARSETdialog.bolditalic.0=Arial Bold Italic,ANSI_CHARSET
dialog.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
dialog.bolditalic.2=WingDings,SYMBOL_CHARSET
dialog.bolditalic.3=Symbol,SYMBOL_CHARSETdialoginput.0=Courier New,ANSI_CHARSET
dialoginput.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.2=WingDings,SYMBOL_CHARSET
dialoginput.3=Symbol,SYMBOL_CHARSETdialoginput.plain.0=Courier New,ANSI_CHARSET
dialoginput.plain.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.plain.2=WingDings,SYMBOL_CHARSET
dialoginput.plain.3=Symbol,SYMBOL_CHARSETdialoginput.bold.0=Courier New Bold,ANSI_CHARSET
dialoginput.bold.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bold.2=WingDings,SYMBOL_CHARSET
dialoginput.bold.3=Symbol,SYMBOL_CHARSETdialoginput.italic.0=Courier New Italic,ANSI_CHARSET
dialoginput.italic.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.italic.2=WingDings,SYMBOL_CHARSET
dialoginput.italic.3=Symbol,SYMBOL_CHARSETdialoginput.bolditalic.0=Courier New Bold Italic,ANSI_CHARSET
dialoginput.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
dialoginput.bolditalic.2=WingDings,SYMBOL_CHARSET
dialoginput.bolditalic.3=Symbol,SYMBOL_CHARSETserif.plain.0=Times New Roman,ANSI_CHARSET
serif.plain.1=\u5b8b\u4f53,GB2312_CHARSET
serif.plain.2=WingDings,SYMBOL_CHARSET
serif.plain.3=Symbol,SYMBOL_CHARSETserif.bold.0=Times New Roman Bold,ANSI_CHARSET
serif.bold.1=\u5b8b\u4f53,GB2312_CHARSET
serif.bold.2=WingDings,SYMBOL_CHARSET
serif.bold.3=Symbol,SYMBOL_CHARSETserif.italic.0=Times New Roman Italic,ANSI_CHARSET
serif.italic.1=\u5b8b\u4f53,GB2312_CHARSET
serif.italic.2=WingDings,SYMBOL_CHARSET
serif.italic.3=Symbol,SYMBOL_CHARSETserif.bolditalic.0=Times New Roman Bold Italic,ANSI_CHARSET
serif.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
serif.bolditalic.2=WingDings,SYMBOL_CHARSET
serif.bolditalic.3=Symbol,SYMBOL_CHARSETsansserif.plain.0=Arial,ANSI_CHARSET
sansserif.plain.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.plain.2=WingDings,SYMBOL_CHARSET
sansserif.plain.3=Symbol,SYMBOL_CHARSETsansserif.bold.0=Arial Bold,ANSI_CHARSET
sansserif.bold.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bold.2=WingDings,SYMBOL_CHARSET
sansserif.bold.3=Symbol,SYMBOL_CHARSETsansserif.italic.0=Arial Italic,ANSI_CHARSET
sansserif.italic.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.italic.2=WingDings,SYMBOL_CHARSET
sansserif.italic.3=Symbol,SYMBOL_CHARSETsansserif.bolditalic.0=Arial Bold Italic,ANSI_CHARSET
sansserif.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
sansserif.bolditalic.2=WingDings,SYMBOL_CHARSET
sansserif.bolditalic.3=Symbol,SYMBOL_CHARSETmonospaced.0=Courier New,ANSI_CHARSET
monospaced.plain.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.plain.2=WingDings,SYMBOL_CHARSET
monospaced.plain.3=Symbol,SYMBOL_CHARSETmonospaced.bold.0=Courier New Bold,ANSI_CHARSET
monospaced.bold.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bold.2=WingDings,SYMBOL_CHARSET
monospaced.bold.3=Symbol,SYMBOL_CHARSETmonospaced.italic.0=Courier New Italic,ANSI_CHARSET
monospaced.italic.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.italic.2=WingDings,SYMBOL_CHARSET
monospaced.italic.3=Symbol,SYMBOL_CHARSETmonospaced.bolditalic.0=Courier New Bold Italic,ANSI_CHARSET
monospaced.bolditalic.1=\u5b8b\u4f53,GB2312_CHARSET
monospaced.bolditalic.2=WingDings,SYMBOL_CHARSET
monospaced.bolditalic.3=Symbol,SYMBOL_CHARSET# Font File Names
#
filename.\u5b8b\u4f53=SIMSUN.TTCfilename.Arial=ARIAL.TTF
filename.Arial_Bold=ARIALBD.TTF
filename.Arial_Italic=ARIALI.TTF
filename.Arial_Bold_Italic=ARIALBI.TTFfilename.Courier_New=COUR.TTF
filename.Courier_New_Bold=COURBD.TTF
filename.Courier_New_Italic=COURI.TTF
filename.Courier_New_Bold_Italic=COURBI.TTFfilename.Times_New_Roman=TIMES.TTF
filename.Times_New_Roman_Bold=TIMESBD.TTF
filename.Times_New_Roman_Italic=TIMESI.TTF
filename.Times_New_Roman_Bold_Italic=TIMESBI.TTFfilename.WingDings=WINGDING.TTF
filename.Symbol=SYMBOL.TTF# Missing Glyph Character
#
default.char=2751# Component Font Character Encodings
#
fontcharset.dialog.1=sun.io.CharToByteGBK
fontcharset.dialog.2=sun.awt.windows.CharToByteWingDings
fontcharset.dialog.3=sun.awt.CharToByteSymbolfontcharset.dialoginput.1=sun.io.CharToByteGBK
fontcharset.dialoginput.2=sun.awt.windows.CharToByteWingDings
fontcharset.dialoginput.3=sun.awt.CharToByteSymbolfontcharset.serif.1=sun.io.CharToByteGBK
fontcharset.serif.2=sun.awt.windows.CharToByteWingDings
fontcharset.serif.3=sun.awt.CharToByteSymbolfontcharset.sansserif.1=sun.io.CharToByteGBK
fontcharset.sansserif.2=sun.awt.windows.CharToByteWingDings
fontcharset.sansserif.3=sun.awt.CharToByteSymbolfontcharset.monospaced.0=sun.io.CharToByteGBK
fontcharset.monospaced.1=sun.io.CharToByteGBK
fontcharset.monospaced.2=sun.awt.windows.CharToByteWingDings
fontcharset.monospaced.3=sun.awt.CharToByteSymbol# Exclusion Ranges
#
exclusion.dialog.0=0100-20ab,20ad-f8ff
exclusion.dialoginput.0=0100-20ab,20ad-f8ff
exclusion.serif.0=0100-20ab,20ad-f8ff
exclusion.sansserif.0=0100-20ab,20ad-f8ff
exclusion.monospaced.0=0100-20ab,20ad-f8ff# Text Input Character Set
#
inputtextcharset=GB2312_CHARSET

解决方案 »

  1.   

    怎么我COPY到JRE目录下没有效果啊?
      

  2.   

    谢谢大家提的意见。
        我本身是搞软件理论的,用Java或者是JB主要是做一些理论的验证工作。搞理论的就是喜欢钻牛角尖:),所以我就觉得改字体这种方法很不解恨,所以我就想知道到底为什么会有这种问题。当然解决问题的方法有很多种,我只是给大家提供一种可能。如果只是JB,那么改字体可能更方便一些,可是如果碰到其他有此问题的Java软件,而它又不提供该字体的功能,哪又该怎么办呢?大家可以暂时不必详细知道这种方法的细节,只要知道有这么回事,等到以后如果真的需要了,就到CSDN来查查,而不用再花时间花精力自己摸索,那我的目的就达到了。
        当然,最根本的解决方案是SUN自己修正这个文件。如果那样的话这篇文章就可以删掉了。
        另外需要说明一点,JB使用的是自己带的JRE,而不是系统中的JRE,所以要修改JB安装目录下jdk目录中jre/lib中的font.properties文件才有效。
      

  3.   

    楼主,我发现安装JB时的字体在font.properties.zh_CN里是有的,而其他我以后安装的字体比如宋体,在这个文件里没有,那应该怎么去修改呢?我一直在JB里用宋体,所有保留字都没有Bold,不爽啊,感谢!!!
      

  4.   

    你想用什么字体呢?如果是宋体的话黑体应该本来就没有问题,只有font.properties中定义的组合字体才有问题。
      

  5.   

    这是JBuilder的BUG,怎么老是不改进,对borland都有些失望了
      

  6.   

    Editor Options -> Display -> Font family
    如果里面选最上面的五个就不会有问题,如果选下面的那些就会有问题,下面那些字体里面就有宋体
      

  7.   

    to pxboy(阿土仔) 不好意思,我一小时以后的火车,暂时不能考虑你的问题。等我下周回来会看的。
      

  8.   

    楼主果然是个高手!!
    建议楼主可以发个EMAIL到SUN公司,,跟他们提出这个问题,,,(希望在以后的版本不会有这种情况!!!)
      

  9.   

    错错,,是borland公司!!
    不好意思!~~ :) ~~~~
      

  10.   

    不过,这样改过之后,只有用DialogInput字体是对的,用宋体还是有问题
      

  11.   

    首先,很高兴看到还有 zkhj(zkhj) 细心的发现:
    “不过,这样改过之后,只有用DialogInput字体是对的,用宋体还是有问题”记得Jbuilder7里面,改过font.properties.zh后,所有字体都好用了;但是到jbuilder9后,改了font.properties.zh后,只有DialogInput字体是对的,宋体仍然不行;
      

  12.   

    其实,使用Jbuilder9,光标问题的最佳解决方案其实是照楼主说的那样修改font.properties.zh文件,然后在Jbuilder的Editor Options中选择DialogInput逻辑字体,这是最佳效果方案,一切问题都不会再有;选择宋体效果就要差的多;
      

  13.   

    靠,偶准备写连载,可是连贴3次就不能贴了呵:)
    我们知道,Java提供了5类逻辑字体:dialog、dialoginput、serif、sansserif和monospaced,只有使用逻辑字体的程序才会受到font.properties.zh的影响;Jbuilder9中Editor Options的字体选择框仅仅提供了一种逻辑字体选项,即dialoginput,其他都是windows平台上的常用的物理字体;但是,Jbuilder是如何使用字体的,我们不得而知,唯一可以确认的就是,如果选择使用dialoginput字体,那么肯定会受font.properties.zh配置文件的影响,事实证明确实如此,改正font.properties.zh的错误后dialoginput字体下的光标问题没有了;但是,仍然无法解释下面两个问题:
    1、为什么没有改正font.properties.zh时,jbuider9能够在dialoginput字体下显示粗体、斜体和粗斜体?
    2、为什么使用物理字体(除dialoginput外的都是)时也存在光标对不齐的问题(不论font.properties.zh对不对)?
    我相信这是borland的问题,为此还曾反编译了Jbuilder的class文件,试图找出Jbuilder的编辑器的实现,但是,由于狡猾的Borland使用了混码技术,所有非public标识都变成了些毫无意义的a、b、c、d....,因而很难看出什么逻辑来,因而也就无功而返了:( (花了两个小时看Jbuilder的源代码,大致的线索是找到了,但要完全弄清那些复杂的逻辑,太难了,哪位厉害能够搞定的话偶拜他为师呵呵;现在已经可以肯定的是Jbuilder是使用下面的方式获得可用字体列表的:
            GraphicsEnvironment graphicsenvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Font[] fonts = graphicsenvironment.getAllFonts();
            String[] fontFamilies = graphicsenvironment.getAvailableFontFamilyNames();
    但是进行了一些筛选分类(比如是否为等宽字体--Monospaced)。下面是与字体相关的几个类,供想继续研究者参考(其中包含了字体扫描算法等):Jbuilder使用的编辑器叫做primetime,可以在lib/primetime.jar中找到,下面这个类挺关键的:
      

  14.   

    各种编辑器的统一管理器:
    com.borland.primetime.editor.EditorManagerEditor Options对话框:
    com.borland.primetime.editor.DisplayPropertyPage字体管理类:
    com.borland.primetime.editor.DisplayPropertyGroup
    这个代码贴一下
    package com.borland.primetime.editor;import com.borland.primetime.ide.Browser;
    import com.borland.primetime.properties.*;
    import com.borland.primetime.util.Platform;
    import java.awt.*;
    import java.util.ArrayList;
    import java.util.Arrays;
    import javax.swing.Timer;// Referenced classes of package com.borland.primetime.editor:
    //            gb, fb, eb, lb, 
    //            Res, EditorManagerpublic class DisplayPropertyGroup
        implements PropertyGroup
    {
        /* member class not found */
        class eb {}    /* member class not found */
        class fb {}    /* member class not found */
        class gb {}
        static Timer h;
        static fb i;
        static boolean e;
        static gb j;
        private static int c = 0;
        private static String l[] = new String[0];
        private static Font q[] = new Font[0];
        private static ArrayList k = new ArrayList();
        private static ArrayList g = new ArrayList();
        public static final GlobalArrayProperty FIXED_FONTS = new GlobalArrayProperty("editor.display", "fixed_fonts");
        public static final GlobalArrayProperty KNOWN_FONTS = new GlobalArrayProperty("editor.display", "known_fonts");
        public static final GlobalIntegerProperty DEFAULT_FONT_SIZE = new GlobalIntegerProperty("editor.display", "default_font_size", 12);
        public static final GlobalIntegerProperty FONT_SIZE = new GlobalIntegerProperty("editor.display", "font_size", 12);
        public static final GlobalProperty FONT_FAMILY;
        public static final GlobalIntegerProperty RIGHT_MARGIN = new GlobalIntegerProperty("editor.display", "right_margin", 80);
        public static final GlobalBooleanProperty VISIBLE_MARGIN = new GlobalBooleanProperty("editor.display", "visible_margin", true);
        public static final String CATEGORY = "editor.display";
        public static final String PAGE_NAME;
        private static final int o = 12;
        private static final String f = "Monospaced";
        private static final String p = "DialogInput";
        private static final int n = 80;
        private static final boolean m = true;
        private static final boolean b = false;
        private static boolean a = false;
        private static boolean d = true;    static String[] f()
        {
            return l;
        }    static ArrayList e()
        {
            return k;
        }    static boolean d()
        {
            return a;
        }    static ArrayList c()
        {
            return g;
        }    static Font[] b()
        {
            return q;
        }    static int a()
        {
            return c;
        }    public void initializeProperties()
        {
            readProperties();
        }    public PropertyPageFactory getPageFactory(Object obj)
        {
            if(obj == EditorManager.EDITOR_TOPIC)
            {
                return new lb(PAGE_NAME, Res.qk);
            } else
            {
                return null;
            }
        }    static void h()
        {
            i = new fb();
            i.startFontScan();
            j = new gb(Browser.getActiveBrowser(), true);
            h = new Timer(250, new eb(null));
            h.start();
            j.setVisible(true);
        }    private static boolean g()
        {
            GraphicsEnvironment graphicsenvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
            q = graphicsenvironment.getAllFonts();
            l = graphicsenvironment.getAvailableFontFamilyNames();
            c = l.length;
            for(int i1 = 0; i1 < c; i1++)
            {
                String s = l[i1].toLowerCase();
                if(s.indexOf(".bold") == -1 && s.indexOf(".italic") == -1 && !g.contains(l[i1]))
                {
                    return false;
                }
            }        return true;
        }    public static ArrayList getKnownFontList()
        {
            if(d && !g())
            {
                h();
            }
            return g;
        }    public static ArrayList getFixedFontList()
        {
            if(d && !g())
            {
                h();
            }
            return k;
        }    public static void readProperties()
        {
            boolean flag = VISIBLE_MARGIN.getBoolean();
            EditorManager.setVisibleMargin(flag);
            EditorManager.setRightMargin(RIGHT_MARGIN.getInteger());
            String s = FONT_FAMILY.getValue();
            int i1 = FONT_SIZE.getInteger();
            EditorManager.setFont(new Font(s, 0, i1));
            if(!d)
            {
                KNOWN_FONTS.setValues(new String[] {
                    "Dialog", "DialogInput", "Monospaced", "SansSerif", "Serif"
                });
                FIXED_FONTS.setValues(new String[] {
                    "DialogInput", "Monospaced"
                });
            }
            g.clear();
            g.addAll(Arrays.asList(KNOWN_FONTS.getValues()));
            k.clear();
            k.addAll(Arrays.asList(FIXED_FONTS.getValues()));
        }    public static void initOpenTool(byte byte0, byte byte1)
        {
            PropertyManager.registerPropertyGroup(new DisplayPropertyGroup());
            String s = System.getProperty("primetime.editor.useVariableWidthFont", "false");
            if(s.equals("true"))
            {
                a = true;
            }
        }    public DisplayPropertyGroup()
        {
        }    static 
        {
            b = false;
            m = true;
            n = 80;
            p = "DialogInput";
            f = "Monospaced";
            o = 12;
            PAGE_NAME = Res.pk;
            CATEGORY = "editor.display";
            FONT_FAMILY = new GlobalProperty("editor.display", "font_family", Platform.MAC ? "Monospaced" : "DialogInput");
        }
    }
      

  15.   

    接下来是一个字体扫描类,是上面这个类的内部类:
    com.borland.primetime.editor.fb
    源代码如下:
    package com.borland.primetime.editor;import com.borland.primetime.properties.GlobalArrayProperty;
    import com.borland.primetime.util.Strings;
    import java.awt.*;
    import java.io.PrintStream;
    import java.util.ArrayList;// Referenced classes of package com.borland.primetime.editor:
    //            Res, DisplayPropertyGroup, hbclass fb
    {    private Thread b;
        private String a;
        private int c;    static Thread a(fb fb1, Thread thread)
        {
            return fb1.b = thread;
        }    void a()
        {
            boolean flag = false;
            boolean flag1 = false;
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            for(c = 0; c < DisplayPropertyGroup.a() && !DisplayPropertyGroup.e; c++)
            {
                String s = DisplayPropertyGroup.f()[c].toLowerCase();
                a = Strings.format(Res.xe, new Object[] {
                    DisplayPropertyGroup.f()[c], new Integer(c), new Integer(DisplayPropertyGroup.a())
                });
                System.out.println(a);
                if(s.indexOf(".bold") != -1 || s.indexOf(".italic") != -1 || DisplayPropertyGroup.c().contains(DisplayPropertyGroup.f()[c]))
                {
                    continue;
                }
                DisplayPropertyGroup.c().add(DisplayPropertyGroup.f()[c]);
                flag = true;
                Font font = new Font(DisplayPropertyGroup.f()[c], 0, 12);
                if(!font.canDisplay('a'))
                {
                    continue;
                }
                if(DisplayPropertyGroup.e)
                {
                    break;
                }
                FontMetrics fontmetrics = toolkit.getFontMetrics(font);
                int i = 0;
                int j = 0;
                if(!DisplayPropertyGroup.d())
                {
                    i = fontmetrics.charWidth('l');
                    j = fontmetrics.charWidth('w');
                }
                if(DisplayPropertyGroup.d() || i == j)
                {
                    DisplayPropertyGroup.e().add(DisplayPropertyGroup.f()[c]);
                    flag1 = true;
                }
            }        if(flag)
            {
                String as[] = (String[])DisplayPropertyGroup.c().toArray(new String[DisplayPropertyGroup.c().size()]);
                DisplayPropertyGroup.KNOWN_FONTS.setValues(as);
            }
            if(flag1)
            {
                String as1[] = (String[])DisplayPropertyGroup.e().toArray(new String[DisplayPropertyGroup.e().size()]);
                DisplayPropertyGroup.FIXED_FONTS.setValues(as1);
            }
        }    public String getStatus()
        {
            return a;
        }    public boolean done()
        {
            return c >= DisplayPropertyGroup.a();
        }    public int getCurrentFont()
        {
            return c;
        }    public void startFontScan()
        {
            c = -1;
            hb hb1 = new hb((fb)this);
            Thread thread = new Thread(hb1);
            thread.setPriority(3);
            thread.start();
        }    public fb()
        {
            a = "";
        }
    }此类创建一个扫描线程,实现如下:package com.borland.primetime.editor;
    // Referenced classes of package com.borland.primetime.editor:
    //            DisplayPropertyGroup, fbclass hb
        implements Runnable
    {    private final fb a; //用到上面的fb类
        public void run()
        {
            try
            {
                a.a();
            }
            finally
            {
                com.borland.primetime.editor.fb.a(a, null);
            }
        }    hb(fb fb1)
        {
            a = fb1;
        }
    }
      

  16.   

    我用JBuilderX,字体里面居然只有两个,一个是Courier New,一个是Lucida Sans Typewriter,哪位知道怎么弄出其他字体?
      

  17.   

    再补充一下,在perferences->Editor->Display设定中font family只能看到上面两种字体,但在UML的设定中却可以看见全部的字体.
      

  18.   

    用宋体显示会发现下面的字符都是等宽的:
    lllll
    wwwww
    ooooo
    mmmmm
    Jbuilder的代码编辑器在部分编辑器中(.java编辑器即是;所有编辑器由EditorManager统管)只使用等宽字体,所以字体列表里面就只有那么几种字体可供选择。下面是说明理由(代码上面已经给出):评什么说Jbuilder的代码编辑器只使用等宽字体?从Editor Options对话框的Display选项卡的代码(com.borland.primetime.editor.DisplayPropertyPage)可以看出,字体列表组合框的初始化代码如下:
            ArrayList arraylist = DisplayPropertyGroup.getFixedFontList();
            DefaultComboBoxModel defaultcomboboxmodel1 = new DefaultComboBoxModel();
            for(int j = 0; j < arraylist.size(); j++)
            {
                defaultcomboboxmodel1.addElement(arraylist.get(j));
            }即,只使用DisplayPropertyGroup.getFixedFontList()返回的字体列表;而判断一种字体是否为等宽字体的依据是:
                FontMetrics fontmetrics = toolkit.getFontMetrics(font);
                int i = 0;
                int j = 0;
                if(!DisplayPropertyGroup.d())
                {
                    i = fontmetrics.charWidth('l');
                    j = fontmetrics.charWidth('w');
                }
                if(DisplayPropertyGroup.d() || i == j)
                {
                    DisplayPropertyGroup.e().add(DisplayPropertyGroup.f()[c]);
                    flag1 = true;
                }
    即,如果FontMetrics类发现字符'l'和'w'的宽度相等的话,则认为是等宽字体;当然,所有被录用的字体首先必须能够显示字符'a',否则不予考虑:
                Font font = new Font(DisplayPropertyGroup.f()[c], 0, 12);
                if(!font.canDisplay('a'))
                {
                    continue;
                }
    比如Windings、Webdings等字体中根本不包含英文字母,所以不予考虑;
    但是上面的判断根本没有考虑字体是否能够显示得了汉字,使用中文字体固然可以,但当使用英文字体时,汉字就没法显示,变成了一个个方块;为什么可选字体列表中会有一个DialogInput和一个Monospaced选项呢?因为,Jbuilder在做字体扫描时是使用下面的代码:
            GraphicsEnvironment graphicsenvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Font[] fonts = graphicsenvironment.getAllFonts();//并没有使用
            String[] fontFamilies = graphicsenvironment.getAvailableFontFamilyNames();
    而这样列出的fontFamilies包含操作系统平台上的所有font families,另外,还包括font.properties.zh中定义的5种逻辑字体:
    dialog
    dialoginput
    monospaced
    sansserif
    serif
    操作系统的font families这里不说了,而上面的逻辑字体中实际上只有DialogInput和Monospaced对应的物理字体是等宽的,别的都不符合要求,这样一来就只有DialogInput和Monospaced逻辑字体类符合要求:而后,所有字体被以下render绘制到列表框中:
    package com.borland.primetime.ui;import java.awt.Component;
    import java.awt.Font;
    import javax.swing.*;// Referenced classes of package com.borland.primetime.ui:
    //            pbpublic class FontNameCellRenderer extends DefaultListCellRenderer
    {    String b;
        boolean a;    public void updateUI()
        {
            setUI(new pb((FontNameCellRenderer)this));
        }    public Component getListCellRendererComponent(JList jlist, Object obj, int i, boolean flag, boolean flag1)
        {
            super.getListCellRendererComponent(jlist, obj, i, flag, flag1);
            if(obj instanceof String)
            {
                String s = (String)obj;
                Font font = jlist.getFont();
                b = s;
                setFont(new Font(s, font.getStyle(), font.getSize()));
            }
            return this;
        }    public FontNameCellRenderer()
        {
        }
    }
    此render使得下拉列表能够像word的字体下拉列表那样直观的看到各个字体的样子;显示的内容是字体的font family name;DialogInput成为了Jbuilder中中英文混排的最佳解决方案(此时实际上是Courier New和宋体同时在起作用,所以英文显示效果要优于选择宋体时的表现)!
      

  19.   

    fb类中有这么一个判断:
                if(DisplayPropertyGroup.d() || i == j)
                {
                    DisplayPropertyGroup.e().add(DisplayPropertyGroup.f()[c]);
                    flag1 = true;
                }
    我猜测DisplayPropertyGroup.d() 应该是判断是否使用全部字体,如果是,那么全部字体都可用;否则,只有等宽字体可用。这便是为什么在有些context下全部字体可用的原因。偶现在用的是Jbuilder9,没有用JbuilderX,所以 Seki(以永今夕) 说的JbuilderX的问题就无从知道了。总之,Jbuilder是英文版的,而且国际化的考虑并不周全,字体就是问题之一;我相信光标对不齐以及字体不能全列出应该不只是简体中文环境才有,不信你可以改一下自己机器的区域设置(这个我没有试过,但我可以肯定问题依旧)。
      

  20.   

    至于光标为什么对不齐,这里还是没有给出真正的缘由;不过可以肯定的是Jbuilder的primetime编辑器在计算字符串宽度时出了差错,因为字符串宽度计算与光标位置计算是直接相关的;至于最终问题要归结到Jbuilder还是Sun的JRE,我现在也有些犹豫。
      

  21.   

    刚刚下火车,这里这么热闹了?:)
    goldenhua(深深地爱上了你)才是高手,我只是拍了块砖,引出了这么大块玉。
    我只是在JBX下试了一下,确实没有考虑其他字体是否有问题。
    我们继续讨论。
      

  22.   

    我修改了以后 影响了我原来用system.out.println正常打印出来的中文字符
    在软件里面还是好的。不知道这个现象对大家有没有帮助 我不太懂
    我用的是jbuild7
      

  23.   

    我在JBX试过宋体的效果,没有错位的问题。等有机会,我会找个JB9来再来试试的。
    在JBX中添加字体的方法:关闭JB,修改Documents and Settings\<username>\.primetimeX下的user_zh.properties文件,找到editor.display;fixed_fonts的位置,根据已存在的编号,顺序添加希望的字体,宋体的Unicode为\u5b8b\u4f53,例如,原有最大编号项为editor.display;fixed_fonts.2,则在该行下添加 editor.display;fixed_fonts.3=\u5b8b\u4f53 即可添加宋体选项,保存,开JB,选择字体。
    一定要先关闭JB再修改。
      

  24.   

    开始我说Jbuilder使用混码技术致使反编译出的代码不可读,后来发现还是基本不影响理解的。谁有时间可以研究一下Jbuilder的源代码,从中可以学到非常多的东西!楼主如果有兴趣可以剖析一下primetime editor的代码,把问题弄个水落石出!偶现在忙的要命,恐怕一个月内少有时间来做工作外的事情了,如果到时候此问题还悬而未决,偶还会继续探讨一下,呵呵。
    (主要逻辑都在com.borland.primetime.editor包里,EditorPane、EditorView、EditorDocument、EditorAction、EditorActions等主要类和一些辅助类周末偶都看过了,不过由于对Swing不是太熟悉,也没有完全弄明白怎么回事;不过倒是对如何自己实现一个象Jbuilder那样的编辑器有了一定的了解)
      

  25.   

    真可怕,有这么多人不知道方法,还好我来了:)
    光改字体没有用,总会在某些时候出乱子。
    搂住介绍的方法俺不懂,太高深(真麻烦:)
    我的方法:
    tools-->editor options-->color
    在左边列表中显示了全部语言元素,平时编辑最常用的“关键字”reserved word,把它的粗体(bold)的勾去掉,就可以了
    对于jsp编辑等,只要把html tag的粗体关掉就可以了
    粗体是罪魁祸首!
      

  26.   

    留个标记先,学习中
    过段时间再来看牛人们的分析。
    Thanks!!!
      

  27.   

    我曾经提问国的问题:
    http://expert.csdn.net/Expert/topic/2426/2426729.xml?temp=.7104456