All, I need to put Arabic (written RTL) on a Canvas. Does anyone know how that’s done?
Can I define the language somewhere and does this take care of it?
Thanks
All, I need to put Arabic (written RTL) on a Canvas. Does anyone know how that’s done?
Can I define the language somewhere and does this take care of it?
Thanks
It helps if you don’t use acronyms like RTL. For me that’s a private TV station in Germany
RTL = Right to Left when in reference to language.
I’d say that’s a biggie, and is on you to know.
Edit: [removed Text Input Canvas question, re-read and this isn’t text input)
Canvas is up to you to draw things where you want them, so like any text align, you should calculate the string width, and start drawing the string the width away from where you want it to end. There may be existing code if you search for it, but it’s not a difficult process.
It references NSResponder in Source:
CMD_CONST(CmdMakeTextWritingDirectionRightToLeft, makeTextWritingDirectionRightToLeft:),
So chances are high.
No, you need to do it by yourself. But it shouldn’t be to hard. Take the String/Text, get it’s length, substract the String/Text-Length from the width of the canvas and Draw your String/Text.
Thank you all.
Off-topic…
I was thinking about just the same thing. One thing, it isn’t a German company. It actually is Luxemburgian. In The Netherlands, we have a Dutch language RTL station as well.
Right-to-left / Bidirectional text should draw correctly as long as you draw entire strings and not individual characters.
The only thing you will need to work out is if the text needs right aligned or not. If the text will always be Arabic then you can probably just use the method described in an earlier post. If your text is not always Arabic then you might be able to use the Xojo string direction function to help you make that decision.
All, I thought the solution Sascha proposed would work, but as the text is multi-line, it doesn’t…
Is there a way I can for instance use HTML code as input for the Canvas?
Separate each line, calculate individually. That’s how it’s done.
What you need to do is split your text into lines and draw each one separately.
One way to do this would be to put the text into a text area control which is sized accordingly. You can then use the linenumatcharpos method to determine where the line breaks are.
I see… would that also mean I need one canvas per line?
No, this can all be done on one canvas.