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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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