8263140: Japanese chars garble in console window in HSDB

Reviewed-by: iklam, prr, cjplummer
This commit is contained in:
Yasumasa Suenaga 2021-03-09 23:43:07 +00:00
parent 70342e8513
commit d0c1aec202
5 changed files with 13 additions and 24 deletions

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -306,7 +306,7 @@ public class AnnotatedMemoryPanel extends JPanel {
}); });
if (font == null) { if (font == null) {
font = GraphicsUtilities.lookupFont("Courier"); font = GraphicsUtilities.getMonospacedFont();
} }
if (font == null) { if (font == null) {
throw new RuntimeException("Error looking up monospace font Courier"); throw new RuntimeException("Error looking up monospace font Courier");

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -60,7 +60,7 @@ public class CommandProcessorPanel extends JPanel {
editor = new JTextArea(); editor = new JTextArea();
editor.setDocument(new EditableAtEndDocument()); editor.setDocument(new EditableAtEndDocument());
editor.setFont(GraphicsUtilities.lookupFont("Courier")); editor.setFont(GraphicsUtilities.getMonospacedFont());
JScrollPane scroller = new JScrollPane(); JScrollPane scroller = new JScrollPane();
scroller.getViewport().add(editor); scroller.getViewport().add(editor);
add(scroller, BorderLayout.CENTER); add(scroller, BorderLayout.CENTER);

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -58,7 +58,7 @@ public class DebuggerConsolePanel extends JPanel {
editor = new JTextArea(); editor = new JTextArea();
editor.setDocument(new EditableAtEndDocument()); editor.setDocument(new EditableAtEndDocument());
editor.setFont(GraphicsUtilities.lookupFont("Courier")); editor.setFont(GraphicsUtilities.getMonospacedFont());
JScrollPane scroller = new JScrollPane(); JScrollPane scroller = new JScrollPane();
scroller.getViewport().add(editor); scroller.getViewport().add(editor);
add(scroller, BorderLayout.CENTER); add(scroller, BorderLayout.CENTER);

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -34,21 +34,10 @@ import javax.swing.border.*;
/** Useful utilities for drawing graphics */ /** Useful utilities for drawing graphics */
public class GraphicsUtilities { public class GraphicsUtilities {
/** Returns a plain-styled 12-point version of the given font, or private static final int FONT_SIZE = 12;
null if the font could not be found */
public static Font lookupFont(String fontName) { public static Font getMonospacedFont() {
Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); return new Font(Font.MONOSPACED, Font.PLAIN, FONT_SIZE);
Font font = null;
for (int i = 0; i < allFonts.length; i++) {
if (allFonts[i].getFontName().indexOf(fontName) != -1) {
font = allFonts[i];
break;
}
}
if (font == null) {
return null;
}
return font.deriveFont(Font.PLAIN, 12);
} }
/** Compute the width and height of given string given the current /** Compute the width and height of given string given the current

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -130,7 +130,7 @@ public class MemoryPanel extends JPanel {
table.setCellSelectionEnabled(true); table.setCellSelectionEnabled(true);
table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
table.setDragEnabled(true); table.setDragEnabled(true);
Font font = GraphicsUtilities.lookupFont("Courier"); Font font = GraphicsUtilities.getMonospacedFont();
if (font == null) { if (font == null) {
throw new RuntimeException("Error looking up monospace font Courier"); throw new RuntimeException("Error looking up monospace font Courier");
} }