org.jpedal.fonts.EncodingISO2022JP 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@
*
* ---------------
* EncodingISO2022JP.java
* ---------------
*/
package org.jpedal.fonts;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import org.jpedal.utils.LogWriter;
public class EncodingISO2022JP implements CmapEncoding {
private final int[] uniMap = new int[65536];
public EncodingISO2022JP() {
final ClassLoader loader = this.getClass().getClassLoader();
String line;
int gbkVal, unicodeVal;
final BufferedReader input_stream;
String xx, yy;
try {
input_stream = new BufferedReader(
new InputStreamReader(loader.getResourceAsStream("org/jpedal/res/pdf/ISO2022JPtoUNI.cfg")));
while (true) {
line = input_stream.readLine();
if (line == null) {
break;
}
if (line.startsWith("0x")) {
final StringTokenizer values = new StringTokenizer(line);
xx = values.nextToken().substring(2);
yy = values.nextToken().substring(2);
unicodeVal = Integer.parseInt(yy, 16);
gbkVal = Integer.parseInt(xx, 16);
uniMap[gbkVal] = unicodeVal;
}
}
input_stream.close();
} catch (final Exception e) {
LogWriter.writeLog("Exception: " + e.getMessage());
}
}
@Override
public int getUnicodeValue(final int cid) {
if (cid >= 0 && cid <= 0x7f) {
return cid;
}
return uniMap[cid];
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy