Changeset 8282 in josm for trunk/src


Ignore:
Timestamp:
2015-04-27T18:46:32+02:00 (10 years ago)
Author:
stoecker
Message:

fix handling of khmer a bit

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r8175 r8282  
    381381        FontsManager.initialize();
    382382
    383         handleSpecialLanguages();
     383        I18n.setupLanguageFonts();
    384384
    385385        final JFrame mainFrame = new JFrame(tr("Java OpenStreetMap Editor"));
     
    502502            info("Enabled EDT checker, wrongful access to gui from non EDT thread will be printed to console");
    503503            RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
    504         }
    505     }
    506 
    507     private static void handleSpecialLanguages() {
    508         // Use special font for Khmer script, as the default Java font do not display these characters
    509         if ("km".equals(Main.pref.get("language"))) {
    510             Collection<String> fonts = Arrays.asList(
    511                     GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
    512             for (String f : new String[]{"Khmer UI", "DaunPenh", "MoolBoran"}) {
    513                 if (fonts.contains(f)) {
    514                     GuiHelper.setUIFont(f);
    515                     break;
    516                 }
    517             }
    518504        }
    519505    }
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r7896 r8282  
    4848import org.openstreetmap.josm.tools.GBC;
    4949import org.openstreetmap.josm.tools.ImageProvider;
     50import org.openstreetmap.josm.tools.LanguageInfo;
    5051
    5152/**
     
    309310    public static Font getMonospacedFont(JComponent component) {
    310311        // Special font for Khmer script
    311         if ("km".equals(Main.pref.get("language"))) {
     312        if ("km".equals(LanguageInfo.getJOSMLocaleCode())) {
    312313            return component.getFont();
    313314        } else {
     
    329330        List<String> fonts = Arrays.asList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
    330331        // Special font for Khmer script
    331         if ("km".equals(Main.pref.get("language"))) {
     332        if ("km".equals(LanguageInfo.getJOSMLocaleCode())) {
    332333            return UIManager.getFont("Label.font").deriveFont(20.0f);
    333334        }
  • trunk/src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

    r8005 r8282  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.gui.util.GuiHelper;
     20import org.openstreetmap.josm.tools.LanguageInfo;
    2021import org.openstreetmap.josm.tools.Utils;
    2122
     
    104105        ss.addRule("ol {margin-left: 1cm; margin-top: 0.1cm; margin-bottom: 0.2cm; list-style-type: decimal}");
    105106        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        if ("km".equals(LanguageInfo.getJOSMLocaleCode())) {
    107108            // Fix rendering problem for Khmer script
    108109            ss.addRule("p {" + getFontRule(UIManager.getFont("Label.font")) + "}");
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r8241 r8282  
    22package org.openstreetmap.josm.tools;
    33
     4import java.awt.GraphicsEnvironment;
    45import java.io.BufferedInputStream;
    56import java.io.File;
     
    2627import org.openstreetmap.gui.jmapviewer.FeatureAdapter.TranslationAdapter;
    2728import org.openstreetmap.josm.Main;
     29import org.openstreetmap.josm.gui.util.GuiHelper;
    2830import org.openstreetmap.josm.gui.widgets.AbstractFileChooser;
    2931
     
    734736        };
    735737    }
     738
     739    /**
     740     * Setup special font for Khmer script, as the default Java font do not display these characters.
     741     *
     742     * @since 8281
     743     */
     744    public static void setupLanguageFonts() {
     745        // Use special font for Khmer script, as the default Java font do not display these characters
     746        if ("km".equals(LanguageInfo.getJOSMLocaleCode())) {
     747            Collection<String> fonts = Arrays.asList(
     748                    GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
     749            for (String f : new String[]{"Khmer UI", "DaunPenh", "MoolBoran"}) {
     750                if (fonts.contains(f)) {
     751                    GuiHelper.setUIFont(f);
     752                    break;
     753                }
     754            }
     755        }
     756    }
    736757}
Note: See TracChangeset for help on using the changeset viewer.