import ascent, descent leading

This commit is contained in:
Jindra Petřík
2021-03-05 21:22:55 +01:00
parent 91c6a5df2c
commit 3ec8ab1f91
10 changed files with 160 additions and 6 deletions
@@ -28,6 +28,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
@@ -38,6 +39,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.function.BiPredicate;
/**
@@ -621,4 +621,41 @@ public class DefineFont2Tag extends FontTag {
}
return kerningAdjustment;
}
@Override
public void setAscent(int ascent) {
if (fontFlagsHasLayout) {
fontAscent = ascent;
}
}
@Override
public void setDescent(int descent) {
if (fontFlagsHasLayout) {
fontDescent = descent;
}
}
@Override
public void setLeading(int leading) {
if (fontFlagsHasLayout) {
fontLeading = leading;
}
}
@Override
public void setHasLayout(boolean hasLayout) {
fontFlagsHasLayout = hasLayout;
if (hasLayout) {
if (fontAdvanceTable == null) {
fontAdvanceTable = new ArrayList<>();
}
if (fontBoundsTable == null) {
fontBoundsTable = new ArrayList<>();
}
if (fontKerningTable == null) {
fontKerningTable = new ArrayList<>();
}
}
}
}
@@ -637,4 +637,42 @@ public class DefineFont3Tag extends FontTag {
}
return kerningAdjustment;
}
@Override
public void setAscent(int ascent) {
if (fontFlagsHasLayout) {
fontAscent = ascent;
}
}
@Override
public void setDescent(int descent) {
if (fontFlagsHasLayout) {
fontDescent = descent;
}
}
@Override
public void setLeading(int leading) {
if (fontFlagsHasLayout) {
fontLeading = leading;
}
}
@Override
public void setHasLayout(boolean hasLayout) {
fontFlagsHasLayout = hasLayout;
if (hasLayout) {
if (fontAdvanceTable == null) {
fontAdvanceTable = new ArrayList<>();
}
if (fontBoundsTable == null) {
fontBoundsTable = new ArrayList<>();
}
if (fontKerningTable == null) {
fontKerningTable = new ArrayList<>();
}
}
}
}
@@ -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;
@@ -378,4 +379,20 @@ public class DefineFontTag extends FontTag {
public int getCharKerningAdjustment(char c1, char c2) {
return 0;
}
@Override
public void setAscent(int ascent) {
}
@Override
public void setDescent(int descent) {
}
@Override
public void setLeading(int leading) {
}
public void setHasLayout(boolean hasLayout) {
}
}
@@ -32,6 +32,7 @@ import com.jpexs.decompiler.flash.types.SHAPE;
import com.jpexs.decompiler.flash.types.TEXTRECORD;
import com.jpexs.decompiler.flash.types.shaperecords.SHAPERECORD;
import com.jpexs.helpers.ByteArrayRange;
import com.jpexs.helpers.Reference;
import com.jpexs.helpers.SerializableImage;
import java.awt.Color;
import java.awt.Font;
@@ -42,6 +43,7 @@ import java.awt.font.GlyphMetrics;
import java.awt.font.GlyphVector;
import java.awt.geom.Area;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -109,6 +111,14 @@ public abstract class FontTag extends DrawableTag implements AloneTag {
public abstract int getLeading();
public abstract void setAscent(int ascent);
public abstract void setDescent(int descent);
public abstract void setLeading(int leading);
public abstract void setHasLayout(boolean hasLayout);
public String getFontName() {
DefineFontNameTag fontNameTag = getFontNameTag();
if (fontNameTag == null) {
@@ -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.gfx;
import com.jpexs.decompiler.flash.SWF;
@@ -455,4 +456,23 @@ public final class DefineCompactedFont extends FontTag {
public boolean hasLayout() {
return true;
}
@Override
public void setAscent(int ascent) {
fonts.get(0).ascent = ascent;
}
@Override
public void setDescent(int descent) {
fonts.get(0).descent = descent;
}
@Override
public void setLeading(int leading) {
fonts.get(0).leading = leading;
}
@Override
public void setHasLayout(boolean hasLayout) {
}
}