Changeset 521 for GraphicTest/Packages/bgrabitmap/bgravectorize.pas
- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/bgravectorize.pas
r494 r521 63 63 ShadowOffset: TPoint; 64 64 65 constructor Create; 66 constructor Create(ADirectoryUTF8: string); 65 constructor Create; overload; 66 constructor Create(ADirectoryUTF8: string); overload; 67 67 function GetFontPixelMetric: TFontPixelMetric; override; 68 procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientation: integer; s: string; c: TBGRAPixel; align: TAlignment); over ride;69 procedure TextOutAngle(ADest: TBGRACustomBitmap; x, y: single; orientation: integer; s: string; texture: IBGRAScanner; align: TAlignment); over ride;70 procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; texture: IBGRAScanner; align: TAlignment); over ride;71 procedure TextOut(ADest: TBGRACustomBitmap; x, y: single; s: string; c: TBGRAPixel; align: TAlignment); over ride;72 procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; s: string; style: TTextStyle; c: TBGRAPixel); over ride;73 procedure TextRect(ADest: TBGRACustomBitmap; ARect: TRect; x, y: integer; s: string; style: TTextStyle; texture: IBGRAScanner); over ride;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; 74 74 procedure CopyTextPathTo(ADest: IBGRAPath; x, y: single; s: string; align: TAlignment); override; 75 function HandlesTextPath: boolean; override; 75 76 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; 76 79 destructor Destroy; override; 77 80 end; … … 151 154 public 152 155 UnderlineDecoration,StrikeOutDecoration: boolean; 153 constructor Create; 154 constructor Create(AVectorizeLCL: boolean); 156 constructor Create; overload; 157 constructor Create(AVectorizeLCL: boolean); overload; 155 158 destructor Destroy; override; 156 159 function GetGlyphSize(AIdentifier:string): TPointF; … … 162 165 AAlign: TBGRATypeWriterAlignment=twaTopLeft); override; 163 166 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; 166 169 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; 169 172 procedure UpdateDirectory; 170 173 function LoadGlyphsInfo(AFilenameUTF8: string): TBGRAGlyphsInfo; … … 190 193 implementation 191 194 192 uses BGRAUTF8 ;195 uses BGRAUTF8, math; 193 196 194 197 function VectorizeMonochrome(ASource: TBGRACustomBitmap; zoom: single; PixelCenteredCoordinates: boolean): ArrayOfTPointF; … … 234 237 inc(nbpoints); 235 238 end; 236 procedure AddLine(x1,y1,x2,y2: integer); 239 procedure AddLine(x1,y1,x2,y2: integer); overload; 237 240 var i,j,k: integer; 238 241 begin … … 267 270 points[k].next := addpoint(x2,y2,k,-1); 268 271 end; 269 procedure AddLine(x1,y1,x2,y2,x3,y3: integer); 272 procedure AddLine(x1,y1,x2,y2,x3,y3: integer); overload; 270 273 begin 271 274 AddLine(x1,y1,x2,y2); 272 275 AddLine(x2,y2,x3,y3); 273 276 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; 275 278 begin 276 279 AddLine(x1,y1,x2,y2); … … 278 281 AddLine(x3,y3,x4,y4); 279 282 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; 281 284 begin 282 285 AddLine(x1,y1,x2,y2); … … 1225 1228 end; 1226 1229 1230 function TBGRAVectorizedFontRenderer.HandlesTextPath: boolean; 1231 begin 1232 Result:= true; 1233 end; 1234 1227 1235 function TBGRAVectorizedFontRenderer.TextSize(s: string): TSize; 1228 1236 var sizeF: TPointF; … … 1232 1240 result.cx := round(sizeF.x); 1233 1241 result.cy := round(sizeF.y); 1242 end; 1243 1244 function TBGRAVectorizedFontRenderer.TextSize(sUTF8: string; 1245 AMaxWidth: integer; ARightToLeft: boolean): TSize; 1246 var 1247 remains: string; 1248 w,h,totalH: single; 1249 begin 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); 1263 end; 1264 1265 function TBGRAVectorizedFontRenderer.TextFitInfo(sUTF8: string; 1266 AMaxWidth: integer): integer; 1267 var 1268 remains: string; 1269 begin 1270 UpdateFont; 1271 FVectorizedFont.SplitText(sUTF8, AMaxWidth, remains); 1272 result := length(sUTF8); 1234 1273 end; 1235 1274 … … 1351 1390 FFont.Height := FontEmHeightSign * 100; 1352 1391 lEmHeight := BGRATextSize(FFont, fqSystem, 'Hg', 1).cy; 1353 FFont.Height := F ontFullHeightSign * 100;1392 FFont.Height := FixLCLFontFullHeight(FFont.Name, FontFullHeightSign * 100); 1354 1393 lFullHeight := BGRATextSize(FFont, fqSystem, 'Hg', 1).cy; 1355 1394 if lEmHeight = 0 then … … 1392 1431 FFont.Name := FName; 1393 1432 FFont.Style := FStyle; 1394 FFont.Height := FontFullHeightSign * FResolution; 1433 FFont.Height := FixLCLFontFullHeight(FFont.Name, FontFullHeightSign * FResolution); 1434 FFont.Quality := fqNonAntialiased; 1395 1435 FFontEmHeightRatio := 1; 1396 1436 FFontEmHeightRatioComputed := false; … … 1960 2000 FBuffer.Fill(BGRAWhite); 1961 2001 FBuffer.Canvas.Font := FFont; 1962 FBuffer.Canvas.Font.Quality := fqNonAntialiased;1963 2002 FBuffer.Canvas.Font.Color := clBlack; 1964 2003 FBuffer.Canvas.TextOut(size.cy div 2,0,AIdentifier);
Note:
See TracChangeset
for help on using the changeset viewer.