shape bound calculation fixed

This commit is contained in:
honfika@gmail.com
2014-12-23 13:15:18 +01:00
parent 04ca818045
commit 12395a13d4
4 changed files with 36 additions and 22 deletions

View File

@@ -99,7 +99,10 @@ public class DefineFont2Tag extends FontTag {
@Override
public RECT getGlyphBounds(int glyphIndex) {
return fontBoundsTable.get(glyphIndex);
if (fontFlagsHasLayout) {
return fontBoundsTable.get(glyphIndex);
}
return super.getGlyphBounds(glyphIndex);
}
@Override

View File

@@ -472,7 +472,10 @@ public class DefineFont3Tag extends FontTag {
@Override
public RECT getGlyphBounds(int glyphIndex) {
return fontBoundsTable.get(glyphIndex);
if (fontFlagsHasLayout) {
return fontBoundsTable.get(glyphIndex);
}
return super.getGlyphBounds(glyphIndex);
}
@Override

View File

@@ -316,6 +316,13 @@ public abstract class TextTag extends CharacterTag implements DrawableTag {
// shapeNum: 1
SHAPE shape = glyphs.get(entry.glyphIndex);
BitmapExporter.export(swf, shape, textColor2, image, mat, colorTransform);
if (SHAPERECORD.DRAW_BOUNDING_BOX){
RGB borderColor = new RGBA(Color.black);
RGB fillColor = new RGBA(new Color(255, 255, 255, 0));
RECT bounds = shape.getBounds();
mat = Matrix.getTranslateInstance(bounds.Xmin, bounds.Ymin).preConcatenate(mat);
TextTag.drawBorder(swf, image, borderColor, fillColor, bounds, new MATRIX(), mat, colorTransform);
}
x += entry.glyphAdvance;
}
}

View File

@@ -50,7 +50,7 @@ import java.util.Set;
public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Serializable {
public static final int MAX_CHARACTERS_IN_FONT_PREVIEW = 400;
private static final boolean DRAW_BOUNDING_BOX = false;
public static final boolean DRAW_BOUNDING_BOX = false;
public abstract void calculateBits();
@@ -78,25 +78,6 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
int min_y = Integer.MAX_VALUE;
boolean started = false;
for (SHAPERECORD r : records) {
x = r.changeX(x);
y = r.changeY(y);
if (x > max_x) {
max_x = x;
}
if (y > max_y) {
max_y = y;
}
if (r.isMove()) {
started = true;
}
if (started) {
if (y < min_y) {
min_y = y;
}
if (x < min_x) {
min_x = x;
}
}
if (r instanceof CurvedEdgeRecord) {
CurvedEdgeRecord curverEdge = (CurvedEdgeRecord) r;
int x2 = x + curverEdge.controlDeltaX;
@@ -116,6 +97,26 @@ public abstract class SHAPERECORD implements Cloneable, NeedsCharacters, Seriali
}
}
}
x = r.changeX(x);
y = r.changeY(y);
if (x > max_x) {
max_x = x;
}
if (y > max_y) {
max_y = y;
}
if (r.isMove()) {
started = true;
}
if (started) {
if (y < min_y) {
min_y = y;
}
if (x < min_x) {
min_x = x;
}
}
}
return new RECT(min_x, max_x, min_y, max_y);
}