Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div>
- <script>
- window.fontTesterOptions = {
- characters: 'aimepytgdobh',
- initial: `
- imbody
- empathy
- `,
- };
- </script>
- <style>
- .font-tester-container {
- --colour-text: black;
- --colour-background: rgba(0, 0, 0, .02);
- --font-name: "wonky";
- }
- @font-face {
- font-family: "wonky";
- /* Add other properties here, as needed. For example: */
- /*
- font-weight: 100 900;
- font-style: normal italic;
- */
- src: url(data:application/font-woff;base64,/*truncated for ur convenience xdd*/);
- }
- #font-tester {
- line-height: 2em;
- text-align: center;
- font-family: var(--font-name);
- font-size: 5rem;
- border: 0;
- background: var(--colour-background);
- color: var(--colour-text);
- box-sizing: border-box;
- padding: 5rem;
- transition: none !important;
- }
- .font-tester-container {
- width: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- </style>
- <div class="font-tester-container">
- <textarea id="font-tester"></textarea>
- </div>
- <script>
- (() => {
- const fontTesterElem = document.getElementById('font-tester');
- const charactersRegex = new RegExp(
- // escaped characters + space + newline
- `[${window.fontTesterOptions.characters.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\n ]`
- );
- fontTesterElem.textContent = window
- .fontTesterOptions
- .initial
- .trim()
- .replace(/ {4}|\t/g, '');
- fontTesterElem.addEventListener(
- 'keypress',
- (event) => charactersRegex.test(event.key) || event.preventDefault(),
- );
- new IntersectionObserver(
- (entry) => {
- if (!entry[0].isIntersecting) return;
- fontTesterElem.focus();
- // move cursor to end
- fontTesterElem.selectionEnd = fontTesterElem.selectionStart = fontTesterElem.textContent.length;
- },
- { threshold: 0.5 },
- )
- .observe(fontTesterElem);
- })();
- </script>
- </div>
Add Comment
Please, Sign In to add comment