Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions source/Img32.SVG.Core.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
(*******************************************************************************
* Author : Angus Johnson *
* Version : 4.9 *
* Date : 9 August 2025 *
* Date : 15 December 2025 *
* Website : https://www.angusj.com *
* Copyright : Angus Johnson 2019-2025 *
* *
Expand Down Expand Up @@ -103,6 +103,7 @@ TSVGFontInfo = record
family : TFontFamily;
familyNames : UTF8Strings;
size : double;
sizeUnitType : TUnitType;
spacing : double;
spacesInText : TSpacesInText;
textLength : double;
Expand Down Expand Up @@ -1681,6 +1682,7 @@ procedure GetSvgFontInfo(const value: UTF8String; var fontInfo: TSVGFontInfo);
var
c, endC: PUTF8Char;
hash: Cardinal;
tmp: TValue;
begin
c := PUTF8Char(value);
endC := c + Length(value);
Expand All @@ -1689,7 +1691,12 @@ procedure GetSvgFontInfo(const value: UTF8String; var fontInfo: TSVGFontInfo);
if c = ';' then
break
else if IsNumPending(c, endC, true) then
ParseNextNum(c, endC, true, fontInfo.size)
begin
tmp.Init;
if not ParseNextNumEx(c, endC, true, tmp.rawVal, tmp.unitType) then Exit;
fontInfo.size := tmp.rawVal;
fontInfo.sizeUnitType := tmp.unitType;
end
else
begin
hash := ParseNextWordHashed(c, endC);
Expand Down
17 changes: 13 additions & 4 deletions source/Img32.SVG.Reader.pas
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ procedure UpdateDrawInfo(var drawDat: TDrawData; thisElement: TBaseElement);
//------------------------------------------------------------------------------

procedure UpdateFontInfo(var drawDat: TDrawData; thisElement: TBaseElement);
var
fontValue: TValue;
begin
with thisElement.fDrawData do
begin
Expand All @@ -806,7 +808,12 @@ procedure UpdateFontInfo(var drawDat: TDrawData; thisElement: TBaseElement);
drawDat.fontInfo.familyNames := fontInfo.familyNames;

if fontInfo.size > 0 then
drawDat.fontInfo.size := fontInfo.size;
begin
// Convert fontsize+unitType to pixels
fontValue.SetValue(fontInfo.size, fontInfo.sizeUnitType);
drawDat.fontInfo.size := fontValue.GetValue(drawDat.fontInfo.size, 1);
drawDat.fontInfo.sizeUnitType := utPixel;
end;
if fontInfo.spacing <> 0 then
drawDat.fontInfo.spacing := fontInfo.spacing;
if fontInfo.textLength > 0 then
Expand Down Expand Up @@ -4672,12 +4679,14 @@ procedure FontFamily_Attrib(aOwnerEl: TBaseElement; const value: UTF8String);

procedure FontSize_Attrib(aOwnerEl: TBaseElement; const value: UTF8String);
var
num: double;
c, endC: PUTF8Char;
tmp: TValue;
begin
c := PUTF8Char(value); endC := c + Length(value);
if not ParseNextNum(c, endC, false, num) then Exit;
aOwnerEl.fDrawData.FontInfo.size := num;
tmp.Init;
if not ParseNextNumEx(c, endC, false, tmp.rawVal, tmp.unitType) then Exit;
aOwnerEl.fDrawData.fontInfo.size := tmp.rawVal;
aOwnerEl.fDrawData.fontInfo.sizeUnitType := tmp.unitType;
end;
//------------------------------------------------------------------------------

Expand Down