}
// System.out.println(XmlUtils.marshaltoString(rPr, true, true));
RFonts rFonts = rPr.getRFonts();
if (rFonts==null) {
return nullRPr(document, text);
}
text = this.arabicNumbering(text, rPr.getRtl(), rPr.getCs(), themeFontLang);
/* If the run has the cs element ("[ISO/IEC-29500-1] §17.3.2.7; cs")
* or the rtl element ("[ISO/IEC-29500-1] §17.3.2.30; rtl"),
* then the cs (or cstheme if defined) font is used,
* regardless of the Unicode character values of the run's content.
*/
if (rPr.getCs()!=null || rPr.getRtl()!=null ) {
// use the cs (or cstheme if defined) font is used
if (rFonts.getCstheme()!=null) {
String fontName = null;
if (getThemePart()!=null) {
try {
fontName = getThemePart().getFont(rFonts.getCstheme(), themeFontLang);
} catch (Docx4JException e) {
// TODO Auto-generated catch block
log.error(e.getMessage(), e);
}
}
if (fontName==null
// || fontName.trim().length()==0
) {
fontName = rFonts.getCs();
}
if (fontName==null
// || fontName.trim().length()==0
) {
// then what?
log.warn("font name is null, for " + text);
log.warn(XmlUtils.marshaltoString(rPr, true, true));
(new Throwable()).printStackTrace();
}
Element span = createElement(document);
if (span!=null) {
// It will be null in MainDocumentPart$FontAndStyleFinder case
document.appendChild(span);
this.setAttribute(span, fontName);
span.setTextContent(text);
}
if (outputType== RunFontActionType.DISCOVERY) {
vis.fontAction(fontName);
}
return result(document);
} else if (rFonts.getCs()!=null) {
String fontName =rFonts.getCs();
Element span = createElement(document);
if (span!=null) {
// It will be null in MainDocumentPart$FontAndStyleFinder case
document.appendChild(span);
this.setAttribute(span, fontName);
span.setTextContent(text);
}
if (outputType== RunFontActionType.DISCOVERY) {
vis.fontAction(fontName);
}
return result(document);
} else {
// No CS value.
// What to do?
}
}
String eastAsia = null;
String ascii = null;
String hAnsi = null;
STHint hint = rFonts.getHint();
if (rFonts.getEastAsiaTheme()!=null
&& getThemePart()!=null) {
try {
eastAsia = getThemePart().getFont(rFonts.getEastAsiaTheme(), themeFontLang);
} catch (Docx4JException e) {
// TODO Auto-generated catch block
log.error(e.getMessage(), e);
}
// ??
//if (getPhysicalFont(eastAsia)==null) {
// log.info("theme font for lang " + themeFontLang + " is " + eastAsia + ", but we don't have that");
// eastAsia = rFonts.getEastAsia();
//}
if (eastAsia==null) {
log.info("theme font for lang " + themeFontLang + " is " + eastAsia + ", but we don't have that");
eastAsia = rFonts.getEastAsia();
}
} else {
// No theme, so
eastAsia = rFonts.getEastAsia();
}
if (rFonts.getAsciiTheme()!=null
&& getThemePart()!=null) {
try {
ascii = getThemePart().getFont(rFonts.getAsciiTheme(), themeFontLang);
} catch (Docx4JException e) {
// TODO Auto-generated catch block
log.error(e.getMessage(), e);
}
} else {
// No theme, so
ascii = rFonts.getAscii();
}
if (rFonts.getHAnsiTheme()!=null
&& getThemePart()!=null) {
try {
hAnsi = getThemePart().getFont(rFonts.getHAnsiTheme(), themeFontLang);
} catch (Docx4JException e) {
// TODO Auto-generated catch block
log.error(e.getMessage(), e);
}
} else {
// No theme, so
hAnsi = rFonts.getHAnsi();
}
/*
* If the eastAsia (or eastAsiaTheme if defined) attribute’s value is “Times New Roman”
* and the ascii (or asciiTheme if defined) and hAnsi (or hAnsiTheme if defined) attributes are equal,