org.jpedal.fonts.EncodingSJIS Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of OpenViewerFX Show documentation
Show all versions of OpenViewerFX Show documentation
Open Source (LGPL) JavaFX PDF Viewer
/*
* ===========================================
* Java Pdf Extraction Decoding Access Library
* ===========================================
*
* Project Info: http://www.idrsolutions.com
* Help section for developers at http://www.idrsolutions.com/support/
*
* (C) Copyright 1997-2017 IDRsolutions and Contributors.
*
* This file is part of JPedal/JPDF2HTML5
*
@LICENSE@
*
* ---------------
* EncodingSJIS.java
* ---------------
*/
package org.jpedal.fonts;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import org.jpedal.utils.LogWriter;
public class EncodingSJIS implements CmapEncoding {
private final int[] uniMap = new int[65536];
public EncodingSJIS() {
final ClassLoader loader = this.getClass().getClassLoader();
String line;
int rawVal, unicodeVal;
final BufferedReader input_stream;
try {
input_stream = new BufferedReader(
new InputStreamReader(loader.getResourceAsStream("org/jpedal/res/pdf/jis.cfg")));
while (true) {
line = input_stream.readLine();
if (line == null) {
break;
}
if (line.startsWith("0") && line.contains("#")) {
final StringTokenizer values = new StringTokenizer(line);
final String xx = values.nextToken().substring(2);
rawVal = Integer.parseInt(xx, 16);
unicodeVal = Integer.parseInt(values.nextToken().substring(2), 16); //unicode
uniMap[rawVal] = unicodeVal;
}
}
input_stream.close();
} catch (final Exception e) {
LogWriter.writeLog("Exception: " + e.getMessage());
}
}
@Override
public int getUnicodeValue(final int cid) {
return uniMap[cid];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy