Ignore:
Timestamp:
Apr 17, 2019, 12:58:41 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Propagate project build mode options to used packages.
  • Added: Check memory leaks using heaptrc.
  • Modified: Update BGRABitmap package.
Location:
GraphicTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest

    • Property svn:ignore
      •  

        old new  
        88GraphicTest.lps
        99GraphicTest.dbg
         10heaptrclog.trc
  • GraphicTest/Packages/bgrabitmap/bgravectorize.pas

    r494 r521  
    6363    ShadowOffset: TPoint;
    6464
    65     constructor Create;
    66     constructor Create(ADirectoryUTF8: string);
     65    constructor Create; overload;
     66    constructor Create(ADirectoryUTF8: string); overload;
    6767    function GetFontPixelMetric: TFontPixelMetric; override;
    68     procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientation: integer; s: string; c: TBGRAPixel; align: TAlignment); override;
    69     procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientation: integer; s: string; texture: IBGRAScanner; align: TAlignment); override;
    70     procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; texture: IBGRAScanner; align: TAlignment); override;
    71     procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; c: TBGRAPixel; align: TAlignment); override;
    72     procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; s: string; style: TTextStyle; c: TBGRAPixel); override;
    73     procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; s: string; style: TTextStyle; texture: IBGRAScanner); override;
     68    procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientation: integer; s: string; c: TBGRAPixel; align: TAlignment); overload; override;
     69    procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientation: integer; s: string; texture: IBGRAScanner; align: TAlignment); overload; override;
     70    procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; texture: IBGRAScanner; align: TAlignment); overload; override;
     71    procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; c: TBGRAPixel; align: TAlignment); overload; override;
     72    procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; s: string; style: TTextStyle; c: TBGRAPixel); overload; override;
     73    procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; s: string; style: TTextStyle; texture: IBGRAScanner); overload; override;
    7474    procedure CopyTextPathTo(ADest: IBGRAPath; x, y: single; s: string; align: TAlignment); override;
     75    function HandlesTextPath: boolean; override;
    7576    function TextSize(s: string): TSize; override;
     77    function TextSize(sUTF8: string; AMaxWidth: integer; {%H-}ARightToLeft: boolean): TSize; override;
     78    function TextFitInfo(sUTF8: string; AMaxWidth: integer): integer; override;
    7679    destructor Destroy; override;
    7780  end;
     
    151154  public
    152155    UnderlineDecoration,StrikeOutDecoration: boolean;
    153     constructor Create;
    154     constructor Create(AVectorizeLCL: boolean);
     156    constructor Create; overload;
     157    constructor Create(AVectorizeLCL: boolean); overload;
    155158    destructor Destroy; override;
    156159    function GetGlyphSize(AIdentifier:string): TPointF;
     
    162165      AAlign: TBGRATypeWriterAlignment=twaTopLeft); override;
    163166    procedure DrawTextWordBreak(ADest: TBGRACanvas2D; ATextUTF8: string; X, Y, MaxWidth: Single; AAlign: TBGRATypeWriterAlignment=twaTopLeft);
    164     procedure DrawTextRect(ADest: TBGRACanvas2D; ATextUTF8: string; X1,Y1,X2,Y2: Single; AAlign: TBGRATypeWriterAlignment=twaTopLeft);
    165     procedure DrawTextRect(ADest: TBGRACanvas2D; ATextUTF8: string; ATopLeft,ABottomRight: TPointF; AAlign: TBGRATypeWriterAlignment=twaTopLeft);
     167    procedure DrawTextRect(ADest: TBGRACanvas2D; ATextUTF8: string; X1,Y1,X2,Y2: Single; AAlign: TBGRATypeWriterAlignment=twaTopLeft); overload;
     168    procedure DrawTextRect(ADest: TBGRACanvas2D; ATextUTF8: string; ATopLeft,ABottomRight: TPointF; AAlign: TBGRATypeWriterAlignment=twaTopLeft); overload;
    166169    function GetTextWordBreakGlyphBoxes(ATextUTF8: string; X,Y, MaxWidth: Single; AAlign: TBGRATypeWriterAlignment = twaTopLeft): TGlyphBoxes;
    167     function GetTextRectGlyphBoxes(ATextUTF8: string; X1,Y1,X2,Y2: Single; AAlign: TBGRATypeWriterAlignment=twaTopLeft): TGlyphBoxes;
    168     function GetTextRectGlyphBoxes(ATextUTF8: string; ATopLeft,ABottomRight: TPointF; AAlign: TBGRATypeWriterAlignment=twaTopLeft): TGlyphBoxes;
     170    function GetTextRectGlyphBoxes(ATextUTF8: string; X1,Y1,X2,Y2: Single; AAlign: TBGRATypeWriterAlignment=twaTopLeft): TGlyphBoxes; overload;
     171    function GetTextRectGlyphBoxes(ATextUTF8: string; ATopLeft,ABottomRight: TPointF; AAlign: TBGRATypeWriterAlignment=twaTopLeft): TGlyphBoxes; overload;
    169172    procedure UpdateDirectory;
    170173    function LoadGlyphsInfo(AFilenameUTF8: string): TBGRAGlyphsInfo;
     
    190193implementation
    191194
    192 uses BGRAUTF8;
     195uses BGRAUTF8, math;
    193196
    194197function VectorizeMonochrome(ASource: TBGRACustomBitmap; zoom: single; PixelCenteredCoordinates: boolean): ArrayOfTPointF;
     
    234237    inc(nbpoints);
    235238  end;
    236   procedure AddLine(x1,y1,x2,y2: integer);
     239  procedure AddLine(x1,y1,x2,y2: integer); overload;
    237240  var i,j,k: integer;
    238241  begin
     
    267270    points[k].next := addpoint(x2,y2,k,-1);
    268271  end;
    269   procedure AddLine(x1,y1,x2,y2,x3,y3: integer);
     272  procedure AddLine(x1,y1,x2,y2,x3,y3: integer); overload;
    270273  begin
    271274    AddLine(x1,y1,x2,y2);
    272275    AddLine(x2,y2,x3,y3);
    273276  end;
    274   procedure AddLine(x1,y1,x2,y2,x3,y3,x4,y4: integer);
     277  procedure AddLine(x1,y1,x2,y2,x3,y3,x4,y4: integer); overload;
    275278  begin
    276279    AddLine(x1,y1,x2,y2);
     
    278281    AddLine(x3,y3,x4,y4);
    279282  end;
    280   procedure AddLine(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5: integer);
     283  procedure AddLine(x1,y1,x2,y2,x3,y3,x4,y4,x5,y5: integer); overload;
    281284  begin
    282285    AddLine(x1,y1,x2,y2);
     
    12251228end;
    12261229
     1230function TBGRAVectorizedFontRenderer.HandlesTextPath: boolean;
     1231begin
     1232  Result:= true;
     1233end;
     1234
    12271235function TBGRAVectorizedFontRenderer.TextSize(s: string): TSize;
    12281236var sizeF: TPointF;
     
    12321240  result.cx := round(sizeF.x);
    12331241  result.cy := round(sizeF.y);
     1242end;
     1243
     1244function TBGRAVectorizedFontRenderer.TextSize(sUTF8: string;
     1245  AMaxWidth: integer; ARightToLeft: boolean): TSize;
     1246var
     1247  remains: string;
     1248  w,h,totalH: single;
     1249begin
     1250  UpdateFont;
     1251
     1252  result.cx := 0;
     1253  totalH := 0;
     1254  h := FVectorizedFont.FullHeight;
     1255  repeat
     1256    FVectorizedFont.SplitText(sUTF8, AMaxWidth, remains);
     1257    w := FVectorizedFont.GetTextSize(sUTF8).x;
     1258    if round(w)>result.cx then result.cx := round(w);
     1259    totalH += h;
     1260    sUTF8 := remains;
     1261  until remains = '';
     1262  result.cy := ceil(totalH);
     1263end;
     1264
     1265function TBGRAVectorizedFontRenderer.TextFitInfo(sUTF8: string;
     1266  AMaxWidth: integer): integer;
     1267var
     1268  remains: string;
     1269begin
     1270  UpdateFont;
     1271  FVectorizedFont.SplitText(sUTF8, AMaxWidth, remains);
     1272  result := length(sUTF8);
    12341273end;
    12351274
     
    13511390      FFont.Height := FontEmHeightSign * 100;
    13521391      lEmHeight := BGRATextSize(FFont, fqSystem, 'Hg', 1).cy;
    1353       FFont.Height := FontFullHeightSign * 100;
     1392      FFont.Height := FixLCLFontFullHeight(FFont.Name, FontFullHeightSign * 100);
    13541393      lFullHeight := BGRATextSize(FFont, fqSystem, 'Hg', 1).cy;
    13551394      if lEmHeight = 0 then
     
    13921431    FFont.Name := FName;
    13931432    FFont.Style := FStyle;
    1394     FFont.Height := FontFullHeightSign * FResolution;
     1433    FFont.Height := FixLCLFontFullHeight(FFont.Name, FontFullHeightSign * FResolution);
     1434    FFont.Quality := fqNonAntialiased;
    13951435    FFontEmHeightRatio := 1;
    13961436    FFontEmHeightRatioComputed := false;
     
    19602000    FBuffer.Fill(BGRAWhite);
    19612001    FBuffer.Canvas.Font := FFont;
    1962     FBuffer.Canvas.Font.Quality := fqNonAntialiased;
    19632002    FBuffer.Canvas.Font.Color := clBlack;
    19642003    FBuffer.Canvas.TextOut(size.cy div 2,0,AIdentifier);
Note: See TracChangeset for help on using the changeset viewer.