Phoenix icon indicating copy to clipboard operation
Phoenix copied to clipboard

Narrow no-break space change font of TextCtrl when using SetValue

Open Nicryc opened this issue 2 years ago • 0 comments

Operating system: Windows 10 wxPython version & source: 4.1.1 from pip Python version & source: 3.9.4 from Windows Store

Description of the problem:

A narrow no-break space (U+202F) in the text change the font of a TextCtrl when using SetValue. See image below: Narrow_No-Break_Space_Bug The narrow no-break space is at the green square position.

Code Example (click to expand)
def __init__(self, *args, **kw) -> None:
    self.text_area1 = wx.TextCtrl(pnl, style=wx.TE_MULTILINE | wx.TE_NOHIDESEL)
    self.text_area2 = wx.TextCtrl(pnl, style = wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_NOHIDESEL | wx.TE_RICH2)
    btn = wx.Button(pnl, label="OK")
    btn.Bind(wx.EVT_BUTTON, self.on_press)

    font = wx.Font()
    font.PointSize = 12
    self.text_area1.SetFont(font)
    self.text_area2.SetFont(font)

def on_press(self, event):
    self.text_area2.SetValue(self.text_area1.GetValue())

Nicryc avatar Jun 11 '22 14:06 Nicryc