fontsize_formats does not respect font sizes in "em" units.
See original GitHub issueThis 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:
- Created 5 years ago
- Reactions:9
- Comments:12 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Is this Issue getting any updates?
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.