mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:39:14 +02:00
fpvectorial: Fixes multiline text drawing in HTML with non-inverted Y coordinates
git-svn-id: trunk@52499 -
This commit is contained in:
parent
d69c951230
commit
953f47fe08
@ -5624,7 +5624,7 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
//
|
//
|
||||||
pt, refPt: TPoint;
|
pt, refPt: TPoint;
|
||||||
LowerDimY: Double;
|
LowerDimY, UpperDimY, CurDimY: Double;
|
||||||
XAnchorAdjustment: Integer;
|
XAnchorAdjustment: Integer;
|
||||||
lLongestLine, lLineWidth, lFontSizePx, lFontDescenderPx: Integer;
|
lLongestLine, lLineWidth, lFontSizePx, lFontDescenderPx: Integer;
|
||||||
lText: string;
|
lText: string;
|
||||||
@ -5685,14 +5685,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// Begin first line at reference point and grow downwards.
|
// Begin first line at reference point and grow downwards.
|
||||||
lowerDimY := IfThen(AMulY < 0, refPt.Y - (lTextSize.CY - lDescender), refPt.Y);
|
// ...
|
||||||
{
|
|
||||||
// We need to keep the order of lines drawing correct regardless of
|
// We need to keep the order of lines drawing correct regardless of
|
||||||
// the drawing direction
|
// the drawing direction
|
||||||
if AMulY < 0 then
|
lowerDimY := refPt.Y - (lTextSize.CY - lDescender); // lowerDim.Y := refPt.Y + lFontSizePx * (1 + LINE_SPACING) * Value.Count * AMulY
|
||||||
lowerDim.Y := refPt.Y + lFontSizePx * (1 + LINE_SPACING) * Value.Count * AMulY else
|
upperDimY := refPt.Y;
|
||||||
lowerDim.Y := refPt.Y;
|
curDimY := IfThen(AMulY < 0, lowerDimY, upperDimY);
|
||||||
}
|
|
||||||
// TvText supports multiple lines
|
// TvText supports multiple lines
|
||||||
for i := 0 to Value.Count - 1 do
|
for i := 0 to Value.Count - 1 do
|
||||||
begin
|
begin
|
||||||
@ -5701,7 +5700,7 @@ begin
|
|||||||
Render_NextText_X := refPt.X + XAnchorAdjustment;
|
Render_NextText_X := refPt.X + XAnchorAdjustment;
|
||||||
|
|
||||||
// Start point of text, rotated around the reference point
|
// Start point of text, rotated around the reference point
|
||||||
pt := Point(round(Render_NextText_X), round(LowerDimY)); // before rotation
|
pt := Point(round(Render_NextText_X), round(curDimY)); // before rotation
|
||||||
pt := Rotate2dPoint(pt, refPt, -Phi); // after rotation
|
pt := Rotate2dPoint(pt, refPt, -Phi); // after rotation
|
||||||
|
|
||||||
// Paint line
|
// Paint line
|
||||||
@ -5718,13 +5717,15 @@ begin
|
|||||||
if (lText = '') then
|
if (lText = '') then
|
||||||
lTextSize.cy := ACanvas.TextHeight(STR_FPVECTORIAL_TEXT_HEIGHT_SAMPLE);
|
lTextSize.cy := ACanvas.TextHeight(STR_FPVECTORIAL_TEXT_HEIGHT_SAMPLE);
|
||||||
// other end of the text
|
// other end of the text
|
||||||
pt := Point(round(Render_NextText_X) + lTextWidth, round(LowerDimY) + lTextSize.cy );
|
pt := Point(round(Render_NextText_X) + lTextWidth, round(curDimY) + lTextSize.cy );
|
||||||
pt := Rotate2dPoint(pt, refPt, -Phi);
|
pt := Rotate2dPoint(pt, refPt, -Phi);
|
||||||
CalcEntityCanvasMinMaxXY(ARenderInfo, pt.x, pt.y);
|
CalcEntityCanvasMinMaxXY(ARenderInfo, pt.x, pt.y);
|
||||||
|
|
||||||
// Prepare next line
|
// Prepare next line
|
||||||
Render_NextText_X := Render_NextText_X + lTextWidth;
|
Render_NextText_X := Render_NextText_X + lTextWidth;
|
||||||
LowerDimY := LowerdimY - (lFontSizePx * (1 + LINE_SPACING) * AMulY);
|
curDimY := IfThen(AMulY < 0,
|
||||||
|
curDimY - (lFontSizePx * (1 + LINE_SPACING) * AMulY),
|
||||||
|
curDimY + (lFontSizePx * (1 + LINE_SPACING) * AMulY));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -8286,7 +8287,8 @@ begin
|
|||||||
CurX := CoordToCanvasX(lText.X + X + lCurWidth, ADestX, AMulX);
|
CurX := CoordToCanvasX(lText.X + X + lCurWidth, ADestX, AMulX);
|
||||||
lText.X := 0;
|
lText.X := 0;
|
||||||
lText.Y := 0;
|
lText.Y := 0;
|
||||||
CurY := CoordToCanvasY(lText.Y + Y, ADestY, AMulY) + lHeight_px;
|
CurY := CoordToCanvasY(lText.Y + Y, ADestY, AMulY);
|
||||||
|
if AMulY < 0 then CurY += lHeight_px; // to keep the position in case of inversed drawing
|
||||||
lText.Render_Use_NextText_X := not lFirstText;
|
lText.Render_Use_NextText_X := not lFirstText;
|
||||||
if lText.Render_Use_NextText_X then
|
if lText.Render_Use_NextText_X then
|
||||||
lText.Render_NextText_X := lPrevText.Render_NextText_X;
|
lText.Render_NextText_X := lPrevText.Render_NextText_X;
|
||||||
|
@ -41,6 +41,9 @@ type
|
|||||||
procedure ReadFromXML(Doc: TXMLDocument; AData: TvVectorialDocument); override;
|
procedure ReadFromXML(Doc: TXMLDocument; AData: TvVectorialDocument); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
gSVGVecReader_RSVG_Path: string = '';
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ TvSVGVectorialReader_RSVG }
|
{ TvSVGVectorialReader_RSVG }
|
||||||
@ -59,6 +62,8 @@ begin
|
|||||||
Result := TvRasterImage.Create(nil);
|
Result := TvRasterImage.Create(nil);
|
||||||
AProcess := TProcessUTF8.Create(nil);
|
AProcess := TProcessUTF8.Create(nil);
|
||||||
try
|
try
|
||||||
|
if gSVGVecReader_RSVG_Path <> '' then FRSVG_CMD := gSVGVecReader_RSVG_Path;
|
||||||
|
|
||||||
if not FileExistsUTF8(FRSVG_CMD) then
|
if not FileExistsUTF8(FRSVG_CMD) then
|
||||||
raise Exception.Create('TvSVGVectorialReader_RSVG: rsvg-convert.exe not found: ' + FRSVG_CMD);
|
raise Exception.Create('TvSVGVectorialReader_RSVG: rsvg-convert.exe not found: ' + FRSVG_CMD);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user