Opened 4 months ago
#24336 new defect
Bidirectional text rendered inconsistently in input box
Reported by: | NeatNit | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | |
Keywords: | template_report | Cc: |
Description
Tags can have bidirectional text. Example: https://www.openstreetmap.org/node/3645671154
name=פיצה USA
To make it easier to demonstrate, I made a dummy node in the development instance: https://master.apis.dev.openstreetmap.org/node/4359512471
Note the rendering of the tags table on the OSM website - this is how it should be rendered. Attached: osm-org-tags.jpg
JOSM renders tags correctly in tables, but all tags are left-aligned. Ideally, RTL tags should be aligned right. Attached: josm-tags.jpg
However, when double-clicking a value to edit it, it is always rendered left-to-right. Attached: josm-change-value.jpg
This input box should change direction based on the text inside it. This direction should be re-computed every time the text is changed, because the user might edit it in such a way to switch its direction.
Currently, the value box is changed to RTL if the key box ends in ":he" or ":ar" (there may be other language codes). Attached: josm-change-value-he-suffix.jpg. This hard-coded solution is not good enough. The main name tag, and many other tags can be RTL as well. The direction of the input box should ONLY be determined by its contents.
The same applies to key tags - even though they are almost always in English, there is no technical limitation on this. See this comment: https://github.com/openstreetmap/openstreetmap-website/pull/4333#issuecomment-1812739184
I have no experience with Java, but most GUI libraries offer ways to automatically detect the text directionality of its contents using the "first strong" rule defined by Unicode: https://www.unicode.org/reports/tr9/#The_Paragraph_Level (P2). Hopefully it's as easy as adding a property to something.
To be clear: yes, it is preferable for the text to switch sides immediately while the user is editing it, if the user typed in a character that changed the computed direction.
I'll be happy to clarify anything further if needed.
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2025-05-01 13:38:02 +0200 (Thu, 01 May 2025) Revision:19396 Build-Date:2025-05-02 01:30:34 URL:https://josm.openstreetmap.de/svn/trunk Identification: JOSM/1.5 (19396 en_GB) Windows 10 64-Bit OS Build number: Windows 10 Pro 22H2 (19045) Memory Usage: 354 MB / 4024 MB (101 MB allocated, but free) Java version: 21.0.5+11-LTS, Azul Systems, Inc., OpenJDK 64-Bit Server VM Look and Feel: com.sun.java.swing.plaf.windows.WindowsLookAndFeel Screen: \Display0 1920x1080x32bpp@60Hz (scaling 1.25×1.25) \Display1 1920x1200x32bpp@59Hz (scaling 1.00×1.00) Maximum Screen Size: 1920×1200 Best cursor sizes: 16×16→32×32, 32×32→32×32 System property file.encoding: UTF-8 System property sun.jnu.encoding: Cp1252 Locale info: en_GB Numbers with default locale: 1234567890 -> 1234567890 VM arguments: [-Dicedtea-web.bin.location=C:\Program Files\OpenWebStart\javaws, -Djava.util.Arrays.useLegacyMergeSort=true, --add-reads=java.base=ALL-UNNAMED,java.desktop, --add-reads=java.desktop=ALL-UNNAMED,java.naming, --add-reads=java.naming=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/sun.awt=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/javax.jnlp=ALL-UNNAMED,java.desktop, --add-exports=java.base/com.sun.net.ssl.internal.ssl=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.action=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.provider=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.util=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.validator=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.security.x509=ALL-UNNAMED,java.desktop, --add-exports=java.base/jdk.internal.util.jar=ALL-UNNAMED,java.desktop, --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/sun.awt.X11=ALL-UNNAMED,java.desktop, --add-exports=java.desktop/sun.applet=ALL-UNNAMED,java.desktop,jdk.jsobject, --add-exports=java.naming/com.sun.jndi.toolkit.url=ALL-UNNAMED,java.desktop, --add-modules=java.scripting,java.sql,javafx.controls,javafx.media,javafx.swing,javafx.web, --add-exports=java.desktop/com.apple.eawt=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED, --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED, --add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED, --add-exports=jdk.deploy/com.sun.deploy.config=ALL-UNNAMED, --add-opens=java.base/java.lang=ALL-UNNAMED, --add-opens=java.base/java.nio=ALL-UNNAMED, --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED, --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED, --add-opens=java.desktop/javax.imageio.spi=ALL-UNNAMED, --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED, --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED, -Djava.security.manager=allow] Dataset consistency test: No problems found Last errors/warnings: - 00000.392 W: extended font config - overriding 'filename.Malgun_Gothic=malgun.ttf' with 'MALGUN.TTF' - 00000.394 W: extended font config - overriding 'filename.Myanmar_Text=mmrtext.ttf' with 'MMRTEXT.TTF' - 00000.394 W: extended font config - overriding 'filename.Mongolian_Baiti=monbaiti.ttf' with 'MONBAITI.TTF'
Attachments (4)
Change History (4)
by , 4 months ago
Attachment: | osm-org-tags.jpg added |
---|
by , 4 months ago
Attachment: | josm-tags.jpg added |
---|
by , 4 months ago
Attachment: | josm-change-value.jpg added |
---|
by , 4 months ago
Attachment: | josm-change-value-he-suffix.jpg added |
---|