Skip to content

Commit

Permalink
fix: text mangling in capacitor builds (#4)
Browse files Browse the repository at this point in the history
This is targeted specifically for mobile devices running on Capacitor.
Adding `Capacitor` manually to your UserAgent will enable this fix for you.
  • Loading branch information
zeruth authored Apr 12, 2024
1 parent 622c118 commit e825750
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/js/jagex2/graphics/PixFont.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e825750

Please sign in to comment.