-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.2
-
sparc
-
solaris_2.6
From: ###@###.###
To: ###@###.###
Subject: PROBLEMS WITH JAVA 2 PLATFORM INTERNATIOLISATION
Cc: ###@###.###
The problems report to Sun Microsystems.
Dear sirs!
We are porting our programs from jdk1.x.x to Java 2 Platform.
The main difficultings are internalisation and using national characters.
The problem consists of the two parts:
1. On Solaris 2.7 in light-weight components method Graphics.drawString(String)
does not draw Russian chars (native components seam to be okey after some changes
in font.properties or font.properties.ru) as long as we use HDS View Station,
but almost everything looks like the right thing on main console, pluged in
system block of x86 computer.
2. The more important at the moment is Russification of Java 2 in Win95/98:
We tried jdk1.2beta jdk1.2 jdk1.2.1 jre1.2.2, the problem persists at the
same form at four cases enumerated.
After instalation, no russian fonts avalible in java, when fonts from java/lib/fonts
instaled (we have Lucida family fonts in java/lib/fonts) situation changes dramaticaly:
for example if we write dialog1=Cucida Regular, RUSSIAN_CHARSET (or so on)
to the font.properties or font.properties.ru java writes: Lucida Regular font in
font.properties not found ... , but Russian characters appeares in our window,
both in native and light-waight components with wrong metrics.
Lines of text lookes 3 higher - spaces above and belaw symbolse are filled with nothing
eache approximately as high as the letters are!
Changing dialog1 and dialog2, one could see that java does not use them as default
substitution for wrong font of dialog0, so this way we can not reveal which font is realy
used at this case, even more Lucida Regulear seam not to have Russian page at all in jre1.2.2,
but it effects the same way as in case of Russian fonts Cucida Regular.
Other applications (Word,Notepad e.t.c. do not detect Lucida fonts, provided with java
inspite of thease fonts installed the right way via fontmanager and detected by Explorer in
windows/fonts directory)
Applying a simple example program, I used to investigation of fonts' problem.
(need to compile it with -J-Dfile.encoding=8859_5 to preserve russian chars in compiled
class or use \uXXXX unicode assignment in drawString and setText methods)
import java.applet.*;
import java.awt.*;
public class FontBrowser extends Panel
{
private Choice fontChoice;
private Choice styleChoice;
private Choice sizeChoice;
private TextArea textArea;
private DComp dc;
/// Called when the applet is first created.
public FontBrowser()
{
setLayout( new BorderLayout() );
setFont(new Font("Dialog",Font.PLAIN,12));
Panel choicePanel = new Panel();
choicePanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
String[] fontNames = getToolkit().getFontList();
String defaultFontName = getFont().getName();
fontChoice = new Choice();
fontChoice.addItem( "" );
fontChoice.select( 0 );
for ( int i = 0; i < fontNames.length; ++i )
{
fontChoice.addItem( fontNames[i] );
if ( fontNames[i].equals( defaultFontName ) )
fontChoice.select( i + 1 );
}
choicePanel.add( fontChoice );
styleChoice = new Choice();
styleChoice.addItem( "PLAIN" );
styleChoice.addItem( "BOLD" );
styleChoice.addItem( "ITALIC" );
styleChoice.addItem( "BOLD ITALIC" );
styleChoice.select( 0 );
choicePanel.add( styleChoice );
sizeChoice = new Choice();
sizeChoice.addItem( "6" );
sizeChoice.addItem( "8" );
sizeChoice.addItem( "10" );
sizeChoice.addItem( "12" );
sizeChoice.addItem( "15" );
sizeChoice.addItem( "20" );
sizeChoice.addItem( "25" );
sizeChoice.select( 3 );
choicePanel.add( sizeChoice );
add( "North", choicePanel );
textArea = new TextArea();
dc = new DComp();
textArea.setFont(new Font("Dialog",Font.PLAIN,12));
dc.setFont(new Font("Dialog",Font.PLAIN,12));
textArea.setEditable( false );
add( "Center", textArea );
add("South",dc);
browse();
}
/// Event handler.
public boolean action( Event event, Object what )
{
if ( event.target == fontChoice || event.target == styleChoice ||
event.target == sizeChoice )
{
browse();
return true;
}
return false;
}
private void browse()
{
textArea.setText( "" );
String fontName = fontChoice.getSelectedItem();
if ( fontName.equals( "" ) )
return;
String styleStr = styleChoice.getSelectedItem();
int style;
if ( styleStr.equals( "PLAIN" ) )
style = Font.PLAIN;
else if ( styleStr.equals( "BOLD" ) )
style = Font.BOLD;
else if ( styleStr.equals( "ITALIC" ) )
style = Font.ITALIC;
else if ( styleStr.equals( "BOLD ITALIC" ) )
style = Font.BOLD | Font.ITALIC;
else
style = Font.PLAIN;
String sizeStr = sizeChoice.getSelectedItem();
int size = Integer.parseInt( sizeStr );
Font font = new Font( fontName, style, size );
textArea.setFont( font );
dc.setFont( font );
textArea.appendText( "family: " + font.getFamily() + "\n" );
textArea.appendText( "name: " + font.getName() + "\n" );
textArea.appendText(
"style:" +
( font.isPlain() ? " PLAIN" : "" ) +
( font.isBold() ? " BOLD" : "" ) +
( font.isItalic() ? " ITALIC" : "" ) +
"\n" );
textArea.appendText( "size: " + font.getSize() + "\n" );
textArea.appendText( "\n" );
FontMetrics fm = textArea.getFontMetrics( font );
if ( fm == null )
return;
textArea.appendText( "leading: " + fm.getLeading() + "\n" );
textArea.appendText( "ascent: " + fm.getAscent() + "\n" );
textArea.appendText( "descent: " + fm.getDescent() + "\n" );
textArea.appendText( "height: " + fm.getHeight() + "\n" );
textArea.appendText( "max ascent: " + fm.getMaxAscent() + "\n" );
textArea.appendText( "max descent: " + fm.getMaxDescent() + "\n" );
textArea.appendText( "max advance: " + fm.getMaxAdvance() + "\n" );
int[] widths = fm.getWidths();
boolean fixed = true;
for ( int i = 33; i <= 126; ++i )
if ( widths[i] != widths[32] )
{
fixed = false;
break;
}
if ( fixed )
textArea.appendText( "fixed width\n" );
else
textArea.appendText( "variable width\n" );
textArea.appendText( "\n" );
textArea.appendText( " !\"#$%&'()*+,-./0123456789:;<=>?\n" );
textArea.appendText( "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\n" );
textArea.appendText( "`abcdefghijklmnopqrstuvwxyz{|}~\n" );
try{
textArea.appendText( "»Ë²Âò´ò²·Ã»º·É»Å¸¼Ãº¼¸°ÃÀ\n" );
}catch(Exception ee0){
ee0.printStackTrace();
}//try
try{
textArea.appendText( "ÒÐßÚÕÖßàÕÖàÝÚàÕÝÞÝÞÞÕÞÕÓÞÝ\n" );
}catch(Exception ee0){
ee0.printStackTrace();
}//try
dc.repaint();
}
public static void main( String[] args )
{
Frame f = new Frame("FontBrowser");
f.setLayout( new BorderLayout() );
FontBrowser fb = new FontBrowser();
f.add(fb,"Center");
f.setSize(400,400);
f.setVisible(true);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class DComp extends Panel {
private Font font = new Font("Dialog",Font.PLAIN,12);
public DComp(){
}
public void paint(Graphics g){
try{
g.setFont(font);
g.drawString( "drawString(...):²¸Ë²¸¾»Ë²Â˲ßÐßÛÐÒÛßÒÛÐßÛÒ\n", 10,30);
}catch(Exception ee0){
ee0.printStackTrace();
}//try
}
public void setFont(Font fnt){
if (fnt!=null){font=fnt;}
}
public Dimension getPreferredSize(){
return (new Dimension(400,50));
}
}
To: ###@###.###
Subject: PROBLEMS WITH JAVA 2 PLATFORM INTERNATIOLISATION
Cc: ###@###.###
The problems report to Sun Microsystems.
Dear sirs!
We are porting our programs from jdk1.x.x to Java 2 Platform.
The main difficultings are internalisation and using national characters.
The problem consists of the two parts:
1. On Solaris 2.7 in light-weight components method Graphics.drawString(String)
does not draw Russian chars (native components seam to be okey after some changes
in font.properties or font.properties.ru) as long as we use HDS View Station,
but almost everything looks like the right thing on main console, pluged in
system block of x86 computer.
2. The more important at the moment is Russification of Java 2 in Win95/98:
We tried jdk1.2beta jdk1.2 jdk1.2.1 jre1.2.2, the problem persists at the
same form at four cases enumerated.
After instalation, no russian fonts avalible in java, when fonts from java/lib/fonts
instaled (we have Lucida family fonts in java/lib/fonts) situation changes dramaticaly:
for example if we write dialog1=Cucida Regular, RUSSIAN_CHARSET (or so on)
to the font.properties or font.properties.ru java writes: Lucida Regular font in
font.properties not found ... , but Russian characters appeares in our window,
both in native and light-waight components with wrong metrics.
Lines of text lookes 3 higher - spaces above and belaw symbolse are filled with nothing
eache approximately as high as the letters are!
Changing dialog1 and dialog2, one could see that java does not use them as default
substitution for wrong font of dialog0, so this way we can not reveal which font is realy
used at this case, even more Lucida Regulear seam not to have Russian page at all in jre1.2.2,
but it effects the same way as in case of Russian fonts Cucida Regular.
Other applications (Word,Notepad e.t.c. do not detect Lucida fonts, provided with java
inspite of thease fonts installed the right way via fontmanager and detected by Explorer in
windows/fonts directory)
Applying a simple example program, I used to investigation of fonts' problem.
(need to compile it with -J-Dfile.encoding=8859_5 to preserve russian chars in compiled
class or use \uXXXX unicode assignment in drawString and setText methods)
import java.applet.*;
import java.awt.*;
public class FontBrowser extends Panel
{
private Choice fontChoice;
private Choice styleChoice;
private Choice sizeChoice;
private TextArea textArea;
private DComp dc;
/// Called when the applet is first created.
public FontBrowser()
{
setLayout( new BorderLayout() );
setFont(new Font("Dialog",Font.PLAIN,12));
Panel choicePanel = new Panel();
choicePanel.setLayout( new FlowLayout( FlowLayout.LEFT ) );
String[] fontNames = getToolkit().getFontList();
String defaultFontName = getFont().getName();
fontChoice = new Choice();
fontChoice.addItem( "" );
fontChoice.select( 0 );
for ( int i = 0; i < fontNames.length; ++i )
{
fontChoice.addItem( fontNames[i] );
if ( fontNames[i].equals( defaultFontName ) )
fontChoice.select( i + 1 );
}
choicePanel.add( fontChoice );
styleChoice = new Choice();
styleChoice.addItem( "PLAIN" );
styleChoice.addItem( "BOLD" );
styleChoice.addItem( "ITALIC" );
styleChoice.addItem( "BOLD ITALIC" );
styleChoice.select( 0 );
choicePanel.add( styleChoice );
sizeChoice = new Choice();
sizeChoice.addItem( "6" );
sizeChoice.addItem( "8" );
sizeChoice.addItem( "10" );
sizeChoice.addItem( "12" );
sizeChoice.addItem( "15" );
sizeChoice.addItem( "20" );
sizeChoice.addItem( "25" );
sizeChoice.select( 3 );
choicePanel.add( sizeChoice );
add( "North", choicePanel );
textArea = new TextArea();
dc = new DComp();
textArea.setFont(new Font("Dialog",Font.PLAIN,12));
dc.setFont(new Font("Dialog",Font.PLAIN,12));
textArea.setEditable( false );
add( "Center", textArea );
add("South",dc);
browse();
}
/// Event handler.
public boolean action( Event event, Object what )
{
if ( event.target == fontChoice || event.target == styleChoice ||
event.target == sizeChoice )
{
browse();
return true;
}
return false;
}
private void browse()
{
textArea.setText( "" );
String fontName = fontChoice.getSelectedItem();
if ( fontName.equals( "" ) )
return;
String styleStr = styleChoice.getSelectedItem();
int style;
if ( styleStr.equals( "PLAIN" ) )
style = Font.PLAIN;
else if ( styleStr.equals( "BOLD" ) )
style = Font.BOLD;
else if ( styleStr.equals( "ITALIC" ) )
style = Font.ITALIC;
else if ( styleStr.equals( "BOLD ITALIC" ) )
style = Font.BOLD | Font.ITALIC;
else
style = Font.PLAIN;
String sizeStr = sizeChoice.getSelectedItem();
int size = Integer.parseInt( sizeStr );
Font font = new Font( fontName, style, size );
textArea.setFont( font );
dc.setFont( font );
textArea.appendText( "family: " + font.getFamily() + "\n" );
textArea.appendText( "name: " + font.getName() + "\n" );
textArea.appendText(
"style:" +
( font.isPlain() ? " PLAIN" : "" ) +
( font.isBold() ? " BOLD" : "" ) +
( font.isItalic() ? " ITALIC" : "" ) +
"\n" );
textArea.appendText( "size: " + font.getSize() + "\n" );
textArea.appendText( "\n" );
FontMetrics fm = textArea.getFontMetrics( font );
if ( fm == null )
return;
textArea.appendText( "leading: " + fm.getLeading() + "\n" );
textArea.appendText( "ascent: " + fm.getAscent() + "\n" );
textArea.appendText( "descent: " + fm.getDescent() + "\n" );
textArea.appendText( "height: " + fm.getHeight() + "\n" );
textArea.appendText( "max ascent: " + fm.getMaxAscent() + "\n" );
textArea.appendText( "max descent: " + fm.getMaxDescent() + "\n" );
textArea.appendText( "max advance: " + fm.getMaxAdvance() + "\n" );
int[] widths = fm.getWidths();
boolean fixed = true;
for ( int i = 33; i <= 126; ++i )
if ( widths[i] != widths[32] )
{
fixed = false;
break;
}
if ( fixed )
textArea.appendText( "fixed width\n" );
else
textArea.appendText( "variable width\n" );
textArea.appendText( "\n" );
textArea.appendText( " !\"#$%&'()*+,-./0123456789:;<=>?\n" );
textArea.appendText( "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\n" );
textArea.appendText( "`abcdefghijklmnopqrstuvwxyz{|}~\n" );
try{
textArea.appendText( "»Ë²Âò´ò²·Ã»º·É»Å¸¼Ãº¼¸°ÃÀ\n" );
}catch(Exception ee0){
ee0.printStackTrace();
}//try
try{
textArea.appendText( "ÒÐßÚÕÖßàÕÖàÝÚàÕÝÞÝÞÞÕÞÕÓÞÝ\n" );
}catch(Exception ee0){
ee0.printStackTrace();
}//try
dc.repaint();
}
public static void main( String[] args )
{
Frame f = new Frame("FontBrowser");
f.setLayout( new BorderLayout() );
FontBrowser fb = new FontBrowser();
f.add(fb,"Center");
f.setSize(400,400);
f.setVisible(true);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class DComp extends Panel {
private Font font = new Font("Dialog",Font.PLAIN,12);
public DComp(){
}
public void paint(Graphics g){
try{
g.setFont(font);
g.drawString( "drawString(...):²¸Ë²¸¾»Ë²Â˲ßÐßÛÐÒÛßÒÛÐßÛÒ\n", 10,30);
}catch(Exception ee0){
ee0.printStackTrace();
}//try
}
public void setFont(Font fnt){
if (fnt!=null){font=fnt;}
}
public Dimension getPreferredSize(){
return (new Dimension(400,50));
}
}