unipdf/internal/cmap/cmap.go

137 lines
40 KiB
Go
Raw Normal View History

//
2020-08-27 21:45:09 +00:00
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
2021-08-13 01:33:42 +00:00
package cmap ;import (_bd "bufio";_g "bytes";_b "encoding/hex";_bc "errors";_f "fmt";_bf "github.com/unidoc/unipdf/v3/common";_a "github.com/unidoc/unipdf/v3/core";_c "github.com/unidoc/unipdf/v3/internal/cmap/bcmaps";_gc "io";_bca "sort";_e "strconv";
_be "strings";_dd "unicode/utf16";);type CIDSystemInfo struct{Registry string ;Ordering string ;Supplement int ;};type CMap struct{*cMapParser ;_cd string ;_ef int ;_ddg int ;_cea string ;_gg string ;_cda CIDSystemInfo ;_fg []Codespace ;_dgb map[CharCode ]CharCode ;
_eb map[CharCode ]CharCode ;_gf map[CharCode ]string ;_fe map[string ]CharCode ;_dde []byte ;_ab *_a .PdfObjectStream ;};func (cmap *CMap )toBfData ()string {if len (cmap ._gf )==0{return "";};_ggdc :=make ([]CharCode ,0,len (cmap ._gf ));for _afbd :=range cmap ._gf {_ggdc =append (_ggdc ,_afbd );
};_bca .Slice (_ggdc ,func (_gff ,_bcb int )bool {return _ggdc [_gff ]< _ggdc [_bcb ]});var _cg []charRange ;_gfe :=charRange {_ggdc [0],_ggdc [0]};_bad :=cmap ._gf [_ggdc [0]];for _ ,_bgeb :=range _ggdc [1:]{_feg :=cmap ._gf [_bgeb ];if _bgeb ==_gfe ._egb +1&&_aag (_feg )==_aag (_bad )+1{_gfe ._egb =_bgeb ;
}else {_cg =append (_cg ,_gfe );_gfe ._gb ,_gfe ._egb =_bgeb ,_bgeb ;};_bad =_feg ;};_cg =append (_cg ,_gfe );var _agc []CharCode ;var _ggf []fbRange ;for _ ,_cdc :=range _cg {if _cdc ._gb ==_cdc ._egb {_agc =append (_agc ,_cdc ._gb );}else {_ggf =append (_ggf ,fbRange {_bcab :_cdc ._gb ,_gd :_cdc ._egb ,_ce :cmap ._gf [_cdc ._gb ]});
};};_bf .Log .Trace ("\u0063\u0068ar\u0052\u0061\u006eg\u0065\u0073\u003d\u0025d f\u0062Ch\u0061\u0072\u0073\u003d\u0025\u0064\u0020fb\u0052\u0061\u006e\u0067\u0065\u0073\u003d%\u0064",len (_cg ),len (_agc ),len (_ggf ));var _cdab []string ;if len (_agc )> 0{_fbf :=(len (_agc )+_eaf -1)/_eaf ;
for _gffd :=0;_gffd < _fbf ;_gffd ++{_df :=_eafd (len (_agc )-_gffd *_eaf ,_eaf );_cdab =append (_cdab ,_f .Sprintf ("\u0025\u0064\u0020\u0062\u0065\u0067\u0069\u006e\u0062f\u0063\u0068\u0061\u0072",_df ));for _dab :=0;_dab < _df ;_dab ++{_ec :=_agc [_gffd *_eaf +_dab ];
_gce :=cmap ._gf [_ec ];_cdab =append (_cdab ,_f .Sprintf ("\u003c%\u0030\u0034\u0078\u003e\u0020\u0025s",_ec ,_bb (_gce )));};_cdab =append (_cdab ,"\u0065n\u0064\u0062\u0066\u0063\u0068\u0061r");};};if len (_ggf )> 0{_cgc :=(len (_ggf )+_eaf -1)/_eaf ;
for _abc :=0;_abc < _cgc ;_abc ++{_ddb :=_eafd (len (_ggf )-_abc *_eaf ,_eaf );_cdab =append (_cdab ,_f .Sprintf ("\u0025d\u0020b\u0065\u0067\u0069\u006e\u0062\u0066\u0072\u0061\u006e\u0067\u0065",_ddb ));for _bfdb :=0;_bfdb < _ddb ;_bfdb ++{_fga :=_ggf [_abc *_eaf +_bfdb ];
_cdab =append (_cdab ,_f .Sprintf ("\u003c%\u00304\u0078\u003e\u003c\u0025\u0030\u0034\u0078\u003e\u0020\u0025\u0073",_fga ._bcab ,_fga ._gd ,_bb (_fga ._ce )));};_cdab =append (_cdab ,"\u0065\u006e\u0064\u0062\u0066\u0072\u0061\u006e\u0067\u0065");};};
return _be .Join (_cdab ,"\u000a");};func (cmap *CMap )parseVersion ()error {_eda :="";_cadg :=false ;for _dee :=0;_dee < 3&&!_cadg ;_dee ++{_afbdd ,_gfeg :=cmap .parseObject ();if _gfeg !=nil {return _gfeg ;};switch _ecb :=_afbdd .(type ){case cmapOperand :switch _ecb .Operand {case "\u0064\u0065\u0066":_cadg =true ;
default:_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0070\u0061\u0072\u0073\u0065\u0056e\u0072\u0073\u0069\u006f\u006e\u003a \u0073\u0074\u0061\u0074\u0065\u0020\u0065\u0072\u0072\u006f\u0072\u002e\u0020o\u003d\u0025\u0023\u0076",_afbdd );
return ErrBadCMap ;};case cmapInt :_eda =_f .Sprintf ("\u0025\u0064",_ecb ._fdeb );case cmapFloat :_eda =_f .Sprintf ("\u0025\u0066",_ecb ._dbgf );case cmapString :_eda =_ecb .String ;default:_bf .Log .Debug ("\u0045\u0052RO\u0052\u003a\u0020p\u0061\u0072\u0073\u0065Ver\u0073io\u006e\u003a\u0020\u0042\u0061\u0064\u0020ty\u0070\u0065\u002e\u0020\u006f\u003d\u0025#\u0076",_afbdd );
};};cmap ._cea =_eda ;return nil ;};func LoadPredefinedCMap (name string )(*CMap ,error ){cmap ,_fc :=_ga (name );if _fc !=nil {return nil ,_fc ;};if cmap ._gg ==""{cmap .computeInverseMappings ();return cmap ,nil ;};_aa ,_fc :=_ga (cmap ._gg );if _fc !=nil {return nil ,_fc ;
};for _eag ,_bfd :=range _aa ._dgb {if _ ,_cebb :=cmap ._dgb [_eag ];!_cebb {cmap ._dgb [_eag ]=_bfd ;};};cmap ._fg =append (cmap ._fg ,_aa ._fg ...);cmap .computeInverseMappings ();return cmap ,nil ;};func (cmap *CMap )CharcodeBytesToUnicode (data []byte )(string ,int ){_bfa ,_ddeg :=cmap .BytesToCharcodes (data );
if !_ddeg {_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0043\u0068\u0061\u0072\u0063\u006f\u0064\u0065\u0042\u0079\u0074\u0065s\u0054\u006f\u0055\u006e\u0069\u0063\u006f\u0064\u0065\u002e\u0020\u004e\u006f\u0074\u0020\u0069n\u0020\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0073\u002e\u0020\u0064\u0061\u0074\u0061\u003d\u005b\u0025\u0020\u0030\u0032\u0078]\u0020\u0063\u006d\u0061\u0070=\u0025\u0073",data ,cmap );
return "",0;};_cee :=make ([]string ,len (_bfa ));var _ca []CharCode ;for _ag ,_gdf :=range _bfa {_aad ,_eee :=cmap ._gf [_gdf ];if !_eee {_ca =append (_ca ,_gdf );_aad =MissingCodeString ;};_cee [_ag ]=_aad ;};_ege :=_be .Join (_cee ,"");if len (_ca )> 0{_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020C\u0068\u0061\u0072c\u006f\u0064\u0065\u0042y\u0074\u0065\u0073\u0054\u006f\u0055\u006e\u0069\u0063\u006f\u0064\u0065\u002e\u0020\u004e\u006f\u0074\u0020\u0069\u006e\u0020\u006d\u0061\u0070\u002e\u000a"+"\u0009d\u0061t\u0061\u003d\u005b\u0025\u00200\u0032\u0078]\u003d\u0025\u0023\u0071\u000a"+"\u0009\u0063h\u0061\u0072\u0063o\u0064\u0065\u0073\u003d\u0025\u0030\u0032\u0078\u000a"+"\u0009\u006d\u0069\u0073\u0073\u0069\u006e\u0067\u003d\u0025\u0064\u0020%\u0030\u0032\u0078\u000a"+"\u0009\u0075\u006e\u0069\u0063\u006f\u0064\u0065\u003d`\u0025\u0073\u0060\u000a"+"\u0009\u0063\u006d\u0061\u0070\u003d\u0025\u0073",data ,string (data ),_bfa ,len (_ca ),_ca ,_ege ,cmap );
};return _ege ,len (_ca );};func NewCIDSystemInfo (obj _a .PdfObject )(_cf CIDSystemInfo ,_ac error ){_ad ,_dg :=_a .GetDict (obj );if !_dg {return CIDSystemInfo {},_a .ErrTypeError ;};_ee ,_dg :=_a .GetStringVal (_ad .Get ("\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079"));
if !_dg {return CIDSystemInfo {},_a .ErrTypeError ;};_dc ,_dg :=_a .GetStringVal (_ad .Get ("\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067"));if !_dg {return CIDSystemInfo {},_a .ErrTypeError ;};_ceb ,_dg :=_a .GetIntVal (_ad .Get ("\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074"));
if !_dg {return CIDSystemInfo {},_a .ErrTypeError ;};return CIDSystemInfo {Registry :_ee ,Ordering :_dc ,Supplement :_ceb },nil ;};func _dce (_fb bool )*CMap {_ade :=16;if _fb {_ade =8;};return &CMap {_ef :_ade ,_dgb :make (map[CharCode ]CharCode ),_eb :make (map[CharCode ]CharCode ),_gf :make (map[CharCode ]string ),_fe :make (map[string ]CharCode )};
};func (cmap *CMap )String ()string {_af :=cmap ._cda ;_cc :=[]string {_f .Sprintf ("\u006e\u0062\u0069\u0074\u0073\u003a\u0025\u0064",cmap ._ef ),_f .Sprintf ("\u0074y\u0070\u0065\u003a\u0025\u0064",cmap ._ddg )};if cmap ._cea !=""{_cc =append (_cc ,_f .Sprintf ("\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u003a\u0025\u0073",cmap ._cea ));
};if cmap ._gg !=""{_cc =append (_cc ,_f .Sprintf ("u\u0073\u0065\u0063\u006d\u0061\u0070\u003a\u0025\u0023\u0071",cmap ._gg ));};_cc =append (_cc ,_f .Sprintf ("\u0073\u0079\u0073\u0074\u0065\u006d\u0049\u006e\u0066\u006f\u003a\u0025\u0073",_af .String ()));
if len (cmap ._fg )> 0{_cc =append (_cc ,_f .Sprintf ("\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0073\u003a\u0025\u0064",len (cmap ._fg )));};if len (cmap ._gf )> 0{_cc =append (_cc ,_f .Sprintf ("\u0063\u006fd\u0065\u0054\u006fU\u006e\u0069\u0063\u006f\u0064\u0065\u003a\u0025\u0064",len (cmap ._gf )));
};return _f .Sprintf ("\u0043\u004d\u0041P\u007b\u0025\u0023\u0071\u0020\u0025\u0073\u007d",cmap ._cd ,_be .Join (_cc ,"\u0020"));};func (_dbgb *cMapParser )parseArray ()(cmapArray ,error ){_beb :=cmapArray {};_beb .Array =[]cmapObject {};_dbgb ._fee .ReadByte ();
for {_dbgb .skipSpaces ();_dbf ,_gfg :=_dbgb ._fee .Peek (1);if _gfg !=nil {return _beb ,_gfg ;};if _dbf [0]==']'{_dbgb ._fee .ReadByte ();break ;};_gdg ,_gfg :=_dbgb .parseObject ();if _gfg !=nil {return _beb ,_gfg ;};_beb .Array =append (_beb .Array ,_gdg );
};return _beb ,nil ;};func (cmap *CMap )Bytes ()[]byte {_bf .Log .Trace ("\u0063\u006d\u0061\u0070.B\u0079\u0074\u0065\u0073\u003a\u0020\u0063\u006d\u0061\u0070\u003d\u0025\u0073",cmap .String ());if len (cmap ._dde )> 0{return cmap ._dde ;};cmap ._dde =[]byte (_be .Join ([]string {_gcb ,cmap .toBfData (),_bef },"\u000a"));
return cmap ._dde ;};func (cmap *CMap )parseCIDRange ()error {for {_fcad ,_fcc :=cmap .parseObject ();if _fcc !=nil {if _fcc ==_gc .EOF {break ;};return _fcc ;};_efe ,_ddba :=_fcad .(cmapHexString );if !_ddba {if _ceg ,_ggde :=_fcad .(cmapOperand );_ggde {if _ceg .Operand ==_agbcd {return nil ;
};return _bc .New ("\u0063\u0069\u0064\u0020\u0069\u006e\u0074\u0065\u0072\u0076\u0061\u006c\u0020s\u0074\u0061\u0072\u0074\u0020\u006du\u0073\u0074\u0020\u0062\u0065\u0020\u0061\u0020\u0068\u0065\u0078\u0020\u0073t\u0072\u0069\u006e\u0067");};};_gecd :=_fcg (_efe );
_fcad ,_fcc =cmap .parseObject ();if _fcc !=nil {if _fcc ==_gc .EOF {break ;};return _fcc ;};_cace ,_ddba :=_fcad .(cmapHexString );if !_ddba {return _bc .New ("\u0063\u0069d\u0020\u0069\u006e\u0074e\u0072\u0076a\u006c\u0020\u0065\u006e\u0064\u0020\u006d\u0075s\u0074\u0020\u0062\u0065\u0020\u0061\u0020\u0068\u0065\u0078\u0020\u0073t\u0072\u0069\u006e\u0067");
};if len (_efe ._efea )!=len (_cace ._efea ){return _bc .New ("\u0075\u006e\u0065\u0071\u0075\u0061\u006c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0062\u0079\u0074\u0065\u0073\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065");};_eab :=_fcg (_cace );
if _gecd > _eab {_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a \u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0043\u0049\u0044\u0020\u0072\u0061\u006e\u0067\u0065\u002e\u0020\u0073t\u0061\u0072\u0074\u003d\u0030\u0078\u0025\u0030\u0032\u0078\u0020\u0065\u006e\u0064=\u0030x\u0025\u0030\u0032\u0078",_gecd ,_eab );
return ErrBadCMap ;};_fcad ,_fcc =cmap .parseObject ();if _fcc !=nil {if _fcc ==_gc .EOF {break ;};return _fcc ;};_fbd ,_ddba :=_fcad .(cmapInt );if !_ddba {return _bc .New ("\u0063\u0069\u0064\u0020\u0073t\u0061\u0072\u0074\u0020\u0076\u0061\u006c\u0075\u0065\u0020\u006d\u0075\u0073t\u0020\u0062\u0065\u0020\u0061\u006e\u0020\u0064\u0065\u0063\u0069\u006d\u0061\u006c\u0020\u006e\u0075\u006d\u0062\u0065\u0072");
};if _fbd ._fdeb < 0{return _bc .New ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0063\u0069\u0064\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0076\u0061\u006c\u0075\u0065");};_gfd :=_fbd ._fdeb ;for _fbdf :=_gecd ;_fbdf <=_eab ;_fbdf ++{cmap ._dgb [_fbdf ]=CharCode (_gfd );
_gfd ++;};_bf .Log .Trace ("C\u0049\u0044\u0020\u0072\u0061\u006eg\u0065\u003a\u0020\u003c\u0030\u0078\u0025\u0058\u003e \u003c\u0030\u0078%\u0058>\u0020\u0025\u0064",_gecd ,_eab ,_fbd ._fdeb );};return nil ;};func (cmap *CMap )StringToCID (s string )(CharCode ,bool ){_gag ,_fafb :=cmap ._fe [s ];
return _gag ,_fafb ;};func (cmap *CMap )parseSystemInfo ()error {_edba :=false ;_bcd :=false ;_cac :="";_eba :=false ;_bbd :=CIDSystemInfo {};for _fad :=0;_fad < 50&&!_eba ;_fad ++{_ega ,_fbb :=cmap .parseObject ();if _fbb !=nil {return _fbb ;};switch _bda :=_ega .(type ){case cmapDict :_dcdb :=_bda .Dict ;
_gdb ,_fge :=_dcdb ["\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079"];if !_fge {_bf .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_dabf ,_fge :=_gdb .(cmapString );
if !_fge {_bf .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bbd .Registry =_dabf .String ;_gdb ,_fge =_dcdb ["\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067"];
if !_fge {_bf .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_dabf ,_fge =_gdb .(cmapString );if !_fge {_bf .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");
return ErrBadCMap ;};_bbd .Ordering =_dabf .String ;_ddbd ,_fge :=_dcdb ["\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074"];if !_fge {_bf .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");
return ErrBadCMap ;};_ggc ,_fge :=_ddbd .(cmapInt );if !_fge {_bf .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bbd .Supplement =int (_ggc ._fdeb );
_eba =true ;case cmapOperand :switch _bda .Operand {case "\u0062\u0065\u0067i\u006e":_edba =true ;case "\u0065\u006e\u0064":_eba =true ;case "\u0064\u0065\u0066":_bcd =false ;};case cmapName :if _edba {_cac =_bda .Name ;_bcd =true ;};case cmapString :if _bcd {switch _cac {case "\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079":_bbd .Registry =_bda .String ;
case "\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067":_bbd .Ordering =_bda .String ;};};case cmapInt :if _bcd {switch _cac {case "\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074":_bbd .Supplement =int (_bda ._fdeb );};};};};if !_eba {_bf .Log .Debug ("\u0045\u0052\u0052O\u0052\u003a\u0020\u0050\u0061\u0072\u0073\u0065\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006e\u0066\u006f\u0020\u0064\u0069\u0063\u0074\u0020\u0069\u006ec\u006f\u0072\u0072\u0065\u0063\u0074\u006c\u0079");
return ErrBadCMap ;};cmap ._cda =_bbd ;return nil ;};type fbRange struct{_bcab CharCode ;_gd CharCode ;_ce string ;};func (_fgag *cMapParser )parseString ()(cmapString ,error ){_fgag ._fee .ReadByte ();_cag :=_g .Buffer {};_eeec :=1;for {_bdb ,_def :=_fgag ._fee .Peek (1);
if _def !=nil {return cmapString {_cag .String ()},_def ;};if _bdb [0]=='\\'{_fgag ._fee .ReadByte ();_aeg ,_dbec :=_fgag ._fee .ReadByte ();if _dbec !=nil {return cmapString {_cag .String ()},_dbec ;};if _a .IsOctalDigit (_aeg ){_aefe ,_fcfc :=_fgag ._fee .Peek (2);
if _fcfc !=nil {return cmapString {_cag .String ()},_fcfc ;};var _ffed []byte ;_ffed =append (_ffed ,_aeg );for _ ,_bcaba :=range _aefe {if _a .IsOctalDigit (_bcaba ){_ffed =append (_ffed ,_bcaba );}else {break ;};};_fgag ._fee .Discard (len (_ffed )-1);
_bf .Log .Trace ("\u004e\u0075\u006d\u0065ri\u0063\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u0020\u0022\u0025\u0073\u0022",_ffed );_aab ,_fcfc :=_e .ParseUint (string (_ffed ),8,32);if _fcfc !=nil {return cmapString {_cag .String ()},_fcfc ;};_cag .WriteByte (byte (_aab ));
continue ;};switch _aeg {case 'n':_cag .WriteByte ('\n');case 'r':_cag .WriteByte ('\r');case 't':_cag .WriteByte ('\t');case 'b':_cag .WriteByte ('\b');case 'f':_cag .WriteByte ('\f');case '(':_cag .WriteByte ('(');case ')':_cag .WriteByte (')');case '\\':_cag .WriteByte ('\\');
};continue ;}else if _bdb [0]=='('{_eeec ++;}else if _bdb [0]==')'{_eeec --;if _eeec ==0{_fgag ._fee .ReadByte ();break ;};};_dcfd ,_ :=_fgag ._fee .ReadByte ();_cag .WriteByte (_dcfd );};return cmapString {_cag .String ()},nil ;};type cmapInt struct{_fdeb int64 };
func _ga (_ge string )(*CMap ,error ){_fa ,_dcd :=_c .Asset (_ge );if _dcd !=nil {return nil ,_dcd ;};return LoadCmapFromDataCID (_fa );};func (cmap *CMap )parseBfrange ()error {for {var _bcg CharCode ;_adc ,_dfa :=cmap .parseObject ();if _dfa !=nil {if _dfa ==_gc .EOF {break ;
};return _dfa ;};switch _bcda :=_adc .(type ){case cmapOperand :if _bcda .Operand ==_gffb {return nil ;};return _bc .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065d\u0020\u006fp\u0065\u0072\u0061\u006e\u0064");case cmapHexString :_bcg =_fcg (_bcda );
default:return _bc .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065\u0064\u0020\u0074\u0079\u0070\u0065");};var _gcf CharCode ;_adc ,_dfa =cmap .parseObject ();if _dfa !=nil {if _dfa ==_gc .EOF {break ;};return _dfa ;};switch _dge :=_adc .(type ){case cmapOperand :_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a \u0049\u006e\u0063\u006f\u006d\u0070\u006c\u0065\u0074\u0065\u0020\u0062\u0066r\u0061\u006e\u0067\u0065\u0020\u0074\u0072i\u0070\u006c\u0065\u0074");
return ErrBadCMap ;case cmapHexString :_gcf =_fcg (_dge );default:_bf .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a \u0055\u006e\u0065\u0078\u0070e\u0063t\u0065d\u0020\u0074\u0079\u0070\u0065\u0020\u0025T",_adc );return ErrBadCMap ;};_adc ,_dfa =cmap .parseObject ();
if _dfa !=nil {if _dfa ==_gc .EOF {break ;};return _dfa ;};switch _bab :=_adc .(type ){case cmapArray :if len (_bab .Array )!=int (_gcf -_bcg )+1{_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0049\u006e\u0076\u0061\u006c\u0069d\u0020\u006e\u0075\u006d\u0062\u0065r\u0020\u006f\u0066\u0020\u0069\u0074\u0065\u006d\u0073\u0020\u0069\u006e\u0020a\u0072\u0072\u0061\u0079");
return ErrBadCMap ;};for _bcef :=_bcg ;_bcef <=_gcf ;_bcef ++{_edd :=_bab .Array [_bcef -_bcg ];_egf ,_acef :=_edd .(cmapHexString );if !_acef {return _bc .New ("\u006e\u006f\u006e-h\u0065\u0078\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0020\u0061\u0072\u0072\u0061\u0079");
};_fceb :=_bga (_egf );cmap ._gf [_bcef ]=string (_fceb );};case cmapHexString :_bcc :=_bga (_bab );_bfab :=len (_bcc );for _acc :=_bcg ;_acc <=_gcf ;_acc ++{cmap ._gf [_acc ]=string (_bcc );if _bfab > 0{_bcc [_bfab -1]++;}else {_bf .Log .Debug ("\u004e\u006f\u0020c\u006d\u0061\u0070\u0020\u0074\u0061\u0072\u0067\u0065\u0074\u0020\u0063\u0068\u0061\u0072\u0061\u0063\u0074\u0065\u0072\u0020\u0073\u0070\u0065\u0063\u0069\u0066\u0069\u0065d\u0020\u0066\u006f\u0072\u0020\u0025\u0023\u0076",_acc );
};};default:_bf .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a \u0055\u006e\u0065\u0078\u0070e\u0063t\u0065d\u0020\u0074\u0079\u0070\u0065\u0020\u0025T",_adc );return ErrBadCMap ;};};return nil ;};func (cmap *CMap )BytesToCharcodes (data []byte )([]CharCode ,bool ){var _ceac []CharCode ;
if cmap ._ef ==8{for _ ,_fdg :=range data {_ceac =append (_ceac ,CharCode (_fdg ));};return _ceac ,true ;};for _feb :=0;_feb < len (data );{_edb ,_ada ,_bde :=cmap .matchCode (data [_feb :]);if !_bde {_bf .Log .Debug ("\u0045\u0052R\u004f\u0052\u003a\u0020\u004e\u006f\u0020\u0063\u006f\u0064\u0065\u0020\u006d\u0061\u0074\u0063\u0068\u0020\u0061\u0074\u0020\u0069\u003d\u0025\u0064\u0020\u0062\u0079\u0074\u0065\u0073\u003d\u005b\u0025\u0020\u0030\u0032\u0078\u005d\u003d\u0025\u0023\u0071",_feb ,data ,string (data ));
return _ceac ,false ;};_ceac =append (_ceac ,_edb );_feb +=_ada ;};return _ceac ,true ;};func (cmap *CMap )parse ()error {var _gaa cmapObject ;for {_cga ,_ecd :=cmap .parseObject ();if _ecd !=nil {if _ecd ==_gc .EOF {break ;};_bf .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u0070\u0061\u0072\u0073\u0069\u006e\u0067\u0020\u0043\u004d\u0061\u0070\u003a\u0020\u0025\u0076",_ecd );
return _ecd ;};switch _gdce :=_cga .(type ){case cmapOperand :_bac :=_gdce ;switch _bac .Operand {case _dad :_bff :=cmap .parseCodespaceRange ();if _bff !=nil {return _bff ;};case _cfe :_ccc :=cmap .parseCIDRange ();if _ccc !=nil {return _ccc ;};case _abec :_cdcf :=cmap .parseBfchar ();
if _cdcf !=nil {return _cdcf ;};case _bdc :_fbe :=cmap .parseBfrange ();if _fbe !=nil {return _fbe ;};case _bggg :if _gaa ==nil {_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0075\u0073\u0065\u0063m\u0061\u0070\u0020\u0077\u0069\u0074\u0068\u0020\u006e\u006f \u0061\u0072\u0067");
return ErrBadCMap ;};_fca ,_dcf :=_gaa .(cmapName );if !_dcf {_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a \u0075\u0073\u0065\u0063\u006d\u0061\u0070\u0020\u0061\u0072\u0067\u0020\u006eo\u0074\u0020\u0061\u0020\u006e\u0061\u006de\u0020\u0025\u0023\u0076",_gaa );
return ErrBadCMap ;};cmap ._gg =_fca .Name ;case _agaf :_caf :=cmap .parseSystemInfo ();if _caf !=nil {return _caf ;};};case cmapName :_agcg :=_gdce ;switch _agcg .Name {case _agaf :_fea :=cmap .parseSystemInfo ();if _fea !=nil {return _fea ;};case _cacb :_fce :=cmap .parseName ();
if _fce !=nil {return _fce ;};case _gad :_afab :=cmap .parseType ();if _afab !=nil {return _afab ;};case _afc :_fef :=cmap .parseVersion ();if _fef !=nil {return _fef ;};};};_gaa =_cga ;};return nil ;};type cmapHexString struct{_ebe int ;_efea []byte ;
};func (cmap *CMap )parseCodespaceRange ()error {for {_eff ,_afae :=cmap .parseObject ();if _afae !=nil {if _afae ==_gc .EOF {break ;};return _afae ;};_egbc ,_bcdc :=_eff .(cmapHexString );if !_bcdc {if _eae ,_dbe :=_eff .(cmapOperand );_dbe {if _eae .Operand ==_efg {return nil ;
};return _bc .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065d\u0020\u006fp\u0065\u0072\u0061\u006e\u0064");};};_eff ,_afae =cmap .parseObject ();if _afae !=nil {if _afae ==_gc .EOF {break ;};return _afae ;};_eeag ,_bcdc :=_eff .(cmapHexString );if !_bcdc {return _bc .New ("\u006e\u006f\u006e-\u0068\u0065\u0078\u0020\u0068\u0069\u0067\u0068");
};if len (_egbc ._efea )!=len (_eeag ._efea ){return _bc .New ("\u0075\u006e\u0065\u0071\u0075\u0061\u006c\u0020\u006e\u0075\u006d\u0062\u0065\u0072\u0020o\u0066 \u0062\u0079\u0074\u0065\u0073\u0020\u0069\u006e\u0020\u0072\u0061\u006e\u0067\u0065");};_agcgf :=_fcg (_egbc );
_efc :=_fcg (_eeag );if _efc < _agcgf {_bf .Log .Debug ("\u0045R\u0052\u004fR\u003a\u0020\u0042\u0061d\u0020\u0063\u006fd\u0065\u0073\u0070\u0061\u0063\u0065\u002e\u0020\u006cow\u003d\u0030\u0078%\u0030\u0032x\u0020\u0068\u0069\u0067\u0068\u003d0\u0078\u00250\u0032\u0078",_agcgf ,_efc );
return ErrBadCMap ;};_cce :=_eeag ._ebe ;_fafd :=Codespace {NumBytes :_cce ,Low :_agcgf ,High :_efc };cmap ._fg =append (cmap ._fg ,_fafd );_bf .Log .Trace ("\u0043\u006f\u0064e\u0073\u0070\u0061\u0063e\u0020\u006c\u006f\u0077\u003a\u0020\u0030x\u0025\u0058\u002c\u0020\u0068\u0069\u0067\u0068\u003a\u0020\u0030\u0078\u0025\u0058",_agcgf ,_efc );
};if len (cmap ._fg )==0{_bf .Log .Debug ("\u0045\u0052R\u004f\u0052\u003a\u0020\u004e\u006f\u0020\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0073\u0020\u0069\u006e\u0020\u0063ma\u0070\u002e");return ErrBadCMap ;};return nil ;};func (_gda *cMapParser )parseObject ()(cmapObject ,error ){_gda .skipSpaces ();
for {_dadd ,_bbe :=_gda ._fee .Peek (2);if _bbe !=nil {return nil ,_bbe ;};if _dadd [0]=='%'{_gda .parseComment ();_gda .skipSpaces ();continue ;}else if _dadd [0]=='/'{_fed ,_baa :=_gda .parseName ();return _fed ,_baa ;}else if _dadd [0]=='('{_bbf ,_dba :=_gda .parseString ();
return _bbf ,_dba ;}else if _dadd [0]=='['{_ccb ,_gffbd :=_gda .parseArray ();return _ccb ,_gffbd ;}else if (_dadd [0]=='<')&&(_dadd [1]=='<'){_cbdc ,_gdcc :=_gda .parseDict ();return _cbdc ,_gdcc ;}else if _dadd [0]=='<'{_dcfe ,_bag :=_gda .parseHexString ();
return _dcfe ,_bag ;}else if _a .IsDecimalDigit (_dadd [0])||(_dadd [0]=='-'&&_a .IsDecimalDigit (_dadd [1])){_gafc ,_acb :=_gda .parseNumber ();if _acb !=nil {return nil ,_acb ;};return _gafc ,nil ;}else {_fcf ,_dfb :=_gda .parseOperand ();if _dfb !=nil {return nil ,_dfb ;
};return _fcf ,nil ;};};};func (_fafg *cMapParser )parseComment ()(string ,error ){var _face _g .Buffer ;_ ,_dabe :=_fafg .skipSpaces ();if _dabe !=nil {return _face .String (),_dabe ;};_bggf :=true ;for {_accd ,_bgga :=_fafg ._fee .Peek (1);if _bgga !=nil {_bf .Log .Debug ("p\u0061r\u0073\u0065\u0043\u006f\u006d\u006d\u0065\u006et\u003a\u0020\u0065\u0072r=\u0025\u0076",_bgga );
return _face .String (),_bgga ;};if _bggf &&_accd [0]!='%'{return _face .String (),ErrBadCMapComment ;};_bggf =false ;if (_accd [0]!='\r')&&(_accd [0]!='\n'){_cdcc ,_ :=_fafg ._fee .ReadByte ();_face .WriteByte (_cdcc );}else {break ;};};return _face .String (),nil ;
};func (cmap *CMap )matchCode (_aade []byte )(_cbd CharCode ,_baec int ,_abf bool ){for _afb :=0;_afb < _eg ;_afb ++{if _afb < len (_aade ){_cbd =_cbd <<8|CharCode (_aade [_afb ]);_baec ++;};_abf =cmap .inCodespace (_cbd ,_afb +1);if _abf {return _cbd ,_baec ,true ;
};};_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u004e\u006f\u0020\u0063o\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0020m\u0061t\u0063\u0068\u0065\u0073\u0020\u0062\u0079\u0074\u0065\u0073\u003d\u005b\u0025\u0020\u0030\u0032\u0078\u005d=\u0025\u0023\u0071\u0020\u0063\u006d\u0061\u0070\u003d\u0025\u0073",_aade ,string (_aade ),cmap );
return 0,0,false ;};func _cbag ()cmapDict {return cmapDict {Dict :map[string ]cmapObject {}}};type cmapString struct{String string ;};func (_ced *CIDSystemInfo )String ()string {return _f .Sprintf ("\u0025\u0073\u002d\u0025\u0073\u002d\u0025\u0030\u0033\u0064",_ced .Registry ,_ced .Ordering ,_ced .Supplement );
};func (cmap *CMap )CharcodeToUnicode (code CharCode )(string ,bool ){if _da ,_bfc :=cmap ._gf [code ];_bfc {return _da ,true ;};return MissingCodeString ,false ;};func (_cfd *cMapParser )skipSpaces ()(int ,error ){_fcef :=0;for {_bbeg ,_ddcb :=_cfd ._fee .Peek (1);
if _ddcb !=nil {return 0,_ddcb ;};if _a .IsWhiteSpace (_bbeg [0]){_cfd ._fee .ReadByte ();_fcef ++;}else {break ;};};return _fcef ,nil ;};func (_fde *cMapParser )parseOperand ()(cmapOperand ,error ){_fffe :=cmapOperand {};_cbge :=_g .Buffer {};for {_beg ,_edeb :=_fde ._fee .Peek (1);
if _edeb !=nil {if _edeb ==_gc .EOF {break ;};return _fffe ,_edeb ;};if _a .IsDelimiter (_beg [0]){break ;};if _a .IsWhiteSpace (_beg [0]){break ;};_dcbd ,_ :=_fde ._fee .ReadByte ();_cbge .WriteByte (_dcbd );};if _cbge .Len ()==0{return _fffe ,_f .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064\u0020\u0028\u0065\u006d\u0070\u0074\u0079\u0029");
};_fffe .Operand =_cbge .String ();return _fffe ,nil ;};func (cmap *CMap )Name ()string {return cmap ._cd };func _ddae (_dagd cmapHexString )rune {_bead :=_bga (_dagd );if _bfcg :=len (_bead );_bfcg ==0{_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0068\u0065\u0078\u0054o\u0052\u0075\u006e\u0065\u002e\u0020\u0045\u0078p\u0065c\u0074\u0065\u0064\u0020\u0061\u0074\u0020\u006c\u0065\u0061\u0073\u0074\u0020\u006f\u006e\u0065\u0020\u0072u\u006e\u0065\u0020\u0073\u0068\u0065\u0078\u003d\u0025\u0023\u0076",_dagd );
return MissingCodeRune ;};if len (_bead )> 1{_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0068\u0065\u0078\u0054\u006f\u0052\u0075\u006e\u0065\u002e\u0020\u0045\u0078p\u0065\u0063\u0074\u0065\u0064\u0020\u0065\u0078\u0061\u0063\u0074\u006c\u0079\u0020\u006f\u006e\u0065\u0020\u0072\u0075\u006e\u0065\u0020\u0073\u0068\u0065\u0078\u003d\u0025\u0023v\u0020\u002d\u003e\u0020\u0025#\u0076",_dagd ,_bead );
};return _bead [0];};type cMapParser struct{_fee *_bd .Reader };func (_gfcdf *cMapParser )parseNumber ()(cmapObject ,error ){_ecbb ,_efag :=_a .ParseNumber (_gfcdf ._fee );if _efag !=nil {return nil ,_efag ;};switch _eage :=_ecbb .(type ){case *_a .PdfObjectFloat :return cmapFloat {float64 (*_eage )},nil ;
case *_a .PdfObjectInteger :return cmapInt {int64 (*_eage )},nil ;};return nil ,_f .Errorf ("\u0075n\u0068\u0061\u006e\u0064\u006c\u0065\u0064\u0020\u006e\u0075\u006db\u0065\u0072\u0020\u0074\u0079\u0070\u0065\u0020\u0025\u0054",_ecbb );};type cmapFloat struct{_dbgf float64 };
func (_edaa *cMapParser )parseDict ()(cmapDict ,error ){_bf .Log .Trace ("\u0052\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0050\u0044\u0046\u0020D\u0069\u0063\u0074\u0021");_bedd :=_cbag ();_gba ,_ :=_edaa ._fee .ReadByte ();if _gba !='<'{return _bedd ,ErrBadCMapDict ;
};_gba ,_ =_edaa ._fee .ReadByte ();if _gba !='<'{return _bedd ,ErrBadCMapDict ;};for {_edaa .skipSpaces ();_ead ,_ceacb :=_edaa ._fee .Peek (2);if _ceacb !=nil {return _bedd ,_ceacb ;};if (_ead [0]=='>')&&(_ead [1]=='>'){_edaa ._fee .ReadByte ();_edaa ._fee .ReadByte ();
break ;};_dgf ,_ceacb :=_edaa .parseName ();_bf .Log .Trace ("\u004be\u0079\u003a\u0020\u0025\u0073",_dgf .Name );if _ceacb !=nil {_bf .Log .Debug ("\u0045\u0052R\u004f\u0052\u003a\u0020\u0052\u0065\u0074\u0075\u0072\u006e\u0069\u006e\u0067\u0020\u006e\u0061\u006d\u0065\u002e\u0020\u0065\u0072r=\u0025\u0076",_ceacb );
return _bedd ,_ceacb ;};_edaa .skipSpaces ();_cba ,_ceacb :=_edaa .parseObject ();if _ceacb !=nil {return _bedd ,_ceacb ;};_bedd .Dict [_dgf .Name ]=_cba ;_edaa .skipSpaces ();_ead ,_ceacb =_edaa ._fee .Peek (3);if _ceacb !=nil {return _bedd ,_ceacb ;};
if string (_ead )=="\u0064\u0065\u0066"{_edaa ._fee .Discard (3);};};return _bedd ,nil ;};type cmapOperand struct{Operand string ;};func NewToUnicodeCMap (codeToRune map[CharCode ]rune )*CMap {_egd :=make (map[CharCode ]string ,len (codeToRune ));for _ba ,_ea :=range codeToRune {_egd [_ba ]=string (_ea );
};cmap :=&CMap {_cd :"\u0041d\u006fb\u0065\u002d\u0049\u0064\u0065n\u0074\u0069t\u0079\u002d\u0055\u0043\u0053",_ddg :2,_ef :16,_cda :CIDSystemInfo {Registry :"\u0041\u0064\u006fb\u0065",Ordering :"\u0055\u0043\u0053",Supplement :0},_fg :[]Codespace {{Low :0,High :0xffff}},_gf :_egd ,_fe :make (map[string ]CharCode ,len (codeToRune )),_dgb :make (map[CharCode ]CharCode ,len (codeToRune )),_eb :make (map[CharCode ]CharCode ,len (codeToRune ))};
cmap .computeInverseMappings ();return cmap ;};func (cmap *CMap )inCodespace (_bed CharCode ,_cad int )bool {for _ ,_dag :=range cmap ._fg {if _dag .Low <=_bed &&_bed <=_dag .High &&_cad ==_dag .NumBytes {return true ;};};return false ;};func (cmap *CMap )parseType ()error {_abe :=0;
_aga :=false ;for _aefa :=0;_aefa < 3&&!_aga ;_aefa ++{_ede ,_ffcd :=cmap .parseObject ();if _ffcd !=nil {return _ffcd ;};switch _db :=_ede .(type ){case cmapOperand :switch _db .Operand {case "\u0064\u0065\u0066":_aga =true ;default:_bf .Log .Error ("\u0070\u0061r\u0073\u0065\u0054\u0079\u0070\u0065\u003a\u0020\u0073\u0074\u0061\u0074\u0065\u0020\u0065\u0072\u0072\u006f\u0072\u002e\u0020\u006f=%\u0023\u0076",_ede );
return ErrBadCMap ;};case cmapInt :_abe =int (_db ._fdeb );};};cmap ._ddg =_abe ;return nil ;};var (ErrBadCMap =_bc .New ("\u0062\u0061\u0064\u0020\u0063\u006d\u0061\u0070");ErrBadCMapComment =_bc .New ("c\u006f\u006d\u006d\u0065\u006e\u0074 \u0073\u0068\u006f\u0075\u006c\u0064\u0020\u0073\u0074a\u0072\u0074\u0020w\u0069t\u0068\u0020\u0025");
ErrBadCMapDict =_bc .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0069\u0063\u0074"););const (_eg =4;MissingCodeRune ='\ufffd';MissingCodeString =string (MissingCodeRune ););type cmapObject interface{};func _fcg (_bccf cmapHexString )CharCode {_cfg :=CharCode (0);
for _ ,_fbaa :=range _bccf ._efea {_cfg <<=8;_cfg |=CharCode (_fbaa );};return _cfg ;};func (cmap *CMap )NBits ()int {return cmap ._ef };func (cmap *CMap )parseBfchar ()error {for {_aagd ,_dbg :=cmap .parseObject ();if _dbg !=nil {if _dbg ==_gc .EOF {break ;
};return _dbg ;};var _fff CharCode ;switch _ddc :=_aagd .(type ){case cmapOperand :if _ddc .Operand ==_fcae {return nil ;};return _bc .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065d\u0020\u006fp\u0065\u0072\u0061\u006e\u0064");case cmapHexString :_fff =_fcg (_ddc );
default:return _bc .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065\u0064\u0020\u0074\u0079\u0070\u0065");};_aagd ,_dbg =cmap .parseObject ();if _dbg !=nil {if _dbg ==_gc .EOF {break ;};return _dbg ;};var _aagf []rune ;switch _aed :=_aagd .(type ){case cmapOperand :if _aed .Operand ==_fcae {return nil ;
};_bf .Log .Debug ("\u0045\u0052\u0052\u004f\u0052\u003a\u0020\u0055\u006e\u0065x\u0070\u0065\u0063\u0074\u0065\u0064\u0020o\u0070\u0065\u0072\u0061\u006e\u0064\u002e\u0020\u0025\u0023\u0076",_aed );return ErrBadCMap ;case cmapHexString :_aagf =_bga (_aed );
case cmapName :_bf .Log .Debug ("E\u0052\u0052\u004f\u0052\u003a\u0020U\u006e\u0065\u0078\u0070\u0065\u0063\u0074\u0065\u0064 \u006e\u0061\u006de\u002e \u0025\u0023\u0076",_aed );_aagf =[]rune {MissingCodeRune };default:_bf .Log .Debug ("E\u0052\u0052\u004f\u0052\u003a\u0020U\u006e\u0065\u0078\u0070\u0065\u0063\u0074\u0065\u0064 \u0074\u0079\u0070e\u002e \u0025\u0023\u0076",_aagd );
return ErrBadCMap ;};cmap ._gf [_fff ]=string (_aagf );};return nil ;};func (cmap *CMap )Type ()int {return cmap ._ddg };type cmapName struct{Name string ;};func (cmap *CMap )CIDToCharcode (cid CharCode )(CharCode ,bool ){_ffe ,_cde :=cmap ._eb [cid ];
return _ffe ,_cde ;};type Codespace struct{NumBytes int ;Low CharCode ;High CharCode ;};func (cmap *CMap )Stream ()(*_a .PdfObjectStream ,error ){if cmap ._ab !=nil {return cmap ._ab ,nil ;};_afa ,_aff :=_a .MakeStream (cmap .Bytes (),_a .NewFlateEncoder ());
if _aff !=nil {return nil ,_aff ;};cmap ._ab =_afa ;return cmap ._ab ,nil ;};func LoadCmapFromData (data []byte ,isSimple bool )(*CMap ,error ){_bf .Log .Trace ("\u004c\u006fa\u0064\u0043\u006d\u0061\u0070\u0046\u0072\u006f\u006d\u0044\u0061\u0074\u0061\u003a\u0020\u0069\u0073\u0053\u0069\u006d\u0070\u006ce=\u0025\u0074",isSimple );
cmap :=_dce (isSimple );cmap .cMapParser =_cbg (data );_dda :=cmap .parse ();if _dda !=nil {return nil ,_dda ;};if len (cmap ._fg )==0{if cmap ._gg !=""{return cmap ,nil ;};_bf .Log .Debug ("\u0045\u0052R\u004f\u0052\u003a\u0020\u004e\u006f\u0020\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0073\u002e\u0020\u0063\u006d\u0061p=\u0025\u0073",cmap );
return nil ,ErrBadCMap ;};cmap .computeInverseMappings ();return cmap ,nil ;};func (cmap *CMap )computeInverseMappings (){for _ae ,_dgg :=range cmap ._dgb {if _faa ,_bae :=cmap ._eb [_dgg ];!_bae ||(_bae &&_faa > _ae ){cmap ._eb [_dgg ]=_ae ;};};for _fd ,_gfc :=range cmap ._gf {if _egg ,_gaf :=cmap ._fe [_gfc ];
!_gaf ||(_gaf &&_egg > _fd ){cmap ._fe [_gfc ]=_fd ;};};_bca .Slice (cmap ._fg ,func (_faf ,_bge int )bool {return cmap ._fg [_faf ].Low < cmap ._fg [_bge ].Low });};func _bb (_aadc string )string {_bba :=[]rune (_aadc );_cgd :=make ([]string ,len (_bba ));
for _gec ,_fbg :=range _bba {_cgd [_gec ]=_f .Sprintf ("\u0025\u0030\u0034\u0078",_fbg );};return _f .Sprintf ("\u003c\u0025\u0073\u003e",_be .Join (_cgd ,""));};type cmapDict struct{Dict map[string ]cmapObject ;};func (cmap *CMap )parseName ()error {_abg :="";
_agbc :=false ;for _dfd :=0;_dfd < 20&&!_agbc ;_dfd ++{_cec ,_fba :=cmap .parseObject ();if _fba !=nil {return _fba ;};switch _cgca :=_cec .(type ){case cmapOperand :switch _cgca .Operand {case "\u0064\u0065\u0066":_agbc =true ;default:_bf .Log .Debug ("\u0070\u0061\u0072\u0073\u0065\u004e\u0061\u006d\u0065\u003a\u0020\u0053\u0074\u0061\u0074\u0065\u0020\u0065\u0072\u0072\u006f\u0072\u002e\u0020o\u003d\u0025\u0023\u0076\u0020n\u0061\u006de\u003d\u0025\u0023\u0071",_cec ,_abg );
if _abg !=""{_abg =_f .Sprintf ("\u0025\u0073\u0020%\u0073",_abg ,_cgca .Operand );};_bf .Log .Debug ("\u0070\u0061\u0072\u0073\u0065\u004e\u0061\u006d\u0065\u003a \u0052\u0065\u0063\u006f\u0076\u0065\u0072e\u0064\u002e\u0020\u006e\u0061\u006d\u0065\u003d\u0025\u0023\u0071",_abg );
};case cmapName :_abg =_cgca .Name ;};};if !_agbc {_bf .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a \u0070\u0061\u0072\u0073\u0065N\u0061m\u0065:\u0020\u004e\u006f\u0020\u0064\u0065\u0066 ");return ErrBadCMap ;};cmap ._cd =_abg ;return nil ;};const (_eaf =100;
_gcb ="\u000a\u002f\u0043\u0049\u0044\u0049\u006e\u0069\u0074\u0020\u002f\u0050\u0072\u006fc\u0053\u0065\u0074\u0020\u0066\u0069\u006e\u0064\u0072es\u006fu\u0072c\u0065 \u0062\u0065\u0067\u0069\u006e\u000a\u0031\u0032\u0020\u0064\u0069\u0063\u0074\u0020\u0062\u0065\u0067\u0069n\u000a\u0062\u0065\u0067\u0069\u006e\u0063\u006d\u0061\u0070\n\u002f\u0043\u0049\u0044\u0053\u0079\u0073\u0074\u0065m\u0049\u006e\u0066\u006f\u0020\u003c\u003c\u0020\u002f\u0052\u0065\u0067\u0069\u0073t\u0072\u0079\u0020\u0028\u0041\u0064\u006f\u0062\u0065\u0029\u0020\u002f\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067\u0020\u0028\u0055\u0043\u0053)\u0020\u002f\u0053\u0075\u0070p\u006c\u0065\u006d\u0065\u006et\u0020\u0030\u0020\u003e\u003e\u0020\u0064\u0065\u0066\u000a\u002f\u0043\u004d\u0061\u0070\u004e\u0061\u006d\u0065\u0020\u002f\u0041\u0064\u006f\u0062\u0065-\u0049\u0064\u0065\u006e\u0074\u0069\u0074\u0079\u002d\u0055\u0043\u0053\u0020\u0064\u0065\u0066\u000a\u002fC\u004d\u0061\u0070\u0054\u0079\u0070\u0065\u0020\u0032\u0020\u0064\u0065\u0066\u000a\u0031\u0020\u0062\u0065\u0067\u0069\u006e\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063e\u0072\u0061n\u0067\u0065\n\u003c\u0030\u0030\u0030\u0030\u003e\u0020<\u0046\u0046\u0046\u0046\u003e\u000a\u0065\u006e\u0064\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065r\u0061\u006e\u0067\u0065\u000a";
_bef ="\u0065\u006e\u0064\u0063\u006d\u0061\u0070\u000a\u0043\u004d\u0061\u0070\u004e\u0061\u006d\u0065\u0020\u0063ur\u0072e\u006e\u0074\u0064\u0069\u0063\u0074\u0020\u002f\u0043\u004d\u0061\u0070 \u0064\u0065\u0066\u0069\u006e\u0065\u0072\u0065\u0073\u006f\u0075\u0072\u0063\u0065\u0020\u0070\u006fp\u000a\u0065\u006e\u0064\u000a\u0065\u006e\u0064\u000a";
);func _aag (_aeb string )rune {_eeb :=[]rune (_aeb );return _eeb [len (_eeb )-1]};type CharCode uint32 ;type cmapArray struct{Array []cmapObject ;};func LoadCmapFromDataCID (data []byte )(*CMap ,error ){return LoadCmapFromData (data ,false )};func (cmap *CMap )CharcodeToCID (code CharCode )(CharCode ,bool ){_gea ,_ed :=cmap ._dgb [code ];
return _gea ,_ed ;};func (_aagff *cMapParser )parseName ()(cmapName ,error ){_dbae :="";_eabf :=false ;for {_cabc ,_fdd :=_aagff ._fee .Peek (1);if _fdd ==_gc .EOF {break ;};if _fdd !=nil {return cmapName {_dbae },_fdd ;};if !_eabf {if _cabc [0]=='/'{_eabf =true ;
_aagff ._fee .ReadByte ();}else {_bf .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u004e\u0061\u006d\u0065\u0020\u0073\u0074a\u0072t\u0069n\u0067 \u0077\u0069\u0074\u0068\u0020\u0025\u0073\u0020\u0028\u0025\u0020\u0078\u0029",_cabc ,_cabc );return cmapName {_dbae },_f .Errorf ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006ea\u006d\u0065:\u0020\u0028\u0025\u0063\u0029",_cabc [0]);
};}else {if _a .IsWhiteSpace (_cabc [0]){break ;}else if (_cabc [0]=='/')||(_cabc [0]=='[')||(_cabc [0]=='(')||(_cabc [0]==']')||(_cabc [0]=='<')||(_cabc [0]=='>'){break ;}else if _cabc [0]=='#'{_cafg ,_gfcd :=_aagff ._fee .Peek (3);if _gfcd !=nil {return cmapName {_dbae },_gfcd ;
};_aagff ._fee .Discard (3);_aced ,_gfcd :=_b .DecodeString (string (_cafg [1:3]));if _gfcd !=nil {return cmapName {_dbae },_gfcd ;};_dbae +=string (_aced );}else {_dbc ,_ :=_aagff ._fee .ReadByte ();_dbae +=string (_dbc );};};};return cmapName {_dbae },nil ;
};func _bga (_eabe cmapHexString )[]rune {if len (_eabe ._efea )==1{return []rune {rune (_eabe ._efea [0])};};_gaaf :=_eabe ._efea ;if len (_gaaf )%2!=0{_gaaf =append (_gaaf ,0);_bf .Log .Debug ("\u0045\u0052\u0052O\u0052\u003a\u0020\u0068\u0065\u0078\u0054\u006f\u0052\u0075\u006e\u0065\u0073\u002e\u0020\u0050\u0061\u0064\u0064\u0069\u006e\u0067\u0020\u0073\u0068\u0065\u0078\u003d\u0025#\u0076\u0020\u0074\u006f\u0020\u0025\u002b\u0076",_eabe ,_gaaf );
};_dceb :=len (_gaaf )>>1;_fegb :=make ([]uint16 ,_dceb );for _fbad :=0;_fbad < _dceb ;_fbad ++{_fegb [_fbad ]=uint16 (_gaaf [_fbad <<1])<<8+uint16 (_gaaf [_fbad <<1+1]);};_ccg :=_dd .Decode (_fegb );return _ccg ;};type charRange struct{_gb CharCode ;_egb CharCode ;
};func _cbg (_efa []byte )*cMapParser {_cabg :=cMapParser {};_fbaf :=_g .NewBuffer (_efa );_cabg ._fee =_bd .NewReader (_fbaf );return &_cabg ;};const (_agaf ="\u0043\u0049\u0044\u0053\u0079\u0073\u0074\u0065\u006d\u0049\u006e\u0066\u006f";_gfff ="\u0062e\u0067\u0069\u006e\u0063\u006d\u0061p";
_affc ="\u0065n\u0064\u0063\u006d\u0061\u0070";_dad ="\u0062\u0065\u0067\u0069nc\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0072\u0061\u006e\u0067\u0065";_efg ="\u0065\u006e\u0064\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065r\u0061\u006e\u0067\u0065";
_abec ="b\u0065\u0067\u0069\u006e\u0062\u0066\u0063\u0068\u0061\u0072";_fcae ="\u0065n\u0064\u0062\u0066\u0063\u0068\u0061r";_bdc ="\u0062\u0065\u0067i\u006e\u0062\u0066\u0072\u0061\u006e\u0067\u0065";_gffb ="\u0065\u006e\u0064\u0062\u0066\u0072\u0061\u006e\u0067\u0065";
_cfe ="\u0062\u0065\u0067\u0069\u006e\u0063\u0069\u0064\u0072\u0061\u006e\u0067\u0065";_agbcd ="e\u006e\u0064\u0063\u0069\u0064\u0072\u0061\u006e\u0067\u0065";_bggg ="\u0075s\u0065\u0063\u006d\u0061\u0070";_cacb ="\u0043\u004d\u0061\u0070\u004e\u0061\u006d\u0065";
_gad ="\u0043\u004d\u0061\u0070\u0054\u0079\u0070\u0065";_afc ="C\u004d\u0061\u0070\u0056\u0065\u0072\u0073\u0069\u006f\u006e";);func _eafd (_aaa ,_caa int )int {if _aaa < _caa {return _aaa ;};return _caa ;};func (_bea *cMapParser )parseHexString ()(cmapHexString ,error ){_bea ._fee .ReadByte ();
_fbae :=[]byte ("\u0030\u0031\u0032\u003345\u0036\u0037\u0038\u0039\u0061\u0062\u0063\u0064\u0065\u0066\u0041\u0042\u0043\u0044E\u0046");_gbf :=_g .Buffer {};for {_bea .skipSpaces ();_fgd ,_fccb :=_bea ._fee .Peek (1);if _fccb !=nil {return cmapHexString {},_fccb ;
};if _fgd [0]=='>'{_bea ._fee .ReadByte ();break ;};_cge ,_ :=_bea ._fee .ReadByte ();if _g .IndexByte (_fbae ,_cge )>=0{_gbf .WriteByte (_cge );};};if _gbf .Len ()%2==1{_bf .Log .Debug ("\u0070\u0061rs\u0065\u0048\u0065x\u0053\u0074\u0072\u0069ng:\u0020ap\u0070\u0065\u006e\u0064\u0069\u006e\u0067 '\u0030\u0027\u0020\u0074\u006f\u0020\u0025#\u0071",_gbf .String ());
_gbf .WriteByte ('0');};_aagdd :=_gbf .Len ()/2;_ffa ,_ :=_b .DecodeString (_gbf .String ());return cmapHexString {_ebe :_aagdd ,_efea :_ffa },nil ;};func IsPredefinedCMap (name string )bool {return _c .AssetExists (name )};