advances fix

This commit is contained in:
Jindra Petřík
2016-12-03 09:22:03 +01:00
parent d6d350bee8
commit 91dabac158
3 changed files with 25 additions and 11 deletions

View File

@@ -14,29 +14,35 @@ import java.util.List;
public class IggyCharAdvances implements StructureInterface {
List<Float> advances;
private long charCount;
private List<IggyShape> glyphs;
public List<Float> getScales() {
return advances;
}
public IggyCharAdvances(ReadDataStreamInterface stream, long charCount) throws IOException {
this.charCount = charCount;
public IggyCharAdvances(ReadDataStreamInterface stream, List<IggyShape> glyphs) throws IOException {
this.glyphs = glyphs;
readFromDataStream(stream);
}
@Override
public void readFromDataStream(ReadDataStreamInterface stream) throws IOException {
advances = new ArrayList<>();
for (int i = 0; i < charCount; i++) {
advances.add(stream.readFloat());
for (int i = 0; i < glyphs.size(); i++) {
if (glyphs.get(i) != null) {
advances.add(stream.readFloat());
} else {
advances.add(null);
}
}
}
@Override
public void writeToDataStream(WriteDataStreamInterface stream) throws IOException {
for (int i = 0; i < advances.size(); i++) {
stream.writeFloat(advances.get(i));
if (advances.get(i) != null) {
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, char_count);
charScales = new IggyCharAdvances(s, glyphs);
}
if (abs_start_of_kern != 0) {
s.seek(abs_start_of_kern, SeekMode.SET);
@@ -366,14 +366,15 @@ public class IggyFont extends IggyTag {
s.writeUI64(0); //pad zero
if (abs_start_of_char_struct != 0) {
s.seek(abs_start_of_char_struct, SeekMode.SET);
long baseOfsAddr = s.position();
//offsets of shapes
for (IggyCharOffset ofs : charOffsets) {
ofs.writeToDataStream(s);
}
//long afterOfsAddr = s.position();
for (int i = 0; i < glyphs.size(); i++) {
IggyShape shp = glyphs.get(i);
if (shp != null) {
s.seek(charOffsets.get(i).getAddress(), SeekMode.SET);
shp.writeToDataStream(s);
}
}

View File

@@ -62,7 +62,11 @@ public class IggySwf implements StructureInterface {
newData = stream.getAllBytes();
newLen = newData.length;
}
long oldLen = font_data_sizes[fontIndex];
//FIXME
Helper.writeFile("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_new\\font" + fontIndex + ".bin", newData);
/* long oldLen = font_data_sizes[fontIndex];
long diff = newLen - oldLen;
if (diff != 0) {
font_data_sizes[fontIndex] = newLen;
@@ -77,7 +81,7 @@ public class IggySwf implements StructureInterface {
}
}
hdr.insertGapAfter(font_data_addresses[fontIndex], diff);
*/
}
@Override
@@ -154,7 +158,10 @@ public class IggySwf implements StructureInterface {
fonts = new HashMap<>();
for (int i = 0; i < hdr.font_count; i++) {
s.seek(font_data_addresses[i], SeekMode.SET);
//byte font_data[] = s.readBytes((int) font_data_sizes[i]);
byte font_data[] = s.readBytes((int) font_data_sizes[i]);
//FIXME
Helper.writeFile("d:\\Dropbox\\jpexs-laptop\\iggi\\extraxtdir_orig\\font" + i + ".bin", font_data);
s.seek(-font_data_sizes[i], SeekMode.CUR);
IggyFont font = new IggyFont(s);
fonts.put(i, font);
}