@@ -154,9 +154,9 @@ public class PdfType0Font extends PdfFont {
154
154
newFont = false ;
155
155
PdfDictionary cidFont = fontDictionary .getAsArray (PdfName .DescendantFonts ).getAsDictionary (0 );
156
156
PdfObject cmap = fontDictionary .get (PdfName .Encoding );
157
+ PdfObject toUnicode = fontDictionary .get (PdfName .ToUnicode );
158
+ CMapToUnicode toUnicodeCMap = FontUtil .processToUnicode (toUnicode );
157
159
if (cmap .isName () && (PdfEncodings .IDENTITY_H .equals (((PdfName )cmap ).getValue ()) || PdfEncodings .IDENTITY_V .equals (((PdfName )cmap ).getValue ()))) {
158
- PdfObject toUnicode = fontDictionary .get (PdfName .ToUnicode );
159
- CMapToUnicode toUnicodeCMap = FontUtil .processToUnicode (toUnicode );
160
160
if (toUnicodeCMap == null ) {
161
161
String uniMap = getUniMapFromOrdering (getOrdering (cidFont ));
162
162
toUnicodeCMap = FontUtil .getToUnicodeFromUniMap (uniMap );
@@ -173,8 +173,7 @@ public class PdfType0Font extends PdfFont {
173
173
} else {
174
174
String cidFontName = cidFont .getAsName (PdfName .BaseFont ).getValue ();
175
175
String uniMap = getUniMapFromOrdering (getOrdering (cidFont ));
176
- if (uniMap != null && uniMap .startsWith ("Uni" )
177
- && CidFontProperties .isCidFont (cidFontName , uniMap )) {
176
+ if (uniMap != null && uniMap .startsWith ("Uni" ) && CidFontProperties .isCidFont (cidFontName , uniMap )) {
178
177
try {
179
178
fontProgram = FontProgramFactory .createFont (cidFontName );
180
179
cmapEncoding = createCMap (cmap , uniMap );
@@ -184,7 +183,9 @@ public class PdfType0Font extends PdfFont {
184
183
cmapEncoding = null ;
185
184
}
186
185
} else {
187
- CMapToUnicode toUnicodeCMap = FontUtil .getToUnicodeFromUniMap (uniMap );
186
+ if (toUnicodeCMap == null ) {
187
+ toUnicodeCMap = FontUtil .getToUnicodeFromUniMap (uniMap );
188
+ }
188
189
if (toUnicodeCMap != null ) {
189
190
fontProgram = DocTrueTypeFont .createFontProgram (cidFont , toUnicodeCMap );
190
191
cmapEncoding = createCMap (cmap , uniMap );
0 commit comments