Fixed: #2332 Imported fonts by class name not available in texts

This commit is contained in:
Jindra Petřík
2024-09-29 00:07:22 +02:00
parent fd5d0cb2f2
commit cf585c51fb
8 changed files with 64 additions and 21 deletions

View File

@@ -1270,13 +1270,11 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
if (fontClass == null) {
return null;
}
for (Tag t : getTags()) {
if (t instanceof FontTag) {
if (((FontTag) t).getClassNames().contains(fontClass)) {
return (FontTag) t;
}
}
CharacterTag t = getCharacterByClass(fontClass);
if (t instanceof FontTag) {
return (FontTag) t;
}
return null;
}
@@ -1290,7 +1288,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
if (fontName == null) {
return null;
}
for (Tag t : getTags()) {
for (Tag t : getCharacters(true).values()) {
if (t instanceof FontTag) {
if (fontName.equals(((FontTag) t).getFontName())) {
return (FontTag) t;
@@ -1313,7 +1311,7 @@ public final class SWF implements SWFContainerItem, Timelined, Openable {
if (fontName == null) {
return null;
}
for (Tag t : getTags()) {
for (Tag t : getCharacters(true).values()) {
if (t instanceof FontTag) {
FontTag ft = (FontTag) t;
if (fontName.equals(ft.getFontNameIntag()) && ft.isBold() == bold && ft.isItalic() == italic) {

View File

@@ -582,7 +582,7 @@ public class DualPdfGraphics2D extends Graphics2D implements BlendModeSetable, G
}
if (rec.styleFlagsHasFont) {
font = swf.getFont(rec.fontId);
font = rec.getFont(swf);
textHeight = rec.textHeight;
}
if (rec.styleFlagsHasXOffset) {

View File

@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.tags.base.MissingCharacterHandler;
import com.jpexs.decompiler.flash.tags.base.RenderContext;
import com.jpexs.decompiler.flash.tags.base.TextTag;
import com.jpexs.decompiler.flash.tags.dynamictext.AdvancedTextRecord;
import com.jpexs.decompiler.flash.tags.dynamictext.CharacterWithStyle;
import com.jpexs.decompiler.flash.tags.dynamictext.DynamicTextModel;
import com.jpexs.decompiler.flash.tags.dynamictext.GlyphCharacter;
@@ -1281,13 +1282,10 @@ public class DefineEditTextTag extends TextTag {
tr.xOffset += currentIndent;
}
for (SameStyleTextRecord tr : line) {
TEXTRECORD tr2 = new TEXTRECORD();
AdvancedTextRecord tr2 = new AdvancedTextRecord();
int fid = fontId;
if (fontClass != null) {
FontTag ft = swf.getFontByClass(fontClass);
if (ft != null) {
fid = swf.getCharacterId(ft);
}
tr2.fontClass = fontClass;
}
if (tr.style.font != null) {
fid = swf.getCharacterId(tr.style.font);

View File

@@ -218,7 +218,7 @@ public abstract class TextTag extends DrawableTag {
for (TEXTRECORD tr : textRecords) {
if (tr.styleFlagsHasFont) {
FontTag font2 = swf.getFont(tr.fontId);
FontTag font2 = tr.getFont(swf);
if (font2 != null) {
font = font2;
}
@@ -329,7 +329,7 @@ public abstract class TextTag extends DrawableTag {
for (int r = 0; r < list.size(); r++) {
TEXTRECORD rec = list.get(r);
if (rec.styleFlagsHasFont) {
FontTag font2 = swf.getFont(rec.fontId);
FontTag font2 = rec.getFont(swf);
if (font2 != null) {
font = font2;
}
@@ -603,7 +603,7 @@ public abstract class TextTag extends DrawableTag {
}
}
if (rec.styleFlagsHasFont) {
FontTag font2 = swf.getFont(rec.fontId);
FontTag font2 = rec.getFont(swf);
if (font2 != null) {
font = font2;
}
@@ -681,7 +681,7 @@ public abstract class TextTag extends DrawableTag {
ExportRectangle result = null;
for (TEXTRECORD rec : textRecords) {
if (rec.styleFlagsHasFont) {
font = swf.getFont(rec.fontId);
font = rec.getFont(swf);
glyphs = font == null ? null : font.getGlyphShapeTable();
textHeight = rec.textHeight;
}
@@ -795,7 +795,7 @@ public abstract class TextTag extends DrawableTag {
}
}
if (rec.styleFlagsHasFont) {
font = swf.getFont(rec.fontId);
font = rec.getFont(swf);
fontId = rec.fontId;
glyphs = font.getGlyphShapeTable();
textHeight = rec.textHeight;
@@ -855,7 +855,7 @@ public abstract class TextTag extends DrawableTag {
}
}
if (rec.styleFlagsHasFont) {
font = swf.getFont(rec.fontId);
font = rec.getFont(swf);
glyphs = font.getGlyphShapeTable();
textHeight = rec.textHeight;
}

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2010-2024 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.tags.dynamictext;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.base.FontTag;
import com.jpexs.decompiler.flash.types.TEXTRECORD;
/**
*
* @author JPEXS
*/
public class AdvancedTextRecord extends TEXTRECORD {
public String fontClass = null;
@Override
public FontTag getFont(SWF swf) {
if (fontClass != null) {
return swf.getFontByClass(fontClass);
}
return super.getFont(swf);
}
}

View File

@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.types;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.tags.DefineText2Tag;
import com.jpexs.decompiler.flash.tags.DefineTextTag;
import com.jpexs.decompiler.flash.tags.base.FontTag;
@@ -122,4 +123,11 @@ public class TEXTRECORD implements Serializable {
}
return width;
}
public FontTag getFont(SWF swf) {
if (fontId == -1) {
return null;
}
return swf.getFont(fontId);
}
}

View File

@@ -4311,7 +4311,7 @@ public class XFLConverter {
for (TEXTRECORD rec : textRecords) {
if (rec.styleFlagsHasFont) {
FontTag ft = swf.getFont(rec.fontId);
FontTag ft = rec.getFont(swf);
if (ft != null && ft.isSmall()) {
fontRenderingMode = "bitmap";
break;