Bug in Text editor


Hi jules,
I am using text editor with different font size, somehow word wrap doesnt seem to work as expected. If a word has different font size eg: Software, it split the word to next line.

        Another small bug in cursor, if current font size is smaller than previous the cursor position is not proper ie, its drawing from height of the line instead it should be lineHeight - cursorHeight.



Ok, I see. I’ve fixed the cursor thing, so maybe try using the code from the tip of SVN, as that might also relate to your other problem…


I checked out the latest code from SVN, still bug is there.

Here is what i have done,

   1) In Juce demo, void FontAndTextDemo::updatePreviewBoxText() i changed textBox->applyFontToAllText (font); to textBox->setFont(font); 

   2) Then i typed a word in which each character is of different font size. 

   Below image may give the clear picture of what is going wrong.



ok, thanks. I’ve checked in a fix for that now…


Thank a lot .

I have found some more bugs,

  1. When i type word which is too big, it gives access violation while wrapping the word to next line (function wrapCurrentAtom() atom is NULL). Happens only if the first word needs to be wrapped to next line.

  2. If there is word where font size is different for each character, while wrapping the text to next line it doesnt trim the space in front of that word.



Thanks - you’re clearly giving the component a good thrashing! I’ve checked in a fix now, let me know how you get on.


Thnxs Jules. Appreciate your help. However i noticed that initial bug has reappeared after last fix.

And if the first word in the editor has character of different font size, an extra line space while word wrapping.

I wasnt able to report all bugs at once bcoz of my schedule. Sorry for that!!!.



Ah… that pesky iterator class… I should probably refactor it a bit so it’s less complicated. Thanks.


I have implemented Text alignment feature in text editor by changing iterator class, i dont know if this is right way to implement. U can check the code here


U have any plan of adding this feature in near future?



What’s going on on this front ?


Been too busy to try it. Will do when I can.


Hi jules,
A small bug in class TextAtom, in function getTrimmedText () whole atomText is return instead it has to be trimmed. Bcoz of this sometimes same character is drawn in two lines.

          Here is the fix 

const juce::String getTrimmedText (const juce::tchar passwordCharacter) const
if (passwordCharacter == 0)
return atomText.substring(0, numChars);
else if (isNewLine())
return juce::String::empty;
return juce::String::repeatedString (juce::String::charToString (passwordCharacter), numChars);



Ah, thanks very much!