mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
add hack for font name consistency issue
https://anki.tenderapp.com/discussions/ankidesktop/30785-bug-font-not-applying-to-japanese-characters
This commit is contained in:
parent
09ff23dc70
commit
ed411b0cc9
1 changed files with 10 additions and 2 deletions
|
@ -17,7 +17,7 @@ from aqt.qt import *
|
||||||
from anki.utils import stripHTML, isWin, isMac, namedtmp, json, stripHTMLMedia, \
|
from anki.utils import stripHTML, isWin, isMac, namedtmp, json, stripHTMLMedia, \
|
||||||
checksum
|
checksum
|
||||||
import anki.sound
|
import anki.sound
|
||||||
from anki.hooks import runHook, runFilter
|
from anki.hooks import runHook, runFilter, addHook
|
||||||
from aqt.sound import getAudio
|
from aqt.sound import getAudio
|
||||||
from aqt.webview import AnkiWebView
|
from aqt.webview import AnkiWebView
|
||||||
from aqt.utils import shortcut, showInfo, showWarning, getFile, \
|
from aqt.utils import shortcut, showInfo, showWarning, getFile, \
|
||||||
|
@ -331,7 +331,8 @@ class Editor:
|
||||||
oncallback)
|
oncallback)
|
||||||
|
|
||||||
def fonts(self):
|
def fonts(self):
|
||||||
return [(f['font'], f['size'], f['rtl'])
|
return [(runFilter("mungeEditingFontName", f['font']),
|
||||||
|
f['size'], f['rtl'])
|
||||||
for f in self.note.model()['flds']]
|
for f in self.note.model()['flds']]
|
||||||
|
|
||||||
def saveNow(self, callback, keepFocus=False):
|
def saveNow(self, callback, keepFocus=False):
|
||||||
|
@ -983,3 +984,10 @@ class EditorWebView(AnkiWebView):
|
||||||
a.triggered.connect(self.onPaste)
|
a.triggered.connect(self.onPaste)
|
||||||
runHook("EditorWebView.contextMenuEvent", self, m)
|
runHook("EditorWebView.contextMenuEvent", self, m)
|
||||||
m.popup(QCursor.pos())
|
m.popup(QCursor.pos())
|
||||||
|
|
||||||
|
# QFont returns "Kozuka Gothic Pro L" but WebEngine expects "Kozuka Gothic Pro"
|
||||||
|
# - there may be other cases like a trailing 'Bold' that need fixing, but will
|
||||||
|
# wait for further reports first.
|
||||||
|
def fontMungeHack(font):
|
||||||
|
return re.sub(" L$", "", font)
|
||||||
|
addHook("mungeEditingFontName", fontMungeHack)
|
||||||
|
|
Loading…
Reference in a new issue