8301254: UNIX sun/font coding does not detect SuSE in openSUSE Leap distribution

Reviewed-by: prr
This commit is contained in:
Alexander Scherbatiy
2023-03-06 07:40:38 +00:00
parent 3eff1a0225
commit 15c76e4c02
2 changed files with 28 additions and 16 deletions

View File

@@ -295,9 +295,13 @@ public class FcFontConfiguration extends FontConfiguration {
return null;
}
private String extractOsInfo(String s) {
private String extractInfo(String s) {
if (s == null) {
return null;
}
if (s.startsWith("\"")) s = s.substring(1);
if (s.endsWith("\"")) s = s.substring(0, s.length()-1);
s = s.replace(' ', '_');
return s;
}
@@ -323,8 +327,8 @@ public class FcFontConfiguration extends FontConfiguration {
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("DISTRIB_ID");
osVersion = props.getProperty("DISTRIB_RELEASE");
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(props.getProperty("DISTRIB_RELEASE"));
} else if ((f = new File("/etc/redhat-release")).canRead()) {
osName = "RedHat";
osVersion = getVersionString(f);
@@ -342,11 +346,13 @@ public class FcFontConfiguration extends FontConfiguration {
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);
osName = extractInfo(props.getProperty("NAME"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
if (FontUtilities.debugFonts()) {

View File

@@ -111,18 +111,20 @@ public class MFontConfiguration extends FontConfiguration {
try (FileInputStream fis = new FileInputStream(f)) {
props.load(fis);
}
osName = props.getProperty("DISTRIB_ID");
osVersion = props.getProperty("DISTRIB_RELEASE");
osName = extractInfo(props.getProperty("DISTRIB_ID"));
osVersion = extractInfo(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);
osName = extractInfo(props.getProperty("NAME"));
osVersion = extractInfo(props.getProperty("VERSION_ID"));
if (osName.equals("SLES")) {
osName = "SuSE";
} else {
osName = extractInfo(props.getProperty("ID"));
}
}
} catch (Exception e) {
}
@@ -143,9 +145,13 @@ public class MFontConfiguration extends FontConfiguration {
return null;
}
private String extractOsInfo(String s) {
private String extractInfo(String s) {
if (s == null) {
return null;
}
if (s.startsWith("\"")) s = s.substring(1);
if (s.endsWith("\"")) s = s.substring(0, s.length()-1);
s = s.replace(' ', '_');
return s;
}