This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Support browser font scaling #11972
Closed
Closed
Support browser font scaling #11972
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -494,11 +494,6 @@ export const SETTINGS: { [setting: string]: ISetting } = { | |
default: FontWatcher.DEFAULT_SIZE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I note there is a reference on line 487 to "16px". It seems like that needs updating, or at least clarifying? Generally it might be nice to add a little documentation about what |
||
controller: new FontSizeController(), | ||
}, | ||
"useCustomFontSize": { | ||
displayName: _td("settings|appearance|custom_font_size"), | ||
supportedLevels: LEVELS_ACCOUNT_SETTINGS, | ||
default: false, | ||
}, | ||
"MessageComposerInput.suggestEmoji": { | ||
supportedLevels: LEVELS_ACCOUNT_SETTINGS, | ||
displayName: _td("settings|emoji_autocomplete"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -119,7 +119,15 @@ export class FontWatcher implements IWatcher { | |||||||||||||||||||
if (fontSize !== size) { | ||||||||||||||||||||
await SettingsStore.setValue("baseFontSizeV2", null, SettingLevel.DEVICE, fontSize); | ||||||||||||||||||||
} | ||||||||||||||||||||
document.querySelector<HTMLElement>(":root")!.style.fontSize = toPx(fontSize); | ||||||||||||||||||||
|
||||||||||||||||||||
// To respect browser font scaling we need to set the base font-size to 100% | ||||||||||||||||||||
// When user has set a custom font size, apply it as a delta to 100% using calc | ||||||||||||||||||||
const cssFontSize = | ||||||||||||||||||||
fontSize === FontWatcher.DEFAULT_SIZE | ||||||||||||||||||||
? "100%" | ||||||||||||||||||||
: `calc(100% + ${toPx(fontSize - FontWatcher.DEFAULT_SIZE)})`; | ||||||||||||||||||||
Comment on lines
+125
to
+128
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a bit DRYer:
Suggested change
(I'd also be inclined to |
||||||||||||||||||||
|
||||||||||||||||||||
document.querySelector<HTMLElement>(":root")!.style.fontSize = cssFontSize; | ||||||||||||||||||||
}; | ||||||||||||||||||||
|
||||||||||||||||||||
public static readonly FONT_FAMILY_CUSTOM_PROPERTY = "--cpd-font-family-sans"; | ||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still true, particularly given we use a custom formatter? Maybe we can switch to a numeric representation and do a bit less
toString
andparseInt
below?(It might also be nice to switch it to holding a relative value, to make it closer to the displayed value and what it actually does? But happy for us to declare that out of scope for this PR)