@@ -51,8 +51,10 @@ var cjkParms = map[string]cjk{
5151 "KANA" : {"UniJIS-UTF16-H" , "Japan1" , 7 },
5252 "JPAN" : {"UniJIS-UTF16-H" , "Japan1" , 7 },
5353 // K
54- "HANG" : {"UniKS-UTF16-H" , "KR" , 9 },
55- "KORE" : {"UniKS-UTF16-H" , "KR" , 9 },
54+ "HANG" : {"UniKS-UTF16-H" , "Korea1" , 1 },
55+ "KORE" : {"UniKS-UTF16-H" , "Korea1" , 1 },
56+ //"HANG": {"UniKS-UTF16-H", "KR", 9},
57+ //"KORE": {"UniKS-UTF16-H", "KR", 9},
5658}
5759
5860func SupportedScript (s string ) bool {
@@ -172,6 +174,56 @@ func ttfSubFontFile(xRefTable *model.XRefTable, ttf font.TTFLight, fontName stri
172174 return indRef , nil
173175}
174176
177+ func PDFDocEncoding (xRefTable * model.XRefTable ) (* types.IndirectRef , error ) {
178+ arr := types.Array {
179+ types .Integer (24 ),
180+ types .Name ("breve" ), types .Name ("caron" ), types .Name ("circumflex" ), types .Name ("dotaccent" ),
181+ types .Name ("hungarumlaut" ), types .Name ("ogonek" ), types .Name ("ring" ), types .Name ("tilde" ),
182+ types .Integer (39 ),
183+ types .Name ("quotesingle" ),
184+ types .Integer (96 ),
185+ types .Name ("grave" ),
186+ types .Integer (128 ),
187+ types .Name ("bullet" ), types .Name ("dagger" ), types .Name ("daggerdbl" ), types .Name ("ellipsis" ), types .Name ("emdash" ), types .Name ("endash" ),
188+ types .Name ("florin" ), types .Name ("fraction" ), types .Name ("guilsinglleft" ), types .Name ("guilsinglright" ), types .Name ("minus" ), types .Name ("perthousand" ),
189+ types .Name ("quotedblbase" ), types .Name ("quotedblleft" ), types .Name ("quotedblright" ), types .Name ("quoteleft" ), types .Name ("quoteright" ), types .Name ("quotesinglbase" ),
190+ types .Name ("trademark" ), types .Name ("fi" ), types .Name ("fl" ), types .Name ("Lslash" ), types .Name ("OE" ), types .Name ("Scaron" ), types .Name ("Ydieresis" ),
191+ types .Name ("Zcaron" ), types .Name ("dotlessi" ), types .Name ("lslash" ), types .Name ("oe" ), types .Name ("scaron" ), types .Name ("zcaron" ),
192+ types .Integer (160 ),
193+ types .Name ("Euro" ),
194+ types .Integer (164 ),
195+ types .Name ("currency" ),
196+ types .Integer (166 ),
197+ types .Name ("brokenbar" ), types .Integer (168 ), types .Name ("dieresis" ), types .Name ("copyright" ), types .Name ("ordfeminine" ),
198+ types .Integer (172 ),
199+ types .Name ("logicalnot" ), types .Name (".notdef" ), types .Name ("registered" ), types .Name ("macron" ), types .Name ("degree" ),
200+ types .Name ("plusminus" ), types .Name ("twosuperior" ), types .Name ("threesuperior" ), types .Name ("acute" ), types .Name ("mu" ),
201+ types .Integer (183 ),
202+ types .Name ("periodcentered" ), types .Name ("cedilla" ), types .Name ("onesuperior" ), types .Name ("ordmasculine" ),
203+ types .Integer (188 ),
204+ types .Name ("onequarter" ), types .Name ("onehalf" ), types .Name ("threequarters" ),
205+ types .Integer (192 ),
206+ types .Name ("Agrave" ), types .Name ("Aacute" ), types .Name ("Acircumflex" ), types .Name ("Atilde" ), types .Name ("Adieresis" ), types .Name ("Aring" ), types .Name ("AE" ),
207+ types .Name ("Ccedilla" ), types .Name ("Egrave" ), types .Name ("Eacute" ), types .Name ("Ecircumflex" ), types .Name ("Edieresis" ), types .Name ("Igrave" ), types .Name ("Iacute" ),
208+ types .Name ("Icircumflex" ), types .Name ("Idieresis" ), types .Name ("Eth" ), types .Name ("Ntilde" ), types .Name ("Ograve" ), types .Name ("Oacute" ), types .Name ("Ocircumflex" ),
209+ types .Name ("Otilde" ), types .Name ("Odieresis" ), types .Name ("multiply" ), types .Name ("Oslash" ), types .Name ("Ugrave" ), types .Name ("Uacute" ), types .Name ("Ucircumflex" ),
210+ types .Name ("Udieresis" ), types .Name ("Yacute" ), types .Name ("Thorn" ), types .Name ("germandbls" ), types .Name ("agrave" ), types .Name ("aacute" ), types .Name ("acircumflex" ),
211+ types .Name ("atilde" ), types .Name ("adieresis" ), types .Name ("aring" ), types .Name ("ae" ), types .Name ("ccedilla" ), types .Name ("egrave" ), types .Name ("eacute" ), types .Name ("ecircumflex" ),
212+ types .Name ("edieresis" ), types .Name ("igrave" ), types .Name ("iacute" ), types .Name ("icircumflex" ), types .Name ("idieresis" ), types .Name ("eth" ), types .Name ("ntilde" ),
213+ types .Name ("ograve" ), types .Name ("oacute" ), types .Name ("ocircumflex" ), types .Name ("otilde" ), types .Name ("odieresis" ), types .Name ("divide" ), types .Name ("oslash" ),
214+ types .Name ("ugrave" ), types .Name ("uacute" ), types .Name ("ucircumflex" ), types .Name ("udieresis" ), types .Name ("yacute" ), types .Name ("thorn" ), types .Name ("ydieresis" ),
215+ }
216+
217+ d := types .Dict (
218+ map [string ]types.Object {
219+ "Type" : types .Name ("Encoding" ),
220+ "Differences" : arr ,
221+ },
222+ )
223+
224+ return xRefTable .IndRefForNewObject (d )
225+ }
226+
175227func coreFontDict (xRefTable * model.XRefTable , coreFontName string ) (* types.IndirectRef , error ) {
176228 d := types .NewDict ()
177229 d .InsertName ("Type" , "Font" )
@@ -180,6 +232,15 @@ func coreFontDict(xRefTable *model.XRefTable, coreFontName string) (*types.Indir
180232 if coreFontName != "Symbol" && coreFontName != "ZapfDingbats" {
181233 d .InsertName ("Encoding" , "WinAnsiEncoding" )
182234 }
235+ // if coreFontName == "Helvetica" {
236+ // indRef, err := PDFDocEncoding(xRefTable)
237+ // if err != nil {
238+ // return nil, err
239+ // }
240+ // d.Insert("Encoding", *indRef)
241+ // } else if coreFontName != "Symbol" && coreFontName != "ZapfDingbats" {
242+ // d.InsertName("Encoding", "WinAnsiEncoding")
243+ // }
183244 return xRefTable .IndRefForNewObject (d )
184245}
185246
@@ -734,8 +795,8 @@ func subFontPrefix() string {
734795 return string (bb )
735796}
736797
737- // CIDFontSpecialEncDict returns the descendant font dict with special encoding for Type0 fonts.
738- func CIDFontSpecialEncDict (xRefTable * model.XRefTable , ttf font.TTFLight , fontName , baseFontName , lang string , parms * cjk ) (* types.IndirectRef , error ) {
798+ // CIDFontDict returns the descendant font dict with special encoding for Type0 fonts.
799+ func CIDFontDict (xRefTable * model.XRefTable , ttf font.TTFLight , fontName , baseFontName , lang string , parms * cjk ) (* types.IndirectRef , error ) {
739800 fdIndRef , err := CIDFontDescriptor (xRefTable , ttf , fontName , baseFontName , lang , parms == nil )
740801 if err != nil {
741802 return nil , err
@@ -798,12 +859,14 @@ func CIDFontSpecialEncDict(xRefTable *model.XRefTable, ttf font.TTFLight, fontNa
798859 d ["CIDToGIDMap" ] = types .Name ("Identity" )
799860 }
800861
801- wIndRef , err := CIDWidths (xRefTable , ttf , fontName , parms == nil , nil )
802- if err != nil {
803- return nil , err
804- }
805- if wIndRef != nil {
806- d ["W" ] = * wIndRef
862+ if parms == nil {
863+ wIndRef , err := CIDWidths (xRefTable , ttf , fontName , parms == nil , nil )
864+ if err != nil {
865+ return nil , err
866+ }
867+ if wIndRef != nil {
868+ d ["W" ] = * wIndRef
869+ }
807870 }
808871
809872 return xRefTable .IndRefForNewObject (d )
@@ -841,7 +904,7 @@ func type0FontDict(xRefTable *model.XRefTable, fontName, lang, script string, in
841904 encoding = parms .encoding
842905 }
843906
844- descendentFontIndRef , err := CIDFontSpecialEncDict (xRefTable , ttf , fontName , baseFontName , lang , parms )
907+ descendentFontIndRef , err := CIDFontDict (xRefTable , ttf , fontName , baseFontName , lang , parms )
845908 if err != nil {
846909 return nil , err
847910 }
@@ -850,7 +913,7 @@ func type0FontDict(xRefTable *model.XRefTable, fontName, lang, script string, in
850913 d .InsertName ("Type" , "Font" )
851914 d .InsertName ("Subtype" , "Type0" )
852915 d .InsertName ("BaseFont" , baseFontName )
853- // d.InsertName("Name", fontName)
916+ d .InsertName ("Name" , fontName )
854917 d .InsertName ("Encoding" , encoding )
855918 d .Insert ("DescendantFonts" , types.Array {* descendentFontIndRef })
856919
0 commit comments