From 0363cc70f445060c45b14ad416dd80f0a0c0db7c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 15 Dec 2010 03:52:18 +0900 Subject: [PATCH] preserve more of the old formatting on upgrade because field formatting is always on now, users with custom font sizes/families set only on the card will still have to alter their templates and either configure the fields or replace the references with triple curly braces --- anki/deck.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/anki/deck.py b/anki/deck.py index c5d7feeef..6a8c83995 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -4366,8 +4366,32 @@ or quizFontFamily is null""") deck.version = 57 deck.s.commit() if deck.version < 61: - # because we've changed the way latex is handled, we're going to - # need to rebuild the q/a + txt = '''\ +%s''' + for m in deck.models: + for cm in m.cardModels: + # embed the old font information into card templates if + # it's been customized + if (cm.questionFontFamily != "Arial" or + cm.questionFontSize != 20 or + cm.questionFontColour != "#000000"): + cm.qformat = txt % ( + cm.questionFontFamily, + cm.questionFontSize, + cm.questionFontColour, + cm.qformat) + if (cm.answerFontFamily != "Arial" or + cm.answerFontSize != 20 or + cm.answerFontColour != "#000000"): + cm.aformat = txt % ( + cm.answerFontFamily, + cm.answerFontSize, + cm.answerFontColour, + cm.aformat) + # fix newlines + cm.qformat = cm.qformat.replace("\n", "
\n") + cm.aformat = cm.aformat.replace("\n", "
\n") + # rebuild q/a for the above & because latex has changed for m in deck.models: deck.updateCardsFromModel(m, dirty=False) # rebuild the media db based on new format