LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 3118|回复: 3

Linux中java中文不能正常显示的问题

[复制链接]
发表于 2003-7-17 11:00:29 | 显示全部楼层 |阅读模式
Linux下通常在使用netscape,mozilla 或 phoenix的时候,java插件中的中文字符显示为方块,原因是java找不到中文字体,解决办法是修改java的字体配置文件。

首先系统要安装中文字体,下边以simsun字体为例。

java中字体配置是下面两个文件:

$JAVA_HOME/1.4/jre/lib/font.properties.zh.Turbo
$JAVA_HOME/1.4/jre/lib/font.properties

首先修改font.properties.zh.Turbo文件,将其中的中文字体通通替换成simsun字体

-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

-default-simsun-medium-r-normal--12-*-*-*-c-*-gb2312.1980-0

上面写的字体在debian中是有效的,在其它系统中不一定完全一样。

改完后font.properties.zh.Turbo文件应该象下面这样:

erif.0=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1
serif.1=-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

serif.italic.0=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1
serif.italic.1=-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

serif.bold.0=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1
serif.bold.1=-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

serif.bolditalic.0=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1
serif.bolditalic.1=-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

sansserif.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
sansserif.1=-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

... ...

dialoginput.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
dialoginput.bolditalic.1=-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

# Missing Glyph Character
#
default.char=274f

# Component Font Character Encodings
#
fontcharset.serif.0=sun.io.CharToByteISO8859_1
fontcharset.serif.1=sun.awt.motif.CharToByteX11GBK

fontcharset.sansserif.0=sun.io.CharToByteISO8859_1
fontcharset.sansserif.1=sun.awt.motif.CharToByteX11GBK

fontcharset.monospaced.0=sun.io.CharToByteISO8859_1
fontcharset.monospaced.1=sun.awt.motif.CharToByteX11GBK

... ...

fontset.serif.plain=\
-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1,\
-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

fontset.serif.italic=\
-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1,\
-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

fontset.serif.bold=\
-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1,\
-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

fontset.serif.bolditalic=\
-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1,\
-default-simsun-medium-r-normal--*-100-*-*-c-*-gb2312.1980-0

... ...

appendedfontpath=/usr/share/fonts/truetype/sim


注意文件的最末一行,这个路径是你的simsun.ttf字体方件存放的位置,不要写错了。

最后,将font.properties.zh.Turbo文件复制为font.properties覆盖掉原来的,否则当你的浏览器运行javavm时会使X重启。当然,最好事先备个份。
发表于 2003-7-18 12:37:20 | 显示全部楼层
我这样修改后
大部分是中文了

但是仍然还有乱码!!  
发表于 2003-7-19 22:01:39 | 显示全部楼层
我修改的是$JAVA_HOME/jre/lib/font.properties.zh,没有乱码。

这是我的文件

  1. # @(#)font.properties.zh.Turbo.linux        1.4 02/06/10
  2. #
  3. # Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  4. #

  5. # Component Font Mappings
  6. #
  7. serif.0=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1
  8. serif.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  9. serif.italic.0=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1
  10. serif.italic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  11. serif.bold.0=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1
  12. serif.bold.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  13. serif.bolditalic.0=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1
  14. serif.bolditalic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  15. sansserif.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
  16. sansserif.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  17. sansserif.italic.0=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
  18. sansserif.italic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  19. sansserif.bold.0=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
  20. sansserif.bold.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  21. sansserif.bolditalic.0=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
  22. sansserif.bolditalic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  23. monospaced.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  24. monospaced.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  25. monospaced.italic.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  26. monospaced.italic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  27. monospaced.bold.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  28. monospaced.bold.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  29. monospaced.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  30. monospaced.bolditalic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  31. dialog.0=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1
  32. dialog.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  33. dialog.italic.0=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1
  34. dialog.italic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  35. dialog.bold.0=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1
  36. dialog.bold.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  37. dialog.bolditalic.0=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1
  38. dialog.bolditalic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  39. dialoginput.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  40. dialoginput.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  41. dialoginput.italic.0=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  42. dialoginput.italic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  43. dialoginput.bold.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  44. dialoginput.bold.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  45. dialoginput.bolditalic.0=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1
  46. dialoginput.bolditalic.1=-misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  47. # Missing Glyph Character
  48. #
  49. default.char=274f

  50. # Component Font Character Encodings
  51. #
  52. fontcharset.serif.0=sun.io.CharToByteISO8859_1
  53. fontcharset.serif.1=sun.awt.motif.CharToByteX11GBK

  54. fontcharset.sansserif.0=sun.io.CharToByteISO8859_1
  55. fontcharset.sansserif.1=sun.awt.motif.CharToByteX11GBK

  56. fontcharset.monospaced.0=sun.io.CharToByteISO8859_1
  57. fontcharset.monospaced.1=sun.awt.motif.CharToByteX11GBK

  58. fontcharset.dialog.0=sun.io.CharToByteISO8859_1
  59. fontcharset.dialog.1=sun.awt.motif.CharToByteX11GBK

  60. fontcharset.dialoginput.0=sun.io.CharToByteISO8859_1
  61. fontcharset.dialoginput.1=sun.awt.motif.CharToByteX11GBK

  62. # Exclusion Ranges
  63. #

  64. # XFontSet Information
  65. #
  66. fontset.serif.plain=\
  67. -b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1,\
  68. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  69. fontset.serif.italic=\
  70. -b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1,\
  71. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  72. fontset.serif.bold=\
  73. -b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1,\
  74. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  75. fontset.serif.bolditalic=\
  76. -b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1,\
  77. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1
  78. fontset.sansserif.plain=\
  79. -b&h-lucida-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  80. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  81. fontset.sansserif.italic=\
  82. -b&h-lucida-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  83. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  84. fontset.sansserif.bold=\
  85. -b&h-lucida-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  86. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  87. fontset.sansserif.bolditalic=\
  88. -b&h-lucida-bold-i-normal-snas-*-%d-*-*-p-*-iso8859-1,\
  89. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  90. fontset.monospaced.plain=\
  91. -b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  92. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  93. fontset.monospaced.italic=\
  94. -b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  95. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  96. fontset.monospaced.bold=\
  97. -b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-,1\
  98. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  99. fontset.monospaced.bolditalic=\
  100. -b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  101. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  102. fontset.dialog.italic=\
  103. -b&h-lucida-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  104. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  105. fontset.dialog.bold=\
  106. -b&h-lucida-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  107. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  108. fontset.dialog.bolditalic=\
  109. -b&h-lucida-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  110. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  111. fontset.dialog.plain=\
  112. -b&h-lucida-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  113. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  114. fontset.dialoginput.italic=\
  115. -b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  116. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  117. fontset.dialoginput.bold=\
  118. -b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  119. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  120. fontset.dialoginput.bolditalic=\
  121. -b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  122. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  123. fontset.dialoginput.plain=\
  124. -b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1,\
  125. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  126. fontset.default=\
  127. -b&h-lucida-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1,\
  128. -misc-SimSun-medium-r-normal--*-%d-*-*-c-*-iso10646-1

  129. appendedfontpath=/usr/X11R6/lib/X11/fonts/TTF
复制代码
发表于 2003-7-20 00:47:27 | 显示全部楼层
那到对应版本的论坛上去问问看呢

想来他们会知道怎样中文化
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表