Cross-Platform Aesthetics: How to Manage Fonts and Deliver a Unified User Experience when Using DevExpress Reports and Office File API

Processing documents on different platforms can be challenging, especially when dealing with fonts that are not universally available across all machines/operating systems. Needless to say, missing fonts can introduce inconsistencies (affecting reports, Word documents, and PDF files) when users create and exchange documents via email or within an app itself.

For the best possible user experience, it is essential to address font-related issues within Blazor WebAssembly and .NET MAUI apps. The underlying challenges are well known: Blazor WebAssembly doesn't offer direct access to system fonts, and .NET MAUI has challenges with system fonts on the iOS platform. Of course, problems also extend to web apps deployed to cloud platforms like Azure or AWS, where only a subset of fonts are available.

The DXFontRepository class of the DevExpress.Drawing graphics library offers a comprehensive solution to address these issues - a solution that is nearly identical to the PrivateFontCollection class. As I will demonstrate shortly,DXFontRepository helps ensure a consistent visual appearance across document types. With it, you can maintain visual element consistency even if fonts are missing/unavailable in the underlying system (downloading them dynamically as needed). The advantage to our implementation is that DXFontRepository is available on any target operating system and in apps that target .NET 6 and above.

Using DXFontRepository with DevExpress Reports and Office File API-powered Apps

We created two examples that help illustrate the benefits ofDXFontRepository. Both applications are dockerized, so you can build and run images with ease.

DevExpress Office File API

The following link loads required fonts into a word processing application: Word Processing Document API – Detect and Download Fonts

This Blazor WebAssembly application uses the Iterator-Visitor pattern to retrieve/display a list of fonts from an uploaded Word document. Once retrieved, you can download them individually/simultaneously.

In our example, fonts are loaded from Google Fonts, but you can modify font source based on business requirements. When fonts are loaded and added to a font repository collection, you can export the sample document to PDF to view results.

office file api load custom fonts

Note: Google Fonts are open-source, but be sure to read the associated license agreement to determine usage rights for your particular use case.

DevExpress Reports

To help illustrate the benefits of DXFontRepository, we created an ASP.NET Core application using the DevExpress Document Viewer. This application loads a sample report with a custom font. The service uses DXFontRepository to find and load these fonts from Google resources. When you open the report, you will see that the specified fonts are applied automatically.

reporting asp dot net core load custom fonts

If you are ready to use DXFontRepository, please refer to the following GitHub link for implementation details: Reporting for ASP.NET Core — Detect and Load Custom Fonts with Ease (DXFontRepository)

As always, your feedback is highly appreciated. Should you have any questions about our sample projects,please submit a suppor ticket via the DevExpress Support Center.

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.