Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions kiva/qpainter.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
draw_modes[constants.FILL_STROKE] = QtCore.Qt.OddEvenFill
draw_modes[constants.EOF_FILL_STROKE] = QtCore.Qt.WindingFill

font_styles = {}
font_styles["regular"] = constants.NORMAL
font_styles["bold"] = constants.BOLD
font_styles["italic"] = constants.ITALIC
font_styles["bold italic"] = constants.BOLD_ITALIC

gradient_coord_modes = {}
gradient_coord_modes["userSpaceOnUse"] = QtGui.QGradient.LogicalMode
gradient_coord_modes["objectBoundingBox"] = QtGui.QGradient.ObjectBoundingMode
Expand Down Expand Up @@ -612,15 +618,23 @@ def draw_image(self, img, rect=None):
# Drawing Text
# ----------------------------------------------------------------

def select_font(self, name, size, textEncoding):
def select_font(self, name, size, style="regular", encoding=None):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is the signature from AbstractGraphicsContext

""" Set the font for the current graphics context.
"""
self.gc.setFont(QtGui.QFont(name, size))
style = font_styles.get(style, constants.NORMAL)
font = Font(name, size=size, style=style)
self.set_font(font)

def set_font(self, font):
""" Set the font for the current graphics context.
"""
self.select_font(font.face_name, font.size, None)
qfont = QtGui.QFont(font.face_name, font.size)

if font.style in (constants.BOLD, constants.BOLD_ITALIC):
qfont.setBold(True)
if font.style in (constants.ITALIC, constants.BOLD_ITALIC):
qfont.setItalic(True)
self.gc.setFont(qfont)

def set_font_size(self, size):
"""
Expand Down