Skip to content

Commit cc704f1

Browse files
committed
Fix BKG for whole foreignObject - broken alignment due to adding inline HTML.
1 parent 984b365 commit cc704f1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Decard64/src/u_Html2SVG.pas

+12-4
Original file line numberDiff line numberDiff line change
@@ -1958,24 +1958,31 @@ function ParseHtml(NOD, XML:TXML_Nod; nodx,nody, lvl:integer; zm1:double; ARgh:s
19581958
n1 := n1.Next;
19591959
end;
19601960

1961+
if Bkg<>nil then
1962+
Bkg.Attribute['transform'] := 'translate('+IntToStr(nodx)+','+IntToStr(nody)+')';
19611963

19621964
if pos('valign:',fmt)>0 then
19631965
begin
19641966
// valign="top | middle | bottom | baseline"
19651967

19661968
if pos('valign:top', fmt)> 0 then
19671969
begin
1968-
Result := '<g transform="translate('+IntToStr(nodx)+','+IntToStr(nody)+') scale('+SvgFloat(ZoomValue)+')">' + RST.Nodes.xml + '</g>'
1970+
Result := '<g transform="translate('+IntToStr(nodx)+','+IntToStr(nody)+') scale('+SvgFloat(ZoomValue)+')">' + RST.Nodes.xml + '</g>';
19691971
end
19701972
else
19711973
if pos('valign:middle', fmt)> 0 then
19721974
begin
1973-
Result := '<g transform="translate('+IntToStr(nodx)+','+IntToStr(nody+(StrToIntDef(NOD.Attribute['height'],0)-round(hgh*ZoomValue)) div 2)+') scale('+SvgFloat(ZoomValue)+')">' + RST.Nodes.xml + '</g>'
1975+
1976+
Result := '<g transform="translate('+IntToStr(nodx)+','+IntToStr(nody+(StrToIntDef(NOD.Attribute['height'],0)-round(hgh*ZoomValue)) div 2)+') scale('+SvgFloat(ZoomValue)+')">' + RST.Nodes.xml + '</g>';
1977+
if (Bkg<>nil) and (lvl=1) then
1978+
Bkg.Attribute['transform'] := 'translate('+IntToStr(nodx)+','+IntToStr(nody+(StrToIntDef(NOD.Attribute['height'],0)-round(hgh*ZoomValue)) div 2)+')';
19741979
end
19751980
else
19761981
if pos('valign:bottom', fmt)> 0 then
19771982
begin
1978-
Result := '<g transform="translate('+IntToStr(nodx)+','+IntToStr(nody+(StrToIntDef(NOD.Attribute['height'],0)-round(hgh*ZoomValue)) )+') scale('+SvgFloat(ZoomValue)+')">' + RST.Nodes.xml + '</g>'
1983+
Result := '<g transform="translate('+IntToStr(nodx)+','+IntToStr(nody+(StrToIntDef(NOD.Attribute['height'],0)-round(hgh*ZoomValue)) )+') scale('+SvgFloat(ZoomValue)+')">' + RST.Nodes.xml + '</g>';
1984+
if (Bkg<>nil) and (lvl=1) then
1985+
Bkg.Attribute['transform'] := 'translate('+IntToStr(nodx)+','+IntToStr(nody+(StrToIntDef(NOD.Attribute['height'],0)-round(hgh*ZoomValue)) )+')';
19791986
end
19801987
end
19811988
else
@@ -1987,7 +1994,8 @@ function ParseHtml(NOD, XML:TXML_Nod; nodx,nody, lvl:integer; zm1:double; ARgh:s
19871994
if Bkg<>nil then
19881995
begin
19891996
// Bkg.Attribute['transform'] := 'translate('+IntToStr(nodx)+','+IntToStr(nody)+') scale('+SvgFloat(ZoomValue)+')';
1990-
Bkg.Attribute['transform'] := 'translate('+IntToStr(nodx)+','+IntToStr(nody)+')';
1997+
1998+
19911999
Result := '<g>' + bkg.xml + Result + '</g>';
19922000
Bkg.Free;
19932001
end;

0 commit comments

Comments
 (0)