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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Issue:TIETextLayer Text cannot be vertically centered

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bajie Posted - Apr 14 2026 : 06:53:00
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;

1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 27 2026 : 23:39:45
Thank you. I have implemented a similar fix in the current beta.

Nigel
Xequte Software
www.imageen.com