Hi,
Can we get the font size of the substituted font that was substituted using below rules,
slidesFontSettings = new FontSubstRuleCollection();
IFontSubstRule fontSubstituteRule = new FontSubstRule(new FontData(entry.getKey()), new FontData(entry.getValue()), FontSubstCondition.WhenInaccessible);
slidesFontSettings.add(fontSubstituteRule);
@aakanksha76
To retrieve the font size of a substituted font using the FontSubstRule
class in Aspose.Slides for C++, you will first need to access the destination font data after applying your substitution rules. Unfortunately, the FontSubstRule
class does not directly provide a method to get the font size of the substituted font.
However, you can follow these steps to achieve your goal:
- Create a
FontSubstRule
instance that defines the source and destination fonts.
- Use the
get_DestFont()
method to retrieve the destination font data.
- From the
IFontData
instance returned, you can access the font size.
Here is a code snippet demonstrating how to implement this:
#include <aspose.slides.h>
using namespace Aspose::Slides;
void GetSubstitutedFontSize(const std::string& sourceFontName, const std::string& destFontName) {
// Create font substitution rule
auto fontSubstituteRule = System::MakeObject<FontSubstRule>(
System::MakeObject<FontData>(sourceFontName),
System::MakeObject<FontData>(destFontName)
);
// Assuming you have a FontSubstRuleCollection to add this rule
FontSubstRuleCollection slidesFontSettings;
slidesFontSettings.Add(fontSubstituteRule);
// Retrieve the destination font data
auto destFont = fontSubstituteRule->get_DestFont();
// Get the font size (assuming you have a way to access the font size)
// Note: You may need to implement a method to retrieve the font size from the font data
// This is a placeholder as the actual method to get font size may vary
float fontSize = GetFontSizeFromFontData(destFont);
std::cout << "Substituted Font Size: " << fontSize << std::endl;
}
float GetFontSizeFromFontData(const System::SharedPtr<IFontData>& fontData) {
// Implement logic to get font size from fontData
// This is a placeholder function
return 12.0f; // Example size
}
In this example, you need to implement the GetFontSizeFromFontData
function to extract the actual font size from the IFontData
instance. The method to retrieve the font size may depend on how the font data is structured in your specific use case.
If you need further assistance or specific details about accessing font properties, feel free to ask!
Please provide solution in java
@aakanksha76,
You have already asked this question here. Please do not duplicate forum threads in the future.