diff --git a/ankiqt/config.py b/ankiqt/config.py index 2ed484669..25f8dfee1 100644 --- a/ankiqt/config.py +++ b/ankiqt/config.py @@ -112,7 +112,6 @@ class Config(dict): 'syncOnProgramOpen': True, 'syncPassword': "", 'syncUsername': "", - 'typeAnswerFontSize': 20, } # disable sync on deck load when upgrading if not self.has_key("syncOnProgramOpen"): diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py index 6dfe0a0d8..3f2089aa6 100755 --- a/ankiqt/ui/main.py +++ b/ankiqt/ui/main.py @@ -636,12 +636,6 @@ counts are %d %d %d self.typeAnswerField = QLineEditNoUndo(self) self.typeAnswerField.setObjectName("typeAnswerField") self.typeAnswerField.setFixedWidth(351) - f = QFont() - f.setPixelSize(self.config['typeAnswerFontSize']) - self.typeAnswerField.setFont(f) - # add some extra space as layout is wrong on osx - self.typeAnswerField.setFixedHeight( - self.typeAnswerField.sizeHint().height() + 10) vbox = QVBoxLayout() vbox.setSpacing(0) vbox.setContentsMargins(0,0,0,0) diff --git a/ankiqt/ui/view.py b/ankiqt/ui/view.py index a535679ba..8fba34851 100644 --- a/ankiqt/ui/view.py +++ b/ankiqt/ui/view.py @@ -150,9 +150,10 @@ class View(object): if (self.state != self.oldState and not nosound and self.main.config['autoplaySounds']): playFromText(q) + if self.main.currentCard.cardModel.typeAnswer: + self.adjustInputFont() - def calculateOkBadStyle(self): - "Precalculates styles for correct and incorrect part of answer" + def getFont(self): sz = 20 fn = u"Arial" for fm in self.main.currentCard.fact.model.fieldModels: @@ -160,6 +161,22 @@ class View(object): sz = fm.quizFontSize or sz fn = fm.quizFontFamily or fn break + return (fn, sz) + + def adjustInputFont(self): + (fn, sz) = self.getFont() + f = QFont() + f.setFamily(fn) + f.setPixelSize(sz) + self.main.typeAnswerField.setFont(f) + # add some extra space as layout is wrong on osx + self.main.typeAnswerField.setFixedHeight( + self.main.typeAnswerField.sizeHint().height() + 10) + + + def calculateOkBadStyle(self): + "Precalculates styles for correct and incorrect part of answer" + (fn, sz) = self.getFont() st = "background: %s; color: #000; font-size: %dpx; font-family: %s;" self.styleOk = st % (passedCharColour, sz, fn) self.styleBad = st % (failedCharColour, sz, fn)