diff --git a/daemon.py b/daemon.py index 9fbfa2984..c3ed83122 100644 --- a/daemon.py +++ b/daemon.py @@ -2152,7 +2152,8 @@ class PubServer(BaseHTTPRequestHandler): debug: bool, access_keys: {}, default_timeline: str, theme_name: str, allow_local_network_access: bool, - system_language: str) -> None: + system_language: str, + dyslexic_font: bool) -> None: """Receive POST from webapp_theme_designer """ users_path = '/users/' + nickname @@ -2191,7 +2192,8 @@ class PubServer(BaseHTTPRequestHandler): allow_local_network_access, system_language) set_theme(base_dir, theme_name, domain, - allow_local_network_access, system_language) + allow_local_network_access, system_language, + dyslexic_font) if calling_domain.endswith('.onion') and onion_domain: origin_path_str = \ @@ -2240,7 +2242,7 @@ class PubServer(BaseHTTPRequestHandler): set_theme_from_designer(base_dir, theme_name, domain, theme_designer_params, allow_local_network_access, - system_language) + system_language, dyslexic_font) # set boolean values if 'rss-icon-at-top' in theme_designer_params: @@ -5066,7 +5068,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.theme_name = fields['themeDropdown'] set_theme(base_dir, self.server.theme_name, domain, allow_local_network_access, - system_language) + system_language, + self.server.dyslexic_font) self.server.text_mode_banner = \ get_text_mode_banner(self.server.base_dir) self.server.iconsCache = {} @@ -6002,7 +6005,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.allow_local_network_access set_theme(base_dir, curr_theme, domain, allow_local_network_access, - system_language) + system_language, + self.server.dyslexic_font) self.server.text_mode_banner = \ get_text_mode_banner(base_dir) self.server.iconsCache = {} @@ -6253,6 +6257,24 @@ class PubServer(BaseHTTPRequestHandler): else: disable_grayscale(base_dir) + # dyslexic font + if path.startswith('/users/' + admin_nickname + '/') or \ + is_artist(base_dir, nickname): + dyslexic_font = False + if fields.get('dyslexicFont'): + if fields['dyslexicFont'] == 'on': + dyslexic_font = True + if dyslexic_font != self.server.dyslexic_font: + self.server.dyslexic_font = dyslexic_font + set_config_param(base_dir, 'dyslexicFont', + self.server.dyslexic_font) + set_theme(base_dir, + self.server.theme_name, + self.server.domain, + self.server.allow_local_network_access, + self.server.system_language, + self.server.dyslexic_font) + # low bandwidth images checkbox if path.startswith('/users/' + admin_nickname + '/') or \ is_artist(base_dir, nickname): @@ -18137,7 +18159,8 @@ class PubServer(BaseHTTPRequestHandler): self.server.default_timeline, self.server.theme_name, allow_local_network_access, - self.server.system_language) + self.server.system_language, + self.server.dyslexic_font) self.server.postreq_busy = False return @@ -18627,7 +18650,8 @@ def load_tokens(base_dir: str, tokens_dict: {}, tokens_lookup: {}) -> None: break -def run_daemon(content_license_url: str, +def run_daemon(dyslexic_font: bool, + content_license_url: str, lists_enabled: str, default_reply_interval_hrs: int, low_bandwidth: bool, @@ -18718,6 +18742,8 @@ def run_daemon(content_license_url: str, httpd.post_to_nickname = None + httpd.dyslexic_font = dyslexic_font + # license for content of the instance if not content_license_url: content_license_url = 'https://creativecommons.org/licenses/by/4.0' diff --git a/epicyon.py b/epicyon.py index 35b798e0d..4cf35b9c9 100644 --- a/epicyon.py +++ b/epicyon.py @@ -381,6 +381,11 @@ parser.add_argument("--broch_mode", type=str2bool, nargs='?', const=True, default=False, help="Enable broch mode") +parser.add_argument("--dyslexic_font", + dest='dyslexic_font', + type=str2bool, nargs='?', + const=True, default=False, + help="Use dyslexic font") parser.add_argument("--nodeinfoaccounts", dest='show_node_info_accounts', type=str2bool, nargs='?', @@ -3120,11 +3125,14 @@ verify_all_signatures = \ if verify_all_signatures is not None: args.verify_all_signatures = bool(verify_all_signatures) -broch_mode = \ - get_config_param(base_dir, 'brochMode') +broch_mode = get_config_param(base_dir, 'brochMode') if broch_mode is not None: args.broch_mode = bool(broch_mode) +dyslexic_font = get_config_param(base_dir, 'dyslexicFont') +if dyslexic_font is not None: + args.dyslexic_font = bool(dyslexic_font) + log_login_failures = \ get_config_param(base_dir, 'logLoginFailures') if log_login_failures is not None: @@ -3188,7 +3196,8 @@ if twitter_domain: args.twitter_replacement_domain = twitter_domain if set_theme(base_dir, theme_name, domain, - args.allow_local_network_access, args.language): + args.allow_local_network_access, args.language, + args.dyslexic_font): print('Theme set to ' + theme_name) # whether new registrations are open or closed @@ -3217,7 +3226,8 @@ if args.defaultCurrency: print('Default currency set to ' + args.defaultCurrency) if __name__ == "__main__": - run_daemon(content_license_url, + run_daemon(args.dyslexic_font, + content_license_url, lists_enabled, args.default_reply_interval_hrs, args.low_bandwidth, args.max_like_count, diff --git a/fonts/LICENSES b/fonts/LICENSES index b55aca208..e0ef4501f 100644 --- a/fonts/LICENSES +++ b/fonts/LICENSES @@ -18,6 +18,7 @@ Minitel is GPL. See https://www.dafont.com/minitel.font Montserrat is under OFL and came from CCC Rc3 style guide https://styleguide.rc3.world Nimbus Sans L is GPL. See https://www.fontsquirrel.com/fonts/nimbus-sans-l Octavius is created by Jack Oatley and described as "100% free to use, though credit is appreciated" https://www.dafont.com/octavius.font +OpenDyslexic is under OFL. See https://github.com/antijingoist/opendyslexic Orbitron is under OFL and came from CCC Rc3 style guide https://styleguide.rc3.world RailModel is GPL. See https://www.fontspace.com/rail-model-font-f10741 Rainyhearts in public domain. By Camellina tr.camellina@gmail.com diff --git a/fonts/OpenDyslexic-Italic.woff2 b/fonts/OpenDyslexic-Italic.woff2 new file mode 100644 index 000000000..00c19082d Binary files /dev/null and b/fonts/OpenDyslexic-Italic.woff2 differ diff --git a/fonts/OpenDyslexic-Regular.otf b/fonts/OpenDyslexic-Regular.otf new file mode 100644 index 000000000..ebef13c4c Binary files /dev/null and b/fonts/OpenDyslexic-Regular.otf differ diff --git a/fonts/OpenDyslexic-Regular.woff b/fonts/OpenDyslexic-Regular.woff new file mode 100644 index 000000000..26a2934d6 Binary files /dev/null and b/fonts/OpenDyslexic-Regular.woff differ diff --git a/fonts/OpenDyslexic-Regular.woff2 b/fonts/OpenDyslexic-Regular.woff2 new file mode 100644 index 000000000..47e26d82a Binary files /dev/null and b/fonts/OpenDyslexic-Regular.woff2 differ diff --git a/tests.py b/tests.py index 07baf487c..635ef73cc 100644 --- a/tests.py +++ b/tests.py @@ -145,7 +145,7 @@ from content import replace_content_duplicates from content import remove_text_formatting from content import remove_html_tag from theme import update_default_themes_list -from theme import set_cs_sparam +from theme import set_css_param from theme import scan_themes_for_scripts from linked_data_sig import generate_json_signature from linked_data_sig import verify_json_signature @@ -813,8 +813,10 @@ def create_server_alice(path: str, domain: str, port: int, default_reply_interval_hrs = 9999999999 lists_enabled = '' content_license_url = 'https://creativecommons.org/licenses/by/4.0' + dyslexic_font = False print('Server running: Alice') - run_daemon(content_license_url, + run_daemon(dyslexic_font, + content_license_url, lists_enabled, default_reply_interval_hrs, low_bandwidth, max_like_count, shared_items_federated_domains, @@ -960,8 +962,10 @@ def create_server_bob(path: str, domain: str, port: int, default_reply_interval_hrs = 9999999999 lists_enabled = '' content_license_url = 'https://creativecommons.org/licenses/by/4.0' + dyslexic_font = False print('Server running: Bob') - run_daemon(content_license_url, + run_daemon(dyslexic_font, + content_license_url, lists_enabled, default_reply_interval_hrs, low_bandwidth, max_like_count, shared_items_federated_domains, @@ -1034,8 +1038,10 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [], default_reply_interval_hrs = 9999999999 lists_enabled = '' content_license_url = 'https://creativecommons.org/licenses/by/4.0' + dyslexic_font = False print('Server running: Eve') - run_daemon(content_license_url, + run_daemon(dyslexic_font, + content_license_url, lists_enabled, default_reply_interval_hrs, low_bandwidth, max_like_count, shared_items_federated_domains, @@ -1110,8 +1116,10 @@ def create_server_group(path: str, domain: str, port: int, default_reply_interval_hrs = 9999999999 lists_enabled = '' content_license_url = 'https://creativecommons.org/licenses/by/4.0' + dyslexic_font = False print('Server running: Group') - run_daemon(content_license_url, + run_daemon(dyslexic_font, + content_license_url, lists_enabled, default_reply_interval_hrs, low_bandwidth, max_like_count, shared_items_federated_domains, @@ -3576,18 +3584,18 @@ def _test_save_load_json(): def _test_theme(): print('test_theme') css = 'somestring --background-value: 24px; --foreground-value: 24px;' - result = set_cs_sparam(css, 'background-value', '32px') + result = set_css_param(css, 'background-value', '32px') assert result == \ 'somestring --background-value: 32px; --foreground-value: 24px;' css = \ 'somestring --background-value: 24px; --foreground-value: 24px; ' + \ '--background-value: 24px;' - result = set_cs_sparam(css, 'background-value', '32px') + result = set_css_param(css, 'background-value', '32px') assert result == \ 'somestring --background-value: 32px; --foreground-value: 24px; ' + \ '--background-value: 32px;' css = '--background-value: 24px; --foreground-value: 24px;' - result = set_cs_sparam(css, 'background-value', '32px') + result = set_css_param(css, 'background-value', '32px') assert result == '--background-value: 32px; --foreground-value: 24px;' diff --git a/theme.py b/theme.py index 25cb40619..a7a868a03 100644 --- a/theme.py +++ b/theme.py @@ -269,7 +269,7 @@ def _remove_theme(base_dir: str): base_dir + '/' + filename) -def set_cs_sparam(css: str, param: str, value: str) -> str: +def set_css_param(css: str, param: str, value: str) -> str: """Sets a CSS parameter to a given value """ # is this just a simple string replacement? @@ -380,7 +380,7 @@ def _set_theme_from_dict(base_dir: str, name: str, else: _set_publish_button_at_top(base_dir, False) continue - css = set_cs_sparam(css, param_name, param_value) + css = set_css_param(css, param_name, param_value) filename = base_dir + '/' + filename with open(filename, 'w+') as cssfile: cssfile.write(css) @@ -457,6 +457,27 @@ def disable_grayscale(base_dir: str) -> None: grayscale_filename) +def _set_dyslexic_font(base_dir: str) -> bool: + """sets the dyslexic font if needed + """ + theme_files = _get_theme_files() + for filename in theme_files: + template_filename = base_dir + '/' + filename + if not os.path.isfile(template_filename): + continue + with open(template_filename, 'r') as cssfile: + css = cssfile.read() + css = \ + set_css_param(css, "*src", + "url('./fonts/OpenDyslexic-Regular.woff2" + + "') format('woff2')") + css = set_css_param(css, "*font-family", "'OpenDyslexic'") + filename = base_dir + '/' + filename + with open(filename, 'w+') as cssfile: + cssfile.write(css) + return False + + def _set_custom_font(base_dir: str): """Uses a dictionary to set a theme """ @@ -484,12 +505,12 @@ def _set_custom_font(base_dir: str): with open(template_filename, 'r') as cssfile: css = cssfile.read() css = \ - set_cs_sparam(css, "*src", + set_css_param(css, "*src", "url('./fonts/custom." + custom_font_ext + "') format('" + custom_font_type + "')") - css = set_cs_sparam(css, "*font-family", "'CustomFont'") + css = set_css_param(css, "*font-family", "'CustomFont'") filename = base_dir + '/' + filename with open(filename, 'w+') as cssfile: cssfile.write(css) @@ -498,11 +519,13 @@ def _set_custom_font(base_dir: str): def set_theme_from_designer(base_dir: str, theme_name: str, domain: str, theme_params: {}, allow_local_network_access: bool, - system_language: str): + system_language: str, + dyslexic_font: bool): custom_theme_filename = base_dir + '/accounts/theme.json' save_json(theme_params, custom_theme_filename) set_theme(base_dir, theme_name, domain, - allow_local_network_access, system_language) + allow_local_network_access, system_language, + dyslexic_font) def reset_theme_designer_settings(base_dir: str, theme_name: str, domain: str, @@ -819,7 +842,8 @@ def _set_clear_cache_flag(base_dir: str) -> None: def set_theme(base_dir: str, name: str, domain: str, - allow_local_network_access: bool, system_language: str) -> bool: + allow_local_network_access: bool, system_language: str, + dyslexic_font: bool) -> bool: """Sets the theme with the given name as the current theme """ result = False @@ -862,7 +886,10 @@ def set_theme(base_dir: str, name: str, domain: str, _read_variables_file(base_dir, name, variables_file, allow_local_network_access) - _set_custom_font(base_dir) + if dyslexic_font: + _set_dyslexic_font(base_dir) + else: + _set_custom_font(base_dir) # set the news avatar news_avatar_theme_filename = \ diff --git a/translations/ar.json b/translations/ar.json index 07d6e5aed..43e8c65b0 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -503,5 +503,6 @@ "Reset": "إعادة ضبط", "Encryption Keys": "مفاتيح التشفير", "Filtered words within bio": "كلمات مفلترة داخل السيرة الذاتية", - "Write your news report": "اكتب تقريرك الإخباري" + "Write your news report": "اكتب تقريرك الإخباري", + "Dyslexic font": "الخط المعسر القراءة" } diff --git a/translations/ca.json b/translations/ca.json index 44f9bbf56..1b2342ef2 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -503,5 +503,6 @@ "Reset": "Restableix", "Encryption Keys": "Claus de xifratge", "Filtered words within bio": "Paraules filtrades dins de la biografia", - "Write your news report": "Escriu la teva notícia" + "Write your news report": "Escriu la teva notícia", + "Dyslexic font": "Tipus de lletra dislèxic" } diff --git a/translations/cy.json b/translations/cy.json index ade3b4cd2..23d6a5e9c 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -503,5 +503,6 @@ "Reset": "Ail gychwyn", "Encryption Keys": "Allweddi Amgryptio", "Filtered words within bio": "Geiriau wedi'u hidlo o fewn cofiant", - "Write your news report": "Ysgrifennwch eich adroddiad newyddion" + "Write your news report": "Ysgrifennwch eich adroddiad newyddion", + "Dyslexic font": "Ffont dyslecsig" } diff --git a/translations/de.json b/translations/de.json index 486108644..7e5fceb83 100644 --- a/translations/de.json +++ b/translations/de.json @@ -503,5 +503,6 @@ "Reset": "Zurücksetzen", "Encryption Keys": "Verschlüsselungsschlüssel", "Filtered words within bio": "Gefilterte Wörter in der Biografie", - "Write your news report": "Schreiben Sie Ihren Nachrichtenbericht" + "Write your news report": "Schreiben Sie Ihren Nachrichtenbericht", + "Dyslexic font": "Schriftart für Legastheniker" } diff --git a/translations/en.json b/translations/en.json index 509731bcb..3ffa0c475 100644 --- a/translations/en.json +++ b/translations/en.json @@ -503,5 +503,6 @@ "Reset": "Reset", "Encryption Keys": "Encryption Keys", "Filtered words within bio": "Filtered words within bio", - "Write your news report": "Write your news report" + "Write your news report": "Write your news report", + "Dyslexic font": "Dyslexic font" } diff --git a/translations/es.json b/translations/es.json index cad2b0fa5..46990fcba 100644 --- a/translations/es.json +++ b/translations/es.json @@ -503,5 +503,6 @@ "Reset": "Reiniciar", "Encryption Keys": "Claves de cifrado", "Filtered words within bio": "Palabras filtradas dentro de la biografía", - "Write your news report": "Escribe tu informe de noticias" + "Write your news report": "Escribe tu informe de noticias", + "Dyslexic font": "Fuente disléxica" } diff --git a/translations/fr.json b/translations/fr.json index c80c0f01e..275da9027 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -503,5 +503,6 @@ "Reset": "Réinitialiser", "Encryption Keys": "Clés de cryptage", "Filtered words within bio": "Mots filtrés dans la biographie", - "Write your news report": "Rédigez votre reportage" + "Write your news report": "Rédigez votre reportage", + "Dyslexic font": "Police dyslexique" } diff --git a/translations/ga.json b/translations/ga.json index 6403f181f..3a1734dd7 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -503,5 +503,6 @@ "Reset": "Athshocraigh", "Encryption Keys": "Eochracha Criptithe", "Filtered words within bio": "Focail scagtha laistigh den bheathaisnéis", - "Write your news report": "Scríobh do thuairisc nuachta" + "Write your news report": "Scríobh do thuairisc nuachta", + "Dyslexic font": "Cló disléicseach" } diff --git a/translations/hi.json b/translations/hi.json index 2075a6c93..b255d624c 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -503,5 +503,6 @@ "Reset": "रीसेट", "Encryption Keys": "एन्क्रिप्शन कुंजी", "Filtered words within bio": "जीवनी के भीतर फ़िल्टर किए गए शब्द", - "Write your news report": "अपनी समाचार रिपोर्ट लिखें" + "Write your news report": "अपनी समाचार रिपोर्ट लिखें", + "Dyslexic font": "डिस्लेक्सिक फ़ॉन्ट" } diff --git a/translations/it.json b/translations/it.json index 5317e383d..5b3e69552 100644 --- a/translations/it.json +++ b/translations/it.json @@ -503,5 +503,6 @@ "Reset": "Ripristina", "Encryption Keys": "Chiavi di crittografia", "Filtered words within bio": "Parole filtrate all'interno della biografia", - "Write your news report": "Scrivi il tuo reportage" + "Write your news report": "Scrivi il tuo reportage", + "Dyslexic font": "Carattere dislessico" } diff --git a/translations/ja.json b/translations/ja.json index 7e2249f12..d59daf636 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -503,5 +503,6 @@ "Reset": "リセット", "Encryption Keys": "暗号化キー", "Filtered words within bio": "伝記内のフィルタリングされた単語", - "Write your news report": "ニュースレポートを書く" + "Write your news report": "ニュースレポートを書く", + "Dyslexic font": "失読症フォント" } diff --git a/translations/ku.json b/translations/ku.json index 2dde594b0..e4355fc2e 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -503,5 +503,6 @@ "Reset": "Reset", "Encryption Keys": "Bişkojkên Şîfrekirinê", "Filtered words within bio": "Peyvên fîlterkirî di hundurê biyografiyê de", - "Write your news report": "Rapora xwe ya nûçeyan binivîsin" + "Write your news report": "Rapora xwe ya nûçeyan binivîsin", + "Dyslexic font": "Font Dyslexic" } diff --git a/translations/oc.json b/translations/oc.json index 43291df8b..25a6f04bd 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -499,5 +499,6 @@ "Reset": "Reset", "Encryption Keys": "Encryption Keys", "Filtered words within bio": "Filtered words within bio", - "Write your news report": "Write your news report" + "Write your news report": "Write your news report", + "Dyslexic font": "Dyslexic font" } diff --git a/translations/pt.json b/translations/pt.json index 56249adab..4bb1e17f0 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -503,5 +503,6 @@ "Reset": "Redefinir", "Encryption Keys": "Chaves de criptografia", "Filtered words within bio": "Palavras filtradas na biografia", - "Write your news report": "Escreva sua reportagem" + "Write your news report": "Escreva sua reportagem", + "Dyslexic font": "Fonte disléxica" } diff --git a/translations/ru.json b/translations/ru.json index d796c6564..a2ec2fab9 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -503,5 +503,6 @@ "Reset": "Сброс настроек", "Encryption Keys": "Ключи шифрования", "Filtered words within bio": "Отфильтрованные слова в биографии", - "Write your news report": "Напишите свой новостной репортаж" + "Write your news report": "Напишите свой новостной репортаж", + "Dyslexic font": "Дислексический шрифт" } diff --git a/translations/sw.json b/translations/sw.json index e19823ac5..51ba6667f 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -503,5 +503,6 @@ "Reset": "Weka upya", "Encryption Keys": "Vifunguo vya Usimbaji", "Filtered words within bio": "Maneno yaliyochujwa ndani ya wasifu", - "Write your news report": "Andika ripoti yako ya habari" + "Write your news report": "Andika ripoti yako ya habari", + "Dyslexic font": "Fonti ya Dyslexic" } diff --git a/translations/zh.json b/translations/zh.json index c27204325..f11fe1d46 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -503,5 +503,6 @@ "Reset": "重启", "Encryption Keys": "加密密钥", "Filtered words within bio": "传记中的过滤词", - "Write your news report": "写你的新闻报道" + "Write your news report": "写你的新闻报道", + "Dyslexic font": "阅读障碍字体" } diff --git a/webapp_profile.py b/webapp_profile.py index 0bda50f92..322b5046e 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1239,6 +1239,10 @@ def _html_themes_dropdown(base_dir: str, translate: {}) -> str: grayscale = _grayscale_enabled(base_dir) themes_dropdown += \ edit_check_box(translate['Grayscale'], 'grayscale', grayscale) + dyslexic_font = get_config_param(base_dir, 'dyslexicFont') + themes_dropdown += \ + edit_check_box(translate['Dyslexic font'], 'dyslexicFont', + dyslexic_font) themes_dropdown += '