Page 1 of 1

stucked by getting font...

PostPosted: Thu Jul 30, 2009 5:57 am
by dqkit
hi all, I am trying to get the font name.
look, the P contents in the docx are as the following codes:
Code: Select all
      <w:p w:rsidR="005C157C" w:rsidRPr="00055DB4" w:rsidP="004C453D">
         <w:pPr>
            <w:pStyle w:val="My7"></w:pStyle>
            <w:rPr>
               <w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"></w:rFonts>
            </w:rPr>
         </w:pPr>
         <w:bookmarkStart w:id="373" w:name="_Toc229233489"></w:bookmarkStart>
         <w:r w:rsidRPr="00055DB4" w:rsidR="004C09D1">
            <w:rPr>
               <w:rFonts w:ascii="Times New Roman" w:hAnsi="Times New Roman"></w:rFonts>
            </w:rPr>
            <w:t>参</w:t>
         </w:r>
         </w:p>

I thought the content "参"(Chinese) is using the font "Times New Roman", but it appears using anther font! It is using the font "黑体"!
why ? or should I go to pStyle and have a look at that ?
I have get some infomations about rFonts from msdn. the rFonts has atributes such as w:ascii, w:hAnsi, cs, eastAsia, hint....
so, which atribute will finally be used to control the font?
And are there any methods in docx4j could get the font in used ?
thank you !

Re: stucked by getting font...

PostPosted: Sun Aug 02, 2009 9:30 am
by jason
See http://dev.plutext.org/trac/docx4j/brow ... olver.java which works out the actual set of properties (paragraph or run)
which apply, following the order specified in ECMA-376.

See also the method getDefaultFont() in that class.

Re: stucked by getting font...

PostPosted: Sun Aug 02, 2009 3:22 pm
by dqkit
I've tried that. but I found it would give your the wrong font when you were using Chines. There might be bugs in Chinese. I am trying to fix it.

Re: stucked by getting font...

PostPosted: Mon Aug 03, 2009 10:46 am
by jason
dqkit wrote:There might be bugs in Chinese. I am trying to fix it.


There could well be; I was focused on the @w:ascii, iirc.

Look forward to your fix :-)