Description:
1. After adding a border (TIETextLayer.TextStyling.BorderWidth), the text cannot be vertically centered.
2. The ImageEn documentation mentions TIECanvas.MeasureText:
MeasureText is not accurate when borders are applied (using TextStyling).
http://www.imageen.com/help/TIECanvas.MeasureText.html
Suggestion:
iegdiplus.pas
function IEDrawTextEx
begin
...
// 2026.4.14 bajie: Temporarily disable BorderWidth to ensure MeasureText measurement accuracy
wasBorderWidth := Canvas.TextStyling.BorderWidth;
Canvas.TextStyling.BorderWidth := 0;
try
if (TextAutoSize and not WordWrap) or ( DrawMode = iedResize ) or ( WordWrap = False ) then
begin
if WordWrap and ( MaxResizeWidth > 0 ) then
// Resizing with a maximum width
OutSize := Canvas.MeasureText( Text, rect( textX, textY, textX + MaxResizeWidth, Max_Text ), -TextAngle )
else
OutSize := Canvas.MeasureText( Text, rect( textX, textY, Max_Text, Max_Text ), -TextAngle );
end
else
begin
OutSize := Canvas.MeasureText( Text, rect( textX, textY, textW - textX, textH - textY ), -TextAngle );
if ( OutSize.cX = 0 ) and ( OutSize.cY = 0 ) then // Invalid rect
begin
OutSize := Canvas.MeasureText( Text, rect( textX, textY, textW - textX, Max_Text ), -TextAngle );
Y2 := Y1 + OutSize.cY;
end;
end;
finally
Canvas.TextStyling.BorderWidth := wasBorderWidth;
end;
...
end;