This repository has been archived by the owner on Oct 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathFonts.py
97 lines (84 loc) · 2.7 KB
/
Fonts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright (c) 2011-2015 Rusty Wagner
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from PySide.QtCore import *
from PySide.QtGui import *
monospaceFont = None
lineSpacing = None
allowBold = None
def getDefaultMonospaceFont():
if sys.platform == 'darwin':
font = QFont('Monaco', 12)
elif sys.platform.find('linux') != -1:
font = QFont('Monospace', 10)
elif sys.platform.find('freebsd') != -1:
font = QFont('Bitstream Vera Sans Mono', 10)
else:
font = QFont('Courier', 10)
return font
def getMonospaceFont():
global monospaceFont
if monospaceFont is None:
settings = QSettings("Binary Ninja", "Binary Ninja")
monospaceFont = settings.value("font", getDefaultMonospaceFont())
font = QFont(monospaceFont)
font.setFixedPitch(True)
font.setStyleHint(QFont.Courier)
return font
def setMonospaceFont(font):
global monospaceFont
if font is None:
font = getDefaultMonospaceFont()
monospaceFont = font
settings = QSettings("Binary Ninja", "Binary Ninja")
settings.setValue("font", monospaceFont)
def getDefaultExtraFontSpacing():
if sys.platform == 'darwin':
return 1
if sys.platform.find('freebsd') != -1:
return 2
return 0
def getExtraFontSpacing():
global lineSpacing
if lineSpacing is None:
settings = QSettings("Binary Ninja", "Binary Ninja")
lineSpacing = int(settings.value("spacing", getDefaultExtraFontSpacing()))
return lineSpacing
def setExtraFontSpacing(spacing):
global lineSpacing
if spacing is None:
spacing = getDefaultExtraFontSpacing()
lineSpacing = spacing
settings = QSettings("Binary Ninja", "Binary Ninja")
settings.setValue("spacing", lineSpacing)
def getFontVerticalOffset():
spacing = getExtraFontSpacing()
return int((spacing + 1) / 2)
def allowBoldFonts():
global allowBold
if allowBold is None:
settings = QSettings("Binary Ninja", "Binary Ninja")
allowBold = int(settings.value("allow_bold", 1)) != 0
return allowBold
def setAllowBoldFonts(allow):
global allowBold
if allow is None:
allow = True
allowBold = allow
settings = QSettings("Binary Ninja", "Binary Ninja")
if allowBold:
settings.setValue("allow_bold", 1)
else:
settings.setValue("allow_bold", 0)