CodeEditorComponent, mouse selection and font issue


Hi Jules,

I’ve found a bug in CodeEditorComponent.
It is triggered if you use a custom font, then the mouse selection is bogus.

You can easily reproduce this In Juce Demo by adding the following line

in CodeEditorDemo.cpp line 45, right before the content loading.

Then you select a sentence portion using the mouse, then copy/paste to another place and you will see that the copied text is not what you just had selected.

Thanks !


If I use a monospace font, it works fine

Maybe adding some assert over this ?


Ah yes, it does keep things simple by requiring a monospaced font. Unfortunately I never found a reliable way to determine whether a font is monospaced - in the introjucer I had to write a hacky function that renders some strings and looks at the spacing of the results.