1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.pdfbox.encoding.conversion; 18 19 import java.util.HashMap; 20 21 /** 22 * This class provides a mapping from char code to unicode mapping files used for CJK-encoding. 23 * @author Andreas Lehmkühler 24 * @version $Revision: 1.0 $ 25 * 26 */ 27 28 public class CMapSubstitution 29 { 30 31 private static HashMap<String,String> cmapSubstitutions = new HashMap<String,String>(); 32 33 private CMapSubstitution() 34 { 35 } 36 37 static 38 { 39 // I don't know if these mappings are complete. Perhaps there 40 // has to be added still one or more 41 42 // chinese simplified 43 cmapSubstitutions.put( "Adobe-GB1-4", "Adobe-GB1-UCS2" ); 44 cmapSubstitutions.put( "GBK-EUC-H", "GBK-EUC-UCS2" ); 45 cmapSubstitutions.put( "GBK-EUC-V", "GBK-EUC-UCS2" ); 46 cmapSubstitutions.put( "GBpc-EUC-H", "GBpc-EUC-UCS2C" ); 47 cmapSubstitutions.put( "GBpc-EUC-V", "GBpc-EUC-UCS2C" ); 48 49 // chinese traditional 50 cmapSubstitutions.put( "Adobe-CNS1-4", "Adobe-CNS1-UCS2" ); 51 cmapSubstitutions.put( "B5pc-H", "B5pc-UCS2" ); 52 cmapSubstitutions.put( "B5pc-V", "B5pc-UCS2" ); 53 cmapSubstitutions.put( "ETen-B5-H", "ETen-B5-UCS2" ); 54 cmapSubstitutions.put( "ETen-B5-V", "ETen-B5-UCS2" ); 55 cmapSubstitutions.put( "ETenms-B5-H", "ETen-B5-UCS2" ); 56 cmapSubstitutions.put( "ETenms-B5-V", "ETen-B5-UCS2" ); 57 58 // japanese 59 cmapSubstitutions.put( "90ms-RKSJ-H", "90ms-RKSJ-UCS2" ); 60 cmapSubstitutions.put( "90ms-RKSJ-V", "90ms-RKSJ-UCS2" ); 61 cmapSubstitutions.put( "90msp-RKSJ-H", "90ms-RKSJ-UCS2" ); 62 cmapSubstitutions.put( "90msp-RKSJ-V", "90ms-RKSJ-UCS2" ); 63 cmapSubstitutions.put( "90pv-RKSJ-H", "90pv-RKSJ-UCS2"); 64 cmapSubstitutions.put( "UniJIS-UCS2-HW-H", "UniJIS-UCS2-H" ); 65 cmapSubstitutions.put( "Adobe-Japan1-4", "Adobe-Japan1-UCS2"); 66 67 } 68 69 /** 70 * 71 * @param cmapName The name of a cmap for which we have to find a possible substitution 72 * @return the substitution for the given cmap name 73 */ 74 public static String substituteCMap(String cmapName) 75 { 76 if (cmapSubstitutions.containsKey(cmapName)) 77 { 78 return (String)cmapSubstitutions.get(cmapName); 79 } 80 return cmapName; 81 } 82 }