parse "face" attributes of font tags in DefineEditTag, and render the text when glyph is not found in swf, too

This commit is contained in:
honfika@gmail.com
2015-05-15 12:57:04 +02:00
parent acd2673226
commit 357d35ed17
4 changed files with 1197 additions and 1143 deletions

View File

@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.tags.text.JustifyAlignGlyphEntry;
import com.jpexs.decompiler.flash.tags.text.TextAlign;
import com.jpexs.decompiler.flash.tags.text.TextParseException;
import com.jpexs.decompiler.flash.types.ColorTransform;
import com.jpexs.decompiler.flash.types.DynamicTextGlyphEntry;
import com.jpexs.decompiler.flash.types.FILLSTYLE;
import com.jpexs.decompiler.flash.types.FILLSTYLEARRAY;
import com.jpexs.decompiler.flash.types.GLYPHENTRY;
@@ -424,7 +425,8 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
y = rec.yOffset;
}
double rat = textHeight / 1024.0 / (font == null ? 1 : font.getDivider());
double divider = font == null ? 1 : font.getDivider();
double rat = textHeight / 1024.0 / divider;
Color textColor2 = new Color(textColor, true);
for (GLYPHENTRY entry : rec.glyphEntries) {
@@ -433,9 +435,18 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
Matrix matTr = Matrix.getTranslateInstance(x, y);
mat = mat.concatenate(matTr);
mat = mat.concatenate(Matrix.getScaleInstance(rat));
SHAPE shape = null;
if (entry.glyphIndex != -1 && glyphs != null) {
// shapeNum: 1
SHAPE shape = glyphs.get(entry.glyphIndex);
shape = glyphs.get(entry.glyphIndex);
} else if (entry instanceof DynamicTextGlyphEntry) {
DynamicTextGlyphEntry dynamicEntry = (DynamicTextGlyphEntry) entry;
if (dynamicEntry.fontFace != null) {
shape = SHAPERECORD.fontCharacterToSHAPE(new Font(dynamicEntry.fontFace, dynamicEntry.fontStyle, 12), (int) Math.round(divider * 1024), dynamicEntry.character);
}
}
if (shape != null) {
BitmapExporter.export(swf, shape, textColor2, image, mat, colorTransform);
if (SHAPERECORD.DRAW_BOUNDING_BOX) {
RGB borderColor = new RGBA(Color.black);
@@ -444,8 +455,9 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
mat = Matrix.getTranslateInstance(bounds.Xmin, bounds.Ymin).preConcatenate(mat);
TextTag.drawBorder(swf, image, borderColor, fillColor, bounds, new MATRIX(), mat, colorTransform);
}
x += entry.glyphAdvance;
}
x += entry.glyphAdvance;
}
}
}

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 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.
* License along with this library.
*/
package com.jpexs.decompiler.flash.tags.dynamictext;
import com.jpexs.decompiler.flash.tags.base.FontTag;
@@ -27,6 +28,8 @@ public final class TextStyle implements Cloneable {
public FontTag font;
public String fontFace;
public int fontHeight;
public int fontLeading;

View File

@@ -0,0 +1,30 @@
/*
* Copyright (C) 2010-2015 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.types;
/**
*
* @author JPEXS
*/
public class DynamicTextGlyphEntry extends GLYPHENTRY {
public String fontFace;
public int fontStyle;
public char character;
}