Bug Hunting Session
Bug 99544 - Character styles don't inherit paragraph style font size
Summary: Character styles don't inherit paragraph style font size
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.6.4.3 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Writer-Styles-Character Font-Size
  Show dependency treegraph
 
Reported: 2016-04-28 07:56 UTC by Buovjaga
Modified: 2018-11-05 21:10 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Buovjaga 2016-04-28 07:56:18 UTC
Copied from bug 58611

To test & explain the character styles bug:
Open a new document and type some text.
Go to the Styles & Formatting window and modify the Default Style font size to be 16pt.
In the Styles and Formatting window, go to Character Styles (second button above the list of styles) and modify the Emphasis character style font size to be 150% (just type 150% into the font size dropdown).
Select the line of text you typed in the document, and set it to the Default Style paragraph style.
Then set it to the Emphasis character style.

From this you would expect that the text become 16pt*150%=24pt. But, as you should have seen in the demo document as well, the resulting font size is 12pt*150%=18pt.
Comment 1 Regina Henschel 2016-08-29 19:38:32 UTC
Please read section "20.183fo:font-size" of ODF 1.2 spec, http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html

The word Emphasis has got a style from the "automatic-styles", but percent values can only be used with common styles. That are those which the user has created. The nesting of the tags does not reflect the intended markup.

You assume, that the percentage refers the font-size of the paragraph, but that is not correct. It refers the font-size value of its parent style. The predefined style "Emphasis" has no parent style at all.

I have created a suitable test document for bug 101783. (I have noticed this bug only after the other has already been submitted.)
Comment 2 Buovjaga 2016-08-30 05:26:09 UTC
(In reply to Regina Henschel from comment #1)
> I have created a suitable test document for bug 101783. (I have noticed this
> bug only after the other has already been submitted.)

What do you propose? To close this as a dupe of the newer one?
Comment 3 Regina Henschel 2016-08-30 12:55:15 UTC
Although such setting is not possible with the current file format, it would be a useful feature to be able to define a font size relative larger or smaller as the size of the environment in which the character, which has applied this style, is used. Therefore I think, it should be set to "enhancement". Do you agree?
Comment 4 Buovjaga 2016-08-30 15:46:07 UTC
Ok (note: I only copy & pasted this report originally, so it is not my idea)
Comment 5 Octavio Alvarez 2016-09-18 10:19:00 UTC
(In reply to Regina Henschel from comment #1)
> Please read section "20.183fo:font-size" of ODF 1.2 spec,
> http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html
> 
> The word Emphasis has got a style from the "automatic-styles", but percent
> values can only be used with common styles. That are those which the user
> has created. The nesting of the tags does not reflect the intended markup.
> 
> You assume, that the percentage refers the font-size of the paragraph, but
> that is not correct. It refers the font-size value of its parent style. The
> predefined style "Emphasis" has no parent style at all.
> 
> I have created a suitable test document for bug 101783. (I have noticed this
> bug only after the other has already been submitted.)

However, section 16.2 specifies how to proceed when a formatting attribute is not found in a style. Not an expert, but my interpretation is that, according to § 20.183 "150%" means "150% of the parent style" so the parent style size must be calculated first. Because the attribute is not found on the parent style, the algorithm in § 16.2 should be followed to first calculate what the "parent size" --so to call it-- would be. Being a "text" style, it will fall back to the containing "paragraph" style (Default Style) and evaluate to 16 (not 12) and then multiply by 150%.

Namely, the paragraph I'm referring to says: "If a search of the parent styles of a style does not result in a value for a formatting property, the determination of its value depends on the style family and the element to which a style is applied." And goes on to state some cases.

I hope I didn't miss anything. Should I also comment this on bug 101783?
Comment 6 Octavio Alvarez 2016-09-18 10:30:08 UTC
(In reply to Regina Henschel from comment #3)
> Although such setting is not possible with the current file format, it would
> be a useful feature to be able to define a font size relative larger or
> smaller as the size of the environment in which the character, which has
> applied this style, is used. Therefore I think, it should be set to
> "enhancement". Do you agree?

Because of this and comment #5 I think that this may be possible with the current file format after all.

Also, 20.183 says:

"... based on the font height of the parent style rather than to the font height of the attributes neighborhood...", whatever "neighborhood" means. I didn't find any definition on the spec, but sounds like the same as "environment".

I conclude that "relative to environment" is prohibited by the spec and not needed because of the algorithm in section 16.2. Therefore I'd like to suggest that this is not an enhancement but a bug.
Comment 7 Regina Henschel 2017-08-09 22:26:04 UTC
Hi Octavio, I ask on the ODF TC mailing list, whether other TC members support your idea to use the algorithm too for getting the base value.


In the meantime I have tried the attribute "20.374 style:text-position". Using a setting like "style:text-position="0% 150%" would make the font-size of the character be 150% of the font-size without this attribute. The font-size of the character would react on the default font-size given by the paragraph as long as the character style has no own font-size setting. LibreOffice renders this fine, but the UI prevents such setting and the re-saved values look curious.