Hi,

I'm attempting to implement a feature in a plain text editor that similar
to Notepad++'s "show hidden characters", which allows toggle the visibility
of non-printable characters, like zero-width space, CR LF and so-on, which
look like this in Notepad++ (see the attachment for the sample document):

[image: image.png]

By looking at QTextLine and QTextLayout, it doesn't seems like there is a
way to specific a certain unicode glyph's width (to reserve the space so we
can then draw the character as visible glyphs manually). What comes to mind
are the following two approaches:

1. Subclass QTextLayout to override the behavior of `cursorToX()` and other
related functions.
By quickly take a look at this approach, it might be more complex than I
thought, which will require using Qt's private header to access
QTextEngine-related stuff.
2. Create a custom font that provides these characters, and ensure that
font will be used before any other fonts.
I'm not exactly sure if this method is possible though.

So the question is, what's the proper approach to implement such a feature
using Qt's public API? Do the mentioned two approaches sound right?

Thanks!
Gary
        aaaaaaa
    
    a
    
    a
  ​  
    

    
     
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to