I found a strange behaviour in highlighting some characters in a styled text.
[code] txtTextArea.StyledText.Text = “file a file”
txtTextArea.StyledText.TextColor(0, 1) = &cFF000000 // red
txtTextArea.StyledText.TextColor(7, 1) = &cFF000000 // red
[/code]
here only the character ‘f’ should be in red but actually ‘fi’ is red
same happens with text is “flle a flle” -> ‘fl’ is in red
with any other characters after f (e.g. “fale a fble”) the styled text works correct
Apparently, something is substituting the font’s built-in ligatures for foxtrot-india and foxxtrot-lima. Thus, they’re being treated as one character. Not certain why this would happen–will see if I can reproduce it. But it does sound like it’s happening at system level as opposed to within Xojo.
Mac or Windows ? Looks like glyph substitution, AKA advanced typography under Windows has been turned on. On Mac this feature should not manifest with system fonts.
It happens using Fonts: System, Gill Sans, Futura, Geneva, …
it does NOT happen on Fonts: Arial, Courier, Tahoma - and very strange with Font ‘Lucida Sans 13’
which I belive is what System font is.
[quote=186574:@Hanspeter Stocker]I’m working on a Mac.
It happens using Fonts: System, Gill Sans, Futura, Geneva, …
it does NOT happen on Fonts: Arial, Courier, Tahoma - and very strange with Font ‘Lucida Sans 13’
which I belive is what System font is.[/quote]
System is a strange story. It may be Lucida Sans or Helvetica Neue, but it is not the plain out of the mill one you see in applications. It is a special version somewhere deep in the system that does not show in the fonts list.
The only way I know of obtaining ligatures is to set them in the Text tab of the Keyboard preferences. But then it applies to all fonts and applications. Besides, as far as I know, fi and fl are not part of the default replacements. But you may want to check there.
By system fonts do you mean the built in ones?
I went through fonts in TextEdit and found several that do this glyph substituting.
So when Hanspeter sets the StyledText color of just the f character, if that font is joining the f and i into a single glyph it has to draw the whole fi glyph as red.
TextEdit can somehow turn off the ligature individually when it needs to color different.
[quote=186587:@Will Shank]By system fonts do you mean the built in ones?
I went through fonts in TextEdit and found several that do this glyph substituting.
So when Hanspeter sets the StyledText color of just the f character, if that font is joining the f and i into a single glyph it has to draw the whole fi glyph as red.
TextEdit can somehow turn off the ligature individually when it needs to color different.
[/quote]
You are right, these fonts do ligatures as you describe.
I guess they use the Open type glyph substitution feature embedded within the font itself, instead of the Text one I described just above.
Not all fonts have this feature. Helvetica, for instance, does not have it. That could be a solution.
Nevertheless, I do not see ligatures in a textArea using the OP code with Geneva. There must be something else at work.
I am having a similar issue on Windows using Menlo typeface. The characters ‘f’ and ‘i’ next to each other in order are automatically replaced by the single character ligature (same for ‘fl’). This issue does not occur on the Mac version with the same typeface. I am using the most recent version of Xojo at the time of writing (2017r3). What’s interesting is that this change only occurs graphically: If one places the cursor immediately before the ligature and highlights the next character (using shift-right arrow), then the ligature is split into two characters again with the ‘f’ highlighted and the ‘i’ not. Highlighting one more character causes the ligature to reform and be highlighted. I tested the most common ligatures used for English text but only ‘fi’ and ‘fl’ seem to be affected.