use a platform-specific font

This commit is contained in:
Damien Elmes 2012-01-11 14:44:50 +09:00
parent 2bad230ca5
commit 4fd1da00fd
7 changed files with 26 additions and 16 deletions

View file

@ -10,7 +10,7 @@ import anki, anki.utils, aqt.forms
from anki.utils import fmtTimeSpan, ids2str, stripHTMLMedia, isWin, intTime
from aqt.utils import saveGeom, restoreGeom, saveSplitter, restoreSplitter, \
saveHeader, restoreHeader, saveState, restoreState, applyStyles, getTag, \
showInfo, askUser, tooltip, openHelp
showInfo, askUser, tooltip, openHelp, fontForPlatform
from anki.errors import *
from anki.db import *
from anki.hooks import runHook, addHook, remHook
@ -599,6 +599,9 @@ class Browser(QMainWindow):
p = QPalette()
p.setColor(QPalette.Base, QColor("#d6dde0"))
self.form.tree.setPalette(p)
f = QFont()
f.setFamily(fontForPlatform())
self.form.tree.setFont(f)
self.buildTree()
def buildTree(self):

View file

@ -122,7 +122,7 @@ h3 { margin-bottom: 0; }
td { font-size: 14px; }
button { font-weight: bold; }
.descfont {
font: 12px/18px "Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif;
font-size: 12px;
padding: 1em; color: #333;
}
.description {

View file

@ -11,7 +11,7 @@ import os, sys, time, random, cPickle, shutil, locale, re, atexit
from anki.db import DB
from anki.utils import isMac, isWin, intTime, checksum
from anki.lang import langs, _
from aqt.utils import showWarning
from aqt.utils import showWarning, fontForPlatform
import aqt.forms
metaConf = dict(
@ -40,7 +40,7 @@ profileConf = dict(
searchHistory=[],
recentColours=["#000000", "#0000ff"],
stripHTML=True,
editFontFamily='Arial',
editFontFamily=fontForPlatform(),
editFontSize=12,
editLineSize=20,
deleteMedia=False,

View file

@ -119,10 +119,6 @@ color: #000;
.hitem:hover {
text-decoration: underline;
}
button {
font-weight: bold;
}
"""
class BottomBar(Toolbar):

View file

@ -345,6 +345,11 @@ def maybeHideClose(bbox):
if b:
bbox.removeButton(b)
def fontForPlatform():
if isMac:
return "Lucida Grande"
return "Arial"
# Tooltips
######################################################################

View file

@ -4,6 +4,8 @@
import sys
from aqt.qt import *
from aqt.utils import fontForPlatform
from anki.utils import isMac
import anki.js
QtConfig = pyqtconfig.Configuration()
@ -80,13 +82,23 @@ class AnkiWebView(QWebView):
self._loadFinishedCB = loadCB
QWebView.setHtml(self, html)
def stdHtml(self, body, css="", bodyClass="", loadCB=None, head=""):
if isMac:
button = "font-weight: bold; height: 24px;"
else:
button = ""
self.setHtml("""
<html><head><style>%s</style>
<html><head><style>
body { font-family: "%s"; }
button {
%s
}
%s</style>
<script>%s</script>
%s
</head>
<body class="%s">%s</body></html>""" % (
css, anki.js.all, head, bodyClass, body), loadCB)
fontForPlatform(), button, css, anki.js.all, head, bodyClass, body), loadCB)
def setBridge(self, bridge):
self._bridge.setBridge(bridge)
def eval(self, js):

View file

@ -43,12 +43,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Helvetica</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>