fix #21 change sizes when selecting bitmaps

This commit is contained in:
Koen Lagveen 2023-07-04 22:24:24 +02:00
parent 0653fdc615
commit ff8d49e37d
1 changed files with 13 additions and 7 deletions

View File

@ -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')