question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Html5 Canvas Web Font Alignment is off

See original GitHub issue

Description

Web Font in Html5 Canvas Alignment (of games developed using Phaser Js library) is off only in Brave (Mac Desktop v. 1.23.71) while there is not any problem in Chrome, Firefox and Safari. Is this a known problem?

Steps to Reproduce

The html5 canvas game showing the problem can be found at https://game.cuckooparrot.com/bonus-jackpot/

Actual result:

Brave Version 1.23.71 (Mac desktop)

Brave Version 1 23 71

Expected result:

Chrome Version 89.0.4389.128 (Mac desktop)

Chrome Version 89 0 4389 128

Safari Version 14.0.3 (Mac desktop)

Safari Version 14 0 3

Firefox 85.0 (Mac desktop)

Firefox 85 0

Reproduces how often:

Always.

Brave version (brave://version info)

Brave Version 1.23.71 Stable (Mac desktop)
Brave	1.23.71 Chromium: 90.0.4430.72 (Official Build) (x86_64)
Revision	b6172ef8d07ef486489a4b11b66b2eaeed50d132-refs/branch-heads/4430@{#1233}
OS	macOS Version 11.2.3 (Build 20D91)
JavaScript	V8 9.0.257.17
User Agent	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36
Command Line	/Applications/Brave Browser.app/Contents/MacOS/Brave Browser --enable-dom-distiller --disable-domain-reliability --no-pings --extension-content-verification=enforce_strict --extensions-install-verification=enforce --origin-trial-public-key=bYUKPJoPnCxeNvu72j4EmPuK7tr1PAC7SHh8ld9Mw3E=,fMS4mpO6buLQ/QMd+zJmxzty/VQ6B1EUZqoCU04zoRU= --sync-url=https://sync-v2.brave.com/v2 --lso-url=https://no-thanks.invalid --variations-server-url=https://variations.brave.com/seed --enable-features=PrefetchPrivacyChanges,SafetyTip,AutoupgradeMixedContent,WebUIDarkMode,PasswordImport,ReducedReferrerGranularity,LegacyTLSEnforced --disable-features=AutofillServerCommunication,TextFragmentAnchor,AutofillEnableAccountWalletStorage,IdleDetection,SafeBrowsingEnhancedProtectionMessageInInterstitials,TabHoverCards,DirectSockets,SharingQRCodeGenerator,NetworkTimeServiceQuerying,LangClientHintHeader,NotificationTriggers,WebOTP,SignedExchangeSubresourcePrefetch,SafeBrowsingEnhancedProtection,SubresourceWebBundles,SignedExchangePrefetchCacheForNavigations,BraveDomainBlock --flag-switches-begin --flag-switches-end
Executable Path	/Applications/Brave Browser.app/Contents/MacOS/Brave Browser
Profile Path	/Users/shu/Library/Application Support/BraveSoftware/Brave-Browser/Default
Variations	7146a73c-3f4a17df

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
shumiyaocommented, Apr 16, 2021

I could find a Phaser Js forum thread referring to privacy.resistFingerprinting

According to Telinc1 in the thread:

This is a shot in the dark, but it might be worth investigating. I’ve seen browsers, often Brave, but maybe also Firefox (with privacy.resistFingerprinting enabled?) that intentionally break font rendering due to privacy concerns. If this guess is correct, I don’t think there’s anything you can do about it short of changing the browser settings.

0reactions
shumiyaocommented, Apr 16, 2021

Thank you everyone here.

Will post a link to this thread in the forum thread to let people know about this issue.

Maybe developers can add a prompt in those html5 game pages telling Brave users to disable the protection or,

In the thread samme suggests a workaround for PhaserJs (using the Text Metrics).

I have tried the sample and I see that the workaround resolves the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Center (proportional font) text in an HTML5 canvas
For centering horizontally we use ctx.textBaseline = 'middle'; ctx.textAlign = 'center'; . But to center vertically we need to use ctx.
Read more >
CanvasRenderingContext2D.textAlign - Web APIs | MDN
The CanvasRenderingContext2D.textAlign property of the Canvas 2D API specifies the current text alignment used when drawing text.
Read more >
Cross-Browser Alignment Of The Canvas FillText Draw Call
We can solve this issue by drawing an “F” character to a canvas element and then looking for the first horizontal pixel and...
Read more >
HTML canvas textAlign Property - W3Schools
The textAlign property sets or returns the current alignment for text content, according to the anchor point. Normally, the text will START in...
Read more >
Chapter 3. The HTML5 Canvas Text API - O'Reilly
These alignments affect the text in relation to Canvas itself, but only to the invisible bounding box that would surround the text's topmost,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found