←Select platform

GetTextSize Method

Summary
Returns the size of a text with an AnnFont and clipping size.
Syntax
C#
VB
C++
public static LeadSizeD GetTextSize( 
   string text, 
   AnnFont font, 
   LeadSizeD layoutArea 
) 
Public Shared Function GetTextSize( _ 
   ByVal text As String, _ 
   ByVal font As AnnFont, _ 
   ByVal layoutArea As LeadSizeD _ 
) As LeadSizeD 
public:  
   static LeadSizeD^ GetTextSize( 
      String^ text, 
      AnnFont^ font, 
      LeadSizeD^ layoutArea 
   ) 

Parameters

text
The source text string

font
The font to use

layoutArea
Clipping size to use.

Return Value

The size of the text.

Example
C#
using Leadtools.Annotations.Automation; 
using Leadtools.Annotations.Engine; 
using Leadtools.Annotations.Rendering; 
using Leadtools.Codecs; 
using Leadtools.Annotations.WinForms; 
 
public void AnnRenderingEngine_GetTextSize() 
{ 
   double inch = 720.0; 
 
   // Get the container 
   AnnContainer container = _automation.Container; 
 
   // Create a new AnnTextObject 
   AnnTextObject txtObject = new AnnTextObject(); 
   txtObject.Rect = LeadRectD.Create(3 * inch, 3 * inch, 1 * inch, 1 * inch); 
   txtObject.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), LeadLengthD.Create(1)); 
   txtObject.Text = "LEADTOOLS"; 
 
   container.Children.Add(txtObject); 
   // Measure the size of a text string 
   LeadSizeD size = AnnWinFormsRenderingEngine.GetTextSize(txtObject.Text, txtObject.Font, txtObject.Bounds.Size); 
   Debug.WriteLine(size.ToString()); 
} 
Requirements

Target Platforms

Help Version 21.0.2021.3.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations.Rendering.WinForms Assembly