Skip to content

Commit de9fa77

Browse files
committed
Fix gradients misaligning text when using a custom font
1 parent 43b6a3c commit de9fa77

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

lua/custom_chat/client/block_types.lua

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,10 @@ end
284284
function Create.Gradient( text, font, colorA, colorB, elementName )
285285
elementName = elementName or "elGradient"
286286

287-
-- Gradient container
287+
-- Gradient container/glow
288288
local lines = { Create.Element( "span", elementName ) }
289289
Append( lines, "%s.className = 'gradient-container';", elementName )
290-
291-
-- Gradient background/glow
292-
Append( lines, Create.Element( "span", "elGradientGlow", elementName ) )
293-
Append( lines, "elGradientGlow.className = 'gradient-bg';" )
294-
Append( lines, "elGradientGlow.textContent = '%s';", text )
290+
Append( lines, "%s.textContent = '%s';", elementName, text )
295291

296292
-- Use the combined colors for the glow effect
297293
local h, s, l = ColorToHSL( Color(
@@ -302,8 +298,8 @@ function Create.Gradient( text, font, colorA, colorB, elementName )
302298

303299
local colorGlow = ColorToRGB( HSLToColor( h, s, l * 0.5 ) )
304300

305-
Append( lines, "elGradientGlow.style.color = '%s';", colorGlow )
306-
Append( lines, "elGradientGlow.style.textShadow = '0px 0px 0.2em %s';", colorGlow )
301+
Append( lines, "%s.style.color = '%s';", elementName, colorGlow )
302+
Append( lines, "%s.style.textShadow = '0px 0px 0.2em %s';", elementName, colorGlow )
307303

308304
-- Gradient foreground/text
309305
Append( lines, Create.Element( "span", "elGradientText", elementName ) )
@@ -312,7 +308,7 @@ function Create.Gradient( text, font, colorA, colorB, elementName )
312308
Append( lines, "elGradientText.style.backgroundImage = '-webkit-linear-gradient(left, %s, %s)';", ColorToRGB( colorA ), ColorToRGB( colorB ) )
313309

314310
if IsStringValid( font ) then
315-
Append( lines, "elGradientGlow.style.fontFamily = '%s';", font )
311+
Append( lines, "%s.style.fontFamily = '%s';", elementName, font )
316312
Append( lines, "elGradientText.style.fontFamily = '%s';", font )
317313
end
318314

lua/custom_chat/client/vgui/chat_history.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,6 @@ img {
345345
346346
.gradient-container {
347347
position: relative;
348-
}
349-
350-
.gradient-bg {
351348
color: blue;
352349
text-shadow: 0px 0px 0.15em blue;
353350
}

0 commit comments

Comments
 (0)