mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-08 11:58:15 +00:00
#1313 Font Change
This commit is contained in:
@@ -19,8 +19,10 @@ package com.jpexs.decompiler.flash.configuration;
|
||||
import com.jpexs.decompiler.flash.ApplicationInfo;
|
||||
import com.jpexs.decompiler.flash.exporters.modes.ExeExportMode;
|
||||
import com.jpexs.decompiler.flash.helpers.CodeFormatting;
|
||||
import com.jpexs.decompiler.flash.helpers.FontHelper;
|
||||
import com.jpexs.decompiler.flash.importers.TextImportResizeTextBoundsMode;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import java.awt.Font;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -289,6 +291,12 @@ public class Configuration {
|
||||
@ConfigurationName("gui.fontSizeMultiplier")
|
||||
public static final ConfigurationItem<Double> guiFontSizeMultiplier = null;
|
||||
|
||||
// font used in AS1/2/3 source area, P-Code area, Define Text area and in Metadata area
|
||||
@ConfigurationDefaultString("Monospaced-Plain-12")
|
||||
@ConfigurationCategory("display")
|
||||
@ConfigurationName("gui.sourceFont")
|
||||
public static final ConfigurationItem<String> sourceFontString = null;
|
||||
|
||||
@ConfigurationDefaultDouble(0.5)
|
||||
@ConfigurationName("gui.avm2.splitPane.dividerLocationPercent")
|
||||
@ConfigurationInternal
|
||||
@@ -707,6 +715,10 @@ public class Configuration {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Font getSourceFont() {
|
||||
return FontHelper.stringToFont(sourceFontString.get());
|
||||
}
|
||||
|
||||
public static List<String> getRecentFiles() {
|
||||
String files = recentFiles.get();
|
||||
if (files == null || files.isEmpty()) {
|
||||
|
||||
@@ -63,19 +63,19 @@ public class FontHelper {
|
||||
Object fm = getFontManager();
|
||||
Class<?> clFm = Class.forName("sun.font.SunFontManager");
|
||||
|
||||
//Delete cached installed names
|
||||
// Delete cached installed names
|
||||
Field inField = clFm.getDeclaredField("installedNames");
|
||||
inField.setAccessible(true);
|
||||
inField.set(null, null);
|
||||
inField.setAccessible(false);
|
||||
|
||||
//Delete cached family names
|
||||
// Delete cached family names
|
||||
Field allFamField = clFm.getDeclaredField("allFamilies");
|
||||
allFamField.setAccessible(true);
|
||||
allFamField.set(fm, null);
|
||||
allFamField.setAccessible(false);
|
||||
|
||||
//Delete cached fonts
|
||||
// Delete cached fonts
|
||||
Field allFonField = clFm.getDeclaredField("allFonts");
|
||||
allFonField.setAccessible(true);
|
||||
allFonField.set(fm, null);
|
||||
@@ -93,7 +93,7 @@ public class FontHelper {
|
||||
List<String> javaFonts = Arrays.asList("Dialog", "DialogInput", "Monospaced", "Serif", "SansSerif");
|
||||
for (Font f : fonts) {
|
||||
String fam = f.getFamily(Locale.ENGLISH);
|
||||
//Do not want Java logical fonts
|
||||
// Do not want Java logical fonts
|
||||
if (javaFonts.contains(fam)) {
|
||||
continue;
|
||||
}
|
||||
@@ -107,6 +107,31 @@ public class FontHelper {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String fontToString(Font font) {
|
||||
int style = font.getStyle();
|
||||
String styleString;
|
||||
switch (style) {
|
||||
case 1:
|
||||
styleString = "Bold";
|
||||
break;
|
||||
case 2:
|
||||
styleString = "Italic";
|
||||
break;
|
||||
case 3:
|
||||
styleString = "BoldItalic";
|
||||
break;
|
||||
default:
|
||||
styleString = "Plain";
|
||||
break;
|
||||
}
|
||||
|
||||
return font.getName() + "-" + styleString + "-" + font.getSize();
|
||||
}
|
||||
|
||||
public static Font stringToFont(String fontString) {
|
||||
return Font.decode(fontString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets kerning offset for two characters of the font
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user