saketh / notalon (http://notalon.org/)

Notalon is note-taking, simplified. It is a note-taking software for students, lifting the burden of formatting so that you can focus on taking notes.

Clone this repository (size: 2.2 MB): HTTPS / SSH
$ hg clone http://bitbucket.org/saketh/notalon/
commit 137: c6050705c1c3
parent 136: c914ab5d5c2f
branch: default
called loadFonts with path explicitly, instead of through __builtin__ homepath
Saketh Bhamidipati
7 months ago

Changed (Δ345 bytes):

raw changeset »

notalonlib/pdf/writer.py (18 lines added, 11 lines removed)

notalonlib/window.py (15 lines added, 11 lines removed)

Up to file-list notalonlib/pdf/writer.py:

@@ -34,19 +34,26 @@ from reportlab.platypus.doctemplate impo
34
34
from reportlab.platypus.frames import Frame
35
35
from reportlab.rl_config import defaultPageSize
36
36
37
def loadFonts(fontpath):
38
    """
39
    Loads all fonts for use in ReportLab.
40
    """
41
    log.debug('Attempting to load fonts from %s...' % fontpath)
37
42
38
# Globally register Gentium family of fonts
39
registerFont(TTFont("Gentium", os.path.join('res', "GenBkBasR.ttf")))
40
registerFont(TTFont("Gentium-B", os.path.join('res', "GenBkBasB.ttf")))
41
registerFont(TTFont("Gentium-I", os.path.join('res', "GenBkBasI.ttf")))
42
registerFont(TTFont("Gentium-BI", os.path.join('res', "GenBkBasBI.ttf")))
43
fonts.addMapping('Gentium', 0, 0, 'Gentium')
44
fonts.addMapping('Gentium', 0, 1, 'Gentium-I')
45
fonts.addMapping('Gentium', 1, 0, 'Gentium-B')
46
fonts.addMapping('Gentium', 1, 1, 'Gentium-BI')
47
fonts._ps2tt_map.update({'Gentium': ('Gentium', 0, 0)})
43
    # Globally register Gentium family of fonts
44
    registerFont(TTFont("Gentium", os.path.join(fontpath, "GenBkBasR.ttf")))
45
    registerFont(TTFont("Gentium-B", os.path.join(fontpath, "GenBkBasB.ttf")))
46
    registerFont(TTFont("Gentium-I", os.path.join(fontpath, "GenBkBasI.ttf")))
47
    registerFont(TTFont("Gentium-BI", os.path.join(fontpath, "GenBkBasBI.ttf")))
48
    fonts.addMapping('Gentium', 0, 0, 'Gentium')
49
    fonts.addMapping('Gentium', 0, 1, 'Gentium-I')
50
    fonts.addMapping('Gentium', 1, 0, 'Gentium-B')
51
    fonts.addMapping('Gentium', 1, 1, 'Gentium-BI')
52
    fonts._ps2tt_map.update({'Gentium': ('Gentium', 0, 0)})
48
53
49
registerFont(TTFont("Optimus-Princeps-SemiBold", os.path.join('res', "OptimusPrincepsSemiBold.ttf")))
54
    registerFont(TTFont("Optimus-Princeps-SemiBold", os.path.join(fontpath, "OptimusPrincepsSemiBold.ttf")))
55
56
    log.debug('Loaded fonts from %s' % fontpath)
50
57
51
58
TITLE_FONTNAME = "Optimus-Princeps-SemiBold"
52
59
HEAD_FONTNAME = "Gentium" # either "Times-Roman" or "Gentium"

Up to file-list notalonlib/window.py:

@@ -38,21 +38,23 @@ except ImportError:
38
38
39
39
from wx.lib.dialogs import ScrolledMessageDialog
40
40
41
from widgets.statusbar import StatusBar
42
from widgets.treectrl import *
43
from widgets.textctrl import *
44
from widgets.undo import UndoManager
45
from widgets.filedroptarget import FileDropTarget
46
from widgets.tipprovider import PyTipProvider
41
from preferences.preferences import NotalonPreferences
42
from resource.resin import Resin
43
from widgets.dialogs.about import AboutDialog
47
44
from widgets.dialogs.find import FindDialog
48
45
from widgets.dialogs.replace import ReplaceDialog
49
from widgets.dialogs.about import AboutDialog
50
from preferences.preferences import NotalonPreferences
51
from resource.resin import Resin
46
from widgets.filedroptarget import FileDropTarget
47
from widgets.statusbar import StatusBar
48
from widgets.textctrl import *
49
from widgets.tipprovider import PyTipProvider
50
from widgets.treectrl import *
51
from widgets.undo import UndoManager
52
52
53
53
from widgets.dialogs.preferences import PreferencesDialog
54
54
from widgets.dialogs.source import BookSourceDialog, LectureSourceDialog
55
55
56
from pdf.writer import PDFWriter, loadFonts # loads fonts
57
56
58
import meta.properties
57
59
58
60
# So that we can use sys.setdefaultencoding
@@ -82,6 +84,9 @@ class NotalonWindow(wx.Frame):
82
84
        # Preferences reader
83
85
        self.preffer = NotalonPreferences(os.path.join(homepath, "preferences.xml"))
84
86
        framesize = (self.preffer.getValue("framewidth"), self.preffer.getValue("frameheight"))
87
88
        # PDFWriter
89
        loadFonts(os.path.join(homepath, 'res'))
85
90
        
86
91
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=framesize, style=style)
87
92
@@ -1488,7 +1493,7 @@ class NotalonWindow(wx.Frame):
1488
1493
1489
1494
    def OnExportPDF(self, e):
1490
1495
        log.debug('Entered OnExportPDF')
1491
        # If there's no headings, there there will be a corrupted PDF. 
1496
        # If there are no headings, then there will be a corrupted PDF. 
1492
1497
        if not self.tree.ItemHasChildren(self.tree.GetRootItem()):
1493
1498
            d = wx.MessageDialog(self,
1494
1499
                                _("You must have at least one heading before you can export to PDF."),
@@ -1519,7 +1524,6 @@ class NotalonWindow(wx.Frame):
1519
1524
        The program logic for this is in `notalonlib.pdf.writer.PDFWriter`.
1520
1525
1521
1526
        """
1522
        from pdf.writer import PDFWriter
1523
1527
        current = self.tree.GetRootItem()
1524
1528
1525
1529
        self.sb.addProgress(10)