Bots Home
|
Create an App
Monospace Character Example
Author:
batorboy4vw
Description
Source Code
Launch Bot
Current Users
Created by:
Batorboy4vw
/* * Transpose the letters and numbers into characters from the Monospace * Mathematical set of characters (0x1D400 - 0x1D7FF). There are full-width * monospaced characters in the 0xFF00-0xFFEF block, but those do not look * very nice. Even though the monospace math set does not include any * punctuation, they end up looking much better (in my opinion). */ const zero = 48 //'0'.charCodeAt(0) const nine = 57 //'9'.charCodeAt(0) const A = 65 //'A'.charCodeAt(0) const Z = 90 //'Z'.charCodeAt(0) const a = 97 //'a'.charCodeAt(0) const z = 122 //'z'.charCodeAt(0) // Starting offsets for the Monospace Mathematical characters 0x1D400 - 0x1D7FF const MONO_A = 120432; // Start of uppercase A-Z const MONO_a = 120458; // Start of lowercase a-z const MONO_0 = 120802; // Start of digits 0-9 const space = '\u{2007}' // non-breaking "figure space" (the width of the digits 0-9) const tab = space.repeat(4) function transpose(code) { if (zero <= code && code <= nine) { return String.fromCodePoint(MONO_0 + code - zero) } if (A <= code && code <= Z) { return String.fromCodePoint(MONO_A + code - A) } if (a <= code && code <= z) { return String.fromCodePoint(MONO_a + code - a) } // Return space characters with non-breaking spaces if (code === 32) return space // Return anything else we don't recognize as is. return String.fromCodePoint(code) } function monospace(s) { let result = '' for (let i = 0; i < s.length; ++i) { result += transpose(s.charCodeAt(i)) } return result } let convert = false cb.onMessage(function(message) { let msg = message['m'] if (msg == '/on') { message['X-Spam'] = true convert = true cb.sendNotice(monospace('Monospaced font enabled.')) return message } if (msg == '/off') { message['X-Spam'] = true convert = false cb.sendNotice('Monospace font disabled.') return message } if (convert) { message.m = monospace(message.m) } return message })
© Copyright Chaturbate 2011- 2024. All Rights Reserved.