Skip to content

Commit 082fe95

Browse files
committed
Merge commit 'a5e370b84f7fec1617d6ef4142504c8901bf865e'
2 parents d54a6f6 + a5e370b commit 082fe95

File tree

6 files changed

+49
-2
lines changed

6 files changed

+49
-2
lines changed

LightTextEditorPlus/Demos/AvaloniaDemo/Business/RichTextCases/RichTextCaseProvider.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,16 @@ void Append(string text, double fontSize)
523523

524524
}, "测试037d9449-加粗的文本里下标渲染错误");
525525

526+
Add(editor =>
527+
{
528+
editor.UseWpfLineSpacingStyle();
529+
editor.AppendRun(new SkiaTextRun("rr.", editor.StyleRunProperty with
530+
{
531+
FontSize = 20,
532+
FontName = new FontName("微软雅黑"),
533+
}));
534+
}, "1d0299-使用 rr.导致字符宽度计算错误");
535+
526536
//Add(editor =>
527537
//{
528538
// editor.UseWpfLineSpacingStyle();
@@ -531,6 +541,6 @@ void Append(string text, double fontSize)
531541
// FontSize = 24,
532542
// FontName = new FontName("HarmonyOS Sans SC")
533543
// }));
534-
//}, "测试龙芯鸿蒙运行渲染效果");
544+
//}, "测试龙芯鸿蒙字体运行渲染效果");
535545
}
536546
}

LightTextEditorPlus/Demos/AvaloniaDemo/Views/TextEditorDebugView.axaml.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
using System.Diagnostics.CodeAnalysis;
33
using System.IO;
44
using System.Linq;
5+
56
using Avalonia;
67
using Avalonia.Controls;
8+
using Avalonia.Input;
79
using Avalonia.Interactivity;
810
using Avalonia.Markup.Xaml;
911
using Avalonia.Media;
1012
using Avalonia.Media.Imaging;
13+
1114
using LightTextEditorPlus.Demo.Business.RichTextCases;
1215
using LightTextEditorPlus.Core.Utils;
1316
using LightTextEditorPlus.FontManagers;
@@ -44,6 +47,31 @@ public TextEditorDebugView(bool runDebug)
4447
// 调试代码
4548
RichTextCaseProvider.Debug();
4649
}
50+
51+
TextEditorGrid.PointerWheelChanged += TextEditorGrid_OnPointerWheelChanged;
52+
53+
void TextEditorGrid_OnPointerWheelChanged(object? sender, PointerWheelEventArgs e)
54+
{
55+
if ((e.KeyModifiers & KeyModifiers.Control) == 0)
56+
{
57+
return;
58+
}
59+
60+
if (TextEditorGrid.RenderTransform is not ScaleTransform scaleTransform)
61+
{
62+
scaleTransform = new ScaleTransform();
63+
TextEditorGrid.RenderTransform = scaleTransform;
64+
TextEditorGrid.RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Relative);
65+
}
66+
67+
var delta = e.Delta.Y / 10;
68+
69+
scaleTransform.ScaleX += delta;
70+
scaleTransform.ScaleY += delta;
71+
72+
scaleTransform.ScaleX = Math.Max(0.1, scaleTransform.ScaleX);
73+
scaleTransform.ScaleY = Math.Max(0.1, scaleTransform.ScaleY);
74+
}
4775
}
4876

4977
[MemberNotNull(nameof(TextEditor), nameof(_textEditor))]

LightTextEditorPlus/Docs/待办.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@
192192
- 经过测试,发现只有 PPT 下才能处理,在 Word 等,都是走 WPF 行距算法,提升行高从而解决问题
193193
- [Javanese Text - Typography - Microsoft Learn](https://learn.microsoft.com/zh-hk/typography/font-list/javanese-text )
194194
- [ ] 带上下标文本的选择范围错误
195+
- [ ] Skia 渲染和 HarfBuzzSharp 计算的宽度不相同
196+
- 问题号:1d0299-使用 rr.导致字符宽度计算错误
195197
- [x] Avalonia 设置文本前景色导致连写字渲染失效
196198
- 问题号: ad1b1c9-设置文本前景色导致连写字渲染失效
197199
- 修复版本: 0e6e2caa4153d50add3ff6bf24588301bd7222ac
4.19 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
测试版本: 1d0299848c7774da9f891ac04335c5faa311c640
2+
3+
问题描述:
4+
5+
如下图,可见字符宽度不正确,第一个 r 字符的宽度明显大于第二个 r 字符宽度
6+
7+
![](./字符宽度计算错误.png)

LightTextEditorPlus/LightTextEditorPlus.Avalonia/Platform/TextEditor.Platform.ava.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ public sealed override void Render(DrawingContext context)
510510
/// <param name="context"></param>
511511
protected virtual void Render(in AvaloniaTextEditorDrawingContext context)
512512
{
513-
_renderEngine.Render(context);
513+
_renderEngine.Render(in context);
514514
}
515515

516516
#endregion

0 commit comments

Comments
 (0)