question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fontsize_formats does not respect font sizes in "em" units.

See original GitHub issue

This is a buh report.

I have this option for TinyMCE: fontsize_formats: "0.7em 0.8em 0.9em 1em 1.2em 1.5em 1.9em 2.4em"

And these sizes do not work. So I searched why and found this code in tinymce.js:

  var fromFontSizeNumber = function (editor, value) {
    var fontSizeNumber = parseInt(value, 10);
    if (fontSizeNumber >= 1 && fontSizeNumber <= 7) {
      var fontSizes = $_6msxiw2jjfuw8lkv.getFontStyleValues(editor);
      var fontClasses = $_6msxiw2jjfuw8lkv.getFontSizeClasses(editor);
      if (fontClasses) {
        return fontClasses[fontSizeNumber - 1] || value;
      } else {
        return fontSizes[fontSizeNumber - 1] || value;
      }
    } else {
      return value;
    }
  };

As you can see, the TinyMCE code uses the integer part of each font size, which is wrong since I specify font sizes in a relative manner (using “em” units). So it replaces the values with “xx-small” and so on.

The expected behavior is to respect values which are specified in “em” units. Test if the value is ending with an “em” and in that case immediately return that.

TinyMCE 4.7.11, Windows 10 x64, Firefox (latest).

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
JCoucecommented, Feb 22, 2019

Is this Issue getting any updates?

5reactions
andrejsverzacommented, Apr 12, 2018

Also I could mention that there is a lack of “font-size” removal option. Like with font color box, which includes a possibility to remove the applied color. The same would be useful for font-sizes. It should include some kind of “select default” option or “dash” option. Or at least a possibility to select the same option from dropdown to cancel the selection. Because - once I selected the font size, I cannot unselect it. I can only remove the whole formatting.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use Rems for Font Size to Respect User Preferences
Assuming that the root font size is 16px (as is the case in all modern browsers), we get the following values: 1rem =...
Read more >
Font Sizes in Responsive Design: px vs. pt vs. em vs. percent?
However, because they are a fixed size, pixels do not size up or down. That means that fonts will be rendered smaller on...
Read more >
Is sizing fonts using "em" still relevant? - Stack Overflow
No, by definition, in CSS, when sizing a font using em units, 1em is the font size of the parent element. You shouldn't...
Read more >
Why you should never use px to set font-size in CSS
em and % units are not always equivalent in other contexts; for example, width: 1em and width: 100% would most likely be very...
Read more >
font-size - CSS: Cascading Style Sheets - MDN Web Docs
Note: Defining font sizes in px is not accessible, because the user ... Like the em unit, an element's font-size set using the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found