Problem with fonts

Posted:
Fri Apr 04, 2014 1:00 am
by parisd
Hi, I am trying to evaluate the xhtml import feature, but I cannot change the font face of the created document.
I have tried using both the font-family css rule and the <font face="xxx"> tag, but the generated document does not change the font from the default (Calibri). (The html file is in UTF-8 and contains Greek characters).
Can you please help?
(I am using the latest stable builds docx4j-3.0.1 and have tried with both docx4j-ImportXHTML-3.0.0 and the latest nightly)
Re: Problem with fonts

Posted:
Fri Apr 04, 2014 11:09 am
by jason
XHTMLImporterImpl contains:
Using java Syntax Highlighting
/**
* Map a font family, for example "Century Gothic" in:
*
* font-family:"Century Gothic", Helvetica, Arial, sans-serif;
*
* to a w:rFonts object, for example:
*
* <w:rFonts w:ascii="Arial Black" w:hAnsi="Arial Black"/>
*
* Assuming style font-family:"Century Gothic", Helvetica, Arial, sans-serif;
* the first font family for which there is a mapping is the one
* which will be used.
*
* xhtml-renderer's CSSName defaults font-family: serif
*
* It is your responsibility to ensure a suitable font is available
* on the target system (or embedded in the docx package). If we
* (eventually) support CSS @font-face, docx4j could do that
* for you (at least for font formats we can convert to something
* embeddable).
*
* @since 3.0
*/
public static void addFontMapping
(String cssFontFamily, RFonts rFonts
) {
fontFamilyToFont.
put(cssFontFamily, rFonts
);
}
Parsed in 0.025 seconds, using
GeSHi 1.0.8.4
You have to create the RFonts object. You can use:
Using java Syntax Highlighting
Context.
getWmlObjectFactory().
createRFonts()
Parsed in 0.023 seconds, using
GeSHi 1.0.8.4
See further
http://webapp.docx4java.org/OnlineDemo/ ... Fonts.html