From cff3eb6fb21746f1ef7b3a3e05c55fd8415decba Mon Sep 17 00:00:00 2001 From: Juliette ELSASS Date: Sun, 2 Jun 2024 11:51:32 +0200 Subject: [PATCH] #111 aliasing for shapes --- lazpaint/tools/utooltext.pas | 1 - lazpaint/tools/utoolvectorial.pas | 16 +++++++--- lazpaintcontrols/lcvectororiginal.pas | 40 +++++++++++++++++++++++-- lazpaintcontrols/lcvectorpolyshapes.pas | 7 +++-- lazpaintcontrols/lcvectorrectshapes.pas | 28 +++++++++-------- lazpaintcontrols/lcvectortextshapes.pas | 33 ++++---------------- 6 files changed, 74 insertions(+), 51 deletions(-) diff --git a/lazpaint/tools/utooltext.pas b/lazpaint/tools/utooltext.pas index 6c96d2ad..6f2ab887 100644 --- a/lazpaint/tools/utooltext.pas +++ b/lazpaint/tools/utooltext.pas @@ -170,7 +170,6 @@ procedure TToolText.AssignShapeStyle(AMatrix: TAffineMatrix; AAlwaysFit: boolean FontEmHeight:= zoom*Manager.TextFontSize*Manager.Image.DPI/72; FontName:= Manager.TextFontName; FontStyle:= Manager.TextFontStyle; - Aliased := Manager.ShapeOptionAliasing; LightPosition := AMatrix*Manager.LightPosition; AltitudePercent:= Manager.PhongShapeAltitude; if FontBidiMode <> Manager.TextBidiMode then diff --git a/lazpaint/tools/utoolvectorial.pas b/lazpaint/tools/utoolvectorial.pas index 0aebc4f1..29d619b0 100644 --- a/lazpaint/tools/utoolvectorial.pas +++ b/lazpaint/tools/utoolvectorial.pas @@ -265,6 +265,8 @@ function ContextualToolbarsFromShape(AShapeClass: TVectorShapeAny; AShape: TVect result := result + [ctText,ctAliasing]; if TTextShape(AShape).PenPhong then include(result, ctAltitude); end; + if vsfAliased in f then + result += [ctAliasing]; end; procedure AlignShape(AShape: TVectorShape; ACommand: TToolCommand; const AMatrix: TAffineMatrix; const ARect: TRect); @@ -440,6 +442,12 @@ procedure TEditShapeTool.UpdateToolManagerFromShape(AShape: TVectorShape); AShape.Usermode := vsuEdit; opt := Manager.ShapeOptions; f := AShape.MultiFields; + if vsfAliased in f then + begin + if AShape.Aliased then + include(opt,toAliasing) + else exclude(opt,toAliasing); + end; doDraw := vsfPenFill in f; doFill := vsfBackFill in f; if vsfPenStyle in f then @@ -510,9 +518,6 @@ procedure TEditShapeTool.UpdateToolManagerFromShape(AShape: TVectorShape); Manager.TextVerticalAlign:= VerticalAlignment; Manager.SetTextFont(FontName, FontEmHeight*zoom*72/Manager.Image.DPI, FontStyle); Manager.TextShadow:= false; - if Aliased then - include(opt,toAliasing) - else exclude(opt,toAliasing); end; Manager.ShapeOptions := opt; @@ -667,6 +672,8 @@ function TEditShapeTool.DoToolUpdate(toolDest: TBGRABitmap): TRect; m := AffineMatrixInverse(Manager.Image.LayerOriginalMatrix[Manager.Image.CurrentLayerIndex]); zoom := (VectLen(m[1,1],m[2,1])+VectLen(m[1,2],m[2,2]))/2; f := shape.MultiFields; + if vsfAliased in f then + shape.Aliased := Manager.ShapeOptionAliasing; if f*[vsfPenFill,vsfBackFill,vsfPenStyle] = [vsfPenFill,vsfBackFill,vsfPenStyle] then begin doDraw := toDrawShape in Manager.ShapeOptions; @@ -725,7 +732,6 @@ function TEditShapeTool.DoToolUpdate(toolDest: TBGRABitmap): TRect; FontName:= Manager.TextFontName; FontEmHeight:= Manager.TextFontSize*zoom*Manager.Image.DPI/72; FontStyle := Manager.TextFontStyle; - Aliased := Manager.ShapeOptionAliasing; end; if shape is TPhongShape then with TPhongShape(shape) do @@ -1974,6 +1980,8 @@ procedure TVectorialTool.AssignShapeStyle(AMatrix: TAffineMatrix; AAlwaysFit: bo zoom := (VectLen(AMatrix[1,1],AMatrix[2,1])+VectLen(AMatrix[1,2],AMatrix[2,2]))/2; f := FShape.MultiFields; gradBox := FShape.SuggestGradientBox(AffineMatrixIdentity); + if vsfAliased in f then + FShape.Aliased:= Manager.ShapeOptionAliasing; if vsfPenFill in f then begin if HasPen then diff --git a/lazpaintcontrols/lcvectororiginal.pas b/lazpaintcontrols/lcvectororiginal.pas index 74510df3..5d8ebc8a 100644 --- a/lazpaintcontrols/lcvectororiginal.pas +++ b/lazpaintcontrols/lcvectororiginal.pas @@ -43,7 +43,8 @@ TVectorShapeDiff = class; TRenderBoundsOption = (rboAssumePenFill, rboAssumeBackFill); TRenderBoundsOptions = set of TRenderBoundsOption; - TVectorShapeField = (vsfPenFill, vsfPenWidth, vsfPenStyle, vsfJoinStyle, vsfBackFill, vsfOutlineFill, vsfOutlineWidth); + TVectorShapeField = (vsfPenFill, vsfPenWidth, vsfPenStyle, vsfJoinStyle, + vsfBackFill, vsfOutlineFill, vsfOutlineWidth, vsfAliased); TVectorShapeFields = set of TVectorShapeField; TVectorShapeUsermode = (vsuEdit, vsuCreate, vsuEditPenFill, vsuEditBackFill, vsuEditOutlineFill, vsuCurveSetAuto, vsuCurveSetCurve, vsuCurveSetAngle, @@ -117,10 +118,12 @@ TVectorShapeEmbeddedFillDiff = class(TVectorShapeDiff) TVectorShapeCommonDiff = class(TVectorShapeDiff) protected + FStartAliased: boolean; FStartPenWidth: single; FStartPenStyle: TBGRAPenStyle; FStartOutlineWidth: single; FStartJoinStyle: TPenJoinStyle; + FEndAliased: boolean; FEndPenWidth: single; FEndPenStyle: TBGRAPenStyle; FEndOutlineWidth: single; @@ -201,13 +204,16 @@ TVectorShape = class FDiffs: TVectorShapeDiffList; FFillBeforeChangeBounds: TRectF; function GetIsUpdating: boolean; + procedure SetAliased(AValue: boolean); procedure SetContainer(AValue: TVectorOriginal); function GetFill(var AFillVariable: TVectorialFill): TVectorialFill; procedure SetFill(var AFillVariable: TVectorialFill; AValue: TVectorialFill; AUpdate: boolean); procedure SetId(AValue: integer); protected - FPenWidth: single; + FAliased: boolean; FOutlineWidth: single; + FPenWidth: single; + FFillChangeWithoutUpdate: boolean; procedure BeginEditingUpdate; procedure EndEditingUpdate; @@ -257,6 +263,7 @@ TVectorShape = class ADefs: TSVGDefine; ANamePrefix: string): string; procedure ApplyStrokeStyleToSVG(AElement: TSVGElement; ADefs: TSVGDefine); procedure ApplyFillStyleToSVG(AElement: TSVGElement; ADefs: TSVGDefine); + procedure ApplyAliasingToSVG(AElement: TSVGElement); property Stroker: TBGRAPenStroker read GetStroker; public constructor Create(AContainer: TVectorOriginal); virtual; @@ -331,6 +338,7 @@ TVectorShape = class property Id: integer read FId write SetId; property IsFollowingMouse: boolean read GetIsFollowingMouse; property IsUpdating: boolean read GetIsUpdating; + property Aliased: boolean read FAliased write SetAliased; property BackVisible: boolean read GetBackVisible; property PenVisible: boolean read GetPenVisibleNow; property OutlineVisible: boolean read GetOutlineVisible; @@ -1011,6 +1019,7 @@ constructor TVectorShapeCommonDiff.Create(AStartShape: TVectorShape); begin with AStartShape do begin + FStartAliased:= Aliased; FStartPenWidth:= PenWidth; FStartPenStyle:= DuplicatePenStyle(PenStyle); FStartOutlineWidth:= OutlineWidth; @@ -1022,6 +1031,7 @@ procedure TVectorShapeCommonDiff.ComputeDiff(AEndShape: TVectorShape); begin with AEndShape do begin + FEndAliased:= Aliased; FEndPenWidth:= PenWidth; FEndPenStyle:= DuplicatePenStyle(PenStyle); FEndOutlineWidth:= OutlineWidth; @@ -1034,6 +1044,7 @@ procedure TVectorShapeCommonDiff.Apply(AStartShape: TVectorShape); with AStartShape do begin BeginUpdate; + FAliased:= FEndAliased; FPenWidth := FEndPenWidth; Stroker.CustomPenStyle := DuplicatePenStyle(FEndPenStyle); FOutlineWidth := FEndOutlineWidth; @@ -1047,6 +1058,7 @@ procedure TVectorShapeCommonDiff.Unapply(AEndShape: TVectorShape); with AEndShape do begin BeginUpdate; + FAliased:= FStartAliased; FPenWidth := FStartPenWidth; Stroker.CustomPenStyle := DuplicatePenStyle(FStartPenStyle); FOutlineWidth := FStartOutlineWidth; @@ -1060,6 +1072,7 @@ procedure TVectorShapeCommonDiff.Append(ADiff: TVectorShapeDiff); next: TVectorShapeCommonDiff; begin next := ADiff as TVectorShapeCommonDiff; + FEndAliased:= next.FEndAliased; FEndPenWidth:= next.FEndPenWidth; FEndPenStyle:= DuplicatePenStyle(next.FEndPenStyle); FEndOutlineWidth:= next.FEndOutlineWidth; @@ -1068,7 +1081,8 @@ procedure TVectorShapeCommonDiff.Append(ADiff: TVectorShapeDiff); function TVectorShapeCommonDiff.IsIdentity: boolean; begin - result := (FStartPenWidth = FEndPenWidth) and + result := (FStartAliased = FEndAliased) and + (FStartPenWidth = FEndPenWidth) and PenStyleEqual(FStartPenStyle, FEndPenStyle) and (FStartOutlineWidth = FEndOutlineWidth) and (FStartJoinStyle = FEndJoinStyle); @@ -1775,6 +1789,14 @@ function TVectorShape.GetIsUpdating: boolean; result := FUpdateCount > 0; end; +procedure TVectorShape.SetAliased(AValue: boolean); +begin + if FAliased=AValue then Exit; + BeginUpdate(TVectorShapeCommonDiff); + FAliased:=AValue; + EndUpdate; +end; + function TVectorShape.GetOutlineWidth: single; begin result := FOutlineWidth; @@ -1940,6 +1962,12 @@ procedure TVectorShape.ApplyFillStyleToSVG(AElement: TSVGElement; ADefs: TSVGDef else AElement.fillNone; end; +procedure TVectorShape.ApplyAliasingToSVG(AElement: TSVGElement); +begin + if Aliased then + AElement.shapeRendering:= 'crispEdges'; +end; + procedure TVectorShape.TransformFill(const AMatrix: TAffineMatrix; ABackOnly: boolean); begin BeginUpdate; @@ -2430,6 +2458,7 @@ procedure TVectorShape.LoadFromStorage(AStorage: TBGRACustomOriginalStorage); if vsfBackFill in f then LoadFill(AStorage, 'back', FBackFill); if vsfOutlineFill in f then LoadFill(AStorage, 'outline', FOutlineFill); if vsfOutlineWidth in f then OutlineWidth := AStorage.FloatDef['outline-width', DefaultShapeOutlineWidth]; + if vsfAliased in f then Aliased:= AStorage.BoolDef['aliased', false]; EndUpdate; end; end; @@ -2462,6 +2491,11 @@ procedure TVectorShape.SaveToStorage(AStorage: TBGRACustomOriginalStorage); AStorage.RemoveAttribute('outline-color'); AStorage.RemoveAttribute('outline-width'); end; + if vsfAliased in f then + begin + if not Aliased then AStorage.RemoveAttribute('aliased') + else AStorage.Bool['aliased'] := Aliased; + end; end; procedure TVectorShape.MouseMove(Shift: TShiftState; X, Y: single; var diff --git a/lazpaintcontrols/lcvectorpolyshapes.pas b/lazpaintcontrols/lcvectorpolyshapes.pas index 154890f0..fadeb5ff 100644 --- a/lazpaintcontrols/lcvectorpolyshapes.pas +++ b/lazpaintcontrols/lcvectorpolyshapes.pas @@ -1258,7 +1258,7 @@ procedure TCustomPolypointShape.TransformFrame(const AMatrix: TAffineMatrix); class function TPolylineShape.Fields: TVectorShapeFields; begin - Result:= [vsfPenFill, vsfPenWidth, vsfPenStyle, vsfJoinStyle, vsfBackFill]; + Result:= [vsfPenFill, vsfPenWidth, vsfPenStyle, vsfJoinStyle, vsfBackFill, vsfAliased]; end; procedure TPolylineShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; @@ -1274,7 +1274,7 @@ procedure TPolylineShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; if BackFill.FillType = vftSolid then backScan := nil else backScan := BackFill.CreateScanner(AMatrix, ADraft); - if ADraft then + if ADraft or Aliased then begin if Assigned(backScan) then ADest.FillPoly(pts, backScan, dmDrawWithTransparency) else @@ -1295,7 +1295,7 @@ procedure TPolylineShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; else penScan := PenFill.CreateScanner(AMatrix, ADraft); pts := ComputeStroke(pts, Closed, AMatrix); - if ADraft and (PenWidth > 4) then + if (ADraft and (PenWidth > 4)) or Aliased then begin if Assigned(penScan) then ADest.FillPoly(pts, penScan, dmDrawWithTransparency) else @@ -1323,6 +1323,7 @@ function TPolylineShape.AppendToSVG(AContent: TSVGContent; ADefs: TSVGDefine): T if PenVisible then result.strokeLineCapLCL := LineCap; ApplyFillStyleToSVG(result, ADefs); + ApplyAliasingToSVG(result); end; function TPolylineShape.GetRenderBounds(ADestRect: TRect; AMatrix: TAffineMatrix; AOptions: TRenderBoundsOptions): TRectF; diff --git a/lazpaintcontrols/lcvectorrectshapes.pas b/lazpaintcontrols/lcvectorrectshapes.pas index 6776fcc5..2dafcce9 100644 --- a/lazpaintcontrols/lcvectorrectshapes.pas +++ b/lazpaintcontrols/lcvectorrectshapes.pas @@ -927,7 +927,7 @@ function TRectShape.GetIsSlow(const AMatrix: TAffineMatrix): boolean; class function TRectShape.Fields: TVectorShapeFields; begin - Result:= [vsfPenFill, vsfPenWidth, vsfPenStyle, vsfJoinStyle, vsfBackFill]; + Result:= [vsfPenFill, vsfPenWidth, vsfPenStyle, vsfJoinStyle, vsfBackFill, vsfAliased]; end; function TRectShape.AppendToSVG(AContent: TSVGContent; ADefs: TSVGDefine): TSVGElement; @@ -973,6 +973,7 @@ function TRectShape.AppendToSVG(AContent: TSVGContent; ADefs: TSVGDefine): TSVGE result.Matrix[cuPixel] := m; ApplyStrokeStyleToSVG(result, ADefs); ApplyFillStyleToSVG(result, ADefs); + ApplyAliasingToSVG(result); end; end; @@ -995,7 +996,7 @@ procedure TRectShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; if GetOrthoRect(AMatrix, orthoRect) then begin - if ADraft then + if ADraft or Aliased then begin r:= rect(round(orthoRect.Left+0.5),round(orthoRect.Top+0.5),round(orthoRect.Right+0.5),round(orthoRect.Bottom+0.5)); if Assigned(backScan) then @@ -1023,7 +1024,7 @@ procedure TRectShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; end; end else begin - if ADraft then + if ADraft or Aliased then begin if Assigned(backScan) then ADest.FillPoly(pts, backScan, dmDrawWithTransparency) else @@ -1059,7 +1060,7 @@ procedure TRectShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; else penScan := PenFill.CreateScanner(AMatrix, ADraft); pts := ComputeStroke(pts,true, AMatrix); - if ADraft and (PenWidth > 4) then + if (ADraft and (PenWidth > 4)) or Aliased then begin if Assigned(penScan) then ADest.FillPoly(pts, penScan, dmDrawWithTransparency) else @@ -1195,7 +1196,7 @@ constructor TEllipseShape.Create(AContainer: TVectorOriginal); class function TEllipseShape.Fields: TVectorShapeFields; begin - Result:= [vsfPenFill, vsfPenWidth, vsfPenStyle, vsfBackFill]; + Result:= [vsfPenFill, vsfPenWidth, vsfPenStyle, vsfBackFill, vsfAliased]; end; function TEllipseShape.AppendToSVG(AContent: TSVGContent; ADefs: TSVGDefine): TSVGElement; @@ -1219,6 +1220,7 @@ function TEllipseShape.AppendToSVG(AContent: TSVGContent; ADefs: TSVGDefine): TS end; ApplyStrokeStyleToSVG(result, ADefs); ApplyFillStyleToSVG(result, ADefs); + ApplyAliasingToSVG(result); end; function TEllipseShape.GetAlignBounds(const ALayoutRect: TRect; @@ -1264,7 +1266,7 @@ procedure TEllipseShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; pts: Array of TPointF; orthoRect: TRectF; center, radius: TPointF; - draftPen, isOrtho: Boolean; + aliasedPen, isOrtho: Boolean; r: TRect; backScan, penScan: TBGRACustomScanner; penZoom: Single; @@ -1280,7 +1282,7 @@ procedure TEllipseShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; if BackFill.FillType = vftSolid then backScan := nil else backScan := BackFill.CreateScanner(AMatrix, ADraft); - if ADraft then + if ADraft or Aliased then begin r := rect(round(orthoRect.Left),round(orthoRect.Top),round(orthoRect.Right),round(orthoRect.Bottom)); if Assigned(backScan) then @@ -1300,13 +1302,13 @@ procedure TEllipseShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; begin if PenFill.FillType = vftSolid then penScan := nil else penScan := PenFill.CreateScanner(AMatrix, ADraft); - draftPen := ADraft and (PenWidth > 4); + aliasedPen := (ADraft and (PenWidth > 4)) or Aliased; - if IsAffineMatrixScaledRotation(AMatrix) and not (draftPen and Assigned(penScan)) then + if IsAffineMatrixScaledRotation(AMatrix) and not (aliasedPen and Assigned(penScan)) then begin penZoom := VectLen(AMatrix[1,1],AMatrix[2,1]); ADest.CustomPenStyle := PenStyle; - if draftPen then + if aliasedPen then ADest.Ellipse(center.x, center.y, radius.x, radius.y, PenColor, PenWidth*penZoom, dmDrawWithTransparency) else begin @@ -1320,7 +1322,7 @@ procedure TEllipseShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; m:= MatrixForPixelCentered(AMatrix); pts := ComputeEllipse(m*FOrigin, m*FXAxis, m*FYAxis); pts := ComputeStroke(pts,true, AMatrix); - if draftPen then + if aliasedPen then begin if Assigned(penScan) then ADest.FillPoly(pts, penScan, dmDrawWithTransparency) else @@ -1345,7 +1347,7 @@ procedure TEllipseShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; if BackFill.FillType = vftSolid then backScan := nil else backScan := BackFill.CreateScanner(AMatrix, ADraft); - if ADraft then + if ADraft or Aliased then begin if Assigned(backScan) then ADest.FillPoly(pts, backScan, dmDrawWithTransparency) else @@ -1366,7 +1368,7 @@ procedure TEllipseShape.Render(ADest: TBGRABitmap; AMatrix: TAffineMatrix; else penScan := PenFill.CreateScanner(AMatrix, ADraft); pts := ComputeStroke(pts,true, AMatrix); - if ADraft and (PenWidth > 4) then + if (ADraft and (PenWidth > 4)) or Aliased then begin if Assigned(penScan) then ADest.FillPoly(pts, penScan, dmDrawWithTransparency) else diff --git a/lazpaintcontrols/lcvectortextshapes.pas b/lazpaintcontrols/lcvectortextshapes.pas index eaccb6ed..22a9a07b 100644 --- a/lazpaintcontrols/lcvectortextshapes.pas +++ b/lazpaintcontrols/lcvectortextshapes.pas @@ -21,12 +21,10 @@ TTextShapeFontDiff = class(TVectorShapeDiff) FFontEmHeightBefore: single; FFontNameBefore: string; FFontStyleBefore: TFontStyles; - FAliasedBefore: boolean; FFontBidiModeAfter: TFontBidiMode; FFontEmHeightAfter: single; FFontNameAfter: string; FFontStyleAfter: TFontStyles; - FAliasedAfter: boolean; public constructor Create(AStartShape: TVectorShape); override; procedure ComputeDiff(AEndShape: TVectorShape); override; @@ -80,7 +78,6 @@ TTextShapeTextDiff = class(TVectorShapeDiff) TTextShape = class(TCustomRectShape) private - FAliased: boolean; FAltitudePercent: single; FPenPhong: boolean; FPenFillIteration: integer; @@ -112,7 +109,6 @@ TTextShape = class(TCustomRectShape) {%H-}ASubBrokenIndex, {%H-}ACharIndex: integer); procedure OnMoveLightPos({%H-}ASender: TObject; {%H-}APrevCoord, ANewCoord: TPointF; {%H-}AShift: TShiftState); - procedure SetAliased(AValue: boolean); procedure SetAltitudePercent(AValue: single); procedure SetPenPhong(AValue: boolean); procedure SetFontBidiMode(AValue: TFontBidiMode); @@ -207,7 +203,6 @@ TTextShape = class(TCustomRectShape) property PenPhong: boolean read FPenPhong write SetPenPhong; property LightPosition: TPointF read FLightPosition write SetLightPosition; property AltitudePercent: single read FAltitudePercent write SetAltitudePercent; - property Aliased: boolean read FAliased write SetAliased; end; function FontStyleToStr(AStyle: TFontStyles): string; @@ -471,7 +466,6 @@ constructor TTextShapeFontDiff.Create(AStartShape: TVectorShape); FFontEmHeightBefore:= FFontEmHeight; FFontNameBefore:= FFontName; FFontStyleBefore:= FFontStyle; - FAliasedBefore := FAliased; end; end; @@ -483,7 +477,6 @@ procedure TTextShapeFontDiff.ComputeDiff(AEndShape: TVectorShape); FFontEmHeightAfter:= FFontEmHeight; FFontNameAfter:= FFontName; FFontStyleAfter:= FFontStyle; - FAliasedAfter := FAliased; end; end; @@ -496,7 +489,6 @@ procedure TTextShapeFontDiff.Apply(AStartShape: TVectorShape); FFontEmHeight := FFontEmHeightAfter; FFontName := FFontNameAfter; FFontStyle := FFontStyleAfter; - FAliased := FAliasedAfter; if Assigned(FTextLayout) then FTextLayout.InvalidateLayout; EndUpdate; end; @@ -511,7 +503,6 @@ procedure TTextShapeFontDiff.Unapply(AEndShape: TVectorShape); FFontEmHeight := FFontEmHeightBefore; FFontName := FFontNameBefore; FFontStyle := FFontStyleBefore; - FAliased := FAliasedBefore; if Assigned(FTextLayout) then FTextLayout.InvalidateLayout; EndUpdate; end; @@ -526,7 +517,6 @@ procedure TTextShapeFontDiff.Append(ADiff: TVectorShapeDiff); FFontEmHeightAfter := next.FFontEmHeightAfter; FFontNameAfter := next.FFontNameAfter; FFontStyleAfter := next.FFontStyleAfter; - FAliasedAfter := next.FAliasedAfter; end; function TTextShapeFontDiff.IsIdentity: boolean; @@ -534,8 +524,7 @@ function TTextShapeFontDiff.IsIdentity: boolean; result := (FFontBidiModeBefore = FFontBidiModeAfter) and (FFontEmHeightBefore = FFontEmHeightAfter) and (FFontNameBefore = FFontNameAfter) and - (FFontStyleBefore = FFontStyleAfter) and - (FAliasedBefore = FAliasedAfter); + (FFontStyleBefore = FFontStyleAfter); end; { TTextShape } @@ -684,15 +673,6 @@ procedure TTextShape.OnMoveLightPos(ASender: TObject; APrevCoord, LightPosition := ANewCoord; end; -procedure TTextShape.SetAliased(AValue: boolean); -begin - if FAliased=AValue then Exit; - BeginUpdate(TTextShapeFontDiff); - FAliased:=AValue; - InvalidateAll; - EndUpdate; -end; - procedure TTextShape.SetAltitudePercent(AValue: single); begin if AValue < 0 then AValue := 0; @@ -1186,7 +1166,6 @@ constructor TTextShape.Create(AContainer: TVectorOriginal); FPenFillIteration := 0; FAltitudePercent:= DefaultAltitudePercent; FLightPosition := PointF(0,0); - FAliased := false; FCurBrokenLineImageId := 0; end; @@ -1247,8 +1226,6 @@ procedure TTextShape.LoadFromStorage(AStorage: TBGRACustomOriginalStorage); end else SetDefaultFont; - Aliased := AStorage.Bool['aliased']; - phongObj := AStorage.OpenObject('pen-phong'); PenPhong := Assigned(phongObj); if PenPhong then @@ -1299,7 +1276,6 @@ procedure TTextShape.SaveToStorage(AStorage: TBGRACustomOriginalStorage); font.RawString['bidi'] := FontBidiModeToStr(FontBidiMode); font.RawString['style'] := FontStyleToStr(FontStyle); font.Free; - AStorage.Bool['aliased'] := Aliased; if PenPhong then begin @@ -1340,7 +1316,7 @@ destructor TTextShape.Destroy; class function TTextShape.Fields: TVectorShapeFields; begin - Result:= [vsfPenFill,vsfOutlineFill,vsfOutlineWidth]; + Result:= [vsfPenFill,vsfOutlineFill,vsfOutlineWidth,vsfAliased]; end; class function TTextShape.PreferPixelCentered: boolean; @@ -1886,7 +1862,8 @@ procedure TTextShape.Render(ADest: TBGRABitmap; ARenderOffset: TPoint; AMatrix: begin tempRenderNewList := TStringList.Create; useBrokenLinesRender := not ADraft and (Usermode = vsuEditText); - if not tempStorage.AffineMatrixEquals('last-matrix', AMatrix) or + if (tempStorage.Bool['aliased'] <> Aliased) or + not tempStorage.AffineMatrixEquals('last-matrix', AMatrix) or not tempStorage.PointFEquals('origin', Origin) or not tempStorage.PointFEquals('x-axis', XAxis) or not tempStorage.PointFEquals('y-axis', YAxis) or @@ -1900,6 +1877,7 @@ procedure TTextShape.Render(ADest: TBGRABitmap; ARenderOffset: TPoint; AMatrix: tempStorage.RemoveObject(tempRenderCurList[fileIdx]); tempRenderCurList.Free; + tempStorage.RemoveAttribute('aliased'); tempStorage.RemoveAttribute('last-matrix'); tempStorage.RemoveAttribute('origin'); tempStorage.RemoveAttribute('x-axis'); @@ -2100,6 +2078,7 @@ procedure TTextShape.Render(ADest: TBGRABitmap; ARenderOffset: TPoint; AMatrix: tempStorage.RemoveObject(tempRenderCurList[fileIdx]); tempRenderCurList.Free; + tempStorage.Bool['aliased'] := Aliased; tempStorage.AffineMatrix['last-matrix'] := AMatrix; tempStorage.PointF['origin'] := Origin; tempStorage.PointF['x-axis'] := XAxis;