From e825750526c094734840f5b36e89d6e9a45955da Mon Sep 17 00:00:00 2001 From: Tyler Bochard Date: Fri, 12 Apr 2024 17:04:00 -0400 Subject: [PATCH] fix: text mangling in capacitor builds (#4) This is targeted specifically for mobile devices running on Capacitor. Adding `Capacitor` manually to your UserAgent will enable this fix for you. --- src/js/jagex2/graphics/PixFont.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/jagex2/graphics/PixFont.ts b/src/js/jagex2/graphics/PixFont.ts index 78ee256a..1cdcfe5c 100644 --- a/src/js/jagex2/graphics/PixFont.ts +++ b/src/js/jagex2/graphics/PixFont.ts @@ -11,9 +11,17 @@ export default class PixFont extends Hashable { static readonly CHARCODESET: number[] = []; static { + const isCapacitor: boolean = navigator.userAgent.includes('Capacitor') + for (let i: number = 0; i < 256; i++) { let c: number = PixFont.CHARSET.indexOf(String.fromCharCode(i)); + // This fixes text mangling in Capacitor native builds (Android/IOS) + if (isCapacitor) + if (c >= 63) { // " + c-- + } + if (c === -1) { c = 74; // space }