Rockbox Technical Forums

Support and General Use => Theming and Appearance Customization => Topic started by: biengo on October 29, 2010, 02:46:36 PM

Title: wps/sbs issue with tags in rtl languages
Post by: biengo on October 29, 2010, 02:46:36 PM
Hi,
I'm trying to implement proper rtl language support in my theme. My problem is, that while metadata tags in ltr look just right, e.g. "Tag_in_ltr:Next Track", with tags in rtl such as hebrew the order gets flipped around. It now prints "Next Track:Tag_in_rtl". I can rearrange the code only to make it right for ltr or rtl tags, but would like to cover both cases.
the code is:
Code: [Select]
%?Sr<%aR%t(3)%s%?it<%it|%fn> :%Sx(Now Playing);%aR%t(3)%s%?It<%It|%Fn> %Sx(Next Track:)|code for ltr languages>I hope the attached screendumps illustrate the issue better.
Title: Re: wps/sbs issue with tags in rtl languages
Post by: JdGordon on October 31, 2010, 06:04:03 PM
You're asking for a check if the actual tags is ltr or rtl instead of the system language? I don't tihnk that is really possible.
Title: Re: wps/sbs issue with tags in rtl languages
Post by: biengo on November 01, 2010, 06:19:13 AM
I just thought the order of the tags would not be rearranged with regard to rtl or ltr script, so that If I wrote for ?%Sr<rtl
Code: [Select]
%It %Sx(Next Track:)it would always be readable from right to left, whether %It is latin or hebrew (See attached snippets).

To me it seems that if the interface language is rtl and the tag language is rtl text direction is reversed to ltr again.

I find it kind of hard to wrap my head around this and I'm beginning to think this is a case that would require complex text layout capabilities to be handled properly... I'll just pick one script to look right then. Thank you, JD!
Title: Re: wps/sbs issue with tags in rtl languages
Post by: JdGordon on November 01, 2010, 07:27:33 AM
Ah, I see what you're saying...
I'd say this is a real bug but I have no idea how the text drawing actually works (I'll try and get someone who does though)

for the benefit of those who cant read hebrew and are not sure of the problem either, the problem is the text line has two parts... <a> and <b>. the skin code suggests that <a> should always be drawn left of <b> (or right in this case because Hebrew is LTR so left and right are switched). The problem apparently is that when <a> is LTR and <b> is RTL the order is mangled.

Actually I'm really confused because the top line (to me) is the correct placement (with the Hebrew on the right) and the bottom image is backwards. (the second image would be the equivalent of "happy birthday Next Track:" in English (where obviously you'd expect it to be "Next Track: Happy Birthday".


blengo: a relatively simple fix would be to put both parts of that line in separate viewports, but I think this is a real bug and should be reported on flyspray
Title: Re: wps/sbs issue with tags in rtl languages
Post by: fml2 on November 01, 2010, 08:43:55 AM
What happens if you just do it like this:

Code: [Select]
%?Sr<%aR%Sx(Next Track:) %?it<%it|%fn>|code for ltr languages>
I think the text drawing engine should handle all this correctly.

IIUC, the engine works so that first a line of text is formed in memory and then it gets rendered. The rendering engine works similar to a typing app that can handle LTR and RTL texts.

I can't try it myself right now.
Title: Re: wps/sbs issue with tags in rtl languages
Post by: JdGordon on November 01, 2010, 08:49:38 AM
hopefully the attached image clears it up a bit....
Title: Re: wps/sbs issue with tags in rtl languages
Post by: JdGordon on November 01, 2010, 09:12:16 AM
Can you post the full wps? I have a feeling %ax and %aR are messing with eachother...
Title: Re: wps/sbs issue with tags in rtl languages
Post by: biengo on November 01, 2010, 09:39:34 AM
Jd, the first example is indeed correctly drawn, also your explanation probably says it more clearly than my two posts:)

fml2, the %aR tag does not handle this differently than the %ar, %ac etcetera, I tried this extensively. If the tag is not the expected direction, it flips the order around.

Is there any more clarification needed to file a bug? I mean, the most difficult part is to explain the problem in a concise manner.

ps. the code is from a .sbs, the full line is
Code: [Select]
%?Sr<%ac%t(3)%s%?it<%it|%fn> :%Sx(Now Playing);%ac%t(3)%s%?It<%It|%Fn> %Sx(Next Track:)|%ac%t(3)%s%Sx(Now Playing): %?it<%it|%fn>;%ac%t(3)%s%Sx(Next Track:) %?It<%It|%Fn>>the full sbs: http://pastebin.com/320V0fZb

edit: the initial post might make the impression that this only makes problems with id3-tags in rtl. but if I switch the tags around it brakes with ltr tags just as well:
Code: [Select]
%Sx(Next Track:) %It
Title: Re: wps/sbs issue with tags in rtl languages
Post by: [Saint] on November 01, 2010, 07:57:56 PM
biengo,

 
Try using the "normal" alignment tags (%ar, %al, %ac etc.) and use the %ax tag to flip the text orientation indirectly by flipping the  horizontal orientation of the entire viewport.


Here's an example:

Code: [Select]
%ax%V(0,0,-,-,-)%Vf(000000)%Vb(FFFFFF)
%s%al%?Sr<%pe %Sx(of) %pp|%pp %Sx(of) %pe>

Doing it this way works fine for me in My FM/SB/WPSes.

There's a "problem" (I'll explain why I have put "problem" in quotes) with the %aR and %AL tags when using the %ax tag...

The thing is that %ax flips the viewports horizontal orientation, so %aR whilst inside a vieport with %ax defined is the equivalent of %al and vice versa with %aL.

I used to believe this was a bug, but when I thought about it, it is actually perfectly sane...and expected behaviour.

I hope the example I gave helps you to work through this problem, I felt like beating my head against a wall several times whilst trying to get my theme fully language aware and translated correctly.



[St.]
Title: Re: wps/sbs issue with tags in rtl languages
Post by: JdGordon on November 01, 2010, 08:08:27 PM
something is still wrong. He isnt using %ax so %aR should be working as expected.
Title: Re: wps/sbs issue with tags in rtl languages
Post by: biengo on November 04, 2010, 04:12:13 AM
I tried several tags for alignment now both within normal viewports and %ax viewports, including %ac, %al, %ar, %aR and %aL. None of them had any impact on the problem. I realize that the issue is not easy to reproduce since the interface language has to be set to hebrew or arabic and music files with rtl meta data are not easy to come by (at least I didn't find a free one to link to).

To sum it up: Just the line %Sx(Now Playing): %it (here: <a> <b>) withouth %?Sr or other tags for alignment.
1.) Interface english, meta data hebrew (rtl) works as expected: left <a>, right <b>.
2.) Interface hebrew, meta data rtl works as expected: right <a>, left <b>.
3.) Interface hebrew, meta data latin (ltr) brakes read order: right <b>, left <a>.