From 5be8fa01edeb1e09a60cedcc400f48cea97f497b Mon Sep 17 00:00:00 2001 From: Brian Hinz Date: Wed, 25 Apr 2012 21:20:24 +0000 Subject: [PATCH] Remove hard-coded font names from UI settings. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4901 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- .../com/tigervnc/vncviewer/OptionsDialog.java | 2 +- java/com/tigervnc/vncviewer/VncViewer.java | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/java/com/tigervnc/vncviewer/OptionsDialog.java b/java/com/tigervnc/vncviewer/OptionsDialog.java index 097b71b9..7854b49f 100644 --- a/java/com/tigervnc/vncviewer/OptionsDialog.java +++ b/java/com/tigervnc/vncviewer/OptionsDialog.java @@ -105,7 +105,7 @@ class OptionsDialog extends Dialog implements addGBComponent(customCompressLevel, tightPanel, 0, 0, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,0,0,0)); addGBComponent(compressLevel, tightPanel, 0, 1, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0)); addGBComponent(compressionLabel, tightPanel, 1, 1, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0)); - addGBComponent(noJpeg, tightPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(0,0,0,0)); + addGBComponent(noJpeg, tightPanel, 0, 2, 2, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.FIRST_LINE_START, new Insets(4,0,0,0)); addGBComponent(qualityLevel, tightPanel, 0, 3, 1, 1, 2, 2, 0, 0, GridBagConstraints.NONE, GridBagConstraints.FIRST_LINE_START, new Insets(0,20,0,0)); addGBComponent(qualityLabel, tightPanel, 1, 3, 1, 1, 2, 2, 1, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.LINE_START, new Insets(0,5,0,0)); diff --git a/java/com/tigervnc/vncviewer/VncViewer.java b/java/com/tigervnc/vncviewer/VncViewer.java index 799ee5d8..28a8c196 100644 --- a/java/com/tigervnc/vncviewer/VncViewer.java +++ b/java/com/tigervnc/vncviewer/VncViewer.java @@ -81,23 +81,25 @@ public class VncViewer extends java.applet.Applet implements Runnable UIManager.put("TitledBorder.titleColor",Color.blue); if (UIManager.getLookAndFeel().getName().equals("Metal")) { UIManager.put("swing.boldMetal", Boolean.FALSE); - FontUIResource f = new FontUIResource("SansSerif", Font.PLAIN, 11); java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); - if (value instanceof javax.swing.plaf.FontUIResource) + if (value instanceof FontUIResource) { + String name = ((FontUIResource)value).getName(); + int style = ((FontUIResource)value).getStyle(); + int size = ((FontUIResource)value).getSize()-1; + FontUIResource f = new FontUIResource(name, style, size); UIManager.put(key, f); + } } } else if (UIManager.getLookAndFeel().getName().equals("Nimbus")) { - FontUIResource f; - String os = System.getProperty("os.name"); - if (os.startsWith("Windows")) { - f = new FontUIResource("Verdana", 0, 11); - } else { - f = new FontUIResource("DejaVu Sans", 0, 11); - } - UIManager.put("TitledBorder.font", f); + Font f = UIManager.getFont("TitledBorder.font"); + String name = f.getName(); + int style = f.getStyle(); + int size = f.getSize()-2; + FontUIResource r = new FontUIResource(name, style, size); + UIManager.put("TitledBorder.font", r); } } catch (java.lang.Exception e) { vlog.info(e.toString()); -- 2.39.5