Package org.docx4j.wml

Examples of org.docx4j.wml.RFonts


    }
   
//    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,
View Full Code Here


//    solidFill
   
//    *latin       
//    <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
      if (lvlPPr.getDefRPr().getLatin()!=null ) {
        RFonts rFonts = factory.createRFonts();
        if (lvlPPr.getDefRPr().getLatin().getTypeface().startsWith("+mj") ) {         
          rFonts.setAscii( fontScheme.getMajorFont().getLatin().getTypeface() );
        } else if (lvlPPr.getDefRPr().getLatin().getTypeface().startsWith("+mn") ) {         
          rFonts.setAscii( fontScheme.getMinorFont().getLatin().getTypeface() );
       
        rPr.setRFonts(rFonts);
      }     
    }
 
View Full Code Here

//    <w:rPr>
    RPr rPr = factory.createRPr();
    style.setRPr(rPr);

//    <w:rFonts w:asciiTheme="majorHAnsi" w:eastAsiaTheme="majorEastAsia" w:hAnsiTheme="majorHAnsi" w:cstheme="majorBidi" />
    RFonts rFonts = factory.createRFonts();
    rFonts.setAscii( fontScheme.getMinorFont().getLatin().getTypeface() );
    rPr.setRFonts(rFonts);
 
    return style;
     
   
View Full Code Here

          // TODO - follow inheritance
         
          Font iTextFont = null;
         
          RPr rPr = run.getRPr();
          RFonts rFonts = rPr.getRFonts();
          String documentFont = Mapper.FONT_FALLBACK;
          if (rFonts !=null ) {
           
            documentFont = rFonts.getAscii();
           
            if (documentFont==null) {
              // TODO - actually what Word does in this case
              // is inherit the default document font eg Calibri
              // (which is what it shows in its user interface)
              documentFont = rFonts.getCs();
            }
           
            if (documentFont==null) {
              log.error("Font was null in: " + XmlUtils.marshaltoString(rPr, true, true));
              documentFont=Mapper.FONT_FALLBACK;
View Full Code Here

TOP

Related Classes of org.docx4j.wml.RFonts

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.