Example #1
0
 def createFonts(self):
     self.fonts = {}
     font = Font()
     font.SetFaceName("Monospace")
     font.SetPointSize(10)
     self.fonts['monospace'] = font
     return
Example #2
0
def createFont(name='mono', face="Monospace", size=10):
    # make font
    font = Font()
    font.SetFaceName(face)
    font.SetPointSize(size)
    # add to dictionary
    _fonts[name] = font
    # done
    return
Example #3
0
 def _createFont(self, name, face, size):
     # make font
     font = Font()
     font.SetFaceName(face)
     font.SetPointSize(size)
     # add to dictionary
     self._fonts[name] = font
     # done
     return
Example #4
0
 def createFonts(self):
     # FONTS
     self.fonts = {}
     # monospace
     font = Font()
     font.SetFaceName("Monospace")
     font.SetPointSize(10)
     self.fonts['monospace'] = font
     # done
     return
 def _setBrailleFont(self, font: wx.Font) -> wx.Font:
     fonts.importFonts()
     fontName = "FreeMono-FixedBraille"
     # Ideally the raw characters should align with the braille dots.
     #
     # On most systems, it seems that Windows will fall back to using "Segoe UI Symbol" font.
     # The width of BRAILLE_SPACE_CHARACTER ('no pins up') does not match the other braille characters.
     # This causes variations in the length of the braille text, particularly when the cursor is flashing.
     # The other disadvantage of using this font is that it is difficult to get its width to match the width
     # of the raw text characters.
     # These issues are solved by using a custom font (FreeMono-FixedBraille), which due to its free (GPL 3)
     # status, allowed us to modify it, and fix the visual issues that it also had.
     #
     # Remaining visual issues:
     # Some words when translated to braille have more characters than the raw text.
     # This may be because there is a leading "number" or "capital letter" cell.
     # Currently we do not handle this.
     font.SetPointSize(20)
     font.SetFaceName(fontName)
     return font
Example #6
0
    def Start(self):

        # define colors
        self.colours = {}
        self.colours['bkgd'] = Colour(52, 61, 70)
        self.colours['text'] = Colour(255, 255, 255)
        self.colours['numb'] = Colour(160, 160, 160)
        self.colours['sepr'] = Colour(200, 120, 120)
        self.colours['selbgd'] = Colour(92, 101, 110)
        self.colours['seltxt'] = Colour(255, 255, 255)

        # brushes
        self.brushes = {}
        # normal background
        b = Brush()
        b.SetStyle(BRUSHSTYLE_SOLID)
        b.SetColour(self.colours['bkgd'])
        self.brushes['bkgd'] = b

        # selected background
        b = Brush()
        b.SetStyle(BRUSHSTYLE_SOLID)
        b.SetColour(self.colours['selbgd'])
        self.brushes['selbgd'] = b

        # pens
        self.pens = {}
        p = Pen()
        p.SetColour(self.colours['sepr'])
        p.SetWidth(1)
        p.SetStyle(PENSTYLE_SOLID)
        self.pens['sepr'] = p

        # create device context to work on bitmaps
        dc = MemoryDC()

        # define font
        self.fonts = {}
        f = Font()
        f.SetFamily(FONTFAMILY_ROMAN)
        f.SetFaceName("Monospace")
        f.SetEncoding(FONTENCODING_DEFAULT)
        f.SetStyle(FONTSTYLE_NORMAL)
        f.SetWeight(FONTWEIGHT_NORMAL)
        f.SetUnderlined(False)
        f.SetPointSize(10)
        self.fonts['monospace'] = f

        # select font
        f = 'monospace'

        # get font size
        dc.SetFont(self.fonts[f])
        w, h = dc.GetTextExtent(' ')

        # build character dictionary
        self.rawChars = {}
        # standard printable ascii table
        for c in range(32, 126):
            self.rawChars[chr(c)] = None
        # extra characters (UK)
        self.rawChars['£'] = None
        # save character size
        self.rawChars['Size'] = w, h

        # set background color
        dc.SetBackground(self.brushes['bkgd'])

        # build characters bitmaps
        for C in self.rawChars.keys():
            if C == 'Size': continue
            # instanciate character bitmap
            self.rawChars[C] = Bitmap(w, h, BITMAP_SCREEN_DEPTH)
            # select bitmap
            dc.SelectObject(self.rawChars[C])
            # clear bitmap
            dc.Clear()
            # set text color
            dc.SetTextForeground(self.colours['text'])
            # draw character shape and color
            dc.DrawText(C, 0, 0)
        # done
        dc.SelectObject(NullBitmap)

        # build selected dictionary
        self.selChars = {}
        # standard printable ascii table
        for c in range(32, 126):
            self.selChars[chr(c)] = None
        # extra characters (UK)
        self.selChars['£'] = None
        # save character size
        self.selChars['Size'] = w, h

        # set background color
        dc.SetBackground(self.brushes['selbgd'])

        # build selected bitmaps
        for C in self.selChars.keys():
            if C == 'Size': continue
            # instanciate character bitmap
            self.selChars[C] = Bitmap(w, h, BITMAP_SCREEN_DEPTH)
            # select bitmap
            dc.SelectObject(self.selChars[C])
            # clear bitmap
            dc.Clear()
            # set text color
            dc.SetTextForeground(self.colours['seltxt'])
            # draw character shape and color
            dc.DrawText(C, 0, 0)
        # done
        dc.SelectObject(NullBitmap)

        # create bitmap buffer display and clear buffer
        self.bitmapBuffer = Bitmap(
            128 * w,  # bitmap width
            10 * h,  # bitmap height
            BITMAP_SCREEN_DEPTH)  # bitmap depth
        dc.SelectObject(self.bitmapBuffer)
        dc.SetBackground(self.brushes['bkgd'])
        dc.Clear()
        dc.SelectObject(NullBitmap)

        # reference BackgroundBitmap to bitmapBuffer
        self.Panel.BackgroundBitmap = self.bitmapBuffer

        # adjust frame position
        scrw, scrh = 3840, 1200  # screen size
        w, h = self.Panel.BackgroundBitmap.GetSize()
        self.Frame.SetPosition(Point(scrw / 4 - 128 * 8 / 2, 800))

        # draw text string
        dc.SelectObject(self.bitmapBuffer)

        t = list("hello")
        # select buffer
        # draw text
        X = 0
        w, h = self.rawChars['Size']
        for c in t:
            dc.DrawBitmap(self.rawChars[c], X, 0)
            X += w

        t = list("World!")
        # select buffer
        # draw text
        X = 0
        w, h = self.selChars['Size']
        for c in t:
            dc.DrawBitmap(self.selChars[c], X, h)
            X += w

        # release bitmap
        dc.SelectObject(NullBitmap)

        # done
        return