Search in sources :

Example 6 with CTTextFont

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont in project poi by apache.

the class XSSFTextRun method setFontFamily.

public void setFontFamily(String typeface, byte charset, byte pictAndFamily, boolean isSymbol) {
    CTTextCharacterProperties rPr = getRPr();
    if (typeface == null) {
        if (rPr.isSetLatin())
            rPr.unsetLatin();
        if (rPr.isSetCs())
            rPr.unsetCs();
        if (rPr.isSetSym())
            rPr.unsetSym();
    } else {
        if (isSymbol) {
            CTTextFont font = rPr.isSetSym() ? rPr.getSym() : rPr.addNewSym();
            font.setTypeface(typeface);
        } else {
            CTTextFont latin = rPr.isSetLatin() ? rPr.getLatin() : rPr.addNewLatin();
            latin.setTypeface(typeface);
            if (charset != -1)
                latin.setCharset(charset);
            if (pictAndFamily != -1)
                latin.setPitchFamily(pictAndFamily);
        }
    }
}
Also used : CTTextFont(org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)

Example 7 with CTTextFont

use of org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont in project poi by apache.

the class XSSFTextRun method getFontFamily.

/**
     * @return  font family or null if not set
     */
public String getFontFamily() {
    CTTextCharacterProperties rPr = getRPr();
    CTTextFont font = rPr.getLatin();
    if (font != null) {
        return font.getTypeface();
    }
    return XSSFFont.DEFAULT_FONT_NAME;
}
Also used : CTTextFont(org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)

Aggregations

CTTextFont (org.openxmlformats.schemas.drawingml.x2006.main.CTTextFont)7 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)6 CharacterPropertyFetcher (org.apache.poi.xslf.model.CharacterPropertyFetcher)2 CTTextParagraphProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties)1