Changeset 7896 in josm
- Timestamp:
- 2014-12-27T05:25:53+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r7894 r7896 8 8 9 9 import java.awt.Dimension; 10 import java.awt.GraphicsEnvironment; 10 11 import java.awt.Image; 11 12 import java.awt.Toolkit; … … 368 369 FontsManager.initialize(); 369 370 371 handleSpecialLanguages(); 372 370 373 final JFrame mainFrame = new JFrame(tr("Java OpenStreetMap Editor")); 371 374 Main.parent = mainFrame; … … 479 482 info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console"); 480 483 RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager()); 484 } 485 } 486 487 private static void handleSpecialLanguages() { 488 // Use special font for Khmer script, as the default Java font do not display these characters 489 if ("km".equals(Main.pref.get("language"))) { 490 Collection<String> fonts = Arrays.asList( 491 GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); 492 for (String f : new String[]{"Khmer UI", "DaunPenh", "MoolBoran"}) { 493 if (fonts.contains(f)) { 494 GuiHelper.setUIFont(f); 495 break; 496 } 497 } 481 498 } 482 499 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java
r7563 r7896 6 6 7 7 import java.awt.Dimension; 8 import java.awt.Font;9 8 import java.awt.GridBagLayout; 10 9 import java.util.ArrayList; … … 45 44 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; 46 45 import org.openstreetmap.josm.gui.mappaint.xml.XmlStyleSource; 46 import org.openstreetmap.josm.gui.util.GuiHelper; 47 47 import org.openstreetmap.josm.gui.widgets.JosmTextArea; 48 48 import org.openstreetmap.josm.tools.GBC; … … 95 95 JPanel p = new JPanel(new GridBagLayout()); 96 96 JosmTextArea txtData = new JosmTextArea(); 97 txtData.setFont( new Font("Monospaced", txtData.getFont().getStyle(), txtData.getFont().getSize()));97 txtData.setFont(GuiHelper.getMonospacedFont(txtData)); 98 98 txtData.setEditable(false); 99 99 txtData.setText(buildDataText()); … … 325 325 p.setLayout(new GridBagLayout()); 326 326 txtMappaint = new JosmTextArea(); 327 txtMappaint.setFont( new Font("Monospaced", txtMappaint.getFont().getStyle(), txtMappaint.getFont().getSize()));327 txtMappaint.setFont(GuiHelper.getMonospacedFont(txtMappaint)); 328 328 txtMappaint.setEditable(false); 329 329 -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r7668 r7896 73 73 import org.openstreetmap.josm.gui.preferences.map.MapPaintPreference; 74 74 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; 75 import org.openstreetmap.josm.gui.util.GuiHelper; 75 76 import org.openstreetmap.josm.gui.widgets.AbstractFileChooser; 76 77 import org.openstreetmap.josm.gui.widgets.FileChooserManager; … … 615 616 private void buildSourcePanel(StyleSource s, JPanel p) { 616 617 JosmTextArea txtSource = new JosmTextArea(); 617 txtSource.setFont( new Font("Monospaced", txtSource.getFont().getStyle(), txtSource.getFont().getSize()));618 txtSource.setFont(GuiHelper.getMonospacedFont(txtSource)); 618 619 txtSource.setEditable(false); 619 620 p.add(new JScrollPane(txtSource), GBC.std().fill()); … … 636 637 private void buildErrorsPanel(StyleSource s, JPanel p) { 637 638 JosmTextArea txtErrors = new JosmTextArea(); 638 txtErrors.setFont( new Font("Monospaced", txtErrors.getFont().getStyle(), txtErrors.getFont().getSize()));639 txtErrors.setFont(GuiHelper.getMonospacedFont(txtErrors)); 639 640 txtErrors.setEditable(false); 640 641 p.add(new JScrollPane(txtErrors), GBC.std().fill()); -
trunk/src/org/openstreetmap/josm/gui/io/DownloadPrimitivesWithReferrersTask.java
r7592 r7896 213 213 } 214 214 JosmTextArea txt = new JosmTextArea(); 215 txt.setFont( new Font("Monospaced", txt.getFont().getStyle(), txt.getFont().getSize()));215 txt.setFont(GuiHelper.getMonospacedFont(txt)); 216 216 txt.setEditable(false); 217 217 txt.setBackground(p.getBackground()); -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r7539 r7896 23 23 import java.lang.reflect.InvocationTargetException; 24 24 import java.util.Arrays; 25 import java.util.Enumeration; 25 26 import java.util.List; 26 27 import java.util.concurrent.Callable; … … 31 32 import javax.swing.Icon; 32 33 import javax.swing.ImageIcon; 34 import javax.swing.JComponent; 33 35 import javax.swing.JLabel; 34 36 import javax.swing.JOptionPane; … … 37 39 import javax.swing.SwingUtilities; 38 40 import javax.swing.Timer; 41 import javax.swing.UIManager; 42 import javax.swing.plaf.FontUIResource; 39 43 40 44 import org.openstreetmap.josm.Main; 41 45 import org.openstreetmap.josm.gui.ExtendedDialog; 42 46 import org.openstreetmap.josm.gui.widgets.HtmlPanel; 47 import org.openstreetmap.josm.tools.CheckParameterUtil; 43 48 import org.openstreetmap.josm.tools.GBC; 44 49 import org.openstreetmap.josm.tools.ImageProvider; … … 297 302 298 303 /** 304 * Gets the font used to display monospaced text in a component, if possible. 305 * @param component The component 306 * @return the font used to display monospaced text in a component, if possible 307 * @since 7896 308 */ 309 public static Font getMonospacedFont(JComponent component) { 310 // Special font for Khmer script 311 if ("km".equals(Main.pref.get("language"))) { 312 return component.getFont(); 313 } else { 314 return new Font("Monospaced", component.getFont().getStyle(), component.getFont().getSize()); 315 } 316 } 317 318 /** 299 319 * Gets the font used to display JOSM title in about dialog and splash screen. 300 320 * @return By order or priority, the first font available in local fonts: … … 303 323 * 3. Arial Bold 20 304 324 * 4. SansSerif Bold 20 325 * Except if current language is Khmer, where it will be current font at size 20 305 326 * @since 5797 306 327 */ 307 328 public static Font getTitleFont() { 308 329 List<String> fonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); 330 // Special font for Khmer script 331 if ("km".equals(Main.pref.get("language"))) { 332 return UIManager.getFont("Label.font").deriveFont(20.0f); 333 } 309 334 // Helvetica is the preferred choice but is not available by default on Windows 310 335 // (https://www.microsoft.com/typography/fonts/product.aspx?pid=161) … … 346 371 return Main.isPlatformOsx() ? KeyEvent.META_DOWN_MASK : KeyEvent.CTRL_DOWN_MASK; 347 372 } 373 374 /** 375 * Sets a global font for all UI, replacing default font of current look and feel. 376 * @param name Font name. It is up to the caller to make sure the font exists 377 * @since 7896 378 * @throws IllegalArgumentException if name is null 379 */ 380 public static void setUIFont(String name) { 381 CheckParameterUtil.ensureParameterNotNull(name, "name"); 382 Main.info("Setting "+name+" as the default UI font"); 383 Enumeration<?> keys = UIManager.getDefaults().keys(); 384 while (keys.hasMoreElements()) { 385 Object key = keys.nextElement(); 386 Object value = UIManager.get(key); 387 if (value != null && value instanceof FontUIResource) { 388 FontUIResource fui = (FontUIResource)value; 389 UIManager.put(key, new FontUIResource(name, fui.getStyle(), fui.getSize())); 390 } 391 } 392 } 348 393 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java
r6935 r7896 16 16 import javax.swing.text.html.StyleSheet; 17 17 18 import org.openstreetmap.josm.Main; 18 19 import org.openstreetmap.josm.gui.util.GuiHelper; 19 20 import org.openstreetmap.josm.tools.Utils; … … 83 84 return result; 84 85 } 85 86 86 87 /** 87 88 * Adapts a {@link JEditorPane} to be used as a powerful replacement of {@link javax.swing.JLabel}. … … 103 104 ss.addRule("ol {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: decimal}"); 104 105 ss.addRule("ul {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: disc}"); 106 if ("km".equals(Main.pref.get("language"))) { 107 // Fix rendering problem for Khmer script 108 ss.addRule("p {" + getFontRule(UIManager.getFont("Label.font")) + "}"); 109 } 105 110 kit.setStyleSheet(ss); 106 111 pane.setEditorKit(kit);
Note:
See TracChangeset
for help on using the changeset viewer.