title: Docx4j - chaging language settings for docDefaultStyle/proper applying custom(or changed) stock styles to any text in docx
body: <p>I'm trying to use mine defined(changed) styles in</p>
  
  <p><code>Styles styles = mp.getStyleDefinitionsPart ().getJaxbElement ();</code></p>
  
  <p>to change styling for my entire table/individual table cells. I managed to make it by setting the properties in RPr runProperties like this:</p>
  
  <p>in method applying style for table cells I use this:<br>
  <code>setFontFamily(runProperties, style.getFontFamily());</code></p>
  
  <pre><code>private static void setFontFamily(RPr runProperties, String fontFamily) {
      if (fontFamily != null) {
          RFonts rf = runProperties.getRFonts();
          if (rf == null) {
              rf = new RFonts();
              runProperties.setRFonts(rf);
          }
          rf.setAscii(fontFamily);
      }
  }
  </code></pre>
  
  <p>the same goes for other style attributes like font size, color etc. and it all works BUT ... The problem is that I use this to dynamically generate documents in Czech language, which has characters like: š, č, ř, ž, ý etc. and I use Verdana font for the table cell content and when I use this way to set the font it only applies characters different from Czech special characters. </p>
  
  <p>So e.g. when I generate String "Pavlovský" into new docx, "Pavlovsk" is in Verdana font (as set) and the "ý" character is in Calibri font.</p>
  
  <p>even if I simply use <code>wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Normal", "íáýěéáěř");</code> - everything changes to Calibri (when I open the docx, style of paragraph is Normal - font Verdana ... as set in my code)</p>
  
  <p>I even tried to set language like this </p>
  
  <pre><code>StyleDefinitionsPart styles = mp.getStyleDefinitionsPart ();
  Style defaultCharacterStyle = styles.getDefaultCharacterStyle();
  extracted(defaultCharacterStyle);
  Style defaultParagraphStyle = styles.getDefaultParagraphStyle();
  extracted(defaultParagraphStyle);
  Style defaultTableStyle = styles.getDefaultTableStyle();
  extracted(defaultTableStyle);
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>private static void extracted(Style style) {
      RPr rPr = style.getRPr();
      if (rPr!=null) {
          CTLanguage lang = factory.createCTLanguage();
          lang.setVal("cs-CZ");
          lang.setEastAsia("cs-CZ");
          lang.setBidi("ar-SA");
          rPr.setLang(lang);
  
          style.setRPr(rPr);
      } else {
          rPr = factory.createRPr();
          CTLanguage lang = factory.createCTLanguage();
          lang.setVal("cs-CZ");
          lang.setEastAsia("cs-CZ");
          lang.setBidi("ar-SA");
          rPr.setLang(lang);
          style.setRPr(rPr);
      }
  }
  </code></pre>
  
  <p>I will be grateful for any hint! Thanks in advance!</p>