The following code applies the styles configuration persisted somewhere (database, file etc).
It is called in a loop for every style persisted that way: both built-in and user-defined styles.
The variable 'q' here is a dynamic object representing the table fields of one record.
This works exactly as described in the examples for the built-in styles as you can see in the attachment: the Heading2 is correct size.
Code:
Style style = document.Styles[q.StyleCode] ?? document.Styles.AddStyle(q.StyleCode, q.BasedOn);
style.BaseStyle = q.BasedOn ?? style.BaseStyle;
style.Font.Name = q.FontName ?? style.Font.Name;
style.Font.Size = q.FontSize ?? style.Font.Size;
style.Font.Bold = q.FontBold ?? style.Font.Bold;
style.Font.Italic = q.FontItalic ?? style.Font.Italic;
style.ParagraphFormat.PageBreakBefore = q.PageBreakBefore ?? false;
style.ParagraphFormat.SpaceBefore = q.SpaceBefore ?? style.ParagraphFormat.SpaceBefore;
style.ParagraphFormat.SpaceAfter = q.SpaceAfter ?? style.ParagraphFormat.SpaceAfter;
style.ParagraphFormat.LeftIndent = q.LeftIndent ?? style.ParagraphFormat.LeftIndent;
style.ParagraphFormat.RightIndent = q.RightIndent ?? style.ParagraphFormat.RightIndent;
style.ParagraphFormat.FirstLineIndent = q.FirstLineIndent ?? style.ParagraphFormat.FirstLineIndent;
When I supply
Normal for
BasedOn and no
FontSize, I expect the font of the paragraphs added w/o specifying any style to be the same size as of the paragraphs added with a style based on
Normal which has some other parameters set (in my case those are
LeftIndent and
FirstLineIndent).
But the font size is different: it is smaller for the unspecified style (yellow highlighter in the attached) and larger for my new style based on Normal (circled in red in the attachment).
What am I doing wrong?