12 lines
6.4 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-10-19 10:58:10 +00:00
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 ,_ad