diff --git a/chrome/content/zotero/preferences/preferences_general.js b/chrome/content/zotero/preferences/preferences_general.js
index 8b53513ebd..28d16f9ac5 100644
--- a/chrome/content/zotero/preferences/preferences_general.js
+++ b/chrome/content/zotero/preferences/preferences_general.js
@@ -54,6 +54,7 @@ Zotero_Preferences.General = {
this.refreshLocale();
this.updateAutoRenameFilesUI();
this._updateFileHandlerUI();
+ this._initEbookFontFamilyMenu();
},
_getAutomaticLocaleMenuLabel: function () {
@@ -364,5 +365,54 @@ Zotero_Preferences.General = {
setTimeout(() => {
this.updateOpenURLResolversMenu();
});
- }
+ },
+
+ EBOOK_FONT_STACKS: {
+ Baskerville: 'Baskerville, serif',
+ Charter: 'Charter, serif',
+ Futura: 'Futura, sans-serif',
+ Georgia: 'Georgia, serif',
+ // Helvetica and equivalent-ish
+ Helvetica: 'Helvetica, Arial, Open Sans, Liberation Sans, sans-serif',
+ Iowan: 'Iowan, serif',
+ 'New York': 'New York, serif',
+ OpenDyslexic: 'OpenDyslexic, eulexia, serif',
+ // Windows has called Palatino by many names
+ Palatino: 'Palatino, Palatino Linotype, Adobe Palatino, Book Antiqua, URW Palladio L, FPL Neu, Domitian, serif',
+ // Times New Roman and equivalent-ish
+ 'Times New Roman': 'Times New Roman, Linux Libertine, Liberation Serif, serif',
+ },
+
+ async _initEbookFontFamilyMenu() {
+ let enumerator = Cc["@mozilla.org/gfx/fontenumerator;1"].createInstance(Ci.nsIFontEnumerator);
+ let fonts = new Set(await enumerator.EnumerateAllFontsAsync());
+
+ let menulist = document.getElementById('reader-ebook-font-family');
+ let popup = menulist.menupopup;
+ for (let [label, stack] of Object.entries(this.EBOOK_FONT_STACKS)) {
+ // If no font in the stack exists on the user's system, don't add it to the list
+ // Exclude the generic family name at the end, which is only there in case no font specified by name in the
+ // stack supports a specific character (e.g. non-Latin)
+ if (!stack.split(', ').slice(0, -1).some(font => fonts.has(font))) {
+ continue;
+ }
+
+ let menuitem = document.createXULElement('menuitem');
+ menuitem.label = label;
+ menuitem.value = stack;
+ menuitem.style.fontFamily = stack;
+ popup.append(menuitem);
+ }
+
+ if (popup.childElementCount && fonts.size) {
+ popup.append(document.createXULElement('menuseparator'));
+ }
+ for (let font of fonts) {
+ let menuitem = document.createXULElement('menuitem');
+ menuitem.label = font;
+ menuitem.value = font;
+ menuitem.style.fontFamily = `'${font.replace(/'/g, "\\'")}'`;
+ popup.append(menuitem);
+ }
+ },
}
diff --git a/chrome/content/zotero/preferences/preferences_general.xhtml b/chrome/content/zotero/preferences/preferences_general.xhtml
index 34b440dcc3..9cea897658 100644
--- a/chrome/content/zotero/preferences/preferences_general.xhtml
+++ b/chrome/content/zotero/preferences/preferences_general.xhtml
@@ -139,33 +139,40 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/chrome/content/zotero/xpcom/reader.js b/chrome/content/zotero/xpcom/reader.js
index b253bcab60..7d0636d47d 100644
--- a/chrome/content/zotero/xpcom/reader.js
+++ b/chrome/content/zotero/xpcom/reader.js
@@ -181,6 +181,7 @@ class ReaderInstance {
...Zotero.Intl.getPrefixedStrings('pdfReader.')
},
showAnnotations: true,
+ fontFamily: Zotero.Prefs.get('reader.ebookFontFamily'),
onOpenContextMenu: () => {
// Functions can only be passed over wrappedJSObject (we call back onClick for context menu items)
this._openContextMenu(this._iframeWindow.wrappedJSObject.contextMenuParams);
@@ -472,7 +473,8 @@ class ReaderInstance {
this._prefObserverIDs = [
Zotero.Prefs.registerObserver('fontSize', this._handleFontSizeChange),
- Zotero.Prefs.registerObserver('tabs.title.reader', this._handleTabTitlePrefChange)
+ Zotero.Prefs.registerObserver('tabs.title.reader', this._handleTabTitlePrefChange),
+ Zotero.Prefs.registerObserver('reader.ebookFontFamily', this._handleFontFamilyChange),
];
return true;
@@ -703,6 +705,10 @@ class ReaderInstance {
this._internalReader.setFontSize(Zotero.Prefs.get('fontSize'));
};
+ _handleFontFamilyChange = () => {
+ this._internalReader.setFontFamily(Zotero.Prefs.get('reader.ebookFontFamily'));
+ };
+
_dataURLtoBlob(dataurl) {
let parts = dataurl.split(',');
let mime = parts[0].match(/:(.*?);/)[1];
diff --git a/chrome/locale/en-US/zotero/preferences.dtd b/chrome/locale/en-US/zotero/preferences.dtd
index d53efcc043..86f9c082fa 100644
--- a/chrome/locale/en-US/zotero/preferences.dtd
+++ b/chrome/locale/en-US/zotero/preferences.dtd
@@ -29,11 +29,12 @@
-
+
+
diff --git a/defaults/preferences/zotero.js b/defaults/preferences/zotero.js
index 8e7a6f279f..8b6ad17215 100644
--- a/defaults/preferences/zotero.js
+++ b/defaults/preferences/zotero.js
@@ -212,3 +212,6 @@ pref("extensions.zotero.scaffold.eslint.enabled", true);
// Tabs
pref("extensions.zotero.tabs.title.reader", "titleCreatorYear");
+
+// Reader
+pref("extensions.zotero.reader.ebookFontFamily", "Georgia, serif");