Here is my code.
XWPFRun run = runlist.get(0);
double fontsize = (double)(run.getFontSize());
String fontfamily = (String)run.getFontFamily();
When it read the .docx file it will sometimes return -1 in font size and null in font family.
I know that it's because they are default value but I don't want -1 and null I just want the name of that default value.
How can I read it?
I had a similar problem and I got it fixed with
document.getStyles().getDefaultRunStyle().getFontSize();
The font/character properties on a XWPFRun only return the override details, so settings which are different on that run to the surrounding text
If the run is using the default stylings, you'll need to move up to the XWPFParagraph it belongs to (or table etc), then call getStyleId() to get the style which applies to the paragraph.
Then, on the document, call XWPFDocument.getStyles().getStyle(styleId) to get the XWPFStyle object that applies to the paragraph of interest.
From the style, you can fetch the properties defined in that style such as the font. You may also need to fetch the parent, if the style inherits from one.
Currently, the XWPFStyle object is a bit low level, so patches to improve it would be gratefully received!