ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Issue:TIETextLayer Text cannot be vertically centered
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

bajie

12 Posts

Posted - Apr 14 2026 :  06:53:00  Show Profile  Reply
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;

xequte

39397 Posts

Posted - Apr 27 2026 :  23:39:45  Show Profile  Reply
Thank you. I have implemented a similar fix in the current beta.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: