Skip to content

Commit

Permalink
Display virtual keyboard without ZWNJ on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
abcboy101 committed Sep 16, 2023
1 parent 7e7a1a4 commit 1045124
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
This is a tool that allows you to preview how Hindi and Thai text will appear in <i>Pokémon GO</i>.
While your phone, computer, and web browser most likely support the complex text layout needed to display Brahmic scripts like Devanagari and Thai correctly, _Pokémon GO_ does not.
Instead, the game uses modified fonts and encodings that allow the game's text engine to display the correct forms of characters.

<!--
To convert your text into the format used by <i>Pokémon GO</i>, tap the "Encode" button.
To convert text from <i>Pokémon GO</i> into a readable format, tap the "Decode" button.

-->

## Fonts used in _Pokémon GO_
_Pokémon GO_ uses the following fonts:
Expand Down Expand Up @@ -34,4 +34,3 @@ This app also uses two additional fonts:
- [Nopua](preview/fonts/Topua-Regular.ttf), which has the Private Use Area mapped to Lato's _uni0000_ glyph

As modified versions of Lato, they are also licensed under the SIL Open Font License, Version 1.1.

9 changes: 8 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,12 @@ function decodeText(value) {
}
*/

const IS_APPLE = window.navigator.userAgent.match(/iPhone|iPad|iPod/i);
const IS_ANDROID = window.navigator.userAgent.match(/Android/i);

// https://github.com/jhildenbiddle/canvas-size#test-results
const MAX_CANVAS_DIM = 32767;
const MAX_CANVAS_AREA = window.navigator.userAgent.match(/iPhone|iPad|iPod/i) ? 4096 * 4096 : window.navigator.userAgent.match(/Android/i) ? 8192 * 8192 : 16384 * 16384;
const MAX_CANVAS_AREA = IS_APPLE ? 4096 * 4096 : IS_ANDROID ? 8192 * 8192 : 16384 * 16384;

window.addEventListener('DOMContentLoaded', () => {
const main = document.getElementById('main');
Expand Down Expand Up @@ -623,6 +626,10 @@ window.addEventListener('DOMContentLoaded', () => {
textCurrent.focus();
textCurrent.selectionStart = textCurrent.selectionEnd = newPos;
});
console.log(element.innerHTML);
if (IS_APPLE && element.innerHTML.includes('\u200C')) {
element.innerHTML = element.innerHTML.replaceAll('\u200C', '');
}
})

const savedMode = localStorage.getItem('mode') ?? 'system';
Expand Down

0 comments on commit 1045124

Please sign in to comment.