Darazaki / Spedread

GTK speed reading software: Read like a speedrunner!
GNU General Public License v3.0
61 stars 5 forks source link

Color picker option for fonts #25

Closed bungadrum closed 3 months ago

bungadrum commented 4 months ago

Can you add the option in preferences to change the font into a color of your choice. Maybe a simple color picker or by adding a hex code field.

Darazaki commented 3 months ago

Do you have a specific use case for this? Are there maybe GTK themes with poor contrasts that'd need a workaround?

If it's a matter of visibility then maybe I'd need to also add a way to set the background color too or simply have a "high contrast" mode where the background & font colors would be pure white & black

bungadrum commented 3 months ago

No specific use case maybe a way where you can set the font to follow your GTK theme accent color

Darazaki commented 3 months ago

In that case I'd rather not implement that sorry. Adding this kind of functionality would bloat the settings panel and add a bit of code complexity for something that'd (imo) barely be used

However, if you want to implement this feature into your own fork and have some questions I'd be happy to help! I know this is not what you wanted but that way you could have the feature without adding complexity to the main codebase :)

The code that initializes the label you're looking for is here: https://github.com/Darazaki/Spedread/blob/7d4cb682176e5be185864009c36d79ec9715b299/src/SpedreadReadTab.vala#L79-L82

To change the text's color, you can add a Pango attribute to the label like so:

// Set the `_word` label's color to pure red
_word.attributes.insert (Pango.attr_foreground_new (
    /* red   = */ uint16.MAX,
    /* green = */ 0,
    /* blue  = */ 0
));

Keep in mind that colors in GTK are RGB with 16-bits per color and not 8 so instead of being in the range [0, 255] they're in [0, 65535]