Skip to content
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

Remove all custom antialiasing [-webkit-font-smoothing] CSS lines #2474

Open
gpeuc opened this issue Oct 17, 2024 · 5 comments
Open

Remove all custom antialiasing [-webkit-font-smoothing] CSS lines #2474

gpeuc opened this issue Oct 17, 2024 · 5 comments
Assignees
Labels
ui-components @sap-ux/ui-components

Comments

@gpeuc
Copy link
Contributor

gpeuc commented Oct 17, 2024

I've just realised that we are rather randomly using

-webkit-font-smoothing: antialiased

through our CSS. Some elements will have that, some not. This on occasion causes issues when two things that are supposed to be the same actually render differently because one of them has forceful antialiasing, and another not.

The reality of this whole topic, on some higher level, is the following:

Webkit by default uses -webkit-font-smoothing: subpixel-antialiased which is a far superior method of antialiasing fonts as it does antialiasing on sub pixel level (so uses individual R / G / B diodes to do antialiasing, instead of entire pixel of the screen).

Us overriding this causes problems.

It additionally causes problems because on Windows machines users can set how fonts render ("Smooth edges of screen fonts"), and sometimes this clashes with us then forcefully adding antialiasing.

Therefore, the best thing we could do is simply remove all -webkit-font-smoothing: antialiased that we have, and simply not mention it again. We let operating system, and user, choose how stuff renders. We should not interfere with that.


https://usabilitypost.com/2012/11/05/stop-fixing-font-smoothing/

@gpeuc gpeuc added the ui-components @sap-ux/ui-components label Oct 17, 2024
@gpeuc
Copy link
Contributor Author

gpeuc commented Oct 17, 2024

Fluent does this at the top level, we should somehow remove this if possible.

Screenshot 2024-10-17 at 15 56 55

@gpeuc
Copy link
Contributor Author

gpeuc commented Oct 18, 2024

In conversation with mr. @815are this is what we will do:

  • Try to override Fluent's top level setting for Webkit Font Smoothing to auto
  • Go to our components that we custom made, and make sure that we remove all Font Smoothing there

This should then get rid of all forceful Font Smoothing, and leave it to the operating system to handle fonts.

@815are
Copy link
Contributor

815are commented Oct 18, 2024

as checked following code works for me:

import { createTheme, loadTheme, Theme } from '@fluentui/react';

const typographyStyles = {
    WebkitFontSmoothing: ''
};

const appTheme: Theme = createTheme({
    fonts: {
        tiny: typographyStyles,
        xSmall: typographyStyles,
        smallPlus: typographyStyles,
        medium: typographyStyles,
        mediumPlus: typographyStyles,
        small: typographyStyles,
        large: typographyStyles,
        xLarge: typographyStyles,
        xxLarge: typographyStyles,
        superLarge: typographyStyles,
        mega: typographyStyles
    }
});

loadTheme(appTheme);

Suggestion to create export method initTheme similar like method initIcons.
image

@eouin
Copy link
Contributor

eouin commented Oct 18, 2024

@815are Tried it and works for me as well. Let's create that initTheme in ui-components

@815are
Copy link
Contributor

815are commented Oct 18, 2024

PR - #2478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ui-components @sap-ux/ui-components
Projects
None yet
Development

No branches or pull requests

3 participants