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

Add font configuration settings #143

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

pinpox
Copy link
Contributor

@pinpox pinpox commented May 27, 2024

Work in progress. I added the requered fields, but it still fails to build with:

   Compiling centerpiece v1.0.0 (/home/pinpox/code/github.com/pinpox/centerpiece/client)
error[E0597]: `settings.font.default` does not live long enough
   --> client/src/main.rs:279:46
    |
276 |         let settings = crate::settings::Settings::new();
    |             -------- binding `settings` declared here
...
279 |             family: iced::font::Family::Name(&settings.font.default),
    |                                              ^^^^^^^^^^^^^^^^^^^^^^
    |                                              |
    |                                              borrowed value does not live long enough
    |                                              this usage requires that `settings.font.default` is borrowed for `'static`
...
309 |     }
    |     - `settings.font.default` dropped here while still borrowed

For more information about this error, try `rustc --explain E0597`.
error: could not compile `centerpiece` (bin "centerpiece") due to previous error

I've tested just setting a different hardcoded string for the font name and it works nicely if the font is present on the system. I added a setting that default to the current font (Fira).

let default_font = iced::Font {
family: iced::font::Family::Name("FiraCode Nerd Font"),
family: iced::font::Family::Name(&settings.font.default),
Copy link
Owner

Choose a reason for hiding this comment

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

Try this dirty hack ;) kindly suggested by @a-kenji
family: iced::font::Family::Name(Box::leak(settings.font.default.into_boxed_str())),

Copy link
Collaborator

Choose a reason for hiding this comment

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

With the current main the following should now be possible, because it has a static lifetime:

family: iced::font::Family::Name(&Settings::get_or_init().font.default)

Comment on lines 264 to +314
#[serde(default)]
pub color: ColorSettings,
#[serde(default)]
pub font: FontSettings,
Copy link
Owner

Choose a reason for hiding this comment

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

Could you also document the font as well as the color options in the Readme.md file and also implement setting those in nix (https://github.com/friedow/centerpiece/blob/main/home-manager-module.nix) in this pr?

@friedow
Copy link
Owner

friedow commented Jun 27, 2024

@pinpox you need any help on this?

@pinpox
Copy link
Contributor Author

pinpox commented Jul 4, 2024

Sorry, I've been quite busy the last weeks. I'll get back to it when I find the time.

Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/8a68b987c476a33e90f203f0927614a75c3f47ea' (2024-07-18)
  → 'github:ipetkov/crane/4c6c77920b8d44cd6660c1621dea6b3fc4b4c4f4' (2024-08-06)
• Updated input 'home-manager':
    'github:nix-community/home-manager/afd2021bedff2de92dfce0e257a3d03ae65c603d' (2024-07-16)
  → 'github:nix-community/home-manager/b3d5ea65d88d67d4ec578ed11d4d2d51e3de525e' (2024-08-07)
• Updated input 'home-manager/nixpkgs':
    'github:NixOS/nixpkgs/00d80d13810dbfea8ab4ed1009b09100cca86ba8' (2024-07-01)
  → 'github:NixOS/nixpkgs/52ec9ac3b12395ad677e8b62106f0b98c1f8569d' (2024-07-28)
• Updated input 'nixpkgs':
    'github:NixOS/nixpkgs/5e73714b16ca222dcb2fc3ea2618fd7ba698da65' (2024-07-17)
  → 'github:NixOS/nixpkgs/f5129fb42b9c262318130a97b47516946da3e7d7' (2024-08-07)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/0fb28f237f83295b4dd05e342f333b447c097398' (2024-07-15)
  → 'github:numtide/treefmt-nix/768acdb06968e53aa1ee8de207fd955335c754b7' (2024-07-30)
• Updated input 'treefmt-nix/nixpkgs':
    'github:nixos/nixpkgs/2741b4b489b55df32afac57bc4bfd220e8bf617e' (2024-06-29)
  → 'github:nixos/nixpkgs/693bc46d169f5af9c992095736e82c3488bf7dbb' (2024-07-14)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants