Spread Windows Forms 17
Spread Windows Forms 17.0 Product Documentation / Developer's Guide / Customizing the Sheet Appearance / Text Rendering with GDI
In This Topic
    Text Rendering with GDI
    In This Topic

    Spread enables you to use GDI (instead of GDI+) for drawing text in your application, by incorporating the FarPoint.Win.TextRenderer.dll assembly into your project. The assembly must be added to your project references and placed in the same directory as the application's executable file (the bin folder) where GDI drawing is preferred. Alternatively, the file may be installed to the Global Assembly Cache(GAC) to ensure that all Spread controls in all applications will use the TextRenderer for text drawing.

    The FarPoint.Win.TextRenderer.dll is designed as a thin wrapper around the TextRenderer class within System.Windows.Forms namespace, allowing Spread to use GDI for text drawing instead of GDI+. When the application is running, it attempts to locate the FarPoint.Win.TextRenderer.dll assembly.  If found, Spread uses reflection to make dynamic calls into assembly for text drawing with System.Windows.Forms.TextRenderer class. If the FarPoint.Win.TextRenderer.dll or the TextRenderer class is not found,  then Spread defaults to using GDI+ which uses Graphics.DrawString method within System.Drawing namespace to draw text.

    Spread uses the TextRenderer class for GDI drawing while other text drawing in the application uses GDI+ or vice versa.  While the differences between GDI and GDI+ are minor, they typically involve slight variations in text spacing and alignment. By including FarPoint.Win.TextRenderer in Spread, you can achieve more consistent text rendering while maintaining the flexibility to use GDI+ elsewhere in your application. This flexibility allows you to choose the rendering methods based on your application needs.

    For detailed differences between Microsoft TextRenderer and Graphics.DrawString methods , refer to the .NET Framework documentation.

    Prevent TextRenderer Assembly Usage

    To prevent the usage of the FarPoint.Win.TextRenderer assembly for rendering the text, you can use UseGDITextRendering property of the TextHelper class of the FarPoint.Win.Text namespace. This property is true by default. However, if you encounter any text rendering issues, you can disable the property. 

    You can use the code implementation of UseGDITextRendering with another code in your application. The code for UseGDITextRendering is described below:

    C#
    Copy Code
    // Set the UseGDITextRendering to false
    TextHelper.UseGDITextRendering = false; 
    
    VB
    Copy Code
    ' Set the UseGDITextRendering to false
    TextHelper.UseGDITextRendering = False 
    

    However, you can also set UseGDITextRendering property to true depending upon the specific needs of your application.

    See Also