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

Suggestion for much better text-stroke #16

Open
Johnnycyan opened this issue Jul 3, 2023 · 3 comments
Open

Suggestion for much better text-stroke #16

Johnnycyan opened this issue Jul 3, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers P-medium Medium priority v2 Not related to code in this repo (v3). See IS2511/ChatIS-v2

Comments

@Johnnycyan
Copy link

The webkit-text-stroke that is currently used is terrible as it puts the stroke inside of the text instead of outlining the text. This means it reduces readability especially on larger sizes. I propose you instead use a combination of drop-shadow and text-shadow filters which can replicate a text-stroke but is actually properly on the outside of the text. The drop-shadow filters go on the name to support 7tv name paints and the text-shadow filters go on the message to avoid emotes getting a stroke applied. The text-stroke has 4 more axis to properly cover the entire text.

The only downside to this method is you can only use whole number pixels and because there is essentially one on each side the size is twice the pixel value. So this means it can only replicate the stroke sizes of 2 and 4 in the current system. But this does theoretically allow as large of a stroke as you want since it isn't placed inside the text.

Here is an example css code using this method

:root {
    --message-stroke: 2px; /*The stroke size of the message which is always 2x the stroke size of the name. Size of 2px is equal to the current stroke=2. 4px is equal to stroke=4.*/
    --message-stroke-min: -2px; /*The negative stroke size of the message which is always 2x the stroke size of the name. Size of -2px is equal to the current stroke=2. -4px is equal to stroke=4.*/
    --name-stroke: 1px; /*The stroke size of the name which has to be half the size of the message stroke because of how drop-shadows are calculated. Size of 1px is equal to the current stroke=2. 2px is equal to stroke=4.*/
    --name-stroke-min: -1px; /*The negative stroke size of the name which has to be half the size of the message stroke because of how drop-shadows are calculated. Size of -1px is equal to the current stroke=2. -2px is equal to stroke=4.*/
}

.nick {
    filter: 
        drop-shadow(var(--name-stroke-min) var(--name-stroke-min) 0 #000)
        drop-shadow(var(--name-stroke) var(--name-stroke-min) 0 #000)
        drop-shadow(var(--name-stroke) var(--name-stroke) 0 #000)
        drop-shadow(var(--name-stroke-min) var(--name-stroke) 0 #000);
}

.message, .colon {
    text-shadow:
        var(--message-stroke-min) var(--message-stroke-min) 0 #000,
        0 var(--message-stroke-min) 0 #000,
        var(--message-stroke) var(--message-stroke-min) 0 #000,
        var(--message-stroke) 0 0 #000,
        var(--message-stroke) var(--message-stroke) 0 #000,
        0 var(--message-stroke) 0 #000,
        var(--message-stroke-min) var(--message-stroke) 0 #000,
        var(--message-stroke-min) 0 0 #000;
}

And here is an example image comparing the current stroke method with this shadow method:
chrome_imeIWOHvrr
chrome_aMntZ0f3t5

@IS2511 IS2511 added enhancement New feature or request good first issue Good for newcomers v2 Not related to code in this repo (v3). See IS2511/ChatIS-v2 labels Mar 14, 2024
@IS2511
Copy link
Owner

IS2511 commented Mar 14, 2024

Honestly forgot if I added this or not, probably didn't.

@IS2511
Copy link
Owner

IS2511 commented Nov 17, 2024

Yeah, forgot to close this. Currently the shadow setting uses filter: drop-shadow();. No text-shadow because I'm pretty sure it looks terrible or breaks something, like the 7tv namepaints. Either way, right now shadows look ok. If there is ever any improvement in CSS in this direction, don't hesitate to open another issue.

@IS2511 IS2511 closed this as completed Nov 17, 2024
@IS2511
Copy link
Owner

IS2511 commented Jan 27, 2025

Giant blunder. This is still not implemented for stroke. For some reason I was thinking of shadows... Reopened until I fix this.

Also, funny story:

Screenshot of a chat message with stroke overlapping into letters

Some fonts apparently have invalid edges (they go into the letters) and stroke goes right in there too. Wow, good one font authors, thanks. I guess doing stroke as shadow is the only way to fix that...

@IS2511 IS2511 reopened this Jan 27, 2025
@IS2511 IS2511 added the P-medium Medium priority label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers P-medium Medium priority v2 Not related to code in this repo (v3). See IS2511/ChatIS-v2
Projects
None yet
Development

No branches or pull requests

2 participants