From 76fc45efb7e307399a142c673cb240019e7ebfb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Thu, 18 Nov 2021 15:58:20 +0100 Subject: [PATCH] Fixed DefineEditText when font has no layout (ascent/descent) --- .../jpexs/decompiler/flash/tags/DefineEditTextTag.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java index dbef29f39..a87fb2821 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineEditTextTag.java @@ -1051,7 +1051,7 @@ public class DefineEditTextTag extends TextTag { String fontName = ge.fontFace != null ? ge.fontFace : FontTag.getDefaultFontName(); int fontStyle = font == null ? ge.fontStyle : font.getFontStyle(); - ge.glyphAdvance = font == null ? (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar)) + ge.glyphAdvance = ge.glyphIndex == -1 ? (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar)) : (int) Math.round(font.getGlyphAdvance(ge.glyphIndex) / font.getDivider() * lastStyle.fontHeight / 1024); textModel.addGlyph(c, ge); @@ -1133,10 +1133,12 @@ public class DefineEditTextTag extends TextTag { } else { for (SameStyleTextRecord tr : line) { width += tr.width; - int lineHeight = (int) Math.round(tr.style.fontHeight * tr.style.font.getAscent() / tr.style.font.getDivider() / 1024.0) + tr.style.fontLeading; - if (tr.style.font != null && !firstLine) { + int lineHeight = tr.style.font.hasLayout() ? (int) Math.round(tr.style.fontHeight * tr.style.font.getAscent() / tr.style.font.getDivider() / 1024.0) + tr.style.fontLeading + : tr.style.fontHeight + tr.style.fontLeading; + if (tr.style.font != null && !firstLine && tr.style.font.hasLayout()) { lineHeight += (int) Math.round(tr.style.fontHeight * tr.style.font.getDescent() / tr.style.font.getDivider() / 1024.0); } + //TODO: maybe get ascent/descent from system font when not haslayout lastHeight = lineHeight; if (lineHeight > currentOffset) { currentOffset = lineHeight;