mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-13 22:28:39 +02:00
fpvectorial: Fix some issues with text in svg files.
This commit is contained in:
parent
ad5d9a11e8
commit
c69c83ead1
@ -5693,6 +5693,7 @@ constructor TvText.Create(APage: TvPage);
|
|||||||
begin
|
begin
|
||||||
inherited Create(APage);
|
inherited Create(APage);
|
||||||
Value := TStringList.Create;
|
Value := TStringList.Create;
|
||||||
|
Value.Options := Value.Options - [soTrailingLineBreak];
|
||||||
Font.Color := colBlack;
|
Font.Color := colBlack;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -5799,7 +5800,7 @@ begin
|
|||||||
lDescender := GetTextMetric_Descender_px(ARenderInfo);
|
lDescender := GetTextMetric_Descender_px(ARenderInfo);
|
||||||
|
|
||||||
// Angle of text rotation
|
// Angle of text rotation
|
||||||
phi := sign(AMulY) * DegToRad(Font.Orientation);
|
phi := -DegToRad(Font.Orientation);
|
||||||
|
|
||||||
// Reference point of the entity (X,Y) in pixels
|
// Reference point of the entity (X,Y) in pixels
|
||||||
// rotation center in case of rotated text
|
// rotation center in case of rotated text
|
||||||
@ -5830,9 +5831,7 @@ begin
|
|||||||
// ...
|
// ...
|
||||||
// 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
|
||||||
lowerDimY := refPt.Y - (lTextSize.CY - lDescender); // lowerDim.Y := refPt.Y + lFontSizePx * (1 + LINE_SPACING) * Value.Count * AMulY
|
curDimY := refPt.Y - (lTextSize.CY - lDescender);
|
||||||
upperDimY := 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
|
||||||
|
@ -633,6 +633,7 @@ const
|
|||||||
TEXT_ANCHORS: array[TvTextAnchor] of string = ('start', 'middle', 'end');
|
TEXT_ANCHORS: array[TvTextAnchor] of string = ('start', 'middle', 'end');
|
||||||
TEXT_DECO: array[0..3] of string = ('none', 'underline', 'line-through', 'line-through,underline');
|
TEXT_DECO: array[0..3] of string = ('none', 'underline', 'line-through', 'line-through,underline');
|
||||||
var
|
var
|
||||||
|
FontName: String;
|
||||||
FontSize: Double;
|
FontSize: Double;
|
||||||
TextStr: String;
|
TextStr: String;
|
||||||
PtX: Double = 0.0;
|
PtX: Double = 0.0;
|
||||||
@ -640,11 +641,10 @@ var
|
|||||||
begin
|
begin
|
||||||
ConvertFPVCoordinatesToSVGCoordinates(APage, AText.X, AText.Y, PtX, PtY);
|
ConvertFPVCoordinatesToSVGCoordinates(APage, AText.X, AText.Y, PtX, PtY);
|
||||||
TextStr := AText.Value.Text;
|
TextStr := AText.Value.Text;
|
||||||
if DefaultTextLineBreakStyle = tlbsCRLF then // Trim extra CRLF appended by TStringList.Text
|
if AText.Font.Name = '' then
|
||||||
TextStr := Copy(TextStr, 1, Length(TextStr) - 2)
|
FontName := 'Arial,Helvetica,sans-serif'
|
||||||
else
|
else
|
||||||
TextStr := Copy(TextStr, 1, Length(TextStr) - 1);
|
FontName := AText.Font.Name;
|
||||||
|
|
||||||
FontSize:= AText.Font.Size * FLOAT_PIXELS_PER_MILLIMETER;
|
FontSize:= AText.Font.Size * FLOAT_PIXELS_PER_MILLIMETER;
|
||||||
|
|
||||||
AStrings.Add(' <text ');
|
AStrings.Add(' <text ');
|
||||||
@ -675,7 +675,7 @@ begin
|
|||||||
Format(' transform="rotate(%g,%g,%g)"', [-AText.Font.Orientation, PtX, PtY], FPointSeparator));
|
Format(' transform="rotate(%g,%g,%g)"', [-AText.Font.Orientation, PtX, PtY], FPointSeparator));
|
||||||
|
|
||||||
AStrings.Add(
|
AStrings.Add(
|
||||||
Format(' font-family="%s"', [AText.Font.Name]));
|
Format(' font-family="%s"', [FontName]));
|
||||||
|
|
||||||
AStrings.Add(
|
AStrings.Add(
|
||||||
Format(' font-size="%f"', [FontSize], FPointSeparator));
|
Format(' font-size="%f"', [FontSize], FPointSeparator));
|
||||||
@ -683,9 +683,7 @@ begin
|
|||||||
AStrings.Add(
|
AStrings.Add(
|
||||||
Format(' fill="#%s"', [FPColorToRGBHexString(AText.Font.Color)]));
|
Format(' fill="#%s"', [FPColorToRGBHexString(AText.Font.Color)]));
|
||||||
|
|
||||||
AStrings.Add(' >');
|
AStrings.Add(' >' + TextStr + '</text>');
|
||||||
AStrings.Add(TextStr);
|
|
||||||
AStrings.Add(' </text>');
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TvSVGVectorialWriter.WriteToStrings(AStrings: TStrings;
|
procedure TvSVGVectorialWriter.WriteToStrings(AStrings: TStrings;
|
||||||
|
Loading…
Reference in New Issue
Block a user