Esempio n. 1
0
    def init_font_config(self):
        self.disasm_font = QFont("DejaVu Sans Mono", 10)
        font_metrics = QFontMetricsF(self.disasm_font)
        self.disasm_font_height = font_metrics.height()
        self.disasm_font_width = font_metrics.width('A')
        self.disasm_font_ascent = font_metrics.ascent()

        self.symexec_font = QFont("DejaVu Sans Mono", 10)
        font_metrics = QFontMetricsF(self.symexec_font)
        self.symexec_font_height = font_metrics.height()
        self.symexec_font_width = font_metrics.width('A')
        self.symexec_font_ascent = font_metrics.ascent()
Esempio n. 2
0
    def __init__(self, main_window):

        self._main_window = main_window
        self._instance = None
        self.views_by_category = defaultdict(list)
        self.views = []
        self.dockable_views = []
        self.view_to_dockable = {}

        #
        # Some generic configurations. move to "configurations" module later
        #
        #self.disasm_font = QFont("courier new", 20)
        self.disasm_font = QFont("DejaVu Sans Mono", 10)
        font_metrics = QFontMetricsF(self.disasm_font)
        self.disasm_font_height = font_metrics.height()
        self.disasm_font_width = font_metrics.width('A')
        self.disasm_font_ascent = font_metrics.ascent()

        default_tabs = [
            FunctionsView(self, 'left'),
            DisassemblyView(self, 'right'),
            SymexecView(self, 'right'),
            StatesView(self, 'right'),
            StringsView(self, 'right'),
            ConsoleView(self, 'bottom'),
        ]

        for tab in default_tabs:
            self.add_view(tab, tab.caption, tab.category)
Esempio n. 3
0
    def createQtNode(self, node, posx, posy, color=QColor(255, 150, 150)):
        """ Create a QtNode with given position, color for given node
        
        Arguments:
            
            - node: The graphviz node
            - posx: The x position from graphviz layout
            - posy: The y position from graphviz layout
            - color: The color of circle (red by default)
        
        """
        #dpi = float(self.gv.graph_attr['dpi'])
        dpi = 96
        try:
            width = float(node.attr['width'])
            height = float(node.attr['height'])
        except ValueError:
            #New created node
            width = 300 / 96
            height = 40 / 96

        qnode = QtNode(-width * dpi / 2, -height * dpi / 2, width * dpi,
                       height * dpi)
        qnode.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)
        qnode.setPos(posx, posy)
        qnode.setFlag(QGraphicsItem.ItemIsMovable)
        qnode.setCallback(weakref.ref(self))
        qnode.setNode(node)
        qnode.setBrush(color)
        txt = QGraphicsSimpleTextItem(qnode)
        font = txt.font()
        font.setPointSize(14)
        txt.setFont(font)
        txt.setText(node)
        txtwidth = QFontMetricsF(font).width(node)
        txtheight = QFontMetricsF(font).height()
        toLeft = (-width * dpi / 2) + (width * dpi - txtwidth) / 2
        toBottom = (-height * dpi / 2) + (height * dpi - txtheight) / 2
        txt.setPos(toLeft, toBottom)

        return qnode
    def __init__(self, name, size):
        self.font = QFont(name, size)
        self.font.setKerning(False)
        self.ascent = int(QFontMetricsF(self.font).ascent())
        self.charWidth = QFontMetricsF(self.font).width("X")
        self.charHeight = int(QFontMetricsF(self.font).height())
        self.charOffset = 0  # can introduce extra linespacing here

        self.bold = QFont(self.font)
        self.bold.setBold(True)

        self.under = QFont(self.font)
        self.under.setUnderline(True)

        # align character width properly
        if self.charWidth % 1.0 < 0.5:
            adjust = -(self.charWidth % 1.0)
        else:
            adjust = 1.0 - (self.charWidth % 1.0)

        self.charWidth += adjust
        self.font.setLetterSpacing(QFont.AbsoluteSpacing, adjust)
        self.bold.setLetterSpacing(QFont.AbsoluteSpacing, adjust)
        self.under.setLetterSpacing(QFont.AbsoluteSpacing, adjust)
 def setUp(self):
     super(QFontMetricsFTest, self).setUp()
     self.font = QFont()
     self.metrics = QFontMetricsF(self.font)