better font name handling

kerning moved to FontHelper
This commit is contained in:
Jindra Petřík
2014-10-26 12:36:56 +01:00
parent bcfb4a1c01
commit 093d17a055
24 changed files with 683 additions and 245 deletions
@@ -452,7 +452,7 @@ public class Configuration {
recentFiles.set(Helper.joinStrings(recentFilesArray, "::"));
}
public static Map<String, String> getFontIdToFamilyMap() {
public static Map<String, String> getFontToNameMap() {
String fonts = fontPairing.get();
if (fonts == null) {
return new HashMap<>();
@@ -467,39 +467,20 @@ public class Configuration {
}
return result;
}
public static Map<String, String> getFontIdToFaceMap() {
String fonts = fontPairing.get();
if (fonts == null) {
return new HashMap<>();
}
Map<String, String> result = new HashMap<>();
for (String pair : fonts.split("::")) {
if (!pair.isEmpty()) {
String[] splittedPair = pair.split("=");
result.put(splittedPair[0], splittedPair.length < 3 ? "" : splittedPair[2]);
}
}
return result;
}
public static void addFontPair(String fileName, int fontId, String fontName, String installedFontFamily, String installedFontFace) {
public static void addFontPair(String fileName, int fontId, String fontName, String installedName) {
String key = fileName + "_" + fontId + "_" + fontName;
Map<String, String> fontPairs = getFontIdToFamilyMap();
fontPairs.put(key, installedFontFamily);
fontPairs.put(fontName, installedFontFamily);
Map<String, String> fontPairs = getFontToNameMap();
fontPairs.put(key, installedName);
fontPairs.put(fontName, installedName);
Map<String, String> facePairs = getFontIdToFaceMap();
facePairs.put(key, installedFontFace);
facePairs.put(fontName, installedFontFace);
StringBuilder sb = new StringBuilder();
int i = 0;
for (Entry<String, String> pair : fontPairs.entrySet()) {
if (i != 0) {
sb.append("::");
}
sb.append(pair.getKey()).append("=").append(pair.getValue()).append("=").append(facePairs.containsKey(pair.getKey()) ? facePairs.get(pair.getKey()) : "");
sb.append(pair.getKey()).append("=").append(pair.getValue());
i++;
}
fontPairing.set(sb.toString());