-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reject font values that are invalid for pango #7092
Conversation
Use pango to parse font configuration early, and reject the command as invalid if the value is invalid for pango. Since we're already parsing the font into a `PangoFontDescription`, keep that instance around and avoid re-parsing the font each time we render text. Fixes: swaywm#6805
if (!(config->font = strdup("monospace 10"))) goto cleanup; | ||
config->font_description = pango_font_description_from_string(config->font); |
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.
Can we call the font
command here with arg "monospace 10"
?
We'd be able to de-duplicate some font-configuration bits, and also drop the
extra call to config_update_font_height
below (which is kind of a hack). In
fact, we can move the logic from config_update_font_height
into the font
command itself, since the font height only changes when the font changes, and
drop the separate config_update_font_height
entirely.
Does this seem reasonable?
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.
I'd rather not execute commands when initializing data structures.
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.
I'll re-think how to optimise that further and address it separately then. It's a non-issue in this scope.
This LGTM! Follow-up issue: also pass a parsed |
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.
This LGTM!
Follow-up issue: also pass a parsed PangoFontDescription
to other text-related functions like render_text
, but that's a more involved change.
Avoids parsing the configured font each time text is rendered.
I'd missed that one! That was quicker than expected (took less than my lunch in the oven 😂 ). I wonder if |
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.
Nice, the new commit LGTM as well, thanks!
Use pango to parse font configuration early, and reject the command as
invalid if the value is invalid for pango. Since we're already parsing
the font into a
PangoFontDescription
, keep that instance around andavoid re-parsing the font each time we render text.
Fixes: #6805