#1303 garbled text when exporting frame with text

This commit is contained in:
honfika@gmail.com
2016-12-02 15:13:31 +01:00
parent bed526c14b
commit f2f03b18ad
4 changed files with 15 additions and 18 deletions

View File

@@ -381,7 +381,6 @@ public class DefineEditTextTag extends TextTag {
try {
saxParser = factory.newSAXParser();
DefaultHandler handler = new DefaultHandler() {
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
TextStyle style = styles.peek();
@@ -999,26 +998,23 @@ public class DefineEditTextTag extends TextTag {
if (i + 1 < txt.size()) {
nextChar = txt.get(i + 1).character;
}
int advance;
FontTag font = lastStyle.font;
DynamicTextGlyphEntry ge = new DynamicTextGlyphEntry();
ge.fontFace = lastStyle.fontFace;
if (ge.fontFace == null && font != null) {
ge.fontFace = font.getFontName();
}
ge.fontStyle = (lastStyle.bold ? Font.BOLD : 0) | (lastStyle.italic ? Font.ITALIC : 0);
ge.character = c;
ge.glyphIndex = font == null ? -1 : font.charToGlyph(c);
if (font != null && font.hasLayout()) {
int kerningAdjustment = 0;
if (nextChar != null) {
kerningAdjustment = font.getCharKerningAdjustment(c, nextChar);
kerningAdjustment /= font.getDivider();
}
advance = (int) Math.round(Math.round((double) lastStyle.fontHeight * (font.getGlyphAdvance(ge.glyphIndex) + kerningAdjustment) / (font.getDivider() * 1024.0)));
} else {
String fontName = lastStyle.fontFace != null ? lastStyle.fontFace : FontTag.defaultFontName;
int fontStyle = font == null ? ge.fontStyle : font.getFontStyle();
advance = (int) Math.round(SWF.unitDivisor * FontTag.getSystemFontAdvance(fontName, fontStyle, (int) (lastStyle.fontHeight / SWF.unitDivisor), c, nextChar));
}
ge.glyphAdvance = advance;
ge.glyphIndex = -1; // always use system character glyphs in edit text
String fontName = ge.fontFace != null ? ge.fontFace : FontTag.defaultFontName;
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));
textModel.addGlyph(c, ge);
if (Character.isWhitespace(c)) {
lastWasWhiteSpace = true;

View File

@@ -497,7 +497,7 @@ public abstract class TextTag extends DrawableTag {
DynamicTextGlyphEntry dynamicEntry = (DynamicTextGlyphEntry) entry;
if (dynamicEntry.fontFace != null) {
FontTag fnt = swf.getFontByName(dynamicEntry.fontFace);
if (fnt != null) {
if (fnt != null && entry.glyphIndex != -1) {
shape = fnt.getGlyphShapeTable().get(entry.glyphIndex);
} else {
shape = SHAPERECORD.fontCharacterToSHAPE(new Font(dynamicEntry.fontFace, dynamicEntry.fontStyle, 12), (int) Math.round(divider * 1024), dynamicEntry.character);