use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts in project poi by apache.
the class XWPFRun method getFontFamily.
/**
* Gets the font family for the specified font char range.
* If fcr is null, the font char range "ascii" is used
*
* @param fcr the font char range, defaults to "ansi"
* @return a string representing the font famil
*/
public String getFontFamily(FontCharRange fcr) {
CTRPr pr = run.getRPr();
if (pr == null || !pr.isSetRFonts())
return null;
CTFonts fonts = pr.getRFonts();
switch(fcr == null ? FontCharRange.ascii : fcr) {
default:
case ascii:
return fonts.getAscii();
case cs:
return fonts.getCs();
case eastAsia:
return fonts.getEastAsia();
case hAnsi:
return fonts.getHAnsi();
}
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts in project Gargoyle by callakrsos.
the class KrXWPFRun method setFontFamily.
@Override
public void setFontFamily(String fontFamily) {
CTR run = getCTR();
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
fonts.setHAnsi(fontFamily);
fonts.setEastAsia(fontFamily);
fonts.setAscii(fontFamily);
super.setFontFamily(fontFamily);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts in project poi by apache.
the class XWPFRun method setFontFamily.
/**
* Specifies the fonts which shall be used to display the text contents of
* this run. The default handling for fcr == null is to overwrite the
* ascii font char range with the given font family and also set all not
* specified font ranges
*
* @param fontFamily
* @param fcr FontCharRange or null for default handling
*/
public void setFontFamily(String fontFamily, FontCharRange fcr) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTFonts fonts = pr.isSetRFonts() ? pr.getRFonts() : pr.addNewRFonts();
if (fcr == null) {
fonts.setAscii(fontFamily);
if (!fonts.isSetHAnsi()) {
fonts.setHAnsi(fontFamily);
}
if (!fonts.isSetCs()) {
fonts.setCs(fontFamily);
}
if (!fonts.isSetEastAsia()) {
fonts.setEastAsia(fontFamily);
}
} else {
switch(fcr) {
case ascii:
fonts.setAscii(fontFamily);
break;
case cs:
fonts.setCs(fontFamily);
break;
case eastAsia:
fonts.setEastAsia(fontFamily);
break;
case hAnsi:
fonts.setHAnsi(fontFamily);
break;
}
}
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts in project poi by apache.
the class TestXWPFStyles method testLanguages.
/**
* YK: tests below don't make much sense,
* they exist only to copy xml beans to pi-ooxml-schemas.jar
*/
@SuppressWarnings("resource")
@Test
public void testLanguages() {
XWPFDocument docOut = new XWPFDocument();
XWPFStyles styles = docOut.createStyles();
styles.setEastAsia("Chinese");
styles.setSpellingLanguage("English");
CTFonts def = CTFonts.Factory.newInstance();
styles.setDefaultFonts(def);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTFonts in project poi by apache.
the class XWPFStyles method setDefaultFonts.
/**
* Sets the default font on ctStyles DocDefaults parameter
* TODO Replace this with specific setters for each type, possibly
* on XWPFDefaultRunStyle
*/
public void setDefaultFonts(CTFonts fonts) {
ensureDocDefaults();
CTRPr runProps = defaultRunStyle.getRPr();
runProps.setRFonts(fonts);
}