Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selecting a range of specific emoji and dragging them raises an exception #51

Open
BladeanMericle opened this issue Dec 15, 2021 · 3 comments

Comments

@BladeanMericle
Copy link

Environment

  • OS: Windows 10
  • .NET Framework version: 4.0、5.0
  • Development tool: Visual Studio 2022 Community
  • emoji.wpf version: latest sources (2021-12-14)

Operation

  1. Compile Sample project in Emoji.Wpf solution.
  2. Launch Sample.exe.
  3. Input "🚏" to emoji:RichTextBox.
  4. Select a range of "🚏".
  5. Drag the selected "🚏".

Expected result.

An exception was not cause.

Actual result.

An exception was cause.

Stacktrace (Sorry for the partial Japanese.)

System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=パラパーター倀は、0 γ‚ˆγ‚Šε€§γγ„εΏ…θ¦γŒγ‚γ‚ŠγΎγ™γ€‚
パラパーター名:pixelWidth
  Source=PresentationCore
  スタック γƒˆγƒ¬γƒΌγ‚Ή:
   場所 System.Windows.Media.Imaging.RenderTargetBitmap..ctor(Int32 pixelWidth, Int32 pixelHeight, Double dpiX, Double dpiY, PixelFormat pixelFormat)
   場所 System.Windows.Documents.WpfPayload.GetBitmapSourceFromImage(Image image)
   場所 System.Windows.Documents.WpfPayload.CreateComponentParts(PackagePart sourcePart)
   場所 System.Windows.Documents.WpfPayload.SaveRange(ITextRange range, Stream& stream, Boolean useFlowDocumentAsRoot, Boolean preserveTextElements)
   場所 System.Windows.Documents.TextEditorCopyPaste._CreateDataObject(TextEditor This, Boolean isDragDrop)
   場所 System.Windows.Documents.TextEditorDragDrop._DragDropProcess.SourceOnMouseMove(Point mouseMovePoint)
   場所 System.Windows.Documents.TextEditorMouse.OnMouseMoveWithFocus(TextEditor This, MouseEventArgs e)
   場所 System.Windows.Controls.Primitives.TextBoxBase.OnMouseMove(MouseEventArgs e)
   場所 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   場所 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   場所 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   場所 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   場所 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   場所 System.Windows.Input.InputManager.ProcessStagingArea()
   場所 System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   場所 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   場所 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   場所 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   場所 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   場所 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   場所 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   場所 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   場所 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   場所 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   場所 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   場所 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   場所 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   場所 System.Windows.Application.RunDispatcher(Object ignore)
   場所 System.Windows.Application.RunInternal(Window window)
   場所 Sample.SampleWindow.Main()

Specific emoji

  • 🚏
  • 🍼
  • πŸ“Ž
  • ◼️
  • ◻️
    etc...
samhocevar added a commit that referenced this issue Dec 30, 2021
Due to how the RTB internals perform the operation, all emoji inlines were
converted to space characters. The workaround is a bit experimental, but it
seems to work.

As a side effect, this may also address issue #51.
@samhocevar
Copy link
Owner

Hello! Unfortunately, I have been unable to reproduce the issue so far. Could you maybe answer a few questions?

  • what is your version of the Segoe UI Emoji font? You can find this information in the Fonts Settings
  • do you insert the 🚏 character by copy/pasting it or through the Win. shortcut?
  • could you post a screenshot of the Sample application as it runs on your system?
  • could you try the latest Git commits I made? I have tweaked the drag-n-drop behaviour

Thanks in advance!

@BladeanMericle
Copy link
Author

Thank you for your reply!

what is your version of the Segoe UI Emoji font? You can find this information in the Fonts Settings

Segoe UI Emoji font version is 1.29.
seguiemj

do you insert the 🚏 character by copy/pasting it or through the Win. shortcut?

I used emoji:Picker to insert 🚏 character.
Picker_select

could you post a screenshot of the Sample application as it runs on your system?

Sample_arrow2

could you try the latest Git commits I made? I have tweaked the drag-n-drop behaviour

Unfortunately, An exception was cause yet. (2022-01-06 latest Git commits.)

@BladeanMericle
Copy link
Author

I discovered that Windows 10 display settings are also involved.
Display -> Scale and layout -> Change the size of text, apps, and other items

  • 100%: Raise exception
  • 150%: Not raise exception

Also, the target emoji had a return width of less than 1 for Emoji.Wpf.Image.RenderEmoji method.
ex) 🚏 width is 0.77685546875

Probably, the exception would occur when the result of multiplying the width of the target emoji by DPI scale is less than 1 for System.Windows.Documents.WpfPayload.GetBitmapSourceFromImage method.
RenderTargetBitmap rtb = new RenderTargetBitmap((int)(di.Width * dpi.DpiScaleX), (int)(di.Height * dpi.DpiScaleY), 96.0, 96.0, PixelFormats.Default);
https://source.dot.net/#PresentationFramework/System/Windows/Documents/WpfPayload.cs,438

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants