---
title: "[转载]Netbeans7.0完美中文+Consolas字体显示配置笔记"
author: "solid210"
date: "2012-08-05T21:13:41Z"
tags: []
categories: ["编程语言"]
slug: "netbeans7-0-consolas"
draft: false
lastmod: "2012-08-05T21:13:41Z"
id: 1621685
url: "https://solid210.iteye.com/blog/1621685"
---

最近把开发环境从Eclipse迁移到了Netbeans上面.因为Netbeans已经相当优秀,速度快功能也不必Eclipse差,但是一只有 一个问题一直让我对eclipse非常纠结:如果把字体选择为Consolas,代码编辑框内的所有中文就会乱码,甚是不爽.今天稍微研究了一下这个问题 并总结出了完美的解决方案, 现分享出来  
1\. 修改JRE的字体配置文件  
Netbean用的是swing开发,而swing的字体选择规则是按照JRE字体配置来的,而这个配置文件就在JRE的目录里  
首先修改中文的配置规则  
我们进入到你的JDK目录的/jre/lib这个文件夹,把fontconfig.properties.src这个文件拷贝为fontconfig.properties 然后用文本编辑器打开它  
找到  
sequence.monospaced.GBK=chinese-ms936, alphabetic,dingbats,symbol  
修改为  
sequence.monospaced.GBK=alphabetic,chinese-ms936,dingbats,symbol  
注意这里的GBK代表的是中文字体编码,如果你是繁体中文,那么就需要修改sequence.monospaced.x-windows-950这个项目  
然后修改默认的等宽字体,请搜索下面4个配置项目  
monospaced.plain.alphabetic=Courier New  
monospaced.bold.alphabetic=Courier New Bold  
monospaced.bolditalic.alphabetic=Courier New Italic  
monospaced.bolditalic.alphabetic=Courier New Bold Italic  
修改为  
monospaced.plain.alphabetic=Consolas  
monospaced.bold.alphabetic=Consolas Bold  
monospaced.bolditalic.alphabetic=Consolas Italic  
monospaced.bolditalic.alphabetic=Consolas Bold Italic  
然后在文件最后增加Consolas字体的定义  
filename.Consolas=CONSOLA.TTF  
filename.Consolas\_Bold=CONSOLAB.TTF  
filename.Consolas\_Italic=CONSOLAI.TTF  
filename.Consolas\_Bold\_Italic=CONSOLAZ.TTF  
注意这里我用的是Consolas,如果你想用其他的字体请自行修改  
2\. 配置Netbeans  
打开Netbeans,选择工具-选项 字体颜色 - 字体

这里注意选择字体时请一定要选择Monospaced,选择其他的字体是没有效果的  
选择完毕后再看代码页面,一切显示正常了.

 

 

本人今天根据此文章，修改了字体，完全OK