put advances back as were,

fix font data size
This commit is contained in:
Jindra Petřík
2016-12-03 09:32:43 +01:00
parent 91dabac158
commit 72af4e6e93
3 changed files with 9 additions and 15 deletions

View File

@@ -14,35 +14,29 @@ import java.util.List;
public class IggyCharAdvances implements StructureInterface {
List<Float> advances;
private List<IggyShape> glyphs;
private long charCount;
public List<Float> getScales() {
return advances;
}
public IggyCharAdvances(ReadDataStreamInterface stream, List<IggyShape> glyphs) throws IOException {
this.glyphs = glyphs;
public IggyCharAdvances(ReadDataStreamInterface stream, long charCount) throws IOException {
this.charCount = charCount;
readFromDataStream(stream);
}
@Override
public void readFromDataStream(ReadDataStreamInterface stream) throws IOException {
advances = new ArrayList<>();
for (int i = 0; i < glyphs.size(); i++) {
if (glyphs.get(i) != null) {
advances.add(stream.readFloat());
} else {
advances.add(null);
}
for (int i = 0; i < charCount; i++) {
advances.add(stream.readFloat());
}
}
@Override
public void writeToDataStream(WriteDataStreamInterface stream) throws IOException {
for (int i = 0; i < advances.size(); i++) {
if (advances.get(i) != null) {
stream.writeFloat(advances.get(i));
}
stream.writeFloat(advances.get(i));
}
}
}

View File

@@ -285,7 +285,7 @@ public class IggyFont extends IggyTag {
}
if (abs_start_of_scale != 0) {
s.seek(abs_start_of_scale, SeekMode.SET);
charScales = new IggyCharAdvances(s, glyphs);
charScales = new IggyCharAdvances(s, char_count);
}
if (abs_start_of_kern != 0) {
s.seek(abs_start_of_kern, SeekMode.SET);

View File

@@ -114,7 +114,7 @@ public class IggySwf implements StructureInterface {
if (next_offset == 1) {
font_data_sizes[i] = hdr.getFontEndAddress() - font_data_addresses[i];
} else {
font_data_sizes[i] = next_offset - offset;
font_data_sizes[i] = next_offset - offset + 8;
}
}
while (true) {
@@ -130,7 +130,7 @@ public class IggySwf implements StructureInterface {
text_data_sizes.add(hdr.getFontEndAddress() - text_addr);
break;
} else {
text_data_sizes.add(next_offset - offset);
text_data_sizes.add(next_offset - offset + 8);
}
}
s.readUI64(); //1