Beispiel #1
0
  private static float calculateScaleFactor() {
    if (SystemInfo.isMac) {
      return 1.0f;
    }

    if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) {
      return 1.0f;
    }

    if (SystemInfo.isLinux) {
      final int dpi = getSystemDPI();
      if (dpi < 120) return 1f;
      if (dpi < 144) return 1.25f;
      if (dpi < 168) return 1.5f;
      if (dpi < 192) return 1.75f;
      return 2f;
    }

    int size = -1;
    /*try {
      if (SystemInfo.isWindows) {
        size = (Integer)Toolkit.getDefaultToolkit().getDesktopProperty("win.system.font.height");
      }
    } catch (Exception e) {//
    }  */
    if (size == -1) {
      size = Fonts.label().getSize();
    }
    if (size <= 13) return 1.0f;
    if (size <= 16) return 1.25f;
    if (size <= 18) return 1.5f;
    if (size < 24) return 1.75f;

    return 2.0f;
  }
Beispiel #2
0
  private static float calculateScaleFactor() {
    if (SystemInfo.isMac) {
      return 1.0f;
    }

    if (SystemProperties.has("hidpi") && !SystemProperties.is("hidpi")) {
      return 1.0f;
    }

    // On Linux: rely on DPI
    if (SystemInfo.isLinux) {
      final int dpi = getSystemDPI();
      if (dpi < 120) return 1f;
      if (dpi < 144) return 1.25f;
      if (dpi < 168) return 1.5f;
      if (dpi < 192) return 1.75f;
      return 2f;
    }

    int size = -1;

    // On Windows: rely on default system font
    if (SystemInfo.isWindows) {
      UIUtil.initSystemFontData();
      Pair<String, Integer> fdata = UIUtil.getSystemFontData();
      if (fdata != null) size = fdata.getSecond();
    }
    if (size == -1) {
      size = Fonts.label().getSize();
    }
    if (size <= 13) return 1.0f;
    if (size <= 16) return 1.25f;
    if (size <= 18) return 1.5f;
    if (size < 24) return 1.75f;

    return 2.0f;
  }