From d09f7605f133d6c3d899ebe57e54f03dcabd1ad9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 19 May 2017 07:23:53 +0530 Subject: [PATCH] Fix font in embedded iframe different from rest of interface --- src/pyj/book_list/main.pyj | 3 ++- src/pyj/read_book/view.pyj | 9 +++++---- src/pyj/utils.pyj | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pyj/book_list/main.pyj b/src/pyj/book_list/main.pyj index c798d14fa0..9e83e5653f 100644 --- a/src/pyj/book_list/main.pyj +++ b/src/pyj/book_list/main.pyj @@ -14,7 +14,7 @@ from utils import safe_set_inner_html from book_list.constants import book_list_container_id, read_book_container_id, INIT_ENDPOINT from book_list.library_data import fetch_init_data, update_library_data, url_books_query -from book_list.theme import get_color +from book_list.theme import get_color, get_font_family from book_list.router import update_window_title, set_default_mode_handler, apply_url, set_mode_handler, on_pop_state from book_list.globals import get_db, set_session_data, get_read_ui from book_list.ui import apply_url_state as book_list_mode_handler @@ -47,6 +47,7 @@ def onerror(msg, script_url, line_number, column_number, error_object): def init_ui(): + document.body.style.fontFamily = get_font_family() install_event_filters() set_default_mode_handler(book_list_mode_handler) window.onerror = onerror diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index d1d08fd2e5..439994ba52 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -21,7 +21,7 @@ from read_book.prefs.font_size import change_font_size_by from read_book.touch import set_left_margin_handler, set_right_margin_handler from read_book.toc import update_visible_toc_nodes from read_book.goto import get_next_section -from book_list.theme import get_color +from book_list.theme import get_color, get_font_family from utils import parse_url_params, username_key LOADING_DOC = ''' @@ -34,8 +34,8 @@ LOADING_DOC = ''' __SCRIPT__ end_script - -
+ +
__BS__
@@ -214,7 +214,8 @@ class View: main_js(None) self.src_doc = LOADING_DOC.replace( '__BS__', _('Bootstrapping book reader...')).replace( - '__SCRIPT__', iframe_script) + '__SCRIPT__', iframe_script).replace( + '__FONT__', get_font_family().replace('"', '"')) def init_iframe(self, iframe_script): self.encrypted_communications = False diff --git a/src/pyj/utils.pyj b/src/pyj/utils.pyj index a131ed5f33..1f6ddf1ab3 100644 --- a/src/pyj/utils.pyj +++ b/src/pyj/utils.pyj @@ -4,6 +4,7 @@ from __python__ import hash_literals from ajax import encode_query from encodings import hexlify +from book_list.theme import get_font_family def debounce(func, wait, immediate=False): # Returns a function, that, as long as it continues to be invoked, will not @@ -228,7 +229,7 @@ def sandboxed_html(html, style, sandbox): ans.setAttribute('seamless', '') ans.style.width = '100%' html = html or '' - css = 'html, body { margin: 0; padding: 0; } p:first-child { margin-top: 0; padding-top: 0; -webkit-margin-before: 0 }' + css = 'html, body { margin: 0; padding: 0; font-family: __FONT__ } p:first-child { margin-top: 0; padding-top: 0; -webkit-margin-before: 0 }'.replace('__FONT__', get_font_family()) css += style or '' ans.srcdoc = f'{html}' return ans