CPPUNIT_TEST_FIXTURE(FontEmbeddingTest, testRoundtripEmbeddedFontsPPTX)
{ #if ENABLE_EOT // Test Import first
// Expect the font to not be available
{
OUString aUrl = EmbeddedFontsHelper::fontFileUrl(
u"Boldonse", FAMILY_ROMAN, ITALIC_NONE, WEIGHT_NORMAL, PITCH_VARIABLE,
EmbeddedFontsHelper::FontRights::ViewingAllowed);
CPPUNIT_ASSERT(aUrl.isEmpty());
}
// Load the document
createSdImpressDoc("BoldonseFontEmbedded.pptx");
// FIXME: for some reason it doesn't work in macOS (see testSubsettedFullEmbeddedFont for a similar case) #if !defined(MACOSX) // Expect the font to be available now, if we imported the embedded fonts correctly
{
OUString aUrl = EmbeddedFontsHelper::fontFileUrl(
u"Boldonse", FAMILY_ROMAN, ITALIC_NONE, WEIGHT_NORMAL, PITCH_VARIABLE,
EmbeddedFontsHelper::FontRights::ViewingAllowed);
CPPUNIT_ASSERT(!aUrl.isEmpty());
} #endif
// Check the document settings for embedded fonts are as expected
{
uno::Reference<lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
CPPUNIT_ASSERT(xFactory.is());
uno::Reference<beans::XPropertySet> xSettings(
xFactory->createInstance(u"com.sun.star.document.Settings"_ustr), uno::UNO_QUERY);
CPPUNIT_ASSERT(xSettings.is());
// Check state of the font embedding settings
CPPUNIT_ASSERT_EQUAL(false, xProps->getPropertyValue(u"EmbedFonts"_ustr).get<bool>());
CPPUNIT_ASSERT_EQUAL(false, xProps->getPropertyValue(u"EmbedOnlyUsedFonts"_ustr).get<bool>());
CPPUNIT_ASSERT_EQUAL(true, xProps->getPropertyValue(u"EmbedLatinScriptFonts"_ustr).get<bool>());
CPPUNIT_ASSERT_EQUAL(true, xProps->getPropertyValue(u"EmbedAsianScriptFonts"_ustr).get<bool>());
CPPUNIT_ASSERT_EQUAL(true,
xProps->getPropertyValue(u"EmbedComplexScriptFonts"_ustr).get<bool>());
// Enable font embedding, only used and latin script fonts
xProps->setPropertyValue(u"EmbedFonts"_ustr, uno::Any(true));
xProps->setPropertyValue(u"EmbedOnlyUsedFonts"_ustr, uno::Any(true));
xProps->setPropertyValue(u"EmbedLatinScriptFonts"_ustr, uno::Any(true));
xProps->setPropertyValue(u"EmbedAsianScriptFonts"_ustr, uno::Any(false));
xProps->setPropertyValue(u"EmbedComplexScriptFonts"_ustr, uno::Any(false));
save(u"Impress Office Open XML"_ustr);
// Check the exported document has the embedded fonts enabled and has entries
{
xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/presentation.xml"_ustr);
assertXPath(pXmlDoc, xPath_Presentation, "embedTrueTypeFonts", u"1");
assertXPath(pXmlDoc, xPath_EmbeddedFont + "[@typeface='DejaVu Sans']");
} #endif
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.