Skip to content

Do not scale font-size when set to a relative unit from in the UI (fixes tiny sub/superscripts)

This fixes the issue of tiny sub/superscripts bug #1658029 which are now visible as a result of the scale introduced with the new mm-based templates.

Please check carefully for regressions as I want to propose this for 0.92.2 (Regressions should only be possible when setting a relative font-size via the UI, which seems to be impossible, see below).

The issue is caused by rescaling the intended font-size of 65% to "match" the scaling of display units to document units, i.e. for the default mm based template:

1 px = 1/96 inch = 1/96 * 25.4 mm should be 1 mm
=> scale = 1/96 * 25.4 = 0.265

font-size = 65% * 0.265= 17.2%

Since the font-size is a relative measure it should not be scaled, though, as it will automatically use the correct size relative to the parent, which is exactly what this MR fixes by setting bool only_with_units = true when calling sp_css_attr_scale_property_single().

"call stack" to this function when setting sub/superscripts

sp_css_attr_scale_property_single()  # style.cpp
 ^sp_css_attr_scale()                # style.cpp
  ^sp_desktop_apply_css_recursive()  # desktop-style.cpp
   ^sp_desktop_set_style()           # desktop-style.cpp
    ^sp_text_script_changed()        # text-toolbar.cpp

The actual sub/superscript size is set in the last function sp_text_script_changed

additional information

@Tavmjong and I were trying to figure out why other attributes in sp_css_attr_scale() were not affected by this issue.

Turns out that they would likely be, but (as far as I can see) the GUI does not allow to set a relative size for any of those attributes, except:

  • line-height (which is already treated properly since cca0541422b3f0a6fcf38769be2a621927e508c1)
  • stroke-width (which seems to do some additional re-calculating of the input value internally - maybe this could be simplified but I did not investigate it further yet).
Edited by username-removed-945074

Merge request reports