From ff8d49e37df4010b9d3a57a414123936c244643e Mon Sep 17 00:00:00 2001 From: Koen Lagveen Date: Tue, 4 Jul 2023 22:24:24 +0200 Subject: [PATCH] fix #21 change sizes when selecting bitmaps --- index.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 74bc324..d92ff89 100644 --- a/index.js +++ b/index.js @@ -48,6 +48,9 @@ const selectFont = () => { if (typeof fontData !== 'undefined' && fontData[font].rendering === 'bitmap') { codeMirror.classList.add('no-smooth') + if (fontData[font]['bitmap size']) { + setSize(fontData[font]['bitmap size']) + } } else { codeMirror.classList.remove('no-smooth') } @@ -74,13 +77,11 @@ const selectFont = () => { document.cookie = `font=${font};max-age=172800` } -window.onhashchange = () => { - plausible('Font Selected') - selectFont() -} - -function setSize () { - const size = document.getElementById('size').value +function setSize (px) { + let size = document.getElementById('size').value + if (px) { + size = px + } document.querySelector('.CodeMirror').style.fontSize = `${size}px` document.cookie = `size=${size};max-age=172800` @@ -330,6 +331,11 @@ function toggleFilter (filter) { applyFilters() } +window.onhashchange = () => { + plausible('Font Selected') + selectFont() +} + window.addEventListener('DOMContentLoaded', () => { const cookieValueSpacing = document.cookie.replace(/(?:(?:^|.*;\s*)spacing\s*=\s*([^;]*).*$)|^.*$/, '$1') const cookieValueSize = document.cookie.replace(/(?:(?:^|.*;\s*)size\s*=\s*([^;]*).*$)|^.*$/, '$1')