Page 1 of 1

HTML fonts

PostPosted: Wed Apr 10, 2013 3:20 am
by jallen
I have also discovered that the font-family styling is placed inline for certain paragraphs and not for others. Unfortunately when it isn't defined the browser sometimes picks whatever it wants. I'm not sure if it would be possible to check for the presence of the font in the paragraph and if it's not there set it to the default.

Re: HTML fonts

PostPosted: Mon Apr 15, 2013 10:48 am
by jason
PropertyResolver contains the following comment:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        public String getDefaultFont() {
               
                // First look at the defaults
                // 3 look at styles/rPrDefault
                //   eg <w:rFonts w:asciiTheme="minorHAnsi" w:eastAsiaTheme="minorEastAsia"
                //                                w:hAnsiTheme="minorHAnsi" w:cstheme="minorBidi"/>
                // 3.1 if there is an rFonts element, do what it says (it may refer you to the theme part,
                //     in which case if there is no theme part, default to "internally stored settings"
                //         (there is no normal.dot; see http://support.microsoft.com/kb/924460/en-us )
                //         in this case Calibri and Cambria)
                // 3.2 if there is no rFonts element, default to Times New Roman.

 
Parsed in 0.014 seconds, using GeSHi 1.0.8.4


The sample document you provided contains:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
<w:styles >
  <w:docDefaults>
    <w:rPrDefault>
      <w:rPr>
        <w:rFonts w:ascii="Times New Roman" w:eastAsiaTheme="minorHAnsi" w:hAnsi="Times New Roman" w:cstheme="minorBidi"/>
 
Parsed in 0.001 seconds, using GeSHi 1.0.8.4


Is that rFonts element present in the documents where this issue arises?

Re: HTML fonts

PostPosted: Tue Apr 16, 2013 1:04 am
by jallen
Edited:

Yes there is an rFonts element and it gets written out to the style sheet.
Code: Select all
.DocDefaults {display:block;font-family: Times New Roman;font-size: 12.0pt;}

I have discovered that this is really an issue with mail clients. We are using the html generated from docx4j to build MIME. Apparently alot of the web based mail clients like gmail completely ignore html style sheets. So we have found that all of the font formatting and line spacing needs to be inline to work. I am currently re-parsing the html and adding the paragraph styling when it is missing.