mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 18:58:12 +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
|
||||
inherited Create(APage);
|
||||
Value := TStringList.Create;
|
||||
Value.Options := Value.Options - [soTrailingLineBreak];
|
||||
Font.Color := colBlack;
|
||||
end;
|
||||
|
||||
@ -5799,7 +5800,7 @@ begin
|
||||
lDescender := GetTextMetric_Descender_px(ARenderInfo);
|
||||
|
||||
// Angle of text rotation
|
||||
phi := sign(AMulY) * DegToRad(Font.Orientation);
|
||||
phi := -DegToRad(Font.Orientation);
|
||||
|
||||
// Reference point of the entity (X,Y) in pixels
|
||||
// rotation center in case of rotated text
|
||||
@ -5830,9 +5831,7 @@ begin
|
||||
// ...
|
||||
// We need to keep the order of lines drawing correct regardless of
|
||||
// the drawing direction
|
||||
lowerDimY := refPt.Y - (lTextSize.CY - lDescender); // lowerDim.Y := refPt.Y + lFontSizePx * (1 + LINE_SPACING) * Value.Count * AMulY
|
||||
upperDimY := refPt.Y;
|
||||
curDimY := IfThen(AMulY < 0, lowerDimY, upperDimY);
|
||||
curDimY := refPt.Y - (lTextSize.CY - lDescender);
|
||||
|
||||
// TvText supports multiple lines
|
||||
for i := 0 to Value.Count - 1 do
|
||||
|
@ -633,6 +633,7 @@ const
|
||||
TEXT_ANCHORS: array[TvTextAnchor] of string = ('start', 'middle', 'end');
|
||||
TEXT_DECO: array[0..3] of string = ('none', 'underline', 'line-through', 'line-through,underline');
|
||||
var
|
||||
FontName: String;
|
||||
FontSize: Double;
|
||||
TextStr: String;
|
||||
PtX: Double = 0.0;
|
||||
@ -640,11 +641,10 @@ var
|
||||
begin
|
||||
ConvertFPVCoordinatesToSVGCoordinates(APage, AText.X, AText.Y, PtX, PtY);
|
||||
TextStr := AText.Value.Text;
|
||||
if DefaultTextLineBreakStyle = tlbsCRLF then // Trim extra CRLF appended by TStringList.Text
|
||||
TextStr := Copy(TextStr, 1, Length(TextStr) - 2)
|
||||
if AText.Font.Name = '' then
|
||||
FontName := 'Arial,Helvetica,sans-serif'
|
||||
else
|
||||
TextStr := Copy(TextStr, 1, Length(TextStr) - 1);
|
||||
|
||||
FontName := AText.Font.Name;
|
||||
FontSize:= AText.Font.Size * FLOAT_PIXELS_PER_MILLIMETER;
|
||||
|
||||
AStrings.Add(' <text ');
|
||||
@ -675,7 +675,7 @@ begin
|
||||
Format(' transform="rotate(%g,%g,%g)"', [-AText.Font.Orientation, PtX, PtY], FPointSeparator));
|
||||
|
||||
AStrings.Add(
|
||||
Format(' font-family="%s"', [AText.Font.Name]));
|
||||
Format(' font-family="%s"', [FontName]));
|
||||
|
||||
AStrings.Add(
|
||||
Format(' font-size="%f"', [FontSize], FPointSeparator));
|
||||
@ -683,9 +683,7 @@ begin
|
||||
AStrings.Add(
|
||||
Format(' fill="#%s"', [FPColorToRGBHexString(AText.Font.Color)]));
|
||||
|
||||
AStrings.Add(' >');
|
||||
AStrings.Add(TextStr);
|
||||
AStrings.Add(' </text>');
|
||||
AStrings.Add(' >' + TextStr + '</text>');
|
||||
end;
|
||||
|
||||
procedure TvSVGVectorialWriter.WriteToStrings(AStrings: TStrings;
|
||||
|
Loading…
Reference in New Issue
Block a user