How to Get Font Subtype Like Extra Bold from a Presentation in C++?

Hi,

When i try to extract font name, it sometimes comes like : Adobe Clean ExtraBold. How can I extract the main font as Adobe Clean and ExtraBold as sub type.

Thanks

@pankajku

To extract the main font name and its subtype (like “ExtraBold”) from a font string such as “Adobe Clean ExtraBold”, you can use string manipulation techniques in your code. Here’s a simple approach in C# that demonstrates how to achieve this:

using System;

class Program
{
    static void Main()
    {
        string fontName = "Adobe Clean ExtraBold";
        string mainFont = GetMainFont(fontName);
        string fontStyle = GetFontStyle(fontName);

        Console.WriteLine($"Main Font: {mainFont}");
        Console.WriteLine($"Font Style: {fontStyle}");
    }

    static string GetMainFont(string fontName)
    {
        // Split the font name by spaces and take all but the last part
        var parts = fontName.Split(' ');
        return string.Join(" ", parts, 0, parts.Length - 1);
    }

    static string GetFontStyle(string fontName)
    {
        // Get the last part of the font name which is the style
        var parts = fontName.Split(' ');
        return parts[^1]; // Using C# 8.0 index from end operator
    }
}

In this example, the GetMainFont method extracts the main font name by splitting the string and joining all parts except the last one. The GetFontStyle method retrieves the last part of the string, which represents the font style (e.g., “ExtraBold”).

This approach should help you separate the main font from its subtype effectively. If you have any further questions or need additional assistance, feel free to ask!

@pankajku,
“Adobe Clean ExtraBold” is the full font name exactly as it is stored inside the font file: “Adobe Clean” is the family and “ExtraBold” is the style (weight) within that family. Aspose.Slides returns this combined name because the font’s Full Name entry already contains both parts. The API does not expose a separate property for “family” versus “sub-family”, so if you need just the family you would have to split the string yourself.