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

fix: correctly scale css fonts based on ide defaults #654

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/resource-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Check Static Resources
run: |
declare -A resources
# Add each resource as a kay, value pair, mapping the local resource to the reference wile (which should be stored in the lanaguage server repository). For example:
# Add each resource as a key, value pair, mapping the local resource to the reference file (which should be stored in the lanaguage server repository). For example:
# resources["<path_to_local_file>"]="<url_of_reference_file>"
resources["src/main/resources/html/ScanSummaryInit.html"]="https://raw.githubusercontent.com/snyk/snyk-ls/refs/heads/main/shared_ide_resources/ui/html/ScanSummaryInit.html"
for key in ${!resources[@]}; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ class ThemeBasedStylingGenerator {
val isHighContrast =
EditorColorsManager.getInstance().globalScheme.name.contains("High contrast", ignoreCase = true)
html = html.replace("--default-font: ", "--default-font: \"${JBUI.Fonts.label().asPlain().family}\", ")
html = html.replace("var(--main-font-size)", JBFont.small().size.toString() + "px")
// CSS from the language server assumes a default size of 10px. JBFont uses a default of 13pt, so we
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering. Should we scale it proportionally or just add the +3 everytime. Also, if we don't scale it but use the configured JBFont size - how does it look?

// scale that here to get the correct relative point size.
html = html.replace("var(--main-font-size)", String.format("%.1fpt", JBFont.regular().size / 1.7))
html = html.replace("var(--text-color)", UIUtil.getLabelForeground().toHex())
html = html.replace("var(--background-color)", UIUtil.getPanelBackground().toHex())
html = html.replace("var(--ide-background-color)", UIUtil.getPanelBackground().toHex())
Expand Down
Loading