Skip to content

Commit

Permalink
Fix upper and lower case conversion for some locales.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccavanaugh committed Nov 22, 2015
1 parent ef3db60 commit f676039
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public static List<SecurityHistoryNode> downloadHistory(final SecurityNode secur

final List<SecurityHistoryNode> newSecurityNodes = new ArrayList<>();

final String s = securityNode.getSymbol().toLowerCase();
final String s = securityNode.getSymbol().toLowerCase(Locale.ROOT);

final String a = Integer.toString(startDate.getMonthValue() - 1);
final String b = Integer.toString(startDate.getDayOfMonth());
Expand Down
22 changes: 12 additions & 10 deletions jgnash-swing/src/main/java/jgnash/ui/report/FontRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Logger;
Expand Down Expand Up @@ -80,7 +81,7 @@ static String getRegisteredFontPath(final String name) {
}
}

return registry.registeredFontMap.get(name.toLowerCase());
return registry.registeredFontMap.get(name.toLowerCase(Locale.ROOT));
}

private static void registerFonts() {
Expand Down Expand Up @@ -114,26 +115,26 @@ public void run() {

private void registerFont(final String path) {
try {
if (path.toLowerCase().endsWith(".ttf") || path.toLowerCase().endsWith(".otf")
|| path.toLowerCase().indexOf(".ttc,") > 0) {
if (path.toLowerCase(Locale.ROOT).endsWith(".ttf") || path.toLowerCase(Locale.ROOT).endsWith(".otf")
|| path.toLowerCase(Locale.ROOT).indexOf(".ttc,") > 0) {
Object allNames[] = BaseFont.getAllFontNames(path, BaseFont.WINANSI, null);

String[][] names = (String[][]) allNames[2]; //full name
for (String[] name : names) {
registeredFontMap.put(name[3].toLowerCase(), path);
registeredFontMap.put(name[3].toLowerCase(Locale.ROOT), path);
}

} else if (path.toLowerCase().endsWith(".ttc")) {
} else if (path.toLowerCase(Locale.ROOT).endsWith(".ttc")) {
String[] names = BaseFont.enumerateTTCNames(path);
for (int i = 0; i < names.length; i++) {
registerFont(path + "," + i);
}
} else if (path.toLowerCase().endsWith(".afm") || path.toLowerCase().endsWith(".pfm")) {
} else if (path.toLowerCase(Locale.ROOT).endsWith(".afm") || path.toLowerCase(Locale.ROOT).endsWith(".pfm")) {
BaseFont bf = BaseFont.createFont(path, BaseFont.CP1252, false);
String fullName = bf.getFullFontName()[0][3].toLowerCase();
String fullName = bf.getFullFontName()[0][3].toLowerCase(Locale.ROOT);
registeredFontMap.put(fullName, path);
}
} catch (DocumentException | IOException e) {
} catch (final DocumentException | IOException e) {
throw new RuntimeException(e);
}
}
Expand All @@ -159,7 +160,7 @@ private void registerFontDirectory(final String dir) {
registerFontDirectory(file.getAbsolutePath());
} else {
String name = file.getPath();
String suffix = name.length() < 4 ? null : name.substring(name.length() - 3).toLowerCase();
String suffix = name.length() < 4 ? null : name.substring(name.length() - 3).toLowerCase(Locale.ROOT);

if (suffix != null) {
switch (suffix) {
Expand All @@ -181,7 +182,8 @@ private void registerFontDirectory(final String dir) {
}
}
} catch (Exception e) {
Logger.getLogger(FontRegistry.class.getName()).log(Level.FINEST, MessageFormat.format("Could not find path for {0}", path), e);
Logger.getLogger(FontRegistry.class.getName()).log(Level.FINEST,
MessageFormat.format("Could not find path for {0}", path), e);
}
}
}
Expand Down

0 comments on commit f676039

Please sign in to comment.