fix(rtl): the preview's frame data keeps its fields in order; charts keep European digits
The right-to-left separator broke the frame data over the preview, a left-to-right
island: after the localized time ("6:03:41 م") the shutter's number read as part
of the previous field and swapped places with the dot. Fields shown in such an
island now use Loc.IslandSeparator, with left-to-right marks in right-to-left
languages. Charts formatted text with the UI culture's digit substitution, so a
number after Arabic words came out in Arabic-Indic digits there only; they now
draw European digits like every text block. The direction marks in source are
written as escapes instead of invisible characters.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
11 files changed
+39
-16
No files matched your search
@@ -89,7 +89,8 @@ public static class EditorText
|
||||
if (frame.FNumber is > 0 and var f) parts.Add(Loc.L("Editor.Shot.Aperture", Number(f)));
|
||||
if (frame.Iso is > 0 and var iso) parts.Add(Loc.L("Editor.Shot.Iso", iso));
|
||||
if (frame.FocalLength is > 0 and var mm) parts.Add(Loc.L("Editor.Shot.Focal", Number(mm)));
|
||||
return string.Join(Separator, parts);
|
||||
// Shown over the photo, a left-to-right island.
|
||||
return string.Join(Loc.IslandSeparator, parts);
|
||||
}
|
||||
|
||||
/// <summary>"0413 / 3,600".</summary>
|
||||
|
||||
@@ -889,7 +889,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
var settings = plan.Setup.Encoder.Settings;
|
||||
var position = plan.Setup.Plan.DurationSeconds * CurrentIndex / double.Max(1, FrameCount - 1);
|
||||
InfoText = string.Join(Loc.Separator, EditorText.Position(CurrentIndex, FrameCount),
|
||||
InfoText = string.Join(Loc.IslandSeparator, EditorText.Position(CurrentIndex, FrameCount),
|
||||
Loc.L("Editor.Preview.OutputTime", EditorText.Clock(position), EditorText.Clock(plan.Setup.Plan.DurationSeconds)),
|
||||
Loc.L("Editor.Preview.OutputSize", EditorText.Size(settings.Width, settings.Height)));
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Titano.App.Import;
|
||||
/// </summary>
|
||||
public static class BidiText
|
||||
{
|
||||
private const char LeftToRightEmbedding = '';
|
||||
private const char PopDirectionalFormatting = '';
|
||||
private const char LeftToRightEmbedding = '\u202A';
|
||||
private const char PopDirectionalFormatting = '\u202C';
|
||||
|
||||
/// <summary><paramref name="text"/> kept left to right in a right-to-left UI language; unchanged otherwise.</summary>
|
||||
public static string Ltr(string text) =>
|
||||
|
||||
@@ -62,5 +62,5 @@ public static class Formatting
|
||||
/// A path, address or fingerprint kept left to right inside right-to-left text (a Unicode left-to-right embedding),
|
||||
/// so its separators and digits stay in place; it reads unchanged in left-to-right languages.
|
||||
/// </summary>
|
||||
public static string LeftToRight(string text) => "" + text + "";
|
||||
public static string LeftToRight(string text) => "\u202A" + text + "\u202C";
|
||||
}
|
||||
@@ -33,7 +33,14 @@ public static class Loc
|
||||
public static string Separator => SeparatorOf(_culture);
|
||||
|
||||
/// <summary><see cref="Separator"/> of <paramref name="culture"/>, for texts built in a language other than the UI's.</summary>
|
||||
public static string SeparatorOf(CultureInfo culture) => culture.TextInfo.IsRightToLeft ? " · " : " · ";
|
||||
public static string SeparatorOf(CultureInfo culture) => culture.TextInfo.IsRightToLeft ? "\u200F · \u200F" : " · ";
|
||||
|
||||
/// <summary>
|
||||
/// Separator of fields shown in a left-to-right island (the frame data over the preview). In a right-to-left language
|
||||
/// it sits between left-to-right marks: after a field that ends in that language (a time with its "PM" mark) the next
|
||||
/// number would otherwise read as part of it and change places with the dot.
|
||||
/// </summary>
|
||||
public static string IslandSeparator => IsRightToLeft ? "\u200E · \u200E" : " · ";
|
||||
|
||||
public static void SetCulture(CultureInfo culture)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Automation.Peers;
|
||||
@@ -398,10 +399,16 @@ public abstract class DrawingElement : FrameworkElement
|
||||
|
||||
protected override AutomationPeer OnCreateAutomationPeer() => new DrawingElementAutomationPeer(this);
|
||||
|
||||
/// <summary>
|
||||
/// Digits as the rest of the UI shows them: with the UI culture alone, Arabic text before a number would turn its
|
||||
/// digits into Arabic-Indic ones in charts only.
|
||||
/// </summary>
|
||||
private static readonly NumberSubstitution EuropeanDigits = new(NumberCultureSource.Override, CultureInfo.InvariantCulture, NumberSubstitutionMethod.European);
|
||||
|
||||
private FormattedText Format(string text, double emSize, Brush brush, bool semiBold, FlowDirection direction)
|
||||
{
|
||||
var typeface = semiBold ? _semiBold ??= CreateTypeface(FontWeights.SemiBold) : _regular ??= CreateTypeface(FontWeights.Normal);
|
||||
return new FormattedText(text, Loc.Culture, direction, typeface, emSize, brush, null,
|
||||
return new FormattedText(text, Loc.Culture, direction, typeface, emSize, brush, EuropeanDigits,
|
||||
TextOptions.GetTextFormattingMode(this), VisualTreeHelper.GetDpi(this).PixelsPerDip);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user