mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
use a platform-specific font
This commit is contained in:
parent
2bad230ca5
commit
4fd1da00fd
7 changed files with 26 additions and 16 deletions
|
@ -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):
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -119,10 +119,6 @@ color: #000;
|
|||
.hitem:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
button {
|
||||
font-weight: bold;
|
||||
}
|
||||
"""
|
||||
|
||||
class BottomBar(Toolbar):
|
||||
|
|
|
@ -345,6 +345,11 @@ def maybeHideClose(bbox):
|
|||
if b:
|
||||
bbox.removeButton(b)
|
||||
|
||||
def fontForPlatform():
|
||||
if isMac:
|
||||
return "Lucida Grande"
|
||||
return "Arial"
|
||||
|
||||
# Tooltips
|
||||
######################################################################
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue