mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-08 03:16:12 +02:00
fpvectorial: minor changes
git-svn-id: trunk@44393 -
This commit is contained in:
parent
68648a037f
commit
796e552c53
@ -1756,21 +1756,25 @@ begin
|
|||||||
[Self.ClassName, Name, lParentName]);
|
[Self.ClassName, Name, lParentName]);
|
||||||
|
|
||||||
if spbfPenColor in SetElements then
|
if spbfPenColor in SetElements then
|
||||||
lStr := lStr + Format('Pen.Color==%s', [TvEntity.GenerateDebugStrForFPColor(Pen.Color)]);
|
lStr := lStr + Format(' Pen.Color=%s', [TvEntity.GenerateDebugStrForFPColor(Pen.Color)]);
|
||||||
{ // Pen, Brush and Font
|
{ spbfPenStyle, spbfPenWidth,
|
||||||
spbfPenColor, spbfPenStyle, spbfPenWidth,
|
spbfBrushColor, spbfBrushStyle, spbfBrushGradient,}
|
||||||
spbfBrushColor, spbfBrushStyle, spbfBrushGradient,
|
if spbfFontColor in SetElements then
|
||||||
spbfFontColor, spbfFontSize, spbfFontName, spbfFontBold, spbfFontItalic,
|
lStr := lStr + Format(' Font.Color=%s', [TvEntity.GenerateDebugStrForFPColor(Pen.Color)]);
|
||||||
|
if spbfFontSize in SetElements then
|
||||||
|
lStr := lStr + Format(' Font.Size=%d', [Font.Size]);
|
||||||
|
if spbfFontName in SetElements then
|
||||||
|
lStr := lStr + ' Font.Name=' + Font.Name;
|
||||||
|
if spbfFontBold in SetElements then
|
||||||
|
if Font.Bold then lStr := lStr + Format(' Font.Bold=%s', [BoolToStr(Font.Bold)]);
|
||||||
|
if spbfFontItalic in SetElements then
|
||||||
|
if Font.Italic then lStr := lStr + Format(' Font.Bold=%s', [BoolToStr(Font.Italic)]);
|
||||||
|
{
|
||||||
spbfFontUnderline, spbfFontStrikeThrough, spbfAlignment,
|
spbfFontUnderline, spbfFontStrikeThrough, spbfAlignment,
|
||||||
// Page style
|
// Page style
|
||||||
sseMarginTop, sseMarginBottom, sseMarginLeft, sseMarginRight,
|
sseMarginTop, sseMarginBottom, sseMarginLeft, sseMarginRight
|
||||||
// Positioning
|
|
||||||
ssePosition
|
|
||||||
);
|
);
|
||||||
{ ,
|
{ Font.Size, Font.Name, Font.Orientation,
|
||||||
Font.Size, Font.Name, Font.Orientation,
|
|
||||||
BoolToStr(Font.Bold),
|
|
||||||
BoolToStr(Font.Italic),
|
|
||||||
BoolToStr(Font.Underline),
|
BoolToStr(Font.Underline),
|
||||||
BoolToStr(Font.StrikeThrough),
|
BoolToStr(Font.StrikeThrough),
|
||||||
GetEnumName(TypeInfo(TvTextAnchor), integer(TextAnchor))}
|
GetEnumName(TypeInfo(TvTextAnchor), integer(TextAnchor))}
|
||||||
@ -5222,6 +5226,8 @@ procedure TvParagraph.Render(ADest: TFPCustomCanvas; ARenderInfo: TvRenderInfo;
|
|||||||
var
|
var
|
||||||
lCurWidth: Double = 0.0;
|
lCurWidth: Double = 0.0;
|
||||||
lLeft, lTop, lRight, lBottom: Double;
|
lLeft, lTop, lRight, lBottom: Double;
|
||||||
|
OldTextX: Double = 0.0;
|
||||||
|
OldTextY: Double = 0.0;
|
||||||
lEntity: TvEntity;
|
lEntity: TvEntity;
|
||||||
lText: TvText absolute lEntity;
|
lText: TvText absolute lEntity;
|
||||||
begin
|
begin
|
||||||
@ -5231,11 +5237,21 @@ begin
|
|||||||
begin
|
begin
|
||||||
if lEntity is TvText then
|
if lEntity is TvText then
|
||||||
begin
|
begin
|
||||||
lText.X := X + lCurWidth;
|
// Direct text position setting resets the auto-positioning
|
||||||
lText.Y := Y;
|
if (OldTextX <> lText.X) or (OldTextY <> lText.Y) then
|
||||||
|
lCurWidth := 0;
|
||||||
|
|
||||||
|
OldTextX := lText.X;
|
||||||
|
OldTextY := lText.Y;
|
||||||
|
lText.X := lText.Y + X + lCurWidth;
|
||||||
|
lText.Y := lText.Y + Y;
|
||||||
|
|
||||||
lText.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMuly);
|
lText.Render(ADest, ARenderInfo, ADestX, ADestY, AMulX, AMuly);
|
||||||
lText.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
|
lText.CalculateBoundingBox(ADest, lLeft, lTop, lRight, lBottom);
|
||||||
lCurWidth := lCurWidth + Abs(lRight - lLeft);
|
lCurWidth := lCurWidth + Abs(lRight - lLeft);
|
||||||
|
|
||||||
|
lText.X := OldTextX;
|
||||||
|
lText.Y := OldTextY;
|
||||||
end;
|
end;
|
||||||
lEntity := GetNextEntity();
|
lEntity := GetNextEntity();
|
||||||
end;
|
end;
|
||||||
|
@ -101,6 +101,7 @@ type
|
|||||||
function ReadSVGPenStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntityWithPen): TvSetPenBrushAndFontElements;
|
function ReadSVGPenStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntityWithPen): TvSetPenBrushAndFontElements;
|
||||||
function ReadSVGBrushStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntityWithPenAndBrush): TvSetPenBrushAndFontElements;
|
function ReadSVGBrushStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntityWithPenAndBrush): TvSetPenBrushAndFontElements;
|
||||||
function ReadSVGFontStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntityWithPenBrushAndFont): TvSetPenBrushAndFontElements;
|
function ReadSVGFontStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntityWithPenBrushAndFont): TvSetPenBrushAndFontElements;
|
||||||
|
function ReadSVGFontStyleWithKeyAndValue_ToStyle(AKey, AValue: string; ADest: TvStyle): TvSetPenBrushAndFontElements;
|
||||||
function ReadSVGGeneralStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntity): TvSetPenBrushAndFontElements;
|
function ReadSVGGeneralStyleWithKeyAndValue(AKey, AValue: string; ADestEntity: TvEntity): TvSetPenBrushAndFontElements;
|
||||||
function IsAttributeFromStyle(AStr: string): Boolean;
|
function IsAttributeFromStyle(AStr: string): Boolean;
|
||||||
procedure ApplyLayerStyles(ADestEntity: TvEntity);
|
procedure ApplyLayerStyles(ADestEntity: TvEntity);
|
||||||
@ -973,6 +974,54 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TvSVGVectorialReader.ReadSVGFontStyleWithKeyAndValue_ToStyle(AKey,
|
||||||
|
AValue: string; ADest: TvStyle): TvSetPenBrushAndFontElements;
|
||||||
|
var
|
||||||
|
lLowerValue: String;
|
||||||
|
begin
|
||||||
|
Result := [];
|
||||||
|
lLowerValue := LowerCase(AValue);
|
||||||
|
// SVG text uses "fill" to indicate the pen color of the text, very unintuitive as
|
||||||
|
// "fill" is usually for brush in other elements
|
||||||
|
if AKey = 'fill' then
|
||||||
|
begin
|
||||||
|
ADest.Font.Color := ReadSVGColor(AValue);
|
||||||
|
Result := Result + [spbfFontColor];
|
||||||
|
end
|
||||||
|
// But sometimes SVG also uses stroke! Oh no...
|
||||||
|
else if AKey = 'stroke' then
|
||||||
|
begin
|
||||||
|
ADest.Font.Color := ReadSVGColor(AValue);
|
||||||
|
Result := Result + [spbfFontColor];
|
||||||
|
end
|
||||||
|
else if AKey = 'fill-opacity' then
|
||||||
|
ADest.Font.Color.Alpha := StrToInt(AValue)*$101
|
||||||
|
else if AKey = 'font-size' then
|
||||||
|
begin
|
||||||
|
ADest.Font.Size := Round(StringWithUnitToFloat(AValue));
|
||||||
|
Result := Result + [spbfFontSize];
|
||||||
|
end
|
||||||
|
else if AKey = 'font-family' then
|
||||||
|
ADest.Font.Name := AValue
|
||||||
|
else if AKey = 'font-weight' then
|
||||||
|
begin
|
||||||
|
case lLowerValue of
|
||||||
|
'bold': ADest.Font.Bold := True;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
// Other text attributes, non-font ones
|
||||||
|
else if AKey = 'text-anchor' then
|
||||||
|
begin
|
||||||
|
// Adjust according to the text-anchor, if necessary
|
||||||
|
{case lLowerValue of
|
||||||
|
'start': ADest.TextAnchor := vtaStart;
|
||||||
|
'middle': ADest.TextAnchor := vtaMiddle;
|
||||||
|
'end': ADest.TextAnchor := vtaEnd;
|
||||||
|
end;}
|
||||||
|
end;
|
||||||
|
ADest.SetElements := ADest.SetElements + Result;
|
||||||
|
end;
|
||||||
|
|
||||||
function TvSVGVectorialReader.ReadSVGGeneralStyleWithKeyAndValue(AKey,
|
function TvSVGVectorialReader.ReadSVGGeneralStyleWithKeyAndValue(AKey,
|
||||||
AValue: string; ADestEntity: TvEntity): TvSetPenBrushAndFontElements;
|
AValue: string; ADestEntity: TvEntity): TvSetPenBrushAndFontElements;
|
||||||
var
|
var
|
||||||
@ -2391,12 +2440,12 @@ var
|
|||||||
if lNodeName = 'x' then
|
if lNodeName = 'x' then
|
||||||
begin
|
begin
|
||||||
lCurStyle.PositionSet := True;
|
lCurStyle.PositionSet := True;
|
||||||
lCurStyle.X := StringWithUnitToFloat(lNodeValue, sckX)
|
lCurStyle.X := StringWithUnitToFloat(lNodeValue, sckX);
|
||||||
end
|
end
|
||||||
else if lNodeName = 'y' then
|
else if lNodeName = 'y' then
|
||||||
begin
|
begin
|
||||||
lCurStyle.PositionSet := True;
|
lCurStyle.PositionSet := True;
|
||||||
lCurStyle.Y := StringWithUnitToFloat(lNodeValue, sckY)
|
lCurStyle.Y := StringWithUnitToFloat(lNodeValue, sckY);
|
||||||
end
|
end
|
||||||
//else if lNodeName = 'id' then
|
//else if lNodeName = 'id' then
|
||||||
// lText.Name := lNodeValue
|
// lText.Name := lNodeValue
|
||||||
@ -2404,7 +2453,7 @@ var
|
|||||||
// ReadSVGStyle(lNodeValue, lParagraph)
|
// ReadSVGStyle(lNodeValue, lParagraph)
|
||||||
else if IsAttributeFromStyle(lNodeName) then
|
else if IsAttributeFromStyle(lNodeName) then
|
||||||
begin
|
begin
|
||||||
//ReadSVGFontStyleWithKeyAndValue(lNodeName, lNodeValue, lText);
|
ReadSVGFontStyleWithKeyAndValue_ToStyle(lNodeName, lNodeValue, lCurStyle);
|
||||||
//ReadSVGGeneralStyleWithKeyAndValue(lNodeName, lNodeValue, lText);
|
//ReadSVGGeneralStyleWithKeyAndValue(lNodeName, lNodeValue, lText);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2585,7 +2634,7 @@ begin
|
|||||||
if ViewBoxAdjustment and (ACoordKind = sckX) then
|
if ViewBoxAdjustment and (ACoordKind = sckX) then
|
||||||
Result := Result * Page_Width / ViewBox_Width;
|
Result := Result * Page_Width / ViewBox_Width;
|
||||||
if ViewBoxAdjustment and (ACoordKind = sckY) then
|
if ViewBoxAdjustment and (ACoordKind = sckY) then
|
||||||
Result := Result * Page_Height / ViewBox_Height;
|
Result := Page_Height - Result * Page_Height / ViewBox_Height;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user