unipdf/internal/cmap/cmap.go
2021-05-11 00:01:27 +00:00

139 lines
40 KiB
Go

//
// 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/
package cmap ;import (_g "bufio";_ef "bytes";_b "encoding/hex";_gf "errors";_e "fmt";_ec "github.com/unidoc/unipdf/v3/common";_aa "github.com/unidoc/unipdf/v3/core";_cg "github.com/unidoc/unipdf/v3/internal/cmap/bcmaps";_d "io";_bb "sort";_eg "strconv";
_c "strings";_ee "unicode/utf16";);func (_gcga *cMapParser )parseComment ()(string ,error ){var _cbee _ef .Buffer ;_ ,_acab :=_gcga .skipSpaces ();if _acab !=nil {return _cbee .String (),_acab ;};_bfgc :=true ;for {_dbg ,_cgge :=_gcga ._efb .Peek (1);if _cgge !=nil {_ec .Log .Debug ("p\u0061r\u0073\u0065\u0043\u006f\u006d\u006d\u0065\u006et\u003a\u0020\u0065\u0072r=\u0025\u0076",_cgge );
return _cbee .String (),_cgge ;};if _bfgc &&_dbg [0]!='%'{return _cbee .String (),ErrBadCMapComment ;};_bfgc =false ;if (_dbg [0]!='\r')&&(_dbg [0]!='\n'){_abd ,_ :=_gcga ._efb .ReadByte ();_cbee .WriteByte (_abd );}else {break ;};};return _cbee .String (),nil ;
};func (cmap *CMap )Name ()string {return cmap ._fb };func (cmap *CMap )parseVersion ()error {_aba :="";_ffd :=false ;for _ffdd :=0;_ffdd < 3&&!_ffd ;_ffdd ++{_ggg ,_eade :=cmap .parseObject ();if _eade !=nil {return _eade ;};switch _bga :=_ggg .(type ){case cmapOperand :switch _bga .Operand {case "\u0064\u0065\u0066":_ffd =true ;
default:_ec .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",_ggg );
return ErrBadCMap ;};case cmapInt :_aba =_e .Sprintf ("\u0025\u0064",_bga ._beea );case cmapFloat :_aba =_e .Sprintf ("\u0025\u0066",_bga ._dcf );case cmapString :_aba =_bga .String ;default:_ec .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",_ggg );
};};cmap ._bc =_aba ;return nil ;};func _eb (_egg bool )*CMap {_fbc :=16;if _egg {_fbc =8;};return &CMap {_cbd :_fbc ,_eec :make (map[CharCode ]CharCode ),_cf :make (map[CharCode ]CharCode ),_fe :make (map[CharCode ]string ),_fc :make (map[string ]CharCode )};
};type CIDSystemInfo struct{Registry string ;Ordering string ;Supplement int ;};func _be (_bcf string )(*CMap ,error ){_gff ,_baa :=_cg .Asset (_bcf );if _baa !=nil {return nil ,_baa ;};return LoadCmapFromDataCID (_gff );};type charRange struct{_dc CharCode ;
_egb CharCode ;};func (_cadad *cMapParser )parseArray ()(cmapArray ,error ){_fba :=cmapArray {};_fba .Array =[]cmapObject {};_cadad ._efb .ReadByte ();for {_cadad .skipSpaces ();_gfa ,_aedd :=_cadad ._efb .Peek (1);if _aedd !=nil {return _fba ,_aedd ;};
if _gfa [0]==']'{_cadad ._efb .ReadByte ();break ;};_ddbf ,_aedd :=_cadad .parseObject ();if _aedd !=nil {return _fba ,_aedd ;};_fba .Array =append (_fba .Array ,_ddbf );};return _fba ,nil ;};func _cfab (_bea ,_fcf int )int {if _bea < _fcf {return _bea ;
};return _fcf ;};func (cmap *CMap )parseCIDRange ()error {for {_ccg ,_gaa :=cmap .parseObject ();if _gaa !=nil {if _gaa ==_d .EOF {break ;};return _gaa ;};_gae ,_gaae :=_ccg .(cmapHexString );if !_gaae {if _gdf ,_gefd :=_ccg .(cmapOperand );_gefd {if _gdf .Operand ==_dcg {return nil ;
};return _gf .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");};};_fefb :=_edb (_gae );
_ccg ,_gaa =cmap .parseObject ();if _gaa !=nil {if _gaa ==_d .EOF {break ;};return _gaa ;};_dceg ,_gaae :=_ccg .(cmapHexString );if !_gaae {return _gf .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 (_gae ._ddgc )!=len (_dceg ._ddgc ){return _gf .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");};_deca :=_edb (_dceg );
if _fefb > _deca {_ec .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",_fefb ,_deca );
return ErrBadCMap ;};_ccg ,_gaa =cmap .parseObject ();if _gaa !=nil {if _gaa ==_d .EOF {break ;};return _gaa ;};_cfed ,_gaae :=_ccg .(cmapInt );if !_gaae {return _gf .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 _cfed ._beea < 0{return _gf .New ("\u0069\u006e\u0076al\u0069\u0064\u0020\u0063\u0069\u0064\u0020\u0073\u0074\u0061\u0072\u0074\u0020\u0076\u0061\u006c\u0075\u0065");};_ccag :=_cfed ._beea ;for _cad :=_fefb ;_cad <=_deca ;_cad ++{cmap ._eec [_cad ]=CharCode (_ccag );
_ccag ++;};_ec .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",_fefb ,_deca ,_cfed ._beea );};return nil ;};func (cmap *CMap )CharcodeToUnicode (code CharCode )(string ,bool ){if _dce ,_cab :=cmap ._fe [code ];
_cab {return _dce ,true ;};return MissingCodeString ,false ;};type cmapDict struct{Dict map[string ]cmapObject ;};func (cmap *CMap )parseSystemInfo ()error {_dba :=false ;_aeb :=false ;_baef :="";_bdgb :=false ;_bbaa :=CIDSystemInfo {};for _ccb :=0;_ccb < 50&&!_bdgb ;
_ccb ++{_efgd ,_dec :=cmap .parseObject ();if _dec !=nil {return _dec ;};switch _fbcb :=_efgd .(type ){case cmapDict :_ebd :=_fbcb .Dict ;_gfc ,_gcggc :=_ebd ["\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079"];if !_gcggc {_ec .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");
return ErrBadCMap ;};_fbgg ,_gcggc :=_gfc .(cmapString );if !_gcggc {_ec .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bbaa .Registry =_fbgg .String ;
_gfc ,_gcggc =_ebd ["\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067"];if !_gcggc {_ec .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_fbgg ,_gcggc =_gfc .(cmapString );
if !_gcggc {_ec .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bbaa .Ordering =_fbgg .String ;_dgb ,_gcggc :=_ebd ["\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074"];
if !_gcggc {_ec .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_ada ,_gcggc :=_dgb .(cmapInt );if !_gcggc {_ec .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");
return ErrBadCMap ;};_bbaa .Supplement =int (_ada ._beea );_bdgb =true ;case cmapOperand :switch _fbcb .Operand {case "\u0062\u0065\u0067i\u006e":_dba =true ;case "\u0065\u006e\u0064":_bdgb =true ;case "\u0064\u0065\u0066":_aeb =false ;};case cmapName :if _dba {_baef =_fbcb .Name ;
_aeb =true ;};case cmapString :if _aeb {switch _baef {case "\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079":_bbaa .Registry =_fbcb .String ;case "\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067":_bbaa .Ordering =_fbcb .String ;};};case cmapInt :if _aeb {switch _baef {case "\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074":_bbaa .Supplement =int (_fbcb ._beea );
};};};};if !_bdgb {_ec .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 ._ac =_bbaa ;return nil ;};func (cmap *CMap )Stream ()(*_aa .PdfObjectStream ,error ){if cmap ._cbad !=nil {return cmap ._cbad ,nil ;};_gfd ,_fd :=_aa .MakeStream (cmap .Bytes (),_aa .NewFlateEncoder ());if _fd !=nil {return nil ,_fd ;
};cmap ._cbad =_gfd ;return cmap ._cbad ,nil ;};func (cmap *CMap )Bytes ()[]byte {_ec .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 ._da )> 0{return cmap ._da ;
};cmap ._da =[]byte (_c .Join ([]string {_ccc ,cmap .toBfData (),_edf },"\u000a"));return cmap ._da ;};type cmapName struct{Name string ;};func (cmap *CMap )inCodespace (_acg CharCode ,_aad int )bool {for _ ,_fff :=range cmap ._afg {if _fff .Low <=_acg &&_acg <=_fff .High &&_aad ==_fff .NumBytes {return true ;
};};return false ;};func (cmap *CMap )matchCode (_gge []byte )(_bbg CharCode ,_aceg int ,_eca bool ){for _ed :=0;_ed < _dg ;_ed ++{if _ed < len (_gge ){_bbg =_bbg <<8|CharCode (_gge [_ed ]);_aceg ++;};_eca =cmap .inCodespace (_bbg ,_ed +1);if _eca {return _bbg ,_aceg ,true ;
};};_ec .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",_gge ,string (_gge ),cmap );
return 0,0,false ;};func _edb (_ebf cmapHexString )CharCode {_bde :=CharCode (0);for _ ,_cbdd :=range _ebf ._ddgc {_bde <<=8;_bde |=CharCode (_cbdd );};return _bde ;};type cmapArray struct{Array []cmapObject ;};func (cmap *CMap )parseName ()error {_gee :="";
_fdb :=false ;for _ggc :=0;_ggc < 20&&!_fdb ;_ggc ++{_gcgg ,_geg :=cmap .parseObject ();if _geg !=nil {return _geg ;};switch _afa :=_gcgg .(type ){case cmapOperand :switch _afa .Operand {case "\u0064\u0065\u0066":_fdb =true ;default:_ec .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",_gcgg ,_gee );
if _gee !=""{_gee =_e .Sprintf ("\u0025\u0073\u0020%\u0073",_gee ,_afa .Operand );};_ec .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",_gee );
};case cmapName :_gee =_afa .Name ;};};if !_fdb {_ec .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a \u0070\u0061\u0072\u0073\u0065N\u0061m\u0065:\u0020\u004e\u006f\u0020\u0064\u0065\u0066 ");return ErrBadCMap ;};cmap ._fb =_gee ;return nil ;};type cMapParser struct{_efb *_g .Reader };
func _bdfb (_aafe cmapHexString )rune {_afeac :=_bada (_aafe );if _dcbc :=len (_afeac );_dcbc ==0{_ec .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",_aafe );
return MissingCodeRune ;};if len (_afeac )> 1{_ec .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",_aafe ,_afeac );
};return _afeac [0];};func (cmap *CMap )CharcodeBytesToUnicode (data []byte )(string ,int ){_cgg ,_bbd :=cmap .BytesToCharcodes (data );if !_bbd {_ec .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;};_aca :=make ([]string ,len (_cgg ));var _fbg []CharCode ;for _gef ,_fcc :=range _cgg {_dad ,_aaa :=cmap ._fe [_fcc ];if !_aaa {_fbg =append (_fbg ,_fcc );_dad =MissingCodeString ;};_aca [_gef ]=_dad ;};_ace :=_c .Join (_aca ,"");if len (_fbg )> 0{_ec .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 ),_cgg ,len (_fbg ),_fbg ,_ace ,cmap );
};return _ace ,len (_fbg );};func (_cgbe *cMapParser )skipSpaces ()(int ,error ){_gea :=0;for {_bbbe ,_agc :=_cgbe ._efb .Peek (1);if _agc !=nil {return 0,_agc ;};if _aa .IsWhiteSpace (_bbbe [0]){_cgbe ._efb .ReadByte ();_gea ++;}else {break ;};};return _gea ,nil ;
};func _ddde ()cmapDict {return cmapDict {Dict :map[string ]cmapObject {}}};type CharCode uint32 ;func _bada (_fgc cmapHexString )[]rune {if len (_fgc ._ddgc )==1{return []rune {rune (_fgc ._ddgc [0])};};_ggga :=_fgc ._ddgc ;if len (_ggga )%2!=0{_ggga =append (_ggga ,0);
_ec .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",_fgc ,_ggga );
};_beeee :=len (_ggga )>>1;_gfbe :=make ([]uint16 ,_beeee );for _dagb :=0;_dagb < _beeee ;_dagb ++{_gfbe [_dagb ]=uint16 (_ggga [_dagb <<1])<<8+uint16 (_ggga [_dagb <<1+1]);};_fgcg :=_ee .Decode (_gfbe );return _fgcg ;};func LoadPredefinedCMap (name string )(*CMap ,error ){cmap ,_ga :=_be (name );
if _ga !=nil {return nil ,_ga ;};if cmap ._gc ==""{cmap .computeInverseMappings ();return cmap ,nil ;};_ade ,_ga :=_be (cmap ._gc );if _ga !=nil {return nil ,_ga ;};for _dda ,_ea :=range _ade ._eec {if _ ,_def :=cmap ._eec [_dda ];!_def {cmap ._eec [_dda ]=_ea ;
};};cmap ._afg =append (cmap ._afg ,_ade ._afg ...);cmap .computeInverseMappings ();return cmap ,nil ;};func (_aec *cMapParser )parseName ()(cmapName ,error ){_cabg :="";_abbc :=false ;for {_aga ,_gefe :=_aec ._efb .Peek (1);if _gefe ==_d .EOF {break ;
};if _gefe !=nil {return cmapName {_cabg },_gefe ;};if !_abbc {if _aga [0]=='/'{_abbc =true ;_aec ._efb .ReadByte ();}else {_ec .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",_aga ,_aga );
return cmapName {_cabg },_e .Errorf ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006ea\u006d\u0065:\u0020\u0028\u0025\u0063\u0029",_aga [0]);};}else {if _aa .IsWhiteSpace (_aga [0]){break ;}else if (_aga [0]=='/')||(_aga [0]=='[')||(_aga [0]=='(')||(_aga [0]==']')||(_aga [0]=='<')||(_aga [0]=='>'){break ;
}else if _aga [0]=='#'{_ede ,_fda :=_aec ._efb .Peek (3);if _fda !=nil {return cmapName {_cabg },_fda ;};_aec ._efb .Discard (3);_dada ,_fda :=_b .DecodeString (string (_ede [1:3]));if _fda !=nil {return cmapName {_cabg },_fda ;};_cabg +=string (_dada );
}else {_cgbee ,_ :=_aec ._efb .ReadByte ();_cabg +=string (_cgbee );};};};return cmapName {_cabg },nil ;};func (cmap *CMap )CharcodeToCID (code CharCode )(CharCode ,bool ){_fbd ,_bae :=cmap ._eec [code ];return _fbd ,_bae ;};const (_gcb =100;_ccc ="\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";
_edf ="\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";
);type cmapString struct{String string ;};func NewToUnicodeCMap (codeToRune map[CharCode ]rune )*CMap {_egc :=make (map[CharCode ]string ,len (codeToRune ));for _gd ,_cd :=range codeToRune {_egc [_gd ]=string (_cd );};cmap :=&CMap {_fb :"\u0041d\u006fb\u0065\u002d\u0049\u0064\u0065n\u0074\u0069t\u0079\u002d\u0055\u0043\u0053",_ca :2,_cbd :16,_ac :CIDSystemInfo {Registry :"\u0041\u0064\u006fb\u0065",Ordering :"\u0055\u0043\u0053",Supplement :0},_afg :[]Codespace {{Low :0,High :0xffff}},_fe :_egc ,_fc :make (map[string ]CharCode ,len (codeToRune )),_eec :make (map[CharCode ]CharCode ,len (codeToRune )),_cf :make (map[CharCode ]CharCode ,len (codeToRune ))};
cmap .computeInverseMappings ();return cmap ;};func LoadCmapFromData (data []byte ,isSimple bool )(*CMap ,error ){_ec .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 :=_eb (isSimple );cmap .cMapParser =_ddeg (data );_dgg :=cmap .parse ();if _dgg !=nil {return nil ,_dgg ;};if len (cmap ._afg )==0{if cmap ._gc !=""{return cmap ,nil ;};_ec .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 ;};const (_fde ="\u0043\u0049\u0044\u0053\u0079\u0073\u0074\u0065\u006d\u0049\u006e\u0066\u006f";_eafa ="\u0062e\u0067\u0069\u006e\u0063\u006d\u0061p";_ecgg ="\u0065n\u0064\u0063\u006d\u0061\u0070";
_eaae ="\u0062\u0065\u0067\u0069nc\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0072\u0061\u006e\u0067\u0065";_fedc ="\u0065\u006e\u0064\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065r\u0061\u006e\u0067\u0065";_dag ="b\u0065\u0067\u0069\u006e\u0062\u0066\u0063\u0068\u0061\u0072";
_gbdb ="\u0065n\u0064\u0062\u0066\u0063\u0068\u0061r";_egbd ="\u0062\u0065\u0067i\u006e\u0062\u0066\u0072\u0061\u006e\u0067\u0065";_aaf ="\u0065\u006e\u0064\u0062\u0066\u0072\u0061\u006e\u0067\u0065";_cfea ="\u0062\u0065\u0067\u0069\u006e\u0063\u0069\u0064\u0072\u0061\u006e\u0067\u0065";
_dcg ="e\u006e\u0064\u0063\u0069\u0064\u0072\u0061\u006e\u0067\u0065";_bbc ="\u0075s\u0065\u0063\u006d\u0061\u0070";_agb ="\u0043\u004d\u0061\u0070\u004e\u0061\u006d\u0065";_gac ="\u0043\u004d\u0061\u0070\u0054\u0079\u0070\u0065";_dbb ="C\u004d\u0061\u0070\u0056\u0065\u0072\u0073\u0069\u006f\u006e";
);func (_cba *CIDSystemInfo )String ()string {return _e .Sprintf ("\u0025\u0073\u002d\u0025\u0073\u002d\u0025\u0030\u0033\u0064",_cba .Registry ,_cba .Ordering ,_cba .Supplement );};func (_eff *cMapParser )parseString ()(cmapString ,error ){_eff ._efb .ReadByte ();
_gcbc :=_ef .Buffer {};_bcdb :=1;for {_acdc ,_ecgc :=_eff ._efb .Peek (1);if _ecgc !=nil {return cmapString {_gcbc .String ()},_ecgc ;};if _acdc [0]=='\\'{_eff ._efb .ReadByte ();_cgc ,_fdc :=_eff ._efb .ReadByte ();if _fdc !=nil {return cmapString {_gcbc .String ()},_fdc ;
};if _aa .IsOctalDigit (_cgc ){_egfe ,_eeba :=_eff ._efb .Peek (2);if _eeba !=nil {return cmapString {_gcbc .String ()},_eeba ;};var _dee []byte ;_dee =append (_dee ,_cgc );for _ ,_gead :=range _egfe {if _aa .IsOctalDigit (_gead ){_dee =append (_dee ,_gead );
}else {break ;};};_eff ._efb .Discard (len (_dee )-1);_ec .Log .Trace ("\u004e\u0075\u006d\u0065ri\u0063\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u0020\u0022\u0025\u0073\u0022",_dee );_dggf ,_eeba :=_eg .ParseUint (string (_dee ),8,32);if _eeba !=nil {return cmapString {_gcbc .String ()},_eeba ;
};_gcbc .WriteByte (byte (_dggf ));continue ;};switch _cgc {case 'n':_gcbc .WriteByte ('\n');case 'r':_gcbc .WriteByte ('\r');case 't':_gcbc .WriteByte ('\t');case 'b':_gcbc .WriteByte ('\b');case 'f':_gcbc .WriteByte ('\f');case '(':_gcbc .WriteByte ('(');
case ')':_gcbc .WriteByte (')');case '\\':_gcbc .WriteByte ('\\');};continue ;}else if _acdc [0]=='('{_bcdb ++;}else if _acdc [0]==')'{_bcdb --;if _bcdb ==0{_eff ._efb .ReadByte ();break ;};};_cdg ,_ :=_eff ._efb .ReadByte ();_gcbc .WriteByte (_cdg );};
return cmapString {_gcbc .String ()},nil ;};type CMap struct{*cMapParser ;_fb string ;_cbd int ;_ca int ;_bc string ;_gc string ;_ac CIDSystemInfo ;_afg []Codespace ;_eec map[CharCode ]CharCode ;_cf map[CharCode ]CharCode ;_fe map[CharCode ]string ;_fc map[string ]CharCode ;
_da []byte ;_cbad *_aa .PdfObjectStream ;};func _adea (_bdg string )string {_eecb :=[]rune (_bdg );_badg :=make ([]string ,len (_eecb ));for _cee ,_afe :=range _eecb {_badg [_cee ]=_e .Sprintf ("\u0025\u0030\u0034\u0078",_afe );};return _e .Sprintf ("\u003c\u0025\u0073\u003e",_c .Join (_badg ,""));
};type cmapInt struct{_beea int64 };func LoadCmapFromDataCID (data []byte )(*CMap ,error ){return LoadCmapFromData (data ,false )};func (_fcda *cMapParser )parseHexString ()(cmapHexString ,error ){_fcda ._efb .ReadByte ();_bbf :=[]byte ("\u0030\u0031\u0032\u003345\u0036\u0037\u0038\u0039\u0061\u0062\u0063\u0064\u0065\u0066\u0041\u0042\u0043\u0044E\u0046");
_dcb :=_ef .Buffer {};for {_fcda .skipSpaces ();_cbag ,_fabb :=_fcda ._efb .Peek (1);if _fabb !=nil {return cmapHexString {},_fabb ;};if _cbag [0]=='>'{_fcda ._efb .ReadByte ();break ;};_cada ,_ :=_fcda ._efb .ReadByte ();if _ef .IndexByte (_bbf ,_cada )>=0{_dcb .WriteByte (_cada );
};};if _dcb .Len ()%2==1{_ec .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",_dcb .String ());_dcb .WriteByte ('0');};_cbg :=_dcb .Len ()/2;
_ddg ,_ :=_b .DecodeString (_dcb .String ());return cmapHexString {_decg :_cbg ,_ddgc :_ddg },nil ;};type Codespace struct{NumBytes int ;Low CharCode ;High CharCode ;};func (cmap *CMap )String ()string {_bdd :=cmap ._ac ;_gbd :=[]string {_e .Sprintf ("\u006e\u0062\u0069\u0074\u0073\u003a\u0025\u0064",cmap ._cbd ),_e .Sprintf ("\u0074y\u0070\u0065\u003a\u0025\u0064",cmap ._ca )};
if cmap ._bc !=""{_gbd =append (_gbd ,_e .Sprintf ("\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u003a\u0025\u0073",cmap ._bc ));};if cmap ._gc !=""{_gbd =append (_gbd ,_e .Sprintf ("u\u0073\u0065\u0063\u006d\u0061\u0070\u003a\u0025\u0023\u0071",cmap ._gc ));
};_gbd =append (_gbd ,_e .Sprintf ("\u0073\u0079\u0073\u0074\u0065\u006d\u0049\u006e\u0066\u006f\u003a\u0025\u0073",_bdd .String ()));if len (cmap ._afg )> 0{_gbd =append (_gbd ,_e .Sprintf ("\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0073\u003a\u0025\u0064",len (cmap ._afg )));
};if len (cmap ._fe )> 0{_gbd =append (_gbd ,_e .Sprintf ("\u0063\u006fd\u0065\u0054\u006fU\u006e\u0069\u0063\u006f\u0064\u0065\u003a\u0025\u0064",len (cmap ._fe )));};return _e .Sprintf ("\u0043\u004d\u0041P\u007b\u0025\u0023\u0071\u0020\u0025\u0073\u007d",cmap ._fb ,_c .Join (_gbd ,"\u0020"));
};func (cmap *CMap )CIDToCharcode (cid CharCode )(CharCode ,bool ){_fef ,_fed :=cmap ._cf [cid ];return _fef ,_fed ;};var (ErrBadCMap =_gf .New ("\u0062\u0061\u0064\u0020\u0063\u006d\u0061\u0070");ErrBadCMapComment =_gf .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 =_gf .New ("\u0069\u006e\u0076a\u006c\u0069\u0064\u0020\u0064\u0069\u0063\u0074"););func (cmap *CMap )parseType ()error {_cef :=0;_bgf :=false ;for _cfe :=0;_cfe < 3&&!_bgf ;_cfe ++{_df ,_gga :=cmap .parseObject ();if _gga !=nil {return _gga ;
};switch _fab :=_df .(type ){case cmapOperand :switch _fab .Operand {case "\u0064\u0065\u0066":_bgf =true ;default:_ec .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",_df );
return ErrBadCMap ;};case cmapInt :_cef =int (_fab ._beea );};};cmap ._ca =_cef ;return nil ;};func (cmap *CMap )parseBfrange ()error {for {var _dcad CharCode ;_aab ,_abb :=cmap .parseObject ();if _abb !=nil {if _abb ==_d .EOF {break ;};return _abb ;};
switch _fbf :=_aab .(type ){case cmapOperand :if _fbf .Operand ==_aaf {return nil ;};return _gf .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065d\u0020\u006fp\u0065\u0072\u0061\u006e\u0064");case cmapHexString :_dcad =_edb (_fbf );default:return _gf .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065\u0064\u0020\u0074\u0079\u0070\u0065");
};var _beee CharCode ;_aab ,_abb =cmap .parseObject ();if _abb !=nil {if _abb ==_d .EOF {break ;};return _abb ;};switch _ege :=_aab .(type ){case cmapOperand :_ec .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 :_beee =_edb (_ege );default:_ec .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a \u0055\u006e\u0065\u0078\u0070e\u0063t\u0065d\u0020\u0074\u0079\u0070\u0065\u0020\u0025T",_aab );return ErrBadCMap ;};_aab ,_abb =cmap .parseObject ();
if _abb !=nil {if _abb ==_d .EOF {break ;};return _abb ;};switch _acgg :=_aab .(type ){case cmapArray :if len (_acgg .Array )!=int (_beee -_dcad )+1{_ec .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 _adf :=_dcad ;_adf <=_beee ;_adf ++{_edd :=_acgg .Array [_adf -_dcad ];_ecd ,_bfa :=_edd .(cmapHexString );if !_bfa {return _gf .New ("\u006e\u006f\u006e-h\u0065\u0078\u0020\u0073\u0074\u0072\u0069\u006e\u0067\u0020\u0069\u006e\u0020\u0061\u0072\u0072\u0061\u0079");
};_gfe :=_bada (_ecd );cmap ._fe [_adf ]=string (_gfe );};case cmapHexString :_ced :=_bada (_acgg );_bff :=len (_ced );for _eeag :=_dcad ;_eeag <=_beee ;_eeag ++{cmap ._fe [_eeag ]=string (_ced );if _bff > 0{_ced [_bff -1]++;}else {_ec .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",_eeag );
};};default:_ec .Log .Debug ("\u0045R\u0052\u004f\u0052\u003a \u0055\u006e\u0065\u0078\u0070e\u0063t\u0065d\u0020\u0074\u0079\u0070\u0065\u0020\u0025T",_aab );return ErrBadCMap ;};};return nil ;};func _bece (_bbdd string )rune {_aea :=[]rune (_bbdd );return _aea [len (_aea )-1]};
type cmapOperand struct{Operand string ;};func (cmap *CMap )computeInverseMappings (){for _db ,_ddb :=range cmap ._eec {if _ab ,_abc :=cmap ._cf [_ddb ];!_abc ||(_abc &&_ab > _db ){cmap ._cf [_ddb ]=_db ;};};for _bf ,_bg :=range cmap ._fe {if _fg ,_bec :=cmap ._fc [_bg ];
!_bec ||(_bec &&_fg > _bf ){cmap ._fc [_bg ]=_bf ;};};_bb .Slice (cmap ._afg ,func (_gca ,_acd int )bool {return cmap ._afg [_gca ].Low < cmap ._afg [_acd ].Low });};func (_eda *cMapParser )parseObject ()(cmapObject ,error ){_eda .skipSpaces ();for {_baec ,_gdee :=_eda ._efb .Peek (2);
if _gdee !=nil {return nil ,_gdee ;};if _baec [0]=='%'{_eda .parseComment ();_eda .skipSpaces ();continue ;}else if _baec [0]=='/'{_aed ,_fabd :=_eda .parseName ();return _aed ,_fabd ;}else if _baec [0]=='('{_fcca ,_acad :=_eda .parseString ();return _fcca ,_acad ;
}else if _baec [0]=='['{_bdf ,_eefb :=_eda .parseArray ();return _bdf ,_eefb ;}else if (_baec [0]=='<')&&(_baec [1]=='<'){_gcc ,_cgaf :=_eda .parseDict ();return _gcc ,_cgaf ;}else if _baec [0]=='<'{_cbab ,_agfg :=_eda .parseHexString ();return _cbab ,_agfg ;
}else if _aa .IsDecimalDigit (_baec [0])||(_baec [0]=='-'&&_aa .IsDecimalDigit (_baec [1])){_cgb ,_fac :=_eda .parseNumber ();if _fac !=nil {return nil ,_fac ;};return _cgb ,nil ;}else {_abaf ,_egf :=_eda .parseOperand ();if _egf !=nil {return nil ,_egf ;
};return _abaf ,nil ;};};};func (cmap *CMap )BytesToCharcodes (data []byte )([]CharCode ,bool ){var _bee []CharCode ;if cmap ._cbd ==8{for _ ,_afgd :=range data {_bee =append (_bee ,CharCode (_afgd ));};return _bee ,true ;};for _adeb :=0;_adeb < len (data );
{_gcd ,_agf ,_bdc :=cmap .matchCode (data [_adeb :]);if !_bdc {_ec .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",_adeb ,data ,string (data ));
return _bee ,false ;};_bee =append (_bee ,_gcd );_adeb +=_agf ;};return _bee ,true ;};func (cmap *CMap )NBits ()int {return cmap ._cbd };type cmapFloat struct{_dcf float64 };type fbRange struct{_cc CharCode ;_f CharCode ;_de string ;};func NewCIDSystemInfo (obj _aa .PdfObject )(_cb CIDSystemInfo ,_bd error ){_af ,_dd :=_aa .GetDict (obj );
if !_dd {return CIDSystemInfo {},_aa .ErrTypeError ;};_aae ,_dd :=_aa .GetStringVal (_af .Get ("\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079"));if !_dd {return CIDSystemInfo {},_aa .ErrTypeError ;};_ba ,_dd :=_aa .GetStringVal (_af .Get ("\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067"));
if !_dd {return CIDSystemInfo {},_aa .ErrTypeError ;};_ad ,_dd :=_aa .GetIntVal (_af .Get ("\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074"));if !_dd {return CIDSystemInfo {},_aa .ErrTypeError ;};return CIDSystemInfo {Registry :_aae ,Ordering :_ba ,Supplement :_ad },nil ;
};func IsPredefinedCMap (name string )bool {return _cg .AssetExists (name )};func (_afce *cMapParser )parseNumber ()(cmapObject ,error ){_fce ,_cda :=_aa .ParseNumber (_afce ._efb );if _cda !=nil {return nil ,_cda ;};switch _cbaf :=_fce .(type ){case *_aa .PdfObjectFloat :return cmapFloat {float64 (*_cbaf )},nil ;
case *_aa .PdfObjectInteger :return cmapInt {int64 (*_cbaf )},nil ;};return nil ,_e .Errorf ("\u0075n\u0068\u0061\u006e\u0064\u006c\u0065\u0064\u0020\u006e\u0075\u006db\u0065\u0072\u0020\u0074\u0079\u0070\u0065\u0020\u0025\u0054",_fce );};func (cmap *CMap )parseCodespaceRange ()error {for {_ega ,_fdd :=cmap .parseObject ();
if _fdd !=nil {if _fdd ==_d .EOF {break ;};return _fdd ;};_bgff ,_aced :=_ega .(cmapHexString );if !_aced {if _bbaf ,_cbcc :=_ega .(cmapOperand );_cbcc {if _bbaf .Operand ==_fedc {return nil ;};return _gf .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065d\u0020\u006fp\u0065\u0072\u0061\u006e\u0064");
};};_ega ,_fdd =cmap .parseObject ();if _fdd !=nil {if _fdd ==_d .EOF {break ;};return _fdd ;};_defg ,_aced :=_ega .(cmapHexString );if !_aced {return _gf .New ("\u006e\u006f\u006e-\u0068\u0065\u0078\u0020\u0068\u0069\u0067\u0068");};if len (_bgff ._ddgc )!=len (_defg ._ddgc ){return _gf .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");
};_cbe :=_edb (_bgff );_cca :=_edb (_defg );if _cca < _cbe {_ec .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",_cbe ,_cca );
return ErrBadCMap ;};_ddd :=_defg ._decg ;_bag :=Codespace {NumBytes :_ddd ,Low :_cbe ,High :_cca };cmap ._afg =append (cmap ._afg ,_bag );_ec .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",_cbe ,_cca );
};if len (cmap ._afg )==0{_ec .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 (cmap *CMap )parseBfchar ()error {for {_fcd ,_caba :=cmap .parseObject ();
if _caba !=nil {if _caba ==_d .EOF {break ;};return _caba ;};var _gfb CharCode ;switch _ece :=_fcd .(type ){case cmapOperand :if _ece .Operand ==_gbdb {return nil ;};return _gf .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065d\u0020\u006fp\u0065\u0072\u0061\u006e\u0064");
case cmapHexString :_gfb =_edb (_ece );default:return _gf .New ("\u0075n\u0065x\u0070\u0065\u0063\u0074\u0065\u0064\u0020\u0074\u0079\u0070\u0065");};_fcd ,_caba =cmap .parseObject ();if _caba !=nil {if _caba ==_d .EOF {break ;};return _caba ;};var _fea []rune ;
switch _bdce :=_fcd .(type ){case cmapOperand :if _bdce .Operand ==_gbdb {return nil ;};_ec .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",_bdce );
return ErrBadCMap ;case cmapHexString :_fea =_bada (_bdce );case cmapName :_ec .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",_bdce );_fea =[]rune {MissingCodeRune };
default:_ec .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",_fcd );return ErrBadCMap ;};cmap ._fe [_gfb ]=string (_fea );};return nil ;};type cmapObject interface{};
func (cmap *CMap )Type ()int {return cmap ._ca };const (_dg =4;MissingCodeRune ='\ufffd';MissingCodeString =string (MissingCodeRune ););type cmapHexString struct{_decg int ;_ddgc []byte ;};func (cmap *CMap )parse ()error {var _abg cmapObject ;for {_gda ,_edc :=cmap .parseObject ();
if _edc !=nil {if _edc ==_d .EOF {break ;};_ec .Log .Debug ("\u0045\u0052\u0052OR\u003a\u0020\u0070\u0061\u0072\u0073\u0069\u006e\u0067\u0020\u0043\u004d\u0061\u0070\u003a\u0020\u0025\u0076",_edc );return _edc ;};switch _beg :=_gda .(type ){case cmapOperand :_dab :=_beg ;
switch _dab .Operand {case _eaae :_bfd :=cmap .parseCodespaceRange ();if _bfd !=nil {return _bfd ;};case _cfea :_fbe :=cmap .parseCIDRange ();if _fbe !=nil {return _fbe ;};case _dag :_fccd :=cmap .parseBfchar ();if _fccd !=nil {return _fccd ;};case _egbd :_afea :=cmap .parseBfrange ();
if _afea !=nil {return _afea ;};case _bbc :if _abg ==nil {_ec .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 ;};_acaec ,_eaf :=_abg .(cmapName );
if !_eaf {_ec .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",_abg );return ErrBadCMap ;};cmap ._gc =_acaec .Name ;
case _fde :_ceg :=cmap .parseSystemInfo ();if _ceg !=nil {return _ceg ;};};case cmapName :_gdd :=_beg ;switch _gdd .Name {case _fde :_aag :=cmap .parseSystemInfo ();if _aag !=nil {return _aag ;};case _agb :_bfda :=cmap .parseName ();if _bfda !=nil {return _bfda ;
};case _gac :_gcdd :=cmap .parseType ();if _gcdd !=nil {return _gcdd ;};case _dbb :_gbe :=cmap .parseVersion ();if _gbe !=nil {return _gbe ;};};};_abg =_gda ;};return nil ;};func (cmap *CMap )toBfData ()string {if len (cmap ._fe )==0{return "";};_ae :=make ([]CharCode ,0,len (cmap ._fe ));
for _dca :=range cmap ._fe {_ae =append (_ae ,_dca );};_bb .Slice (_ae ,func (_fee ,_aaad int )bool {return _ae [_fee ]< _ae [_aaad ]});var _ead []charRange ;_eea :=charRange {_ae [0],_ae [0]};_feda :=cmap ._fe [_ae [0]];for _ ,_fgf :=range _ae [1:]{_fbb :=cmap ._fe [_fgf ];
if _fgf ==_eea ._egb +1&&_bece (_fbb )==_bece (_feda )+1{_eea ._egb =_fgf ;}else {_ead =append (_ead ,_eea );_eea ._dc ,_eea ._egb =_fgf ,_fgf ;};_feda =_fbb ;};_ead =append (_ead ,_eea );var _fccf []CharCode ;var _ddef []fbRange ;for _ ,_cabe :=range _ead {if _cabe ._dc ==_cabe ._egb {_fccf =append (_fccf ,_cabe ._dc );
}else {_ddef =append (_ddef ,fbRange {_cc :_cabe ._dc ,_f :_cabe ._egb ,_de :cmap ._fe [_cabe ._dc ]});};};_ec .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 (_ead ),len (_fccf ),len (_ddef ));
var _cce []string ;if len (_fccf )> 0{_fbbb :=(len (_fccf )+_gcb -1)/_gcb ;for _bfg :=0;_bfg < _fbbb ;_bfg ++{_eaa :=_cfab (len (_fccf )-_bfg *_gcb ,_gcb );_cce =append (_cce ,_e .Sprintf ("\u0025\u0064\u0020\u0062\u0065\u0067\u0069\u006e\u0062f\u0063\u0068\u0061\u0072",_eaa ));
for _bfc :=0;_bfc < _eaa ;_bfc ++{_ffb :=_fccf [_bfg *_gcb +_bfc ];_acae :=cmap ._fe [_ffb ];_cce =append (_cce ,_e .Sprintf ("\u003c%\u0030\u0034\u0078\u003e\u0020\u0025s",_ffb ,_adea (_acae )));};_cce =append (_cce ,"\u0065n\u0064\u0062\u0066\u0063\u0068\u0061r");
};};if len (_ddef )> 0{_cbc :=(len (_ddef )+_gcb -1)/_gcb ;for _daf :=0;_daf < _cbc ;_daf ++{_bge :=_cfab (len (_ddef )-_daf *_gcb ,_gcb );_cce =append (_cce ,_e .Sprintf ("\u0025d\u0020b\u0065\u0067\u0069\u006e\u0062\u0066\u0072\u0061\u006e\u0067\u0065",_bge ));
for _dcd :=0;_dcd < _bge ;_dcd ++{_bbb :=_ddef [_daf *_gcb +_dcd ];_cce =append (_cce ,_e .Sprintf ("\u003c%\u00304\u0078\u003e\u003c\u0025\u0030\u0034\u0078\u003e\u0020\u0025\u0073",_bbb ._cc ,_bbb ._f ,_adea (_bbb ._de )));};_cce =append (_cce ,"\u0065\u006e\u0064\u0062\u0066\u0072\u0061\u006e\u0067\u0065");
};};return _c .Join (_cce ,"\u000a");};func (cmap *CMap )StringToCID (s string )(CharCode ,bool ){_fa ,_cdc :=cmap ._fc [s ];return _fa ,_cdc };func _ddeg (_eef []byte )*cMapParser {_bcd :=cMapParser {};_dga :=_ef .NewBuffer (_eef );_bcd ._efb =_g .NewReader (_dga );
return &_bcd ;};func (_gag *cMapParser )parseDict ()(cmapDict ,error ){_ec .Log .Trace ("\u0052\u0065\u0061\u0064\u0069\u006e\u0067\u0020\u0050\u0044\u0046\u0020D\u0069\u0063\u0074\u0021");_dac :=_ddde ();_cdd ,_ :=_gag ._efb .ReadByte ();if _cdd !='<'{return _dac ,ErrBadCMapDict ;
};_cdd ,_ =_gag ._efb .ReadByte ();if _cdd !='<'{return _dac ,ErrBadCMapDict ;};for {_gag .skipSpaces ();_cade ,_begb :=_gag ._efb .Peek (2);if _begb !=nil {return _dac ,_begb ;};if (_cade [0]=='>')&&(_cade [1]=='>'){_gag ._efb .ReadByte ();_gag ._efb .ReadByte ();
break ;};_bab ,_begb :=_gag .parseName ();_ec .Log .Trace ("\u004be\u0079\u003a\u0020\u0025\u0073",_bab .Name );if _begb !=nil {_ec .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",_begb );
return _dac ,_begb ;};_gag .skipSpaces ();_bbad ,_begb :=_gag .parseObject ();if _begb !=nil {return _dac ,_begb ;};_dac .Dict [_bab .Name ]=_bbad ;_gag .skipSpaces ();_cade ,_begb =_gag ._efb .Peek (3);if _begb !=nil {return _dac ,_begb ;};if string (_cade )=="\u0064\u0065\u0066"{_gag ._efb .Discard (3);
};};return _dac ,nil ;};func (_bbba *cMapParser )parseOperand ()(cmapOperand ,error ){_dddc :=cmapOperand {};_abad :=_ef .Buffer {};for {_baf ,_aeab :=_bbba ._efb .Peek (1);if _aeab !=nil {if _aeab ==_d .EOF {break ;};return _dddc ,_aeab ;};if _aa .IsDelimiter (_baf [0]){break ;
};if _aa .IsWhiteSpace (_baf [0]){break ;};_dced ,_ :=_bbba ._efb .ReadByte ();_abad .WriteByte (_dced );};if _abad .Len ()==0{return _dddc ,_e .Errorf ("\u0069\u006e\u0076al\u0069\u0064\u0020\u006f\u0070\u0065\u0072\u0061\u006e\u0064\u0020\u0028\u0065\u006d\u0070\u0074\u0079\u0029");
};_dddc .Operand =_abad .String ();return _dddc ,nil ;};