mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-26 16:30:45 +00:00
loading list of fonts on demand - X11 load bug on Java9
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -1023,7 +1024,7 @@ public class DefineEditTextTag extends TextTag {
|
||||
|
||||
ge.glyphIndex = -1; // always use system character glyphs in edit text
|
||||
|
||||
String fontName = ge.fontFace != null ? ge.fontFace : FontTag.defaultFontName;
|
||||
String fontName = ge.fontFace != null ? ge.fontFace : FontTag.getDefaultFontName();
|
||||
int fontStyle = font == null ? ge.fontStyle : font.getFontStyle();
|
||||
ge.glyphAdvance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar));
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
@@ -121,14 +122,19 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
|
||||
return fontNameTag.fontCopyright;
|
||||
}
|
||||
|
||||
public static Map<String, Map<String, Font>> installedFontsByFamily;
|
||||
private static Map<String, Map<String, Font>> installedFontsByFamily;
|
||||
|
||||
public static Map<String, Font> installedFontsByName;
|
||||
private static Map<String, Font> installedFontsByName;
|
||||
|
||||
public static String defaultFontName;
|
||||
private static String defaultFontName;
|
||||
|
||||
static {
|
||||
reload();
|
||||
private static boolean firstLoaded = false;
|
||||
|
||||
private static void ensureLoaded() {
|
||||
if (!firstLoaded) {
|
||||
reload();
|
||||
}
|
||||
firstLoaded = true;
|
||||
}
|
||||
|
||||
public int getFontId() {
|
||||
@@ -259,6 +265,11 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
|
||||
return gm.getAdvanceX();
|
||||
}
|
||||
|
||||
public static String getDefaultFontName() {
|
||||
ensureLoaded();
|
||||
return defaultFontName;
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
installedFontsByFamily = FontHelper.getInstalledFonts();
|
||||
installedFontsByName = new HashMap<>();
|
||||
@@ -279,6 +290,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
|
||||
}
|
||||
|
||||
public static String getFontNameWithFallback(String fontName) {
|
||||
ensureLoaded();
|
||||
if (installedFontsByFamily.containsKey(fontName)) {
|
||||
return fontName;
|
||||
}
|
||||
@@ -307,6 +319,7 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
|
||||
}
|
||||
|
||||
public static String findInstalledFontName(String fontName) {
|
||||
ensureLoaded();
|
||||
if (installedFontsByName.containsKey(fontName)) {
|
||||
return fontName;
|
||||
}
|
||||
@@ -413,4 +426,15 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
|
||||
public FontTag toClassicFont() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Map<String, Map<String, Font>> getInstalledFontsByFamily() {
|
||||
ensureLoaded();
|
||||
return installedFontsByFamily;
|
||||
}
|
||||
|
||||
public static Map<String, Font> getInstalledFontsByName() {
|
||||
ensureLoaded();
|
||||
return installedFontsByName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-3
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags.base;
|
||||
|
||||
import java.awt.Font;
|
||||
@@ -30,10 +31,10 @@ public class MissingCharacterHandler {
|
||||
|
||||
public boolean handle(TextTag textTag, FontTag font, char character) {
|
||||
String fontName = font.getFontNameIntag();
|
||||
if (!FontTag.installedFontsByFamily.containsKey(fontName)) {
|
||||
if (!FontTag.getInstalledFontsByFamily().containsKey(fontName)) {
|
||||
return false;
|
||||
}
|
||||
Map<String, Font> faces = FontTag.installedFontsByFamily.get(fontName);
|
||||
Map<String, Font> faces = FontTag.getInstalledFontsByFamily().get(fontName);
|
||||
|
||||
Font f = null;
|
||||
for (String face : faces.keySet()) {
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.␍ */
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.xfl;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
@@ -2358,7 +2359,7 @@ public class XFLConverter {
|
||||
fontName = font.getFontNameIntag();
|
||||
}
|
||||
if (fontName == null) {
|
||||
fontName = FontTag.defaultFontName;
|
||||
fontName = FontTag.getDefaultFontName();
|
||||
}
|
||||
int fontStyle = font.getFontStyle();
|
||||
String installedFont;
|
||||
@@ -3035,7 +3036,7 @@ public class XFLConverter {
|
||||
fontName = font.getFontNameIntag();
|
||||
}
|
||||
if (fontName == null) {
|
||||
fontName = FontTag.defaultFontName;
|
||||
fontName = FontTag.getDefaultFontName();
|
||||
}
|
||||
int fontStyle = 0;
|
||||
if (font != null) {
|
||||
@@ -3197,7 +3198,7 @@ public class XFLConverter {
|
||||
fontName = ft.getFontNameIntag();
|
||||
}
|
||||
if (fontName == null) {
|
||||
fontName = FontTag.defaultFontName;
|
||||
fontName = FontTag.getDefaultFontName();
|
||||
}
|
||||
italic = ft.isItalic();
|
||||
bold = ft.isBold();
|
||||
@@ -3934,7 +3935,7 @@ public class XFLConverter {
|
||||
fontName = ft.getFontNameIntag();
|
||||
}
|
||||
if (fontName == null) {
|
||||
fontName = FontTag.defaultFontName;
|
||||
fontName = FontTag.getDefaultFontName();
|
||||
}
|
||||
italic = ft.isItalic();
|
||||
bold = ft.isBold();
|
||||
|
||||
Reference in New Issue
Block a user