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/
2020-08-31 21:12:07 +00:00
package cmap ;import (_d "bufio";_ga "bytes";_ge "encoding/hex";_da "errors";_e "fmt";_dg "github.com/unidoc/unipdf/v3/common";_a "github.com/unidoc/unipdf/v3/core";_ee "github.com/unidoc/unipdf/v3/internal/cmap/bcmaps";_c "io";_fe "sort";_g "strconv";_b "strings";_ed "unicode/utf16";);type cmapFloat struct{_aag float64 };func (_ffbg *cMapParser )skipSpaces ()(int ,error ){_ffg :=0;for {_beef ,_aaf :=_ffbg ._afd .Peek (1);if _aaf !=nil {return 0,_aaf ;};if _a .IsWhiteSpace (_beef [0]){_ffbg ._afd .ReadByte ();_ffg ++;}else {break ;};};return _ffg ,nil ;};func (_bacc *cMapParser )parseName ()(cmapName ,error ){_agd :="";_dcb :=false ;for {_fgaa ,_bdfa :=_bacc ._afd .Peek (1);if _bdfa ==_c .EOF {break ;};if _bdfa !=nil {return cmapName {_agd },_bdfa ;};if !_dcb {if _fgaa [0]=='/'{_dcb =true ;_bacc ._afd .ReadByte ();}else {_dg .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",_fgaa ,_fgaa );return cmapName {_agd },_e .Errorf ("\u0069n\u0076a\u006c\u0069\u0064\u0020\u006ea\u006d\u0065:\u0020\u0028\u0025\u0063\u0029",_fgaa [0]);};}else {if _a .IsWhiteSpace (_fgaa [0]){break ;}else if (_fgaa [0]=='/')||(_fgaa [0]=='[')||(_fgaa [0]=='(')||(_fgaa [0]==']')||(_fgaa [0]=='<')||(_fgaa [0]=='>'){break ;}else if _fgaa [0]=='#'{_edc ,_geaa :=_bacc ._afd .Peek (3);if _geaa !=nil {return cmapName {_agd },_geaa ;};_bacc ._afd .Discard (3);_caa ,_geaa :=_ge .DecodeString (string (_edc [1:3]));if _geaa !=nil {return cmapName {_agd },_geaa ;};_agd +=string (_caa );}else {_ceca ,_ :=_bacc ._afd .ReadByte ();_agd +=string (_ceca );};};};return cmapName {_agd },nil ;};type cmapArray struct{Array []cmapObject ;};const (_cc =4;MissingCodeRune ='\ufffd';MissingCodeString =string (MissingCodeRune ););func NewToUnicodeCMap (codeToRune map[CharCode ]rune )*CMap {_ce :=make (map[CharCode ]string ,len (codeToRune ));for _eb ,_gd :=range codeToRune {_ce [_eb ]=string (_gd );};cmap :=&CMap {_dc :"\u0041d\u006fb\u0065\u002d\u0049\u0064\u0065n\u0074\u0069t\u0079\u002d\u0055\u0043\u0053",_cbb :2,_edf :16,_bc :CIDSystemInfo {Registry :"\u0041\u0064\u006fb\u0065",Ordering :"\u0055\u0043\u0053",Supplement :0},_geff :[]Codespace {{Low :0,High :0xffff}},_fd :_ce ,_fec :make (map[string ]CharCode ,len (codeToRune )),_eefe :make (map[CharCode ]CharCode ,len (codeToRune )),_eg :make (map[CharCode ]CharCode ,len (codeToRune ))};cmap .computeInverseMappings ();return cmap ;};func (cmap *CMap )parseSystemInfo ()error {_gf :=false ;_cafd :=false ;_cbfg :="";_gaf :=false ;_bfa :=CIDSystemInfo {};for _eagf :=0;_eagf < 50&&!_gaf ;_eagf ++{_eefa ,_gcdc :=cmap .parseObject ();if _gcdc !=nil {return _gcdc ;};switch _gbd :=_eefa .(type ){case cmapDict :_ffea :=_gbd .Dict ;_cdb ,_bgc :=_ffea ["\u0052\u0065\u0067\u0069\u0073\u0074\u0072\u0079"];if !_bgc {_dg .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_eagg ,_bgc :=_cdb .(cmapString );if !_bgc {_dg .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bfa .Registry =_eagg .String ;_cdb ,_bgc =_ffea ["\u004f\u0072\u0064\u0065\u0072\u0069\u006e\u0067"];if !_bgc {_dg .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_eagg ,_bgc =_cdb .(cmapString );if !_bgc {_dg .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bfa .Ordering =_eagg .String ;_eda ,_bgc :=_ffea ["\u0053\u0075\u0070\u0070\u006c\u0065\u006d\u0065\u006e\u0074"];if !_bgc {_dg .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0020\u0042\u0061\u0064\u0020\u0053\u0079\u0073\u0074\u0065\u006d\u0020\u0049\u006ef\u006f");return ErrBadCMap ;};_bce ,_bgc :=_eda .(cmapInt );if !_bgc {_dg .Log .Debug ("\u0045\u0052\u0052\u004fR:\u0