[gnome-maps/wip/mlundblad/phone-number-ltr] placeView: Always set text direction to LTR for phone numbers




commit cbb6dd5616f85d4d7452388ef47c020776a3580d
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Feb 9 23:15:17 2021 +0100

    placeView: Always set text direction to LTR for phone numbers
    
    Since phone numbers are typically displayed using
    international format (starting with a +) this
    seems to result in Pango laying out the text with
    an overall RTL direction in RTL languages, resulting
    in groups of digits (separated by spaces) being
    arranged RTL, while the digit groups internally
    correctly is rendered LTR. And since also eastern
    Arabic numerals are written left-to-right, just
    insert a LRM marker to ensure the direction within
    the text is LTR (setting the text direction of the
    entire label widget gives off alignment).

 src/placeView.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/src/placeView.js b/src/placeView.js
index 36dd10af..038a4b08 100644
--- a/src/placeView.js
+++ b/src/placeView.js
@@ -42,6 +42,9 @@ const Wikipedia = imports.wikipedia;
 // maximum dimension of thumbnails to fetch from Wikipedia
 const THUMBNAIL_FETCH_SIZE = 360;
 
+// Unicode left-to-right marker
+const LRM = '\u200E';
+
 var PlaceView = GObject.registerClass({
     Properties: {
         'overpass-place': GObject.ParamSpec.object('overpass-place',
@@ -259,7 +262,7 @@ var PlaceView = GObject.registerClass({
         if (place.phone) {
             let phone = { label: _("Phone number"),
                           icon: 'phone-oldschool-symbolic',
-                          info: GLib.markup_escape_text(place.phone, -1) };
+                          info: LRM + GLib.markup_escape_text(place.phone, -1) };
 
             if (Utils.uriSchemeSupported('tel')) {
                 /* RFC3966 only allows "-", '.", "(", and ")" as visual


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]