Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8278549: UNIX sun/font coding misses SUSE distro detection on recent …
…distro SUSE 15

Reviewed-by: mdoerr
Backport-of: 84976b45315feb6c37a9f3db6e1e62812c9b0a37
  • Loading branch information
MBaesken committed Mar 28, 2022
1 parent 8d7f26b commit 86ac4ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/java.desktop/unix/classes/sun/font/FcFontConfiguration.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -294,6 +294,12 @@ private String getVersionString(File f) {
return null;
}

private String extractOsInfo(String s) {
if (s.startsWith("\"")) s = s.substring(1);
if (s.endsWith("\"")) s = s.substring(0, s.length()-1);
return s;
}

/**
* Sets the OS name and version from environment information.
*/
Expand Down Expand Up @@ -328,6 +334,16 @@ protected void setOsNameAndVersion() {
} else if ((f = new File("/etc/fedora-release")).canRead()) {
osName = "Fedora";
osVersion = getVersionString(f);
} else if ((f = new File("/etc/os-release")).canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("NAME");
osVersion = props.getProperty("VERSION_ID");
osName = extractOsInfo(osName);
if (osName.equals("SLES")) osName = "SuSE";
osVersion = extractOsInfo(osVersion);
}
} catch (Exception e) {
if (FontUtilities.debugFonts()) {
Expand Down
18 changes: 17 additions & 1 deletion src/java.desktop/unix/classes/sun/font/MFontConfiguration.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -112,6 +112,16 @@ protected void setOsNameAndVersion(){
props.load(new FileInputStream(f));
osName = props.getProperty("DISTRIB_ID");
osVersion = props.getProperty("DISTRIB_RELEASE");
} else if ((f = new File("/etc/os-release")).canRead()) {
Properties props = new Properties();
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("NAME");
osVersion = props.getProperty("VERSION_ID");
osName = extractOsInfo(osName);
if (osName.equals("SLES")) osName = "SuSE";
osVersion = extractOsInfo(osVersion);
}
} catch (Exception e) {
}
Expand All @@ -132,6 +142,12 @@ private String getVersionString(File f){
return null;
}

private String extractOsInfo(String s) {
if (s.startsWith("\"")) s = s.substring(1);
if (s.endsWith("\"")) s = s.substring(0, s.length()-1);
return s;
}

private static final String fontsDirPrefix = "$JRE_LIB_FONTS";

protected String mapFileName(String fileName) {
Expand Down

1 comment on commit 86ac4ab

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.