As can be seen in following screenshot, the formatting is applied via Style and by using “direct attributes”:
So, the reason is that you set both the Style and Paragraph properties, therefore some of the style properties are overridden. To avoid this, you should simply either use only style or only paragraph properties. We suggest to use only Style, remove all this ‘
builder.getFont().setSize(tokenSize);’ and leave only ‘
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);’. It should work as expected.
Also some code looks a bit strange, and you may want to remove it. For example:
Color tokenColor = builder.getParagraphFormat().getStyle().getFont().getColor();
We are planning to close linked issue (WORDSNET-20644) with “Not a Bug” status.
P.S. Please note that Formatting is applied on a few different levels. For example, let’s consider formatting of simple text. Text in documents is represented by Run element and a Run can only be a child of a Paragraph. You can apply formatting 1) to Run nodes by using Styles e.g. a Glyph Style, 2) to the parent of those Run nodes i.e. a Paragraph node (possibly via paragraph Styles) and 3) you can also apply ‘direct formatting’ to Run nodes by using Run attributes (Font). In this case the Run will inherit formatting of Paragraph Style, a Glyph Style and then direct formatting.