Skip to content

Commit

Permalink
Remove font issue workaround, workaround already in cpp code
Browse files Browse the repository at this point in the history
  • Loading branch information
ViliusSutkus89 committed Aug 5, 2024
1 parent d863c76 commit f9a7e9f
Showing 1 changed file with 0 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@
import com.getkeepsafe.relinker.ReLinker;
import com.viliussutkus89.android.assetextractor.AssetExtractor;

import java.io.BufferedInputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;


@SuppressWarnings("unused")
Expand Down Expand Up @@ -181,37 +175,6 @@ public File convert() throws IOException, ConversionFailedException {

int retVal = NativeConverter.convert(nc.mConverter);
if (0 == retVal) {
// Workaround for https://github.com/opendocument-app/pdf2htmlEX-Android/issues/94
// Workaround for https://github.com/opendocument-app/OpenDocument.droid/issues/348
byte[] needle = "{font-family:sans-serif;visibility:hidden;}".getBytes(StandardCharsets.UTF_8);
byte[] replacement = "{font-family:sans-serif;visibility:visible}".getBytes(StandardCharsets.UTF_8);
List<Long> needlePositions = new LinkedList<>();
try (FileInputStream fis = new FileInputStream(outputFile)) {
try (BufferedInputStream bis = new BufferedInputStream(fis)) {
long totalRead = 0;
int matchedNeedle = 0;
byte[] buffer = new byte[1];
while (1 == bis.read(buffer)) {
if (buffer[0] == needle[matchedNeedle]) {
if (++matchedNeedle == needle.length) {
needlePositions.add(totalRead - needle.length + 1);
matchedNeedle = 0;
}
} else {
matchedNeedle = 0;
}
totalRead++;
}
}
}
if (!needlePositions.isEmpty()) {
try (RandomAccessFile raf = new RandomAccessFile(outputFile, "rw")) {
for (long i : needlePositions) {
raf.seek(i);
raf.write(replacement, 0, replacement.length);
}
}
}
return outputFile;
}

Expand Down

0 comments on commit f9a7e9f

Please sign in to comment.