2022-06-27 19:58:38 +00:00

37 lines
7.1 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 (_ga "errors";_a "github.com/unidoc/freetype/truetype";_gg "github.com/unidoc/unipdf/v3/core";_e "github.com/unidoc/unipdf/v3/internal/textencoding";_b "github.com/unidoc/unipdf/v3/internal/transform";_gaa "github.com/unidoc/unipdf/v3/model";
_gf "golang.org/x/image/font";_f "image";_d "image/color";);const (FillRuleWinding FillRule =iota ;FillRuleEvenOdd ;);const (LineCapRound LineCap =iota ;LineCapButt ;LineCapSquare ;);type Gradient interface{Pattern ;AddColorStop (_ac float64 ,_bg _d .Color );
};func (_dfe *TextFont )BytesToCharcodes (data []byte )[]_e .CharCode {if _dfe ._cg !=nil {return _dfe ._cg .BytesToCharcodes (data );};return _dfe .Font .BytesToCharcodes (data );};func (_bdc *TextState )ProcQ (data []byte ,ctx Context ){_bdc .ProcTStar ();
_bdc .ProcTj (data ,ctx )};func (_dg *TextFont )GetCharMetrics (code _e .CharCode )(float64 ,float64 ,bool ){if _gbfb ,_cfd :=_dg .Font .GetCharMetrics (code );_cfd &&_gbfb .Wx !=0{return _gbfb .Wx ,_gbfb .Wy ,_cfd ;};if _dg ._cg ==nil {return 0,0,false ;
};_dgd ,_fe :=_dg ._cg .GetCharMetrics (code );return _dgd .Wx ,_dgd .Wy ,_fe &&_dgd .Wx !=0;};type Context interface{Push ();Pop ();Matrix ()_b .Matrix ;SetMatrix (_bgd _b .Matrix );Translate (_ace ,_ee float64 );Scale (_de ,_bf float64 );Rotate (_gc float64 );
MoveTo (_aa ,_bca float64 );LineTo (_fg ,_ba float64 );CubicTo (_bcd ,_fgf ,_ae ,_fgb ,_da ,_ge float64 );QuadraticTo (_fc ,_c ,_ec ,_ce float64 );NewSubPath ();ClosePath ();ClearPath ();Clip ();ClipPreserve ();ResetClip ();LineWidth ()float64 ;SetLineWidth (_gfd float64 );
SetLineCap (_bgb LineCap );SetLineJoin (_ca LineJoin );SetDash (_ecg ...float64 );SetDashOffset (_bab float64 );Fill ();FillPreserve ();Stroke ();StrokePreserve ();SetRGBA (_cf ,_aeg ,_gff ,_be float64 );SetFillRGBA (_fa ,_af ,_geg ,_ff float64 );SetFillStyle (_gea Pattern );
SetFillRule (_dd FillRule );SetStrokeRGBA (_ef ,_dec ,_df ,_fd float64 );SetStrokeStyle (_gd Pattern );FillPattern ()Pattern ;StrokePattern ()Pattern ;TextState ()*TextState ;DrawString (_dac string ,_efg _gf .Face ,_fff ,_db float64 );MeasureString (_gb string ,_bae _gf .Face )(_bff ,_cc float64 );
DrawRectangle (_bd ,_cab ,_gfb ,_afa float64 );DrawImage (_ag _f .Image ,_bda ,_eca int );DrawImageAnchored (_gge _f .Image ,_ccc ,_gad int ,_efc ,_gaaa float64 );Height ()int ;Width ()int ;};func (_dgf *TextState )ProcDQ (data []byte ,aw ,ac float64 ,ctx Context ){_dgf .Tw =aw ;
_dgf .Tc =ac ;_dgf .ProcQ (data ,ctx );};func (_daa *TextState )ProcTD (tx ,ty float64 ){_daa .Tl =-ty ;_daa .ProcTd (tx ,ty )};func (_fcd *TextState )ProcTm (a ,b ,c ,d ,e ,f float64 ){_fcd .Tm =_b .NewMatrix (a ,b ,c ,d ,e ,f );_fcd .Tlm =_fcd .Tm .Clone ();
};type LineJoin int ;const (TextRenderingModeFill TextRenderingMode =iota ;TextRenderingModeStroke ;TextRenderingModeFillStroke ;TextRenderingModeInvisible ;TextRenderingModeFillClip ;TextRenderingModeStrokeClip ;TextRenderingModeFillStrokeClip ;TextRenderingModeClip ;
);func NewTextFontFromPath (filePath string ,size float64 )(*TextFont ,error ){_aceb ,_bfa :=_gaa .NewPdfFontFromTTFFile (filePath );if _bfa !=nil {return nil ,_bfa ;};return NewTextFont (_aceb ,size );};func (_daf *TextState )ProcTf (font *TextFont ){_daf .Tf =font };
type Pattern interface{ColorAt (_ggg ,_bc int )_d .Color ;};func (_bgdb *TextState )Translate (tx ,ty float64 ){_bgdb .Tm =_bgdb .Tm .Mult (_b .TranslationMatrix (tx ,ty ));};func (_fdg *TextState )ProcTd (tx ,ty float64 ){_fdg .Tlm .Concat (_b .TranslationMatrix (tx ,ty ));
_fdg .Tm =_fdg .Tlm .Clone ();};func (_eg *TextFont )WithSize (size float64 ,originalFont *_gaa .PdfFont )*TextFont {return &TextFont {Font :_eg .Font ,Size :size ,_dfb :_eg ._dfb ,_cg :originalFont };};func NewTextState ()TextState {return TextState {Th :100,Tm :_b .IdentityMatrix (),Tlm :_b .IdentityMatrix ()};
};func (_dgc *TextState )ProcTj (data []byte ,ctx Context ){_dcg :=_dgc .Tf .Size ;_gfc :=_dgc .Th /100.0;_fef :=_dgc .GlobalScale ;_fad :=_b .NewMatrix (_dcg *_gfc ,0,0,_dcg ,0,_dgc .Ts );_efb :=ctx .Matrix ();_afd :=_efb .Clone ().Mult (_dgc .Tm .Clone ().Mult (_fad )).ScalingFactorY ();
_eef :=_dgc .Tf .NewFace (_afd );_ddc :=_dgc .Tf .BytesToCharcodes (data );for _ ,_cea :=range _ddc {_dcgf ,_bfe :=_dgc .Tf .CharcodeToRunes (_cea );_bad :=string (_bfe );if _bad =="\u0000"{continue ;};_bdf :=_efb .Clone ().Mult (_dgc .Tm .Clone ().Mult (_fad ));
_fda :=_bdf .ScalingFactorY ();_bdf =_bdf .Scale (1/_fda ,-1/_fda );if _dgc .Tr !=TextRenderingModeInvisible {ctx .SetMatrix (_bdf );ctx .DrawString (_bad ,_eef ,0,0);ctx .SetMatrix (_efb );};_befb :=0.0;if _bad =="\u0020"{_befb =_dgc .Tw ;};_gdf ,_ ,_ccb :=_dgc .Tf .GetCharMetrics (_dcgf );
if _ccb {_gdf =_gdf *0.001*_dcg ;}else {_gdf ,_ =ctx .MeasureString (_bad ,_eef );_gdf =_gdf /_fef ;};_fdae :=(_gdf +_dgc .Tc +_befb )*_gfc ;_dgc .Tm =_dgc .Tm .Mult (_b .TranslationMatrix (_fdae ,0));};};const (LineJoinRound LineJoin =iota ;LineJoinBevel ;
);func NewTextFont (font *_gaa .PdfFont ,size float64 )(*TextFont ,error ){_dc :=font .FontDescriptor ();if _dc ==nil {return nil ,_ga .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");
};_beb ,_gbf :=_gg .GetStream (_dc .FontFile2 );if !_gbf {return nil ,_ga .New ("\u006di\u0073\u0073\u0069\u006e\u0067\u0020\u0066\u006f\u006e\u0074\u0020f\u0069\u006c\u0065\u0020\u0073\u0074\u0072\u0065\u0061\u006d");};_dbb ,_cfb :=_gg .DecodeStream (_beb );
if _cfb !=nil {return nil ,_cfb ;};_bef ,_cfb :=_a .Parse (_dbb );if _cfb !=nil {return nil ,_cfb ;};return &TextFont {Font :font ,Size :size ,_dfb :_bef },nil ;};type FillRule int ;type TextFont struct{Font *_gaa .PdfFont ;Size float64 ;_dfb *_a .Font ;
_cg *_gaa .PdfFont ;};func (_ad *TextFont )NewFace (size float64 )_gf .Face {return _a .NewFace (_ad ._dfb ,&_a .Options {Size :size });};func (_bdg *TextFont )CharcodeToRunes (charcode _e .CharCode )(_e .CharCode ,[]rune ){_dbbd :=[]_e .CharCode {charcode };
if _bdg ._cg ==nil ||_bdg ._cg ==_bdg .Font {if _bdg .Font .IsSimple ()&&_bdg ._dfb !=nil {if _dbbb :=_bdg ._dfb .Index (rune (charcode ));_dbbb > 0{return charcode ,[]rune {rune (charcode )};};};return charcode ,_bdg .Font .CharcodesToUnicode (_dbbd );
};_fb :=_bdg ._cg .CharcodesToUnicode (_dbbd );_fge ,_ :=_bdg .Font .RunesToCharcodeBytes (_fb );_bgf :=_bdg .Font .BytesToCharcodes (_fge );_aef :=charcode ;if len (_bgf )> 0&&_bgf [0]!=0{_aef =_bgf [0];};return _aef ,_fb ;};func (_gab *TextState )ProcTStar (){_gab .ProcTd (0,-_gab .Tl )};
type LineCap int ;func (_gag *TextState )Reset (){_gag .Tm =_b .IdentityMatrix ();_gag .Tlm =_b .IdentityMatrix ()};type TextRenderingMode int ;type TextState struct{Tc float64 ;Tw float64 ;Th float64 ;Tl float64 ;Tf *TextFont ;Ts float64 ;Tm _b .Matrix ;
Tlm _b .Matrix ;Tr TextRenderingMode ;GlobalScale float64 ;};