@@ -23,7 +23,6 @@ This file is part of the iText (R) project.
23
23
package com .itextpdf .io .font ;
24
24
25
25
import com .itextpdf .io .exceptions .IOException ;
26
- import com .itextpdf .io .font .cmap .CMapCidUni ;
27
26
import com .itextpdf .io .font .cmap .CMapUniCid ;
28
27
import com .itextpdf .io .font .otf .Glyph ;
29
28
import com .itextpdf .io .util .IntHashtable ;
@@ -35,27 +34,20 @@ This file is part of the iText (R) project.
35
34
36
35
public class CidFont extends FontProgram {
37
36
38
-
39
37
private String fontName ;
40
38
private int pdfFontFlags ;
41
39
private Set <String > compatibleCmaps ;
42
40
43
- CidFont (String fontName , Set <String > cmaps ) {
41
+ CidFont (String fontName , String cmap , Set <String > compatibleCmaps ) {
44
42
this .fontName = fontName ;
45
- compatibleCmaps = cmaps ;
43
+ this . compatibleCmaps = compatibleCmaps ;
46
44
fontNames = new FontNames ();
47
45
initializeCidFontNameAndStyle (fontName );
48
46
Map <String , Object > fontDesc = CidFontProperties .getAllFonts ().get (fontNames .getFontName ());
49
47
if (fontDesc == null ) {
50
48
throw new IOException ("There is no such predefined font: {0}" ).setMessageParams (fontName );
51
49
}
52
- initializeCidFontProperties (fontDesc );
53
- }
54
-
55
- CidFont (String fontName , Set <String > cmaps , Map <String , Object > fontDescription ) {
56
- initializeCidFontNameAndStyle (fontName );
57
- initializeCidFontProperties (fontDescription );
58
- compatibleCmaps = cmaps ;
50
+ initializeCidFontProperties (fontDesc , cmap );
59
51
}
60
52
61
53
public boolean compatibleWith (String cmap ) {
@@ -97,7 +89,7 @@ private void initializeCidFontNameAndStyle(String fontName) {
97
89
fontNames .setFullName (new String [][]{new String []{"" , "" , "" , fontNames .getFontName ()}});
98
90
}
99
91
100
- private void initializeCidFontProperties (Map <String , Object > fontDesc ) {
92
+ private void initializeCidFontProperties (Map <String , Object > fontDesc , String cmap ) {
101
93
fontIdentification .setPanose ((String ) fontDesc .get ("Panose" ));
102
94
fontMetrics .setItalicAngle (Integer .parseInt ((String ) fontDesc .get ("ItalicAngle" )));
103
95
fontMetrics .setCapHeight (Integer .parseInt ((String ) fontDesc .get ("CapHeight" )));
@@ -113,10 +105,10 @@ private void initializeCidFontProperties(Map<String, Object> fontDesc) {
113
105
int ury = Integer .parseInt (tk .nextToken ());
114
106
fontMetrics .updateBbox (llx , lly , urx , ury );
115
107
registry = (String ) fontDesc .get ("Registry" );
116
- String uniMap = getCompatibleUniMap (registry );
108
+ String uniMap = getCompatibleUniMap (registry , cmap );
117
109
if (uniMap != null ) {
118
110
IntHashtable metrics = (IntHashtable ) fontDesc .get ("W" );
119
- CMapUniCid uni2cid = FontCache .getUni2CidCmap (uniMap );
111
+ CMapUniCid uni2cid = CjkResourceLoader .getUni2CidCmap (uniMap );
120
112
avgWidth = 0 ;
121
113
for (int cp : uni2cid .getCodePoints ()) {
122
114
int cid = uni2cid .lookup (cp );
@@ -133,14 +125,22 @@ private void initializeCidFontProperties(Map<String, Object> fontDesc) {
133
125
}
134
126
}
135
127
136
- private static String getCompatibleUniMap (String registry ) {
128
+ private static String getCompatibleUniMap (String registry , String cmap ) {
129
+ Set <String > compatibleUniMaps = CidFontProperties .getRegistryNames ().get (registry + "_Uni" );
130
+ // 'cmap != null &&' part here is for autoport
131
+ if (cmap != null && compatibleUniMaps .contains (cmap )) {
132
+ return cmap ;
133
+ }
134
+
137
135
String uniMap = "" ;
138
- for (String name : CidFontProperties . getRegistryNames (). get ( registry + "_Uni" ) ) {
136
+ for (String name : compatibleUniMaps ) {
139
137
uniMap = name ;
140
138
if (name .endsWith ("H" )) {
139
+ uniMap = name ;
141
140
break ;
142
141
}
143
142
}
143
+
144
144
return uniMap ;
145
145
}
146
146
}
0 commit comments