2020-10-19 10:58:10 +00:00

12 lines
6.4 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 context ;import (_ae "errors";_ad "github.com/golang/freetype/truetype";_ge "github.com/unidoc/unipdf/v3/core";_d "github.com/unidoc/unipdf/v3/internal/textencoding";_ab "github.com/unidoc/unipdf/v3/internal/transform";_ag "github.com/unidoc/unipdf/v3/model";_c "golang.org/x/image/font";_ga "image";_a "image/color";);func (_fg *TextFont )CharcodesToUnicode (charcodes []_d .CharCode )[]rune {if _fg ._ffe !=nil {return _fg ._ffe .CharcodesToUnicode (charcodes );};return _fg .Font .CharcodesToUnicode (charcodes );};func (_adcfa *TextState )ProcDQ (data []byte ,aw ,ac float64 ,ctx Context ){_adcfa .Tw =aw ;_adcfa .Tc =ac ;_adcfa .ProcQ (data ,ctx );};func (_dcd *TextFont )BytesToCharcodes (data []byte )[]_d .CharCode {if _dcd ._ffe !=nil {return _dcd ._ffe .BytesToCharcodes (data );};return _dcd .Font .BytesToCharcodes (data );};func (_aed *TextFont )WithSize (size float64 ,originalFont *_ag .PdfFont )*TextFont {if size <=1{size =10;};return &TextFont {Font :_aed .Font ,Face :_ad .NewFace (_aed ._dc ,&_ad .Options {Size :size }),Size :size ,_dc :_aed ._dc ,_ffe :originalFont };};type LineJoin int ;type Pattern interface{ColorAt (_e ,_abf int )_a .Color ;};func (_adcc *TextState )ProcTm (a ,b ,c ,d ,e ,f float64 ){_adcc .Tm =_ab .NewMatrix (a ,b ,c ,d ,e ,-f );_adcc .Tlm =_adcc .Tm .Clone ();};type TextState struct{Tc float64 ;Tw float64 ;Th float64 ;Tl float64 ;Tf *TextFont ;Ts float64 ;Tm _ab .Matrix ;Tlm _ab .Matrix ;};func NewTextState ()*TextState {return &TextState {Th :100,Tm :_ab .IdentityMatrix (),Tlm :_ab .IdentityMatrix ()};};func (_beb *TextFont )GetRuneMetrics (r rune )(float64 ,float64 ,bool ){if _ggd ,_cf :=_beb .Font .GetRuneMetrics (r );_cf &&_ggd .Wx !=0{return _ggd .Wx ,_ggd .Wy ,_cf ;};if _beb ._ffe ==nil {return 0,0,false ;};_dgfd ,_cag :=_beb ._ffe .GetRuneMetrics (r );return _dgfd .Wx ,_dgfd .Wy ,_cag &&_dgfd .Wx !=0;};func NewTextFont (font *_ag .PdfFont ,size float64 )(*TextFont ,error ){_eed :=font .FontDescriptor ();if _eed ==nil {return nil ,_ae .New ("\u0063\u006fu\u006c\u0064\u0020\u006e\u006f\u0074\u0020\u0067\u0065\u0074\u0020\u0066\u006f\u006e\u0074\u0020\u0064\u0065\u0073\u0063\u0072\u0069pt\u006f\u0072");};_bf ,_dag :=_ge .GetStream (_eed .FontFile2 );if !_dag {return nil ,_ae .New ("\u006di\u0073\u0073\u0069\u006e\u0067\u0020\u0066\u006f\u006e\u0074\u0020f\u0069\u006c\u0065\u0020\u0073\u0074\u0072\u0065\u0061\u006d");};_agc ,_aae :=_ge .DecodeStream (_bf );if _aae !=nil {return nil ,_aae ;};_db ,_aae :=_ad .Parse (_agc );if _aae !=nil {return nil ,_aae ;};if size <=1{size =10;};return &TextFont {Font :font ,Face :_ad .NewFace (_db ,&_ad .Options {Size :size }),Size :size ,_dc :_db },nil ;};func (_cgb *TextFont )GetCharMetrics (code _d .CharCode )(float64 ,float64 ,bool ){if _dagb ,_cac :=_cgb .Font .GetCharMetrics (code );_cac &&_dagb .Wx !=0{return _dagb .Wx ,_dagb .Wy ,_cac ;};if _cgb ._ffe ==nil {return 0,0,false ;};_de ,_gd :=_cgb ._ffe .GetCharMetrics (code );return _de .Wx ,_de .Wy ,_gd &&_de .Wx !=0;};type Context interface{Push ();Pop ();Matrix ()_ab .Matrix ;SetMatrix (_da _ab .Matrix );Translate (_gc ,_af float64 );Scale (_gg ,_afa float64 );Rotate (_cg float64 );MoveTo (_ec ,_ged float64 );LineTo (_eb ,_ef float64 );CubicTo (_be ,_ed ,_cc ,_bc ,_f ,_bd float64 );QuadraticTo (_fa ,_efc ,_aa ,_ca float64 );NewSubPath ();ClosePath ();ClearPath ();Clip ();ClipPreserve ();ResetClip ();LineWidth ()float64 ;SetLineWidth (_dgc float64 );SetLineCap (_agg LineCap );SetLineJoin (_aba LineJoin );SetDash (_fc ...float64 );SetDashOffset (_gge float64 );Fill ();FillPreserve ();Stroke ();StrokePreserve ();SetRGBA (_fb ,_bcg ,_fe ,_cab float64 );SetFillRGBA (_aec ,_fbg ,_fed ,_efg float64 );SetFillStyle (_edg Pattern );SetFillRule (_ecg FillRule );SetStrokeRGBA (_df ,_cb ,_gee ,_fbb float64 );SetStrokeStyle (_eda Pattern );TextState ()*TextState ;DrawString (_fba string ,_fbgd ,_ff float64 );MeasureString (_ba string )(_gb ,_gbb float64 );DrawRectangle (_dgf ,_gac ,_adc ,_ecc float64 );DrawImage (_aef _ga .Image ,_ea ,_bg int );DrawImageAnchored (_bac _ga .Image ,_ebe ,_dga int ,_ee ,_adcf float64 );Height ()int ;Width ()int ;};func (_cca *TextState )ProcTd (tx ,ty float64 ){_cca .Tlm .Concat (_ab .TranslationMatrix (tx ,-ty ));_cca .Tm =_cca .Tlm .Clone ();};func (_bcf *TextState )ProcTStar (){_bcf .ProcTd (0,-_bcf .Tl )};type FillRule int ;const (FillRuleWinding FillRule =iota ;FillRuleEvenOdd ;);func NewTextFontFromPath (filePath string ,size float64 )(*TextFont ,error ){_fad ,_gce :=_ag .NewPdfFontFromTTFFile (filePath );if _gce !=nil {return nil ,_gce ;};return NewTextFont (_fad ,size );};type Gradient interface{Pattern ;AddColorStop (_b float64 ,_dg _a .Color );};func (_bb *TextState )ProcTD (tx ,ty float64 ){_bb .Tl =-ty ;_bb .ProcTd (tx ,ty )};type LineCap int ;func (_abbb *TextState )Reset (){_abbb .Tm =_ab .IdentityMatrix ();_abbb .Tlm =_ab .IdentityMatrix ()};func (_egb *TextState )ProcTf (font *TextFont ){_egb .Tf =font };const (LineJoinRound LineJoin =iota ;LineJoinBevel ;);func (_ebb *TextState )Translate (tx ,ty float64 ){_ebb .Tm =_ab .TranslationMatrix (tx ,ty ).Mult (_ebb .Tm );};func (_eg *TextState )ProcTj (data []byte ,ctx Context ){_abb :=_eg .Tf .Size ;_aad :=_eg .Th /100.0;_gedb :=_ab .NewMatrix (_abb *_aad ,0,0,_abb ,0,_eg .Ts );_cd :=_eg .Tf .CharcodesToUnicode (_eg .Tf .BytesToCharcodes (data ));for _ ,_gged :=range _cd {if _gged =='\x00'{continue ;};_aaa :=_eg .Tm .Clone ();_eg .Tm .Concat (_gedb );_dgfe ,_cdg :=_eg .Tm .Transform (0,0);ctx .Scale (1,-1);ctx .DrawString (string (_gged ),_dgfe ,_cdg );ctx .Scale (1,-1);_ggf :=0.0;if _gged ==' '{_ggf =_eg .Tw ;};var _efa float64 ;if _ac ,_ ,_ccg :=_eg .Tf .GetRuneMetrics (_gged );_ccg {_efa =_ac *0.001*_abb ;}else {_efa ,_ =ctx .MeasureString (string (_gged ));};_egd :=(_efa +_eg .Tc +_ggf )*_aad ;_eg .Tm =_ab .TranslationMatrix (_egd ,0).Mult (_aaa );};};func (_efd *TextState )ProcQ (data []byte ,ctx Context ){_efd .ProcTStar ();_efd .ProcTj (data ,ctx )};const (LineCapRound LineCap =iota ;LineCapButt ;LineCapSquare ;);type TextFont struct{Font *_ag .PdfFont ;Face _c .Face ;Size float64 ;_dc *_ad .Font ;_ffe *_ag .PdfFont ;};