Realistic Jersey Previews with Canvas and Fabric Shading

ملخص

Pixel’s announcement explores a jersey personalization system that makes names and numbers look printed on the fabric, using club fonts, perspective warping, and shirt-photo shading. It covers three fixes: quoting multi-word font names, preserving weave texture, and preventing ink shading from becoming too dark. The tool supports 285 live jerseys across 83 kit styles.

DEV Community

I made a jersey's name and number look printed, not pasted. Three things broke.

Most name-and-number personalizers drop flat text on top of a photo. Shoppers can tell. The jersey store I build for wanted the opposite: a preview that looks like the real printed shirt, in each club's own lettering. It now runs on 285 live jerseys across 83 kit styles, from one canvas script inside the theme. No app, no per-order fee. How it works The back photo of the shirt goes onto a canvas. The name and number are drawn in the club's font, warped through a mesh for perspective and curve (48 columns minimum, about 3 px wide on larger prints), then shaded with the photo itself. The finished image is attached to the order, so production prints what the shopper saw. Three things broke on the way. 1. The font that rendered at 10px The name appeared, but tiny. When ctx.font gets a family it can't parse, it doesn't throw. The context just keeps its previous font and moves on. The culprit was a font family called "Madrid 2627 Reference Traced". An unquoted, multi-word family is only valid if every word is a legal bare CSS identifier, and "2627" isn't. The fix was boring: quote every family name before it goes into the shorthand. 2. The print that looked like a sticker I shaded the print with a grayscale copy of the shirt photo, multiplied into the ink. On light shirts, which get dark ink, it still looked flat. Multiply can only darken, so any fabric texture baked into that layer vanished in dark ink. Two changes fixed it. The weave became its own layer, the difference between a sharp and a blurred copy, screened on top. And the shading got a floor, so a white print on a dark shirt can't be crushed to nothing: // simplified from the real code
sctx.filter = 'grayscale(1)';
sctx.drawImage(image, 0, 0, w, h); // sharp copy
sctx.globalCompositeOperation = 'difference';
sctx.drawImage(blurredGray, 0, 0); // |sharp - blurred| = weave detail

ctx.globalCompositeOperation = 'lighten';
ctx.fillStyle = '#5c5c5c'; // floor for the multiply layer
ctx.fillRect(0, 0, w, h);
3. document.fonts.check() tells you nothing Every club has its own fonts, and a wrong-looking font on a club shirt is worse than no print. So the rule is hard: exact font or no print. The catch is that document.fonts.load() and .check() both succeed for a family that was never declared, because the browser would just use a system font. So the gate looks for the family's own face in document.fonts with status loaded. If it isn't there, the preview shows a message instead of printing in a fallback. Clubs are data, not code Each club is a Shopify metaobject (fonts, crest-in-digit style, print layout). A product points to its club with one metafield. Adding a club means a new entry, not a theme change. There are over 160 club looks in the store, including the 2026 World Cup national teams. If you've warped text onto fabric, or any curved surface, on canvas, I'd like to know what you used. A 48-column mesh worked for me, but I'm not sure it's the best answer. I build custom Shopify product-page features like this. More at fahadazhar.site.
Realistic Jersey Previews with Canvas and Fabric Shading
Powered by Readybot.io

الأحدث من Pixel

Incident Response: Look Beyond the Red Alert

Pixel’s DEV Community announcement explores how teams can fixate on one failing service while overlooking the real cause of an outage, such as a full …

Sach: AI Fact-Checks WhatsApp Forwards in India

Pixel’s announcement introduces Sach, a tool that checks forwarded messages in English, Hindi, Telugu, and 14 other Indian languages against official sources. It gives cited …

Java 25 Removes SecurityManager: What to Fix

Pixel’s announcement explains how Java 24’s JEP 486 permanently disabled the SecurityManager, breaking test workarounds that intercept System.exit. It recommends returning exit codes or throwing …

Why a Java HPA Got Stuck at 20 Kubernetes Pods

Pixel shares how a Spring Boot pricing service autoscaled to 20 Kubernetes pods and stayed there because the JVM retained committed heap memory after traffic …