From 7de3f421832a788d6f6dc5b82b21ffcf577d475e Mon Sep 17 00:00:00 2001 From: Marco Omainska Date: Wed, 3 May 2023 22:06:38 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E2=9C=A8=20adobe=20webfonts,=20other=20web?= =?UTF-8?q?fonts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jitai.user.js | 193 ++++++++++++++++++++++++++++-------------- fonts/ArmedBanana.css | 7 -- fonts/Darts.css | 7 -- fonts/FCFlower.css | 7 -- fonts/HosoFuwa.css | 7 -- fonts/NagayamaKai.css | 7 -- fonts/PopRumCute.css | 7 -- fonts/SanChouMe.css | 7 -- 8 files changed, 129 insertions(+), 113 deletions(-) delete mode 100644 fonts/ArmedBanana.css delete mode 100644 fonts/Darts.css delete mode 100644 fonts/FCFlower.css delete mode 100644 fonts/HosoFuwa.css delete mode 100644 fonts/NagayamaKai.css delete mode 100644 fonts/PopRumCute.css delete mode 100644 fonts/SanChouMe.css diff --git a/Jitai.user.js b/Jitai.user.js index 5dff781..a7091bd 100644 --- a/Jitai.user.js +++ b/Jitai.user.js @@ -3,7 +3,7 @@ // @author @marciska // @namespace marciska // @description Displays your WaniKani reviews with randomized fonts (based on original by @obskyr) -// @version 3.1.1 +// @version 3.2 // @icon https://raw.github.com/marciska/Jitai/master/imgs/jitai.ico // @match https://*.wanikani.com/subjects/review* // @match https://*.wanikani.com/subjects/extra_study* @@ -35,54 +35,65 @@ // available fonts let font_pool = { // Default OSX fonts - "Hiragino-Kaku-Gothic-Pro" : {full_font_name: "Hiragino Kaku Gothic Pro, ヒラギノ角ゴ Pro W3", display_name: "Hiragino Kaku Gothic Pro", url: 'local', recommended: false}, - "Hiragino-Maru-Gothic-Pro" : {full_font_name: "Hiragino Maru Gothic Pro, ヒラギノ丸ゴ Pro W3", display_name: "Hiragino Maru Gothic Pro", url: 'local', recommended: false}, - "Hiragino-Mincho-Pro" : {full_font_name: "Hiragino Mincho Pro, ヒラギノ明朝 Pro W3", display_name: "Hiragino Mincho Pro", url: 'local', recommended: false}, + "Hiragino-Kaku-Gothic-Pro" : {full_font_name: "Hiragino Kaku Gothic Pro, ヒラギノ角ゴ Pro W3", display_name: "Hiragino Kaku Gothic Pro", url: 'local', download: '', recommended: false}, + "Hiragino-Maru-Gothic-Pro" : {full_font_name: "Hiragino Maru Gothic Pro, ヒラギノ丸ゴ Pro W3", display_name: "Hiragino Maru Gothic Pro", url: 'local', download: '', recommended: false}, + "Hiragino-Mincho-Pro" : {full_font_name: "Hiragino Mincho Pro, ヒラギノ明朝 Pro W3", display_name: "Hiragino Mincho Pro", url: 'local', download: '', recommended: false}, // Default Windows fonts - "Meiryo" : {full_font_name: "Meiryo, メイリオ", display_name: "Meiryo", url: 'local', recommended: false}, - "MS-PGothic" : {full_font_name: "MS PGothic, MS Pゴシック, MS Gothic, MS ゴック", display_name: "MS Gothic", url: 'local', recommended: false}, - "MS-PMincho" : {full_font_name: "MS PMincho, MS P明朝, MS Mincho, MS 明朝", display_name: "MS Mincho", url: 'local', recommended: false}, - "Yu-Gothic" : {full_font_name: "Yu Gothic, YuGothic", display_name: "Yu Gothic", url: 'local', recommended: false}, - "Yu-Mincho" : {full_font_name: "Yu Mincho, YuMincho", display_name: "Yu Mincho", url: 'local', recommended: false}, + "Meiryo" : {full_font_name: "Meiryo, メイリオ", display_name: "Meiryo", url: 'local', download: '', recommended: false}, + "MS-PGothic" : {full_font_name: "MS PGothic, MS Pゴシック, MS Gothic, MS ゴック", display_name: "MS Gothic", url: 'local', download: '', recommended: false}, + "MS-PMincho" : {full_font_name: "MS PMincho, MS P明朝, MS Mincho, MS 明朝", display_name: "MS Mincho", url: 'local', download: '', recommended: false}, + "Yu-Gothic" : {full_font_name: "Yu Gothic, YuGothic", display_name: "Yu Gothic", url: 'local', download: '', recommended: false}, + "Yu-Mincho" : {full_font_name: "Yu Mincho, YuMincho", display_name: "Yu Mincho", url: 'local', download: '', recommended: false}, // GoogleFonts - "Zen-Kurenaido" : {full_font_name: "Zen Kurenaido", display_name: "Zen Kurenaido", url: 'https://fonts.googleapis.com/css?family=Zen+Kurenaido&subset=japanese', recommended: false}, - "Kaisei-Opti" : {full_font_name: "Kaisei Opti", display_name: "Kaisei Opti", url: 'https://fonts.googleapis.com/css?family=Kaisei+Opti&subset=japanese', recommended: false}, - "Reggae-One" : {full_font_name: "Reggae One", display_name: "Reggae One", url: 'https://fonts.googleapis.com/css?family=Reggae+One&subset=japanese', recommended: false}, - "New-Tegomin" : {full_font_name: "New Tegomin", display_name: "New Tegomin", url: 'https://fonts.googleapis.com/css?family=New+Tegomin&subset=japanese', recommended: false}, - "Yuji-Boku" : {full_font_name: "Yuji Boku", display_name: "Yuji Boku", url: 'https://fonts.googleapis.com/css?family=Yuji+Boku&subset=japanese', recommended: false}, - "Yuji-Mai" : {full_font_name: "Yuji Mai", display_name: "Yuji Mai", url: 'https://fonts.googleapis.com/css?family=Yuji+Mai&subset=japanese', recommended: false}, - "Yuji-Syuku" : {full_font_name: "Yuji Syuku", display_name: "Yuji Syuku", url: 'https://fonts.googleapis.com/css?family=Yuji+Syuku&subset=japanese', recommended: false}, - "DotGothic16" : {full_font_name: "DotGothic16", display_name: "DotGothic16", url: 'https://fonts.googleapis.com/css?family=DotGothic16&subset=japanese', recommended: true}, - "Hachi-Maru-Pop" : {full_font_name: "Hachi Maru Pop", display_name: "Hachi Maru Pop", url: 'https://fonts.googleapis.com/css?family=Hachi+Maru+Pop&subset=japanese', recommended: true}, - "Yomogi" : {full_font_name: "Yomogi", display_name: "Yomogi", url: 'https://fonts.googleapis.com/css?family=Yomogi&subset=japanese', recommended: false}, - "Potta-One" : {full_font_name: "Potta One", display_name: "Potta One", url: 'https://fonts.googleapis.com/css?family=Potta+One&subset=japanese', recommended: false}, - "Dela-Gothic-One" : {full_font_name: "Dela Gothic One", display_name: "Dela Gothic One", url: 'https://fonts.googleapis.com/css?family=Dela+Gothic+One&subset=japanese', recommended: true}, - "RocknRoll-One" : {full_font_name: "RocknRoll One", display_name: "RocknRoll One", url: 'https://fonts.googleapis.com/css?family=RocknRoll+One&subset=japanese', recommended: false}, - "Stick" : {full_font_name: "Stick", display_name: "Stick", url: 'https://fonts.googleapis.com/css?family=Stick&subset=japanese', recommended: true}, - "Yusei-Magic" : {full_font_name: "Yusei Magic", display_name: "Yusei Magic", url: 'https://fonts.googleapis.com/css?family=Yusei+Magic&subset=japanese', recommended: false}, - "Kaisei-Decol" : {full_font_name: "Kaisei Decol", display_name: "Kaisei Decol", url: 'https://fonts.googleapis.com/css?family=Kaisei+Decol&subset=japanese', recommended: false}, - "Kaisei-Tokumin" : {full_font_name: "Kaisei Tokumin", display_name: "Kaisei Tokumin", url: 'https://fonts.googleapis.com/css?family=Kaisei+Tokumin&subset=japanese', recommended: false}, + "Zen-Kurenaido" : {full_font_name: "Zen Kurenaido", display_name: "Zen Kurenaido", url: 'https://fonts.googleapis.com/css?family=Zen+Kurenaido&subset=japanese', download: 'https://fonts.google.com/specimen/Zen+Kurenaido', recommended: false}, + "Kaisei-Opti" : {full_font_name: "Kaisei Opti", display_name: "Kaisei Opti", url: 'https://fonts.googleapis.com/css?family=Kaisei+Opti&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Opti', recommended: false}, + "Reggae-One" : {full_font_name: "Reggae One", display_name: "Reggae One", url: 'https://fonts.googleapis.com/css?family=Reggae+One&subset=japanese', download: 'https://fonts.google.com/specimen/Reggae+One', recommended: false}, + "New-Tegomin" : {full_font_name: "New Tegomin", display_name: "New Tegomin", url: 'https://fonts.googleapis.com/css?family=New+Tegomin&subset=japanese', download: 'https://fonts.google.com/specimen/New+Tegomin', recommended: false}, + "Yuji-Boku" : {full_font_name: "Yuji Boku", display_name: "Yuji Boku", url: 'https://fonts.googleapis.com/css?family=Yuji+Boku&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Boku', recommended: false}, + "Yuji-Mai" : {full_font_name: "Yuji Mai", display_name: "Yuji Mai", url: 'https://fonts.googleapis.com/css?family=Yuji+Mai&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Mai', recommended: false}, + "Yuji-Syuku" : {full_font_name: "Yuji Syuku", display_name: "Yuji Syuku", url: 'https://fonts.googleapis.com/css?family=Yuji+Syuku&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Syuku', recommended: false}, + "DotGothic16" : {full_font_name: "DotGothic16", display_name: "DotGothic16", url: 'https://fonts.googleapis.com/css?family=DotGothic16&subset=japanese', download: 'https://fonts.google.com/specimen/DotGothic16', recommended: true}, + "Hachi-Maru-Pop" : {full_font_name: "Hachi Maru Pop", display_name: "Hachi Maru Pop", url: 'https://fonts.googleapis.com/css?family=Hachi+Maru+Pop&subset=japanese', download: 'https://fonts.google.com/specimen/Hachi+Maru+Pop', recommended: true}, + "Yomogi" : {full_font_name: "Yomogi", display_name: "Yomogi", url: 'https://fonts.googleapis.com/css?family=Yomogi&subset=japanese', download: 'https://fonts.google.com/specimen/Yomogi', recommended: false}, + "Potta-One" : {full_font_name: "Potta One", display_name: "Potta One", url: 'https://fonts.googleapis.com/css?family=Potta+One&subset=japanese', download: 'https://fonts.google.com/specimen/Potta+One', recommended: false}, + "Dela-Gothic-One" : {full_font_name: "Dela Gothic One", display_name: "Dela Gothic One", url: 'https://fonts.googleapis.com/css?family=Dela+Gothic+One&subset=japanese', download: 'https://fonts.google.com/specimen/Dela+Gothic+One', recommended: true}, + "RocknRoll-One" : {full_font_name: "RocknRoll One", display_name: "RocknRoll One", url: 'https://fonts.googleapis.com/css?family=RocknRoll+One&subset=japanese', download: 'https://fonts.google.com/specimen/RocknRoll+One', recommended: false}, + "Stick" : {full_font_name: "Stick", display_name: "Stick", url: 'https://fonts.googleapis.com/css?family=Stick&subset=japanese', download: 'https://fonts.google.com/specimen/Stick', recommended: true}, + "Yusei-Magic" : {full_font_name: "Yusei Magic", display_name: "Yusei Magic", url: 'https://fonts.googleapis.com/css?family=Yusei+Magic&subset=japanese', download: 'https://fonts.google.com/specimen/Yusei+MagicYusei+Magic', recommended: false}, + "Kaisei-Decol" : {full_font_name: "Kaisei Decol", display_name: "Kaisei Decol", url: 'https://fonts.googleapis.com/css?family=Kaisei+Decol&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Decol', recommended: false}, + "Kaisei-Tokumin" : {full_font_name: "Kaisei Tokumin", display_name: "Kaisei Tokumin", url: 'https://fonts.googleapis.com/css?family=Kaisei+Tokumin&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Tokumin', recommended: false}, + // AdobeFonts + "AB-Andante" : {full_font_name: "ab-andante", display_name: "AB Andante", url: 'adobe', download: 'http://www.font1000.com', recommended: false}, + "AB-Appare" : {full_font_name: "ab-appare", display_name: "AB Appare", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false}, + "AB-Karuta-El" : {full_font_name: "ab-karuta-el", display_name: "AB Karuta El", url: 'adobe', download: 'http://www.font1000.com', recommended: false}, + "AB-Kikori" : {full_font_name: "ab-kikori", display_name: "AB Kikori", url: 'adobe', download: 'http://www.font1000.com', recommended: false}, + "AB-Kouran-Gyosho" : {full_font_name: "ab-kouran-gyosho", display_name: "AB Kouran Gyosho", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false}, + "AB-Shinyubipenjigyosyotai" : {full_font_name: "ab-shinyubipenjigyosyotai", display_name: "AB Shinyubipenjigyosyotai", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false}, + "Hakusyu-Sosho" : {full_font_name: "hot-soshokk, HakusyuSosho", display_name: "Hakusyu Sosho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: true}, + "Hakusyu-Tensho" : {full_font_name: "hot-tenshokk, HakusyuTensho", display_name: "Hakusyu Tensho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: false}, // Other popular fonts - "ArmedBanana" : {full_font_name: "ArmedBanana", display_name: "Armed Banana", url: 'https://marciska.github.io/Jitai/ArmedBanana.css', recommended: true}, - "ArmedLemon" : {full_font_name: "ArmedLemon", display_name: "Armed Lemon", url: 'local', recommended: false}, - "AoyagiReisyosimo-AoyagiKouzan" : {full_font_name: "aoyagireisyosimo2, AoyagiKouzanFont2OTF", display_name: "Aoyagi Kouzan", url: 'local', recommended: false}, - "Aquafont" : {full_font_name: "aquafont", display_name: "Aquafont", url: 'local', recommended: false}, - "Shin-Maru-Go-Pro" : {full_font_name: "A-OTF Shin Maru Go Pro", display_name: "Shin Maru Go Pro", url: 'local', recommended: false}, - "Chifont" : {full_font_name: "'chifont+', chifont", display_name: "Chifont", url: 'local', recommended: false}, - "Cinecaption" : {full_font_name: "cinecaption", display_name: "Cinecaption", url: 'local', recommended: false}, - "Darts" : {full_font_name: "darts font", display_name: "Darts", url: 'https://marciska.github.io/Jitai/Darts.css', recommended: false}, - "EPSON-行書体M" : {full_font_name: "EPSON 行書体M", display_name: "EPSON 行書体M", url: 'local', recommended: false}, - "EPSON-正楷書体M" : {full_font_name: "EPSON 正楷書体M", display_name: "EPSON 正楷書体M", url: 'local', recommended: false}, - "EPSON-教科書体M" : {full_font_name: "EPSON 教科書体M", display_name: "EPSON 教科書体M", url: 'local', recommended: false}, - "EPSON-太明朝体B" : {full_font_name: "EPSON 太明朝体B", display_name: "EPSON 太明朝体B", url: 'local', recommended: false}, - "EPSON-太行書体B" : {full_font_name: "EPSON 太行書体B", display_name: "EPSON 太行書体B", url: 'local', recommended: false}, - "EPSON-丸ゴシック体M" : {full_font_name: "EPSON 丸ゴシック体M", display_name: "EPSON 丸ゴシック体M", url: 'local', recommended: false}, - "FC-Flower" : {full_font_name: "FC-Flower", display_name: "FC-Flower", url: 'https://marciska.github.io/Jitai/FCFlower.css', recommended: false}, - "HakusyuKaisyoExtraBold_kk" : {full_font_name: "HakusyuKaisyoExtraBold_kk", display_name: "Hakusyu Kaisyo (Extra Bold)", url: 'local', recommended: false}, - "Hosofuwafont" : {full_font_name: "Hosofuwafont", display_name: "Hoso Fuwa", url: 'https://marciska.github.io/Jitai/HosoFuwa.css', recommended: false}, - "Nagayama-Kai" : {full_font_name: "nagayama_kai", display_name: "Nagayama Kai", url: 'https://marciska.github.io/Jitai/NagayamaKai.css', recommended: false}, - "Pop-Rum-Cute" : {full_font_name: "PopRumCute", display_name: "Pop Rum Cute", url: 'https://marciska.github.io/Jitai/PopRumCute.css', recommended: false}, - "San-Chou-Me" : {full_font_name: "santyoume-font", display_name: "San Chou Me", url: 'https://marciska.github.io/Jitai/SanChouMe.css', recommended: false}, + "ArmedBanana" : {full_font_name: "ArmedBanana", display_name: "Armed Banana", url: 'https://marciska.github.io/Jitai-Fonts/ArmedBanana.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: true}, + "ArmedLemon" : {full_font_name: "ArmedLemon", display_name: "Armed Lemon", url: 'https://marciska.github.io/Jitai-Fonts/ArmedLemon.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: false}, + "Aoyagi-Reisho" : {full_font_name: "Aoyagi Reisho, Aoyagi Reisyo, aoyagireisyo2, aoyagireisyosimo2", display_name: "Aoyagi Reisho", url: 'https://marciska.github.io/Jitai-Fonts/AoyagiReisyo.css', download: 'https://opentype.jp/aoyagireisho.htm', recommended: false}, + "Aoyagi-Gyousho" : {full_font_name: "KouzanBrushFontGyousyoOTF, AoyagiKouzanFont2OTF, Aoyagi Gyousyo, Aoyagi Gyousho", display_name: "Aoyagi Gyousho", url: 'https://marciska.github.io/Jitai-Fonts/AoyagiGyousyo.css', download: 'https://opentype.jp/kouzangyousho.htm', recommended: false}, + "Aquafont" : {full_font_name: "Aquafont, aquafont", display_name: "Aquafont", url: 'https://marciska.github.io/Jitai-Fonts/Aquafont.css', download: 'https://www.freejapanesefont.com/aqua-font/', recommended: false}, + "Chifont" : {full_font_name: "'chifont+', chifont, Nchifont, 'Nchifont+'", display_name: "Chifont", url: 'local', download: 'https://welina.xyz/font/tegaki/nchif/', recommended: false}, + "Chihaya-Gothic" : {full_font_name: "ChihayaGothic", display_name: "Chihaya Gothic", url: 'local', download: 'https://welina.xyz/font/tegaki/gothic/', recommended: false}, + "Cinecaption" : {full_font_name: "cinecaption", display_name: "Cinecaption", url: 'local', download: 'https://cooltext.com/Download-Font-しねきゃぷしょん+cinecaption', recommended: false}, + "Darts" : {full_font_name: "DartsFont, 'darts font'", display_name: "Darts Font", url: 'https://marciska.github.io/Jitai-Fonts/DartsFont.css', download: 'https://www.p-darts.jp/font/dartsfont/', recommended: false}, + "EPSON-行書体M" : {full_font_name: "EPSON 行書体M", display_name: "EPSON 行書体M", url: 'local', download: '', recommended: false}, + "EPSON-正楷書体M" : {full_font_name: "EPSON 正楷書体M", display_name: "EPSON 正楷書体M", url: 'local', download: '', recommended: false}, + "EPSON-教科書体M" : {full_font_name: "EPSON 教科書体M", display_name: "EPSON 教科書体M", url: 'local', download: '', recommended: false}, + "EPSON-太明朝体B" : {full_font_name: "EPSON 太明朝体B", display_name: "EPSON 太明朝体B", url: 'local', download: '', recommended: false}, + "EPSON-太行書体B" : {full_font_name: "EPSON 太行書体B", display_name: "EPSON 太行書体B", url: 'local', download: '', recommended: false}, + "EPSON-丸ゴシック体M" : {full_font_name: "EPSON 丸ゴシック体M", display_name: "EPSON 丸ゴシック体M", url: 'local', download: '', recommended: false}, + "FC-Flower" : {full_font_name: "FC-Flower", display_name: "FC-Flower (Experimental)", url: 'local', download: 'https://web.archive.org/web/20200718072012/http://fscolor.happy.nu/font/fl.html', recommended: false}, + "Hakusyu-Kaisho-Bold" : {full_font_name: "HakusyuKaisyoExtraBold_kk", display_name: "Hakusyu Kaisho Bold", url: 'local', download: 'https://www.hakusyu.com/download_education.htm', recommended: false}, + "Hoso-Fuwa" : {full_font_name: "Hosofuwafont", display_name: "Hoso Fuwa", url: 'https://marciska.github.io/Jitai-Fonts/HosoFuwa.css', download: 'https://huwahuwa.ff-design.net/ほそふわフォント/', recommended: false}, + "Nagayama-Kai" : {full_font_name: "Nagayama Kai, nagayama_kai", display_name: "Nagayama Kai", url: 'https://marciska.github.io/Jitai-Fonts/NagayamaKai.css', download: 'https://www.bokushin.org/en/nagayama-sensei-font/', recommended: false}, + "Pop-Rum-Cute" : {full_font_name: "PopRumCute", display_name: "Pop Rum Cute", url: 'https://marciska.github.io/Jitai-Fonts/PopRumCute.css', download: 'https://moji-waku.com/poprumcute/', recommended: false}, + "Ronde-B-Square" : {full_font_name: "Ronde B Square, Ronde-B, Ronde-B-Square", display_name: "Ronde B square", url: 'https://marciska.github.io/Jitai-Fonts/PopRumCute.css', download: 'https://moji-waku.com/poprumcute/', recommended: false}, + "San-Chou-Me" : {full_font_name: "San Chou Me, santyoume-font", display_name: "San Chou Me", url: 'https://marciska.github.io/Jitai-Fonts/SanChouMe.css', download: 'https://web.archive.org/web/20190330133455/http://www.geocities.jp/bokurano_yume/', recommended: false}, }; // fonts that are selected by user to be shown @@ -119,8 +130,8 @@ for (const [fontkey, value] of Object.entries(font_pool)) { if (!(fontkey in settings)) { continue; } if (!settings[fontkey]) { // check if font is disabled - // if it is a webfont, uninstall webfont - if (value.url !== 'local') { + // if it is a non-Adobe webfont, uninstall webfont + if (value.url !== 'local' && value.url !== 'adobe') { uninstallWebfont(value.full_font_name, value.url); } } @@ -133,13 +144,14 @@ for (const [fontkey, value] of Object.entries(font_pool)) { if (!(fontkey in settings)) { continue; } if (settings[fontkey]) { // check if font is enabled - // if it is a webfont, install webfont - if (value.url !== 'local') { + if (value.url === 'local') { // check if local font is installed on machine + if (!isFontInstalled(value.full_font_name)) { continue; } + } else if (value.url === 'adobe') { // if it is a webfont from adobe + // do nothing + } else { // must be webfont not from adobe, so install it installWebfont(value.full_font_name, value.url); // recheck if font is installed on machine // if (!isFontInstalled(value.full_font_name)) { continue; } - } else { // check if local font is installed on machine - if (!isFontInstalled(value.full_font_name)) { continue; } } // put fonts in selected fonts let frequency = settings[fontkey+'_frequency']; @@ -159,27 +171,40 @@ function settingsOpen() { // install webfonts, and remove non-accesible local fonts for selection + let fonts_available = {}; + let fonts_unavailable = {}; for (const [fontkey, value] of Object.entries(font_pool)) { - if (value.url !== 'local') { // install webfonts + if (value.url === 'local') { // LOCAL FONT + if (isFontInstalled(value.full_font_name)) { + fonts_available[fontkey] = value; + } else { + fonts_unavailable[fontkey] = value; + } + } else if (value.url === 'adobe') { // ADOBE WEBFONT + fonts_available[fontkey] = value; + } else { // GENERAL WEBFONT installWebfont(value.full_font_name, value.url); - } else if (!isFontInstalled(value.full_font_name)) { // remove local fonts that are not installed for selection - delete font_pool[fontkey]; + fonts_available[fontkey] = value; } } // order fonts alphabetically - const fontkeys = Object.keys(font_pool).sort((a, b) => - font_pool[a].display_name.localeCompare(font_pool[b].display_name, undefined, {sensitivity: 'base'}) + const fontkeys_available = Object.keys(fonts_available).sort((a, b) => + fonts_available[a].display_name.localeCompare(fonts_available[b].display_name, undefined, {sensitivity: 'base'}) + ); + const fontkeys_unavailable = Object.keys(fonts_unavailable).sort((a, b) => + fonts_unavailable[a].display_name.localeCompare(fonts_unavailable[b].display_name, undefined, {sensitivity: 'base'}) ); // prepare selection option for every font - const font_selector = Object.fromEntries(fontkeys.map(fontkey => ['BOX_'+fontkey, { + const font_available_selector = Object.fromEntries(fontkeys_available.map(fontkey => ['BOX_'+fontkey, { type: 'group', - label: `${font_pool[fontkey].display_name}`, + // label: `${font_pool[fontkey].display_name}`, + label: `${fonts_available[fontkey].display_name} ${fonts_available[fontkey].url !== 'local' ? '' : ''}`, content: { sampletext: { type: 'html', - html: `

${example_sentence}

` + html: `

${example_sentence}

` }, [fontkey]: { type: 'checkbox', @@ -196,6 +221,10 @@ } } }])); + const font_unavailable_selector = Object.fromEntries(fontkeys_unavailable.map(fontkey => ['BOX_'+fontkey, { + type: 'html', + html: `

${fonts_unavailable[fontkey].download !== '' ? '' : ''}${fonts_unavailable[fontkey].display_name}

`, + }])); // prepare configuration dialog let dialog = new wkof.Settings({ @@ -217,13 +246,18 @@ }, legend: { type: 'html', - html: `
: Recommended Font
` + html: `
: Recommended Font: Webfont (click to download): Local font available for download if clicked
` + }, + divider_available: { + type: 'section', + label: `Filter Fonts (${fontkeys_available.length} available)` }, - divider: { + ...font_available_selector, + divider_unavailable: { type: 'section', - label: `Filter Fonts (${fontkeys.length} available)` + label: `Local Fonts not found: ${fontkeys_unavailable.length}` }, - ...font_selector + ...font_unavailable_selector } }); dialog.open(); @@ -322,6 +356,20 @@ gstaticLink.crossOrigin = true; document.head.append(gstaticLink); } + + // connect to AdobeFonts via their method + document.head.insertAdjacentHTML('beforeend', + `` + ); } function shuffleArray(array) { @@ -422,11 +470,20 @@ .font_label { font-size: 1.2em; display: flex; + gap: 5px; align-items: center; } + .font_label a:link, .font_label a:visited, .font_label a:hover, .font_label a:active { + text-decoration: none; + } .font_legend { text-align: center; margin: 15px !important; + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 5px; + padding-left: 25% !important; } .font_example { margin: 5px 10px 10px 10px !important; @@ -437,6 +494,14 @@ content: '⭐️'; font-size: 1.4em; } + .webfont::before { + content: '🌐'; + font-size: 1.4em; + } + .downloadfont::before { + content: '⬇️'; + font-size: 1.4em; + } ` ); } diff --git a/fonts/ArmedBanana.css b/fonts/ArmedBanana.css deleted file mode 100644 index a3d97bb..0000000 --- a/fonts/ArmedBanana.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'ArmedBanana'; - font-style: normal; - font-weight: normal; - src: local('ArmedBanana'), - url('https://raw.githubusercontent.com/davidsansome/tsurukame/master/www/fonts/armed-banana.ttf') format('truetype'); -} \ No newline at end of file diff --git a/fonts/Darts.css b/fonts/Darts.css deleted file mode 100644 index a5b8e5f..0000000 --- a/fonts/Darts.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'darts font'; - font-style: normal; - font-weight: normal; - src: local('darts font'), - url('https://raw.githubusercontent.com/davidsansome/tsurukame/master/www/fonts/darts-font.woff') format('woff'); -} \ No newline at end of file diff --git a/fonts/FCFlower.css b/fonts/FCFlower.css deleted file mode 100644 index 9387c6d..0000000 --- a/fonts/FCFlower.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'FC-Flower'; - font-style: normal; - font-weight: normal; - src: local('FC-Flower'), - url('https://raw.githubusercontent.com/davidsansome/tsurukame/master/www/fonts/fc-flower.ttf') format('truetype'); -} \ No newline at end of file diff --git a/fonts/HosoFuwa.css b/fonts/HosoFuwa.css deleted file mode 100644 index c897b59..0000000 --- a/fonts/HosoFuwa.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'Hosofuwafont'; - font-style: normal; - font-weight: normal; - src: local('Hosofuwafont'), - url('https://raw.githubusercontent.com/davidsansome/tsurukame/master/www/fonts/hoso-fuwa.ttf') format('truetype'); -} \ No newline at end of file diff --git a/fonts/NagayamaKai.css b/fonts/NagayamaKai.css deleted file mode 100644 index 5449b7f..0000000 --- a/fonts/NagayamaKai.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'nagayama_kai'; - font-style: normal; - font-weight: normal; - src: local('nagayama_kai'), - url('https://raw.githubusercontent.com/davidsansome/tsurukame/master/www/fonts/nagayama-kai.otf') format('truetype'); -} \ No newline at end of file diff --git a/fonts/PopRumCute.css b/fonts/PopRumCute.css deleted file mode 100644 index 8501091..0000000 --- a/fonts/PopRumCute.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'PopRumCute'; - font-style: normal; - font-weight: normal; - src: local('PopRumCute'), - url('https://moji-waku.com/poprumcute/font/poprum.woff') format('woff'); -} \ No newline at end of file diff --git a/fonts/SanChouMe.css b/fonts/SanChouMe.css deleted file mode 100644 index 88c9450..0000000 --- a/fonts/SanChouMe.css +++ /dev/null @@ -1,7 +0,0 @@ -@font-face { - font-family: 'santyoume-font'; - font-style: normal; - font-weight: normal; - src: local('santyoume-font'), - url('https://raw.githubusercontent.com/davidsansome/tsurukame/master/www/fonts/san-chou-me.ttf') format('truetype'); -} \ No newline at end of file From a0884a15cdb7bd6790b7b86a6e816c87efbb142a Mon Sep 17 00:00:00 2001 From: Marco Omainska Date: Wed, 3 May 2023 22:30:16 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=90=9B=20fix=20few=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jitai.user.js | 54 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/Jitai.user.js b/Jitai.user.js index a7091bd..d19027b 100644 --- a/Jitai.user.js +++ b/Jitai.user.js @@ -200,11 +200,11 @@ const font_available_selector = Object.fromEntries(fontkeys_available.map(fontkey => ['BOX_'+fontkey, { type: 'group', // label: `${font_pool[fontkey].display_name}`, - label: `${fonts_available[fontkey].display_name} ${fonts_available[fontkey].url !== 'local' ? '' : ''}`, + label: `${fonts_available[fontkey].display_name} ${fonts_available[fontkey].url !== 'local' ? '' : ''}`, content: { sampletext: { type: 'html', - html: `

${example_sentence}

` + html: `

${example_sentence}

` }, [fontkey]: { type: 'checkbox', @@ -223,7 +223,7 @@ }])); const font_unavailable_selector = Object.fromEntries(fontkeys_unavailable.map(fontkey => ['BOX_'+fontkey, { type: 'html', - html: `

${fonts_unavailable[fontkey].download !== '' ? '' : ''}${fonts_unavailable[fontkey].display_name}

`, + html: `

${fonts_unavailable[fontkey].download !== '' ? '' : ''}${fonts_unavailable[fontkey].display_name}

`, }])); // prepare configuration dialog @@ -240,7 +240,7 @@ content: { sampletext: { type: 'html', - html: `

${example_sentence}

` + html: `

${example_sentence}

` } } }, @@ -358,18 +358,40 @@ } // connect to AdobeFonts via their method - document.head.insertAdjacentHTML('beforeend', - `` - ); + // document.head.insertAdjacentHTML('beforeend', + // `` + // ); + let config = { + kitId: 'xad5qou', + scriptTimeout: 3000, + async: true + }; + let h=document.documentElement; + let t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";}, config.scriptTimeout); + let tk=document.createElement("script"); + let f=false; + let s=document.getElementsByTagName("script")[0]; + let a; + h.className+=" wf-loading"; + tk.src='https://use.typekit.net/'+config.kitId+'.js'; + tk.async=true; + tk.onload=tk.onreadystatechange=function(){ + a=this.readyState; + if(f||a&&a!="complete"&&a!="loaded") { return; } + f=true; + clearTimeout(t); + try{Typekit.load(config)}catch(e){} + }; + s.parentNode.insertBefore(tk,s); } function shuffleArray(array) { From c40ee5e27503643071d4352342867a08332d3511 Mon Sep 17 00:00:00 2001 From: Marco Omainska Date: Thu, 4 May 2023 15:25:12 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=90=9B=20fix=20bunch=20of=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jitai.user.js | 256 ++++++++++++++++++++++++++------------------------ 1 file changed, 135 insertions(+), 121 deletions(-) diff --git a/Jitai.user.js b/Jitai.user.js index d19027b..bb25437 100644 --- a/Jitai.user.js +++ b/Jitai.user.js @@ -29,71 +29,71 @@ // ----- Fonts ----- const example_sentence = '質問:私立探偵 (P.I.) はどんな靴を履いていますか?
答え:・・・スニーカー。(笑)'; - let font_default = getDefaultFont(); + let font_default = {display_name:'Default Font', full_font_name:getDefaultFont()}; let font_randomized = font_default; // available fonts let font_pool = { // Default OSX fonts - "Hiragino-Kaku-Gothic-Pro" : {full_font_name: "Hiragino Kaku Gothic Pro, ヒラギノ角ゴ Pro W3", display_name: "Hiragino Kaku Gothic Pro", url: 'local', download: '', recommended: false}, - "Hiragino-Maru-Gothic-Pro" : {full_font_name: "Hiragino Maru Gothic Pro, ヒラギノ丸ゴ Pro W3", display_name: "Hiragino Maru Gothic Pro", url: 'local', download: '', recommended: false}, - "Hiragino-Mincho-Pro" : {full_font_name: "Hiragino Mincho Pro, ヒラギノ明朝 Pro W3", display_name: "Hiragino Mincho Pro", url: 'local', download: '', recommended: false}, + "Hiragino-Kaku-Gothic-Pro" : {full_font_name: "Hiragino Kaku Gothic Pro, ヒラギノ角ゴ Pro W3", display_name: "Hiragino Kaku Gothic Pro", url: 'local', download: '', recommended: false, bugged: false}, + "Hiragino-Maru-Gothic-Pro" : {full_font_name: "Hiragino Maru Gothic Pro, ヒラギノ丸ゴ Pro W3", display_name: "Hiragino Maru Gothic Pro", url: 'local', download: '', recommended: false, bugged: false}, + "Hiragino-Mincho-Pro" : {full_font_name: "Hiragino Mincho Pro, ヒラギノ明朝 Pro W3", display_name: "Hiragino Mincho Pro", url: 'local', download: '', recommended: false, bugged: false}, // Default Windows fonts - "Meiryo" : {full_font_name: "Meiryo, メイリオ", display_name: "Meiryo", url: 'local', download: '', recommended: false}, - "MS-PGothic" : {full_font_name: "MS PGothic, MS Pゴシック, MS Gothic, MS ゴック", display_name: "MS Gothic", url: 'local', download: '', recommended: false}, - "MS-PMincho" : {full_font_name: "MS PMincho, MS P明朝, MS Mincho, MS 明朝", display_name: "MS Mincho", url: 'local', download: '', recommended: false}, - "Yu-Gothic" : {full_font_name: "Yu Gothic, YuGothic", display_name: "Yu Gothic", url: 'local', download: '', recommended: false}, - "Yu-Mincho" : {full_font_name: "Yu Mincho, YuMincho", display_name: "Yu Mincho", url: 'local', download: '', recommended: false}, + "Meiryo" : {full_font_name: "Meiryo, メイリオ", display_name: "Meiryo", url: 'local', download: '', recommended: false, bugged: false}, + "MS-PGothic" : {full_font_name: "MS PGothic, MS Pゴシック, MS Gothic, MS ゴック", display_name: "MS Gothic", url: 'local', download: '', recommended: false, bugged: false}, + "MS-PMincho" : {full_font_name: "MS PMincho, MS P明朝, MS Mincho, MS 明朝", display_name: "MS Mincho", url: 'local', download: '', recommended: false, bugged: false}, + "Yu-Gothic" : {full_font_name: "Yu Gothic, YuGothic", display_name: "Yu Gothic", url: 'local', download: '', recommended: false, bugged: false}, + "Yu-Mincho" : {full_font_name: "Yu Mincho, YuMincho", display_name: "Yu Mincho", url: 'local', download: '', recommended: false, bugged: false}, // GoogleFonts - "Zen-Kurenaido" : {full_font_name: "Zen Kurenaido", display_name: "Zen Kurenaido", url: 'https://fonts.googleapis.com/css?family=Zen+Kurenaido&subset=japanese', download: 'https://fonts.google.com/specimen/Zen+Kurenaido', recommended: false}, - "Kaisei-Opti" : {full_font_name: "Kaisei Opti", display_name: "Kaisei Opti", url: 'https://fonts.googleapis.com/css?family=Kaisei+Opti&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Opti', recommended: false}, - "Reggae-One" : {full_font_name: "Reggae One", display_name: "Reggae One", url: 'https://fonts.googleapis.com/css?family=Reggae+One&subset=japanese', download: 'https://fonts.google.com/specimen/Reggae+One', recommended: false}, - "New-Tegomin" : {full_font_name: "New Tegomin", display_name: "New Tegomin", url: 'https://fonts.googleapis.com/css?family=New+Tegomin&subset=japanese', download: 'https://fonts.google.com/specimen/New+Tegomin', recommended: false}, - "Yuji-Boku" : {full_font_name: "Yuji Boku", display_name: "Yuji Boku", url: 'https://fonts.googleapis.com/css?family=Yuji+Boku&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Boku', recommended: false}, - "Yuji-Mai" : {full_font_name: "Yuji Mai", display_name: "Yuji Mai", url: 'https://fonts.googleapis.com/css?family=Yuji+Mai&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Mai', recommended: false}, - "Yuji-Syuku" : {full_font_name: "Yuji Syuku", display_name: "Yuji Syuku", url: 'https://fonts.googleapis.com/css?family=Yuji+Syuku&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Syuku', recommended: false}, - "DotGothic16" : {full_font_name: "DotGothic16", display_name: "DotGothic16", url: 'https://fonts.googleapis.com/css?family=DotGothic16&subset=japanese', download: 'https://fonts.google.com/specimen/DotGothic16', recommended: true}, - "Hachi-Maru-Pop" : {full_font_name: "Hachi Maru Pop", display_name: "Hachi Maru Pop", url: 'https://fonts.googleapis.com/css?family=Hachi+Maru+Pop&subset=japanese', download: 'https://fonts.google.com/specimen/Hachi+Maru+Pop', recommended: true}, - "Yomogi" : {full_font_name: "Yomogi", display_name: "Yomogi", url: 'https://fonts.googleapis.com/css?family=Yomogi&subset=japanese', download: 'https://fonts.google.com/specimen/Yomogi', recommended: false}, - "Potta-One" : {full_font_name: "Potta One", display_name: "Potta One", url: 'https://fonts.googleapis.com/css?family=Potta+One&subset=japanese', download: 'https://fonts.google.com/specimen/Potta+One', recommended: false}, - "Dela-Gothic-One" : {full_font_name: "Dela Gothic One", display_name: "Dela Gothic One", url: 'https://fonts.googleapis.com/css?family=Dela+Gothic+One&subset=japanese', download: 'https://fonts.google.com/specimen/Dela+Gothic+One', recommended: true}, - "RocknRoll-One" : {full_font_name: "RocknRoll One", display_name: "RocknRoll One", url: 'https://fonts.googleapis.com/css?family=RocknRoll+One&subset=japanese', download: 'https://fonts.google.com/specimen/RocknRoll+One', recommended: false}, - "Stick" : {full_font_name: "Stick", display_name: "Stick", url: 'https://fonts.googleapis.com/css?family=Stick&subset=japanese', download: 'https://fonts.google.com/specimen/Stick', recommended: true}, - "Yusei-Magic" : {full_font_name: "Yusei Magic", display_name: "Yusei Magic", url: 'https://fonts.googleapis.com/css?family=Yusei+Magic&subset=japanese', download: 'https://fonts.google.com/specimen/Yusei+MagicYusei+Magic', recommended: false}, - "Kaisei-Decol" : {full_font_name: "Kaisei Decol", display_name: "Kaisei Decol", url: 'https://fonts.googleapis.com/css?family=Kaisei+Decol&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Decol', recommended: false}, - "Kaisei-Tokumin" : {full_font_name: "Kaisei Tokumin", display_name: "Kaisei Tokumin", url: 'https://fonts.googleapis.com/css?family=Kaisei+Tokumin&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Tokumin', recommended: false}, + "Zen-Kurenaido" : {full_font_name: "Zen Kurenaido", display_name: "Zen Kurenaido", url: 'https://fonts.googleapis.com/css?family=Zen+Kurenaido&subset=japanese', download: 'https://fonts.google.com/specimen/Zen+Kurenaido', recommended: false, bugged: false}, + "Kaisei-Opti" : {full_font_name: "Kaisei Opti", display_name: "Kaisei Opti", url: 'https://fonts.googleapis.com/css?family=Kaisei+Opti&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Opti', recommended: false, bugged: false}, + "Reggae-One" : {full_font_name: "Reggae One", display_name: "Reggae One", url: 'https://fonts.googleapis.com/css?family=Reggae+One&subset=japanese', download: 'https://fonts.google.com/specimen/Reggae+One', recommended: false, bugged: false}, + "New-Tegomin" : {full_font_name: "New Tegomin", display_name: "New Tegomin", url: 'https://fonts.googleapis.com/css?family=New+Tegomin&subset=japanese', download: 'https://fonts.google.com/specimen/New+Tegomin', recommended: false, bugged: false}, + "Yuji-Boku" : {full_font_name: "Yuji Boku", display_name: "Yuji Boku", url: 'https://fonts.googleapis.com/css?family=Yuji+Boku&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Boku', recommended: false, bugged: false}, + "Yuji-Mai" : {full_font_name: "Yuji Mai", display_name: "Yuji Mai", url: 'https://fonts.googleapis.com/css?family=Yuji+Mai&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Mai', recommended: false, bugged: false}, + "Yuji-Syuku" : {full_font_name: "Yuji Syuku", display_name: "Yuji Syuku", url: 'https://fonts.googleapis.com/css?family=Yuji+Syuku&subset=japanese', download: 'https://fonts.google.com/specimen/Yuji+Syuku', recommended: false, bugged: false}, + "DotGothic16" : {full_font_name: "DotGothic16", display_name: "DotGothic16", url: 'https://fonts.googleapis.com/css?family=DotGothic16&subset=japanese', download: 'https://fonts.google.com/specimen/DotGothic16', recommended: true, bugged: false}, + "Hachi-Maru-Pop" : {full_font_name: "Hachi Maru Pop", display_name: "Hachi Maru Pop", url: 'https://fonts.googleapis.com/css?family=Hachi+Maru+Pop&subset=japanese', download: 'https://fonts.google.com/specimen/Hachi+Maru+Pop', recommended: true, bugged: false}, + "Yomogi" : {full_font_name: "Yomogi", display_name: "Yomogi", url: 'https://fonts.googleapis.com/css?family=Yomogi&subset=japanese', download: 'https://fonts.google.com/specimen/Yomogi', recommended: false, bugged: false}, + "Potta-One" : {full_font_name: "Potta One", display_name: "Potta One", url: 'https://fonts.googleapis.com/css?family=Potta+One&subset=japanese', download: 'https://fonts.google.com/specimen/Potta+One', recommended: false, bugged: false}, + "Dela-Gothic-One" :{full_font_name: "Dela Gothic One", display_name: "Dela Gothic One", url: 'https://fonts.googleapis.com/css?family=Dela+Gothic+One&subset=japanese', download: 'https://fonts.google.com/specimen/Dela+Gothic+One', recommended: true, bugged: false}, + "RocknRoll-One" : {full_font_name: "RocknRoll One", display_name: "RocknRoll One", url: 'https://fonts.googleapis.com/css?family=RocknRoll+One&subset=japanese', download: 'https://fonts.google.com/specimen/RocknRoll+One', recommended: false, bugged: false}, + "Stick" : {full_font_name: "Stick", display_name: "Stick", url: 'https://fonts.googleapis.com/css?family=Stick&subset=japanese', download: 'https://fonts.google.com/specimen/Stick', recommended: true, bugged: false}, + "Yusei-Magic" : {full_font_name: "Yusei Magic", display_name: "Yusei Magic", url: 'https://fonts.googleapis.com/css?family=Yusei+Magic&subset=japanese', download: 'https://fonts.google.com/specimen/Yusei+MagicYusei+Magic', recommended: false, bugged: false}, + "Kaisei-Decol" : {full_font_name: "Kaisei Decol", display_name: "Kaisei Decol", url: 'https://fonts.googleapis.com/css?family=Kaisei+Decol&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Decol', recommended: false, bugged: false}, + "Kaisei-Tokumin" : {full_font_name: "Kaisei Tokumin", display_name: "Kaisei Tokumin", url: 'https://fonts.googleapis.com/css?family=Kaisei+Tokumin&subset=japanese', download: 'https://fonts.google.com/specimen/Kaisei+Tokumin', recommended: false, bugged: false}, // AdobeFonts - "AB-Andante" : {full_font_name: "ab-andante", display_name: "AB Andante", url: 'adobe', download: 'http://www.font1000.com', recommended: false}, - "AB-Appare" : {full_font_name: "ab-appare", display_name: "AB Appare", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false}, - "AB-Karuta-El" : {full_font_name: "ab-karuta-el", display_name: "AB Karuta El", url: 'adobe', download: 'http://www.font1000.com', recommended: false}, - "AB-Kikori" : {full_font_name: "ab-kikori", display_name: "AB Kikori", url: 'adobe', download: 'http://www.font1000.com', recommended: false}, - "AB-Kouran-Gyosho" : {full_font_name: "ab-kouran-gyosho", display_name: "AB Kouran Gyosho", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false}, - "AB-Shinyubipenjigyosyotai" : {full_font_name: "ab-shinyubipenjigyosyotai", display_name: "AB Shinyubipenjigyosyotai", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false}, - "Hakusyu-Sosho" : {full_font_name: "hot-soshokk, HakusyuSosho", display_name: "Hakusyu Sosho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: true}, - "Hakusyu-Tensho" : {full_font_name: "hot-tenshokk, HakusyuTensho", display_name: "Hakusyu Tensho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: false}, + "AB-Andante" : {full_font_name: "ab-andante", display_name: "AB Andante", url: 'adobe', download: 'http://www.font1000.com', recommended: false, bugged: true}, + "AB-Appare" : {full_font_name: "ab-appare", display_name: "AB Appare", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false, bugged: false}, + "AB-Karuta-El" : {full_font_name: "ab-karuta-el", display_name: "AB Karuta El", url: 'adobe', download: 'http://www.font1000.com', recommended: false, bugged: true}, + "AB-Kikori" : {full_font_name: "ab-kikori", display_name: "AB Kikori", url: 'adobe', download: 'http://www.font1000.com', recommended: false, bugged: true}, + "AB-Kouran-Gyosho" : {full_font_name: "ab-kouran-gyosho", display_name: "AB Kouran Gyosho", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false, bugged: true}, + "AB-Shinyubipenjigyosyotai" : {full_font_name: "ab-shinyubipenjigyosyotai", display_name: "AB Shinyubipenjigyosyotai", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false, bugged: false}, + "Hakusyu-Sosho" : {full_font_name: "hot-soshokk, HakusyuSosho", display_name: "Hakusyu Sosho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: true, bugged: false}, + "Hakusyu-Tensho" : {full_font_name: "hot-tenshokk, HakusyuTensho", display_name: "Hakusyu Tensho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: false, bugged: false}, // Other popular fonts - "ArmedBanana" : {full_font_name: "ArmedBanana", display_name: "Armed Banana", url: 'https://marciska.github.io/Jitai-Fonts/ArmedBanana.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: true}, - "ArmedLemon" : {full_font_name: "ArmedLemon", display_name: "Armed Lemon", url: 'https://marciska.github.io/Jitai-Fonts/ArmedLemon.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: false}, - "Aoyagi-Reisho" : {full_font_name: "Aoyagi Reisho, Aoyagi Reisyo, aoyagireisyo2, aoyagireisyosimo2", display_name: "Aoyagi Reisho", url: 'https://marciska.github.io/Jitai-Fonts/AoyagiReisyo.css', download: 'https://opentype.jp/aoyagireisho.htm', recommended: false}, - "Aoyagi-Gyousho" : {full_font_name: "KouzanBrushFontGyousyoOTF, AoyagiKouzanFont2OTF, Aoyagi Gyousyo, Aoyagi Gyousho", display_name: "Aoyagi Gyousho", url: 'https://marciska.github.io/Jitai-Fonts/AoyagiGyousyo.css', download: 'https://opentype.jp/kouzangyousho.htm', recommended: false}, - "Aquafont" : {full_font_name: "Aquafont, aquafont", display_name: "Aquafont", url: 'https://marciska.github.io/Jitai-Fonts/Aquafont.css', download: 'https://www.freejapanesefont.com/aqua-font/', recommended: false}, - "Chifont" : {full_font_name: "'chifont+', chifont, Nchifont, 'Nchifont+'", display_name: "Chifont", url: 'local', download: 'https://welina.xyz/font/tegaki/nchif/', recommended: false}, - "Chihaya-Gothic" : {full_font_name: "ChihayaGothic", display_name: "Chihaya Gothic", url: 'local', download: 'https://welina.xyz/font/tegaki/gothic/', recommended: false}, - "Cinecaption" : {full_font_name: "cinecaption", display_name: "Cinecaption", url: 'local', download: 'https://cooltext.com/Download-Font-しねきゃぷしょん+cinecaption', recommended: false}, - "Darts" : {full_font_name: "DartsFont, 'darts font'", display_name: "Darts Font", url: 'https://marciska.github.io/Jitai-Fonts/DartsFont.css', download: 'https://www.p-darts.jp/font/dartsfont/', recommended: false}, - "EPSON-行書体M" : {full_font_name: "EPSON 行書体M", display_name: "EPSON 行書体M", url: 'local', download: '', recommended: false}, - "EPSON-正楷書体M" : {full_font_name: "EPSON 正楷書体M", display_name: "EPSON 正楷書体M", url: 'local', download: '', recommended: false}, - "EPSON-教科書体M" : {full_font_name: "EPSON 教科書体M", display_name: "EPSON 教科書体M", url: 'local', download: '', recommended: false}, - "EPSON-太明朝体B" : {full_font_name: "EPSON 太明朝体B", display_name: "EPSON 太明朝体B", url: 'local', download: '', recommended: false}, - "EPSON-太行書体B" : {full_font_name: "EPSON 太行書体B", display_name: "EPSON 太行書体B", url: 'local', download: '', recommended: false}, - "EPSON-丸ゴシック体M" : {full_font_name: "EPSON 丸ゴシック体M", display_name: "EPSON 丸ゴシック体M", url: 'local', download: '', recommended: false}, - "FC-Flower" : {full_font_name: "FC-Flower", display_name: "FC-Flower (Experimental)", url: 'local', download: 'https://web.archive.org/web/20200718072012/http://fscolor.happy.nu/font/fl.html', recommended: false}, - "Hakusyu-Kaisho-Bold" : {full_font_name: "HakusyuKaisyoExtraBold_kk", display_name: "Hakusyu Kaisho Bold", url: 'local', download: 'https://www.hakusyu.com/download_education.htm', recommended: false}, - "Hoso-Fuwa" : {full_font_name: "Hosofuwafont", display_name: "Hoso Fuwa", url: 'https://marciska.github.io/Jitai-Fonts/HosoFuwa.css', download: 'https://huwahuwa.ff-design.net/ほそふわフォント/', recommended: false}, - "Nagayama-Kai" : {full_font_name: "Nagayama Kai, nagayama_kai", display_name: "Nagayama Kai", url: 'https://marciska.github.io/Jitai-Fonts/NagayamaKai.css', download: 'https://www.bokushin.org/en/nagayama-sensei-font/', recommended: false}, - "Pop-Rum-Cute" : {full_font_name: "PopRumCute", display_name: "Pop Rum Cute", url: 'https://marciska.github.io/Jitai-Fonts/PopRumCute.css', download: 'https://moji-waku.com/poprumcute/', recommended: false}, - "Ronde-B-Square" : {full_font_name: "Ronde B Square, Ronde-B, Ronde-B-Square", display_name: "Ronde B square", url: 'https://marciska.github.io/Jitai-Fonts/PopRumCute.css', download: 'https://moji-waku.com/poprumcute/', recommended: false}, - "San-Chou-Me" : {full_font_name: "San Chou Me, santyoume-font", display_name: "San Chou Me", url: 'https://marciska.github.io/Jitai-Fonts/SanChouMe.css', download: 'https://web.archive.org/web/20190330133455/http://www.geocities.jp/bokurano_yume/', recommended: false}, + "ArmedBanana" : {full_font_name: "ArmedBanana", display_name: "Armed Banana", url: 'https://marciska.github.io/Jitai-Fonts/ArmedBanana.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: true, bugged: false}, + "ArmedLemon" : {full_font_name: "ArmedLemon", display_name: "Armed Lemon", url: 'https://marciska.github.io/Jitai-Fonts/ArmedLemon.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: false, bugged: false}, + "Aoyagi-Reisho" : {full_font_name: "Aoyagi Reisho, Aoyagi Reisyo, aoyagireisyo2, aoyagireisyosimo2", display_name: "Aoyagi Reisho", url: 'https://marciska.github.io/Jitai-Fonts/AoyagiReisyo.css', download: 'https://opentype.jp/aoyagireisho.htm', recommended: false, bugged: false}, + "Aoyagi-Gyousho" : {full_font_name: "KouzanBrushFontGyousyoOTF, AoyagiKouzanFont2OTF, Aoyagi Gyousyo, Aoyagi Gyousho", display_name: "Aoyagi Gyousho", url: 'https://marciska.github.io/Jitai-Fonts/AoyagiGyousyo.css', download: 'https://opentype.jp/kouzangyousho.htm', recommended: false, bugged: false}, + "Aquafont" : {full_font_name: "Aquafont, aquafont", display_name: "Aquafont", url: 'https://marciska.github.io/Jitai-Fonts/Aquafont.css', download: 'https://www.freejapanesefont.com/aqua-font/', recommended: false, bugged: false}, + "Chifont" : {full_font_name: "'chifont+', chifont, Nchifont, 'Nchifont+'", display_name: "Chifont", url: 'local', download: 'https://welina.xyz/font/tegaki/nchif/', recommended: false, bugged: false}, + "Chihaya-Gothic" : {full_font_name: "ChihayaGothic", display_name: "Chihaya Gothic", url: 'local', download: 'https://welina.xyz/font/tegaki/gothic/', recommended: false, bugged: false}, + "Cinecaption" : {full_font_name: "cinecaption", display_name: "Cinecaption", url: 'local', download: 'https://cooltext.com/Download-Font-しねきゃぷしょん+cinecaption', recommended: false, bugged: false}, + "Darts" : {full_font_name: "DartsFont, darts font", display_name: "Darts Font", url: 'https://marciska.github.io/Jitai-Fonts/DartsFont.css', download: 'https://www.p-darts.jp/font/dartsfont/', recommended: false, bugged: false}, + "EPSON-行書体M" : {full_font_name: "EPSON 行書体M", display_name: "EPSON 行書体M", url: 'local', download: '', recommended: false, bugged: false}, + "EPSON-正楷書体M" : {full_font_name: "EPSON 正楷書体M", display_name: "EPSON 正楷書体M", url: 'local', download: '', recommended: false, bugged: false}, + "EPSON-教科書体M" : {full_font_name: "EPSON 教科書体M", display_name: "EPSON 教科書体M", url: 'local', download: '', recommended: false, bugged: false}, + "EPSON-太明朝体B" : {full_font_name: "EPSON 太明朝体B", display_name: "EPSON 太明朝体B", url: 'local', download: '', recommended: false, bugged: false}, + "EPSON-太行書体B" : {full_font_name: "EPSON 太行書体B", display_name: "EPSON 太行書体B", url: 'local', download: '', recommended: false, bugged: false}, + "EPSON-丸ゴシック体M" : {full_font_name: "EPSON 丸ゴシック体M", display_name: "EPSON 丸ゴシック体M", url: 'local', download: '', recommended: false, bugged: false}, + "FC-Flower" : {full_font_name: "FC-Flower", display_name: "FC-Flower", url: 'https://marciska.github.io/Jitai-Fonts/FCFlower.css', download: 'https://web.archive.org/web/20200718072012/http://fscolor.happy.nu/font/fl.html', recommended: false, bugged: true}, + "Hakusyu-Kaisho-Bold" : {full_font_name: "HakusyuKaisyoExtraBold_kk", display_name: "Hakusyu Kaisho Bold", url: 'local', download: 'https://www.hakusyu.com/download_education.htm', recommended: false, bugged: false}, + "Hoso-Fuwa" : {full_font_name: "Hosofuwafont", display_name: "Hoso Fuwa", url: 'https://marciska.github.io/Jitai-Fonts/HosoFuwa.css', download: 'https://huwahuwa.ff-design.net/ほそふわフォント/', recommended: false, bugged: false}, + "Nagayama-Kai" : {full_font_name: "Nagayama Kai, nagayama_kai", display_name: "Nagayama Kai", url: 'https://marciska.github.io/Jitai-Fonts/NagayamaKai.css', download: 'https://www.bokushin.org/en/nagayama-sensei-font/', recommended: false, bugged: false}, + "Pop-Rum-Cute" : {full_font_name: "PopRumCute", display_name: "Pop Rum Cute", url: 'https://marciska.github.io/Jitai-Fonts/PopRumCute.css', download: 'https://moji-waku.com/poprumcute/', recommended: false, bugged: false}, + "Ronde-B-Square" : {full_font_name: "Ronde B Square, Ronde-B, Ronde-B-Square", display_name: "Ronde B square", url: 'https://marciska.github.io/Jitai-Fonts/RondeBSquare.css', download: 'https://moji-waku.com/poprumcute/', recommended: false, bugged: false}, + "San-Chou-Me" : {full_font_name: "San Chou Me, santyoume-font", display_name: "San Chou Me", url: 'https://marciska.github.io/Jitai-Fonts/SanChouMe.css', download: 'https://web.archive.org/web/20190330133455/http://www.geocities.jp/bokurano_yume/', recommended: false, bugged: false}, }; // fonts that are selected by user to be shown @@ -118,7 +118,7 @@ dialog.dialog({width:720}); } async function settingsSave(settings) { - await wkof.Settings.save(script_id); //.then(settingsApply).then(settingsClose); + await wkof.Settings.save(script_id); settingsApply(settings); settingsClose(settings); } @@ -158,7 +158,7 @@ if (frequency === undefined) { frequency = 1; } // if script started first time, the value might be undefined frequency = Math.ceil(frequency); for (let i = 0; i < frequency; i++) { - font_pool_selected.push(value.full_font_name); + font_pool_selected.push(value); } } } @@ -183,8 +183,13 @@ } else if (value.url === 'adobe') { // ADOBE WEBFONT fonts_available[fontkey] = value; } else { // GENERAL WEBFONT - installWebfont(value.full_font_name, value.url); - fonts_available[fontkey] = value; + if (isFontInstalled(value.full_font_name)) { + fonts_available[fontkey] = value; + fonts_available[fontkey].url = 'local'; + } else { + installWebfont(value.full_font_name, value.url); + fonts_available[fontkey] = value; + } } } @@ -200,7 +205,7 @@ const font_available_selector = Object.fromEntries(fontkeys_available.map(fontkey => ['BOX_'+fontkey, { type: 'group', // label: `${font_pool[fontkey].display_name}`, - label: `${fonts_available[fontkey].display_name} ${fonts_available[fontkey].url !== 'local' ? '' : ''}`, + label: `${fonts_available[fontkey].display_name} ${fonts_available[fontkey].url !== 'local' ? '' : ''}`, content: { sampletext: { type: 'html', @@ -223,7 +228,7 @@ }])); const font_unavailable_selector = Object.fromEntries(fontkeys_unavailable.map(fontkey => ['BOX_'+fontkey, { type: 'html', - html: `

${fonts_unavailable[fontkey].download !== '' ? '' : ''}${fonts_unavailable[fontkey].display_name}

`, + html: `

${fonts_unavailable[fontkey].download !== '' ? '' : ''}${fonts_unavailable[fontkey].display_name}

`, }])); // prepare configuration dialog @@ -236,17 +241,17 @@ content: { currentfont: { type: 'group', - label: `Current Font: ${font_randomized}`, + label: `Current Font: ${font_randomized.display_name}`, content: { sampletext: { type: 'html', - html: `

${example_sentence}

` + html: `

${example_sentence}

` } } }, legend: { type: 'html', - html: `
: Recommended Font: Webfont (click to download): Local font available for download if clicked
` + html: `
: Recommended Font: Imported as webfont (click to download): Bugged on Safari (and Firefox if tracking prevention enabled)

Don't worry about fonts that don't come with all Kanjis (shown as invisible glyphs). Jitai will during review only choose fonts that can fully represent the current review item.

` }, divider_available: { type: 'section', @@ -257,6 +262,10 @@ type: 'section', label: `Local Fonts not found: ${fontkeys_unavailable.length}` }, + legend_fonts_unavailable: { + type: 'html', + html: `
: Local font available for download. Click on link to visit website.
` + }, ...font_unavailable_selector } }); @@ -292,6 +301,16 @@ return testWidth != defaultWidth; } + function checkIfWebfontsLocallyInstalled() { + // NOTE this function should run BEFORE addPreconnectLinks(). + // If it is run after, adobe-webfonts are falsely detected as local fonts + for (const fontkey of Object.keys(font_pool)) { + if (font_pool[fontkey].url === 'local') { return; } + if (isFontInstalled(font_pool[fontkey].full_font_name)) { + font_pool[fontkey].url = 'local'; + } + } + } function isCanvasBlank(canvas) { return !canvas.getContext('2d') @@ -299,25 +318,22 @@ .some(channel => channel !== 0); } function canRepresentGlyphs(fontName, glyphs) { - var canvas = document.createElement('canvas'); + let canvas = document.createElement('canvas'); canvas.width = 50; canvas.height = 50; - var context = canvas.getContext("2d"); - context.textBaseline = 'top'; - - context.font = "24px " + fontName; - - var result = true; - for (var i = 0; i < glyphs.length; i++) { - context.fillText(glyphs[i], 0, 0); - if (isCanvasBlank(canvas)) { - result = false; - break; - } - context.clearRect(0, 0, canvas.width, canvas.height); + let ctx = canvas.getContext("2d"); + ctx.textBaseline = 'top'; + ctx.font = "24px " + fontName; + + // write each glyph on the canvas; if canvas is empty then glyph cannot be represented + // BUG on Safari, ctx.fillText() doesn't work with custom fonts (sometimes?!) + for (let i = 0; i < glyphs.length; i++) { + ctx.fillText(glyphs[i], 0, 0); + if (isCanvasBlank(canvas)) { return false; } + ctx.clearRect(0, 0, canvas.width, canvas.height); } - return result; + return true; } function installWebfont(font_name, url) { @@ -358,40 +374,22 @@ } // connect to AdobeFonts via their method - // document.head.insertAdjacentHTML('beforeend', - // `` - // ); - let config = { - kitId: 'xad5qou', - scriptTimeout: 3000, - async: true - }; - let h=document.documentElement; - let t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";}, config.scriptTimeout); - let tk=document.createElement("script"); - let f=false; - let s=document.getElementsByTagName("script")[0]; - let a; - h.className+=" wf-loading"; - tk.src='https://use.typekit.net/'+config.kitId+'.js'; - tk.async=true; - tk.onload=tk.onreadystatechange=function(){ - a=this.readyState; - if(f||a&&a!="complete"&&a!="loaded") { return; } - f=true; - clearTimeout(t); - try{Typekit.load(config)}catch(e){} - }; - s.parentNode.insertBefore(tk,s); + let script = document.getElementById("adobe_fonts_script"); + if (!script) { + script = document.createElement("script"); + script.setAttribute('id','adobe_fonts_script'); + script.innerHTML = ` + (function(d) { + var config = { + kitId: 'xad5qou', + scriptTimeout: 3000, + async: true + }, + h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s) + })(document); + `; + document.head.appendChild(script); + } } function shuffleArray(array) { @@ -409,19 +407,24 @@ console.log(script_name+': empty font pool!') font_randomized = font_default; } else { + let i = 0; do { + i = i + 1; font_randomized = font_pool_selected[Math.floor(Math.random() * font_pool_selected.length)]; - } while (!canRepresentGlyphs(font_randomized, glyphs)); + } while (!canRepresentGlyphs(font_randomized.full_font_name, glyphs) && i < 100); + if (i >= 100) { + font_randomized = font_default; + } } } // show font if (hover_flipped) { - item_element.style.setProperty("--font-family-japanese", font_default); - item_element.style.setProperty("--font-family-japanese-hover", font_randomized); + item_element.style.setProperty("--font-family-japanese", font_default.full_font_name); + item_element.style.setProperty("--font-family-japanese-hover", font_randomized.full_font_name); } else { - item_element.style.setProperty("--font-family-japanese", font_randomized); - item_element.style.setProperty("--font-family-japanese-hover", font_default); + item_element.style.setProperty("--font-family-japanese", font_randomized.full_font_name); + item_element.style.setProperty("--font-family-japanese-hover", font_default.full_font_name); } } @@ -431,7 +434,7 @@ // - hovering: default font let style = document.createElement("style"); style.appendChild(document.createTextNode(".character-header__characters:hover { font-family: var(--font-family-japanese-hover); }")); - item_element.style.setProperty("--font-family-japanese-hover", font_default); + item_element.style.setProperty("--font-family-japanese-hover", font_default.full_font_name); document.head.appendChild(style); // on answer submission, invert hovering event @@ -480,6 +483,7 @@ wkof.include(wkof_modules); wkof .ready(wkof_modules) + .then(checkIfWebfontsLocallyInstalled) .then(addPreconnectLinks) .then(registerJitaiEvents) .then(settingsLoad) @@ -505,7 +509,13 @@ flex-direction: column; align-items: flex-start; gap: 5px; - padding-left: 25% !important; + padding-left: 15% !important; + } + p.font_legend { + display: block; + text-align: start; + margin: 15px !important; + padding: 0px !important; } .font_example { margin: 5px 10px 10px 10px !important; @@ -516,6 +526,10 @@ content: '⭐️'; font-size: 1.4em; } + .font_bugged::after { + content: '🐛'; + font-size: 1.4em; + } .webfont::before { content: '🌐'; font-size: 1.4em; From 16f75e303e997c7c16ffb8a1dac7798dfd7f641d Mon Sep 17 00:00:00 2001 From: Marco Omainska Date: Thu, 4 May 2023 16:12:04 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=A9=B9=20fix=20sizing=20and=20example?= =?UTF-8?q?=20sentence=20rendering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jitai.user.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Jitai.user.js b/Jitai.user.js index bb25437..5cf3cf4 100644 --- a/Jitai.user.js +++ b/Jitai.user.js @@ -3,7 +3,7 @@ // @author @marciska // @namespace marciska // @description Displays your WaniKani reviews with randomized fonts (based on original by @obskyr) -// @version 3.2 +// @version 3.2.1 // @icon https://raw.github.com/marciska/Jitai/master/imgs/jitai.ico // @match https://*.wanikani.com/subjects/review* // @match https://*.wanikani.com/subjects/extra_study* @@ -27,7 +27,8 @@ const item_element = document.getElementsByClassName("character-header__characters")[0]; // ----- Fonts ----- - const example_sentence = '質問:私立探偵 (P.I.) はどんな靴を履いていますか?
答え:・・・スニーカー。(笑)'; + // const example_sentence = '質問:私立探偵 (P.I.) はどんな靴を履いていますか?
答え:・・・スニーカー。(笑)'; + const example_sentence = '質問:クモの味は何だと思う?
答え:・・・酸っぱいだ!(笑)'; let font_default = {display_name:'Default Font', full_font_name:getDefaultFont()}; let font_randomized = font_default; @@ -115,7 +116,8 @@ } function settingsPrepare(dialog) { - dialog.dialog({width:720}); + // dialog.dialog({width:720}); + dialog.dialog({width:500}); } async function settingsSave(settings) { await wkof.Settings.save(script_id); @@ -251,7 +253,7 @@ }, legend: { type: 'html', - html: `
: Recommended Font: Imported as webfont (click to download): Bugged on Safari (and Firefox if tracking prevention enabled)

Don't worry about fonts that don't come with all Kanjis (shown as invisible glyphs). Jitai will during review only choose fonts that can fully represent the current review item.

` + html: `
: Recommended Font: Imported as webfont (click to download): Bugged on Safari (and some Firefox settings)

Don't worry about fonts that don't come with all Kanjis (shown as invisible glyphs). Jitai will during review only choose fonts that can fully represent the current review item.

` }, divider_available: { type: 'section', @@ -264,7 +266,7 @@ }, legend_fonts_unavailable: { type: 'html', - html: `
: Local font available for download. Click on link to visit website.
` + html: `
: Local font available. Click to visit download website.
` }, ...font_unavailable_selector } @@ -509,7 +511,7 @@ flex-direction: column; align-items: flex-start; gap: 5px; - padding-left: 15% !important; + padding-left: 5% !important; } p.font_legend { display: block; From d5fc542a99f331d5d2da61aa4aedbe1f164356a5 Mon Sep 17 00:00:00 2001 From: Marco Omainska Date: Thu, 4 May 2023 18:49:11 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=A9=B9=20some=20vizualization=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jitai.user.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Jitai.user.js b/Jitai.user.js index 5cf3cf4..b3b6335 100644 --- a/Jitai.user.js +++ b/Jitai.user.js @@ -3,7 +3,7 @@ // @author @marciska // @namespace marciska // @description Displays your WaniKani reviews with randomized fonts (based on original by @obskyr) -// @version 3.2.1 +// @version 3.2.2 // @icon https://raw.github.com/marciska/Jitai/master/imgs/jitai.ico // @match https://*.wanikani.com/subjects/review* // @match https://*.wanikani.com/subjects/extra_study* @@ -69,8 +69,8 @@ "AB-Karuta-El" : {full_font_name: "ab-karuta-el", display_name: "AB Karuta El", url: 'adobe', download: 'http://www.font1000.com', recommended: false, bugged: true}, "AB-Kikori" : {full_font_name: "ab-kikori", display_name: "AB Kikori", url: 'adobe', download: 'http://www.font1000.com', recommended: false, bugged: true}, "AB-Kouran-Gyosho" : {full_font_name: "ab-kouran-gyosho", display_name: "AB Kouran Gyosho", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false, bugged: true}, - "AB-Shinyubipenjigyosyotai" : {full_font_name: "ab-shinyubipenjigyosyotai", display_name: "AB Shinyubipenjigyosyotai", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: false, bugged: false}, - "Hakusyu-Sosho" : {full_font_name: "hot-soshokk, HakusyuSosho", display_name: "Hakusyu Sosho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: true, bugged: false}, + "AB-Shinyubipenjigyosyotai" : {full_font_name: "ab-shinyubipenjigyosyotai", display_name: "AB Shinyubipenjigyosyotai", url: 'adobe', download: 'https://fonts.adobe.com/foundries/tegakiya-honpo', recommended: true, bugged: false}, + "Hakusyu-Sosho" : {full_font_name: "hot-soshokk, HakusyuSosho", display_name: "Hakusyu Sosho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: false, bugged: false}, "Hakusyu-Tensho" : {full_font_name: "hot-tenshokk, HakusyuTensho", display_name: "Hakusyu Tensho", url: 'adobe', download: 'https://www.hakusyu.com/download_education.htm', recommended: false, bugged: false}, // Other popular fonts "ArmedBanana" : {full_font_name: "ArmedBanana", display_name: "Armed Banana", url: 'https://marciska.github.io/Jitai-Fonts/ArmedBanana.css', download: 'http://calligra-tei.oops.jp/download.html', recommended: true, bugged: false}, @@ -185,13 +185,13 @@ } else if (value.url === 'adobe') { // ADOBE WEBFONT fonts_available[fontkey] = value; } else { // GENERAL WEBFONT - if (isFontInstalled(value.full_font_name)) { - fonts_available[fontkey] = value; - fonts_available[fontkey].url = 'local'; - } else { - installWebfont(value.full_font_name, value.url); - fonts_available[fontkey] = value; - } + // if (isFontInstalled(value.full_font_name)) { + // fonts_available[fontkey] = value; + // fonts_available[fontkey].url = 'local'; + // } else { + installWebfont(value.full_font_name, value.url); + fonts_available[fontkey] = value; + // } } } From f01ed41b9e62437635e8e1cbd8a077d2967fd9fc Mon Sep 17 00:00:00 2001 From: Pacharapol Withayasakpunt Date: Fri, 9 Jun 2023 16:40:19 +0700 Subject: [PATCH 6/6] font list as fallback; click to change font canvas support isn't yet guaranteed --- Jitai.user.js | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/Jitai.user.js b/Jitai.user.js index b3b6335..6a76b8d 100644 --- a/Jitai.user.js +++ b/Jitai.user.js @@ -31,7 +31,7 @@ const example_sentence = '質問:クモの味は何だと思う?
答え:・・・酸っぱいだ!(笑)'; let font_default = {display_name:'Default Font', full_font_name:getDefaultFont()}; - let font_randomized = font_default; + let font_randomized = [font_default]; // available fonts let font_pool = { @@ -165,9 +165,6 @@ } } - // randomly shuffle font pool - shuffleArray(font_pool_selected); - updateRandomFont(true); } @@ -243,11 +240,11 @@ content: { currentfont: { type: 'group', - label: `Current Font: ${font_randomized.display_name}`, + label: `Current Font: ${font_randomized[0].display_name}`, content: { sampletext: { type: 'html', - html: `

${example_sentence}

` + html: `

${example_sentence}

` } } }, @@ -401,31 +398,32 @@ } } + function makeFontRandomizedString() { + return font_randomized.map((f) => f.full_font_name).join(',') + } + function updateRandomFont(update) { // choose new random font if (update) { const glyphs = item_element.innerText; if (font_pool_selected.length == 0) { console.log(script_name+': empty font pool!') - font_randomized = font_default; + font_randomized = [font_default]; } else { - let i = 0; - do { - i = i + 1; - font_randomized = font_pool_selected[Math.floor(Math.random() * font_pool_selected.length)]; - } while (!canRepresentGlyphs(font_randomized.full_font_name, glyphs) && i < 100); - if (i >= 100) { - font_randomized = font_default; - } + const f0 = font_randomized.shift(); + font_randomized = font_pool_selected.filter((f) => f !== f0 && canRepresentGlyphs(f.full_font_name, glyphs)); + shuffleArray(font_randomized); + font_randomized.push(f0); + font_randomized.push(font_default); } } // show font if (hover_flipped) { item_element.style.setProperty("--font-family-japanese", font_default.full_font_name); - item_element.style.setProperty("--font-family-japanese-hover", font_randomized.full_font_name); + item_element.style.setProperty("--font-family-japanese-hover", makeFontRandomizedString()); } else { - item_element.style.setProperty("--font-family-japanese", font_randomized.full_font_name); + item_element.style.setProperty("--font-family-japanese", makeFontRandomizedString()); item_element.style.setProperty("--font-family-japanese-hover", font_default.full_font_name); } } @@ -446,12 +444,24 @@ hover_flipped = true; updateRandomFont(false); }); - + // on advancing to next item question, randomize font again global.addEventListener("willShowNextQuestion", function(event) { hover_flipped = false; updateRandomFont(true); + + const characterEl = document.querySelector(".character-header__characters"); + if (characterEl && !characterEl.onclick) { + characterEl.onclick = () => { + updateRandomFont(true); + item_element.style.setProperty("--font-family-japanese-hover", makeFontRandomizedString()); + characterEl.onmouseleave = () => { + updateRandomFont(false); + characterEl.onmouseleave = null; + } + }; + } }); // on reverting an answer by DoubleCheckScript, reroll random font and fix inverting of hovering