Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile text displayed right to left but correct on web #3294

Closed
1 task done
nyankoframe opened this issue Feb 10, 2023 · 6 comments · Fixed by #3328
Closed
1 task done

Profile text displayed right to left but correct on web #3294

nyankoframe opened this issue Feb 10, 2023 · 6 comments · Fixed by #3328

Comments

@nyankoframe
Copy link

The profile text for https://mastodon.social/dungeons changes based on the current character. At the moment the profile in website looks like this:

Screenshot_20230210_101352

But it appears in Tusky like this:

Screenshot_20230210_101059

The timeline posts mentioning this character also appear using right to left text:

Screenshot_20230210_101437


  • Tusky Version: 21.0

  • Android Version: 12

  • Android Device: Galaxy S10

  • Mastodon instance (if applicable):

  • I searched or browsed the repo’s other issues to ensure this is not a duplicate.

@nikclayton
Copy link
Contributor

nikclayton commented Feb 11, 2023

The account is https://mastodon.social/api/v1/accounts/109354069933492315, if you pull that and look at the bytes for the profile info you get:

00000000  3c 70 3e e2 9a 94 ef b8  8f 20 e1 8e af ef ac a1  |<p>...... ......|
00000010  f0 9d 98 ad ea ad bf ef  ac a1 2c 20 74 68 65 20  |.........., the |
00000020  44 72 61 67 6f 6e 62 6f  72 6e 20 46 69 67 68 74  |Dragonborn Fight|
00000030  65 72 3c 62 72 20 2f 3e  0a                       |er<br />.|

If you paste the text in to an editor that supports bidirectionality (e.g., Android Studio) and run the cursor through the name text you'll see a marker at the top of the cursor swap direction as you move through the text.

The sword emoji is e2 9a 94 ef b8 8f, e1 8e af ef ac a1 f0 9d 98 ad ea ad bf ef ac a1 is the name.

I thought this might be https://www.w3.org/International/articles/inline-bidi-markup/#nomarkup, but it doesn't look like there's embedded unicode to change the directionality of the text, it's the individual "letters" themselves.

https://www.babelstone.co.uk/Unicode/whatisit.html seems to confirm that, reporting:

U+13AF : CHEROKEE LETTER HI
U+FB21 : HEBREW LETTER WIDE ALEF
U+1D62D : MATHEMATICAL SANS-SERIF ITALIC SMALL L
U+AB7F : CHEROKEE SMALL LETTER HI
U+FB21 : HEBREW LETTER WIDE ALEF

Hebrew is written right-to-left (unlike Cherokee).

Given https://developer.android.com/reference/kotlin/androidx/compose/ui/text/style/TextDirection and other references in the docs I think Android is seeing the first Hebrew character as having a strong text direction (right to left) and is using that for the rest of the text.

It might be possible to work around this.

@nikclayton
Copy link
Contributor

Spot checked Megalodon and Fedilab, they handle this correctly, so there is something that can be done.

@nyankoframe
Copy link
Author

The profile page has changed since I submitted this issue, so here is a link to a post with the same characters if you need it:

https://mastodon.social/@dungeons/109850440310010558

@nikclayton
Copy link
Contributor

Hmm.

Did that post have the same problem 3 days ago? I just went to look at it, and I see it showing correctly now.

image

I'll keep poking and see if I can trigger the problem.

@nikclayton
Copy link
Contributor

Yeah, I can duplicate this on my profile page. That should be enough to debug some more.

@nikclayton
Copy link
Contributor

I think I've tracked this down.

layout/activity_account.xml has android:textDirection="anyRtl" set on a view close to the root.

Per https://developer.android.com/reference/android/view/View.html#attr_android:textDirection this will set the text direction like so:

The paragraph direction is RTL if it contains any strong RTL character, otherwise it is LTR if it contains any strong LTR characters. If there are neither, the paragraph direction is the view’s resolved layout direction.

This was added in #964.

The discussion on that PR has these two comments:


@charlag: Didn't we have this discussion at #878 and decided against anyRTL?

@connyduck: yes but #878 was about user generated content and this is about our interface (or am I missing something?)


If that (setting anyRtl on user generated content is bad) correct (I'm not qualified to judge if it is or not) then I think the correct fix on AccountActivity is to restore the default text direction (firstStrong) on views in AccountActivity that show user generated content.

That's the private note, the account bio, and the titles/content of the account fields.

I'll prep a PR that does that for further discussion.

connyduck pushed a commit that referenced this issue Mar 2, 2023
`activity_account` sets the root text direction to `anyRtl`.

This is OK for UI elements, but can be a problem for user generated content
(UGC) that may contain bidirectional text.

Fix this by explicitly restoring the default behaviour, `firstStrong`, on
views in `activity_account` that can show UGC.

Fixes #3294
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants