[gnome-maps/wip/mlundblad/phone-number-ltr] placeView: Always set text direction to LTR for phone numbers
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/phone-number-ltr] placeView: Always set text direction to LTR for phone numbers
- Date: Wed, 10 Feb 2021 17:27:35 +0000 (UTC)
commit 94ad5918dc97f305623af1d4ff6414bbc449817d
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 | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/src/placeView.js b/src/placeView.js
index 36dd10af..faa96a10 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',
@@ -257,9 +260,15 @@ var PlaceView = GObject.registerClass({
}
if (place.phone) {
+ /* since the phone numbers are typically always rendered
+ * left-to-right, insert an explicit LRM char to avoid issues
+ * with phone numbers in international format starting with a +
+ * which is considered a "weak" character to determine Unicode
+ * text direction
+ */
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]