-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default font name and size display is confusing #800
Comments
Hi @cuboci I checked that the font size is displayed in pixel. |
It seems that all of them are displayed in "px" units when you use "getComputedStyle" to get the font size. |
Hi @JiHong88
My bad actually. In the original screenshot I provided you can see that font name in the drop-down list is styled using the actual font but the button text uses a generic serif font. I thought - incorrectly - that in the 2.28 version of the editor I used earlier the button was styled, too. But it wasn't. I checked the debugger for both versions. The only thing that changed is that in 2.28 it used {font-family: "Helvetica Neue", sans-serif;} and now it uses {font-family: "Helvetica Neue";}. Since there's no "Helvetica Neue" on my system the browser falls back to the default font, which is a serif one. Before, there was a fallback to sans-serif. That's why it looks different now but I can live with that.
Indeed. I checked that and got the same. Even if you somehow converted the applied style's font size to the unit set by "fontSizeUnit" you'd get rounding errors. A font size of 10pt set in the default style and applied to .sun-editor-editable yields "13.3333px" from getComputedStyle. Theoretically you could convert that to "pt", since 1 pt = 1/72 inch and 1 px = 1/96 inch, as per CSS specification. But doing that you'd get 9.999975pt because of lack of precision. The only way I see out of this is not using a generic "defaultStyle" but creating that from single values (defaultFontSize, defaultFontFamily, etc.) and using these single values as button text. |
Added "__defaultFontSize" option. |
The 2.43.0 version has been updated. |
Describe the bug
Default font size and family are not displayed in the toolbar correctly. The default font size is displayed in "px" even when fontSizeUnit is set to "pt". This is confusing because, for example, 10pt = 13.3333px.
Also, the font family is rendered in serif font, although the default (Arial) is a sans-serif one and the font names in the select box are appropriately styled.
Once a specific font size has been selected or the cursor is within text that does have a specific size set the font size in the toolbar is displayed in the choosen font size unit.
To Reproduce
Expected behavior
The default font family and font size unit should be used to display the default values. It's confusing for users to see 13.3333px and get a smaller font than after they have selected 12pt, for a example.
Desktop (please complete the following information):
Additional information
This only happened after I upgraded from 2.28.x to 2.41.2. I know the older version didn't display default values but at least the font name was always appropriately styled.
The text was updated successfully, but these errors were encountered: