unipdf/internal/cmap/cmap.go

12 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-01-26 01:31:56 +00:00
package cmap ;import (_g "bufio";_c "bytes";_ef "encoding/hex";_ce "errors";_d "fmt";_eb "github.com/unidoc/unipdf/v3/common";_ge "github.com/unidoc/unipdf/v3/core";_ed "github.com/unidoc/unipdf/v3/internal/cmap/bcmaps";_f "io";_cea "sort";_b "strconv";_af "strings";_a "unicode/utf16";);func IsPredefinedCMap (name string )bool {return _ed .AssetExists (name )};const (_ecf ="\u0043\u0049\u0044\u0053\u0079\u0073\u0074\u0065\u006d\u0049\u006e\u0066\u006f";_cege ="\u0062e\u0067\u0069\u006e\u0063\u006d\u0061p";_acg ="\u0065n\u0064\u0063\u006d\u0061\u0070";_ecce ="\u0062\u0065\u0067\u0069nc\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065\u0072\u0061\u006e\u0067\u0065";_ddf ="\u0065\u006e\u0064\u0063\u006f\u0064\u0065\u0073\u0070\u0061\u0063\u0065r\u0061\u006e\u0067\u0065";_beda ="b\u0065\u0067\u0069\u006e\u0062\u0066\u0063\u0068\u0061\u0072";_bagc ="\u0065n\u0064\u0062\u0066\u0063\u0068\u0061r";_eag ="\u0062\u0065\u0067i\u006e\u0062\u0066\u0072\u0061\u006e\u0067\u0065";_bbcg ="\u0065\u006e\u0064\u0062\u0066\u0072\u0061\u006e\u0067\u0065";_egd ="\u0062\u0065\u0067\u0069\u006e\u0063\u0069\u0064\u0072\u0061\u006e\u0067\u0065";_caf ="e\u006e\u0064\u0063\u0069\u0064\u0072\u0061\u006e\u0067\u0065";_ffa ="\u0075s\u0065\u0063\u006d\u0061\u0070";_aege ="\u0043\u004d\u0061\u0070\u004e\u0061\u006d\u0065";_fbe ="\u0043\u004d\u0061\u0070\u0054\u0079\u0070\u0065";_cefa ="C\u004d\u0061\u0070\u0056\u0065\u0072\u0073\u0069\u006f\u006e";);func LoadPredefinedCMap (name string )(*CMap ,error ){cmap ,_ceb :=_dg (name );if _ceb !=nil {return nil ,_ceb ;};if cmap ._ba ==""{cmap .computeInverseMappings ();return cmap ,nil ;};_ebg ,_ceb :=_dg (cmap ._ba );if _ceb !=nil {return nil ,_ceb ;};for _gdg ,_cec :=range _ebg ._ac {if _ ,_gf :=cmap ._ac [_gdg ];!_gf {cmap ._ac [_gdg ]=_cec ;};};cmap ._eef =append (cmap ._eef ,_ebg ._eef ...);cmap .computeInverseMappings ();return cmap ,nil ;};func (cmap *CMap )Bytes ()[]byte {_eb .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 ._df )> 0{return cmap ._df ;};cmap ._df =[]byte (_af .Join ([]string {_bgda ,cmap .toBfData (),_fgdb },"\u000a"));return cmap ._df ;};func _efac (_bde cmapHexString )[]rune {if len (_bde ._bcdb )==1{return []rune {rune (_bde ._bcdb [0])};};_agg :=_bde ._bcdb ;if len (_agg )%2!=0{_agg =append (_agg ,0);_eb .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",_bde ,_agg );};_gfaa :=len (_agg )>>1;_eeef :=make ([]uint16 ,_gfaa );for _cgec :=0;_cgec < _gfaa ;_cgec ++{_eeef [_cgec ]=uint16 (_agg [_cgec <<1])<<8+uint16 (_agg [_cgec <<1+1]);};_bgbe :=_a .Decode (_eeef );return _bgbe ;};func LoadCmapFromDataCID (data []byte )(*CMap ,error ){return LoadCmapFromData (data ,false )};func (cmap *CMap )CharcodeToUnicode (code CharCode )(string ,bool ){if _aadc ,_ggd :=cmap ._eed [code ];_ggd {return _aadc ,true ;};return MissingCodeString ,false ;};func (cmap *CMap )Stream ()(*_ge .PdfObjectStream ,error ){if cmap ._dff !=nil {return cmap ._dff ,nil ;};_agb ,_gda :=_ge .MakeStream (cmap .Bytes (),_ge .NewFlateEncoder ());if _gda !=nil {return nil ,_gda ;};cmap ._dff =_agb ;return cmap ._dff ,nil ;};func (cmap *CMap )CIDToCharcode (cid CharCode )(CharCode ,bool ){_aec ,_bab :=cmap ._egf [cid ];return _aec ,_bab ;};type cmapArray struct{Array []cmapObject ;};func (cmap *CMap )parseName ()error {_eda :="";_afc :=false ;for _agbf :=0;_agbf < 20&&!_afc ;_agbf ++{_bef ,_afb :=cmap .parseObject ();if _afb !=nil {return _afb ;};switch _bbcb :=_bef .(type ){case cmapOperand :switch _bbcb .Operand {case "\u0064\u0065\u0066":_afc =true ;default:_eb .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",_bef ,_eda );if _eda !=""{_eda =_d .