I’ve slightly reduced the font size of my StyledTextCtrl, but it didn’t affect the font size in the margins of the text control, namely the line number font:

Is there any way to control the font size in the margins?
For those interested, here is my subclass:
class CustomTextCtrl(StyledTextCtrl):
"""A `StyledTextCtrl` subclass with custom settings."""
def __init__(self, *args, **kwargs):
StyledTextCtrl.__init__(self, *args, **kwargs)
# Set the highlight color to the system highlight color.
highlight_color = wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT)
self.SetSelBackground(True, highlight_color)
# Set the font to a fixed width font.
font = wx.Font(12, wx.FONTFAMILY_TELETYPE, wx.FONTSTYLE_NORMAL,
wx.FONTWEIGHT_NORMAL, False, 'Consolas',
wx.FONTENCODING_UTF8)
self.StyleSetFont(0, font)
# Enable line numbers.
self.SetMarginType(1, wx.stc.STC_MARGIN_NUMBER)
self.SetMarginMask(1, 0)
self.SetMarginWidth(1, 25)
def SetText(self, text):
"""Override of the `SetText` function to circumvent readonly."""
readonly = self.GetReadOnly()
self.SetReadOnly(False)
StyledTextCtrl.SetText(self, text)
self.SetReadOnly(readonly)
def ClearAll(self):
"""Override of the `ClearAll` function to circumvent readonly."""
readonly = self.GetReadOnly()
self.SetReadOnly(False)
StyledTextCtrl.ClearAll(self)
self.SetReadOnly(readonly)
You’re using the wrong style number for StyleSetFont. You probably meant to use:
which has a value of 32 not 0. If you want to set the font for the line numbers separately, use:
See wxStyledTextCtrl – Styling & Style Definition for more details.