Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Red Squigly and DPI - RapidSpell Desktop .NET - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
bknapik
#1 Posted : Friday, February 7, 2014 7:48:49 PM
Rank: Member

Groups: Registered

Joined: 2/7/2014
Posts: 4
Hello,

We are doing system testing on our application before we ship. We found that in 125 and 150 DPI the red squiggly is actually rendered through the words. An example of this can be found here: https://dl.dropboxusercontent.co.../593291/dpi%20keyoti.png

Is there any way we can resolve this? We are using the latest version. 5.1.1

Thanks,

Brett Knapik
Jim
#2 Posted : Saturday, February 8, 2014 12:54:39 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Hi Brett, I couldn't reproduce this in Win 8, the underlines don't move. Also this hasn't been brought up before, so I wonder, was the test machine restarted after the DPI was changed? I believe if you don't restart it can cause odd behaviour like that.

Jim

-your feedback is helpful to other users, thank you!

-your feedback is helpful to other users, thank you!


bknapik
#3 Posted : Monday, February 10, 2014 2:20:14 PM
Rank: Member

Groups: Registered

Joined: 2/7/2014
Posts: 4
Hi Jim,

So I did a little bit more testing on a Surface Pro 1 with Windows 8.1 at 150% dpi. It appears that some fonts work okay, while others do not. For example, Segoe Print works well. However, Tahoma, size 8, or Segoe UI, size 10, appear to have the red squiggly through the text. Let me know if this shows up for you.

To give some more context to our application. Basically, what we do is we make a richtext box and add it as a child to a win forms control. We set the Bounds property of the rich text control to an appropriate rectangle. The user modifies the rich text until they click outside the window and we commit our value.

Thanks,

Brett
Jim
#4 Posted : Monday, February 10, 2014 6:48:27 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Thanks Brett, it still works OK for me, with Segoe UI 10pt. I tried with RichTextBox and TextBox. Which are you seeing it in?

Are you able to reproduce with our demo project?

Jim

-your feedback is helpful to other users, thank you!

-your feedback is helpful to other users, thank you!


bknapik
#5 Posted : Tuesday, February 11, 2014 7:22:08 PM
Rank: Member

Groups: Registered

Joined: 2/7/2014
Posts: 4
Okay, so I got a sample application showing the problem. It can be downloaded at: https://dl.dropboxuserco...291/WpfApplication2.zip

Upon further inspection, it appears that since we are hosting the RichTextBox in a Windows Form Host in WPF it messes up the red squiggles. Our application is a WPF application, with a Windows Form control in it, which uses a Win Forms RichTextBox inside of that control.

Interestingly, the physical font sizes are different in the Win Forms RichTextBox based on whether it hosted in WPF or a pure win forms application. The WPF application matches the physical size of MS Word, while the pure win forms application does not.

Thanks,

Brett
Jim
#6 Posted : Wednesday, February 12, 2014 5:20:53 AM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
I'm sure you have your own reasons for using the Win Forms RTB in WPF (like how different WPF's RTB is to use) but I should mention that RapidSpell WPF is nearly identical to RapidSpell Desktop .NET.

We can measure where the underline should go using one of two Win32 interop calls. I tried with both and they both behave the same in your situation. They're pretty basic calls to EM_FORMATRANGE, so there's not much that I can see that is wrong with it. I have emailed you a modification to your project, which includes all the code we use to measure the text - I don't know if you want to have a look at it.

Not really sure what to suggest - I suppose it may be possible for you to use some kind of heuristic to arrive at a displacement for the underline, and then modify it's position accordingly. To do that you'd need to change your textboxes from RichTextBox to AYTRichTextBox (it's our subclass, that includes a y offset property).

Let me know your thoughts please.
Jim



-your feedback is helpful to other users, thank you!

-your feedback is helpful to other users, thank you!


bknapik
#7 Posted : Wednesday, February 12, 2014 5:57:05 PM
Rank: Member

Groups: Registered

Joined: 2/7/2014
Posts: 4
So after working with Jim in e-mails, we figured it out.

The problem is that when a Win Forms RichTextBox is hosted in a WPF WindowsFormsHost DPI scaling gets applied to the text inside of it. So to fix this, we need to have Keyoti adapt to the DPI scaling. To achieve this we need to make a simple class:

Code:

internal class WpfAsYouTypeAdapter : RichTextBoxIAYTAdapter
    {
        internal WpfAsYouTypeAdapter(RichTextBox rtb, bool contextMenu)
            : base(rtb, contextMenu)
        {

        }

        public override int GetBaselineOffsetAtCharIndex(int i)
        {
            int offset = base.GetBaselineOffsetAtCharIndex(i);

            using(Graphics g = Graphics.FromHwnd(this.tbb.Handle))
            {
                float dpiYFactor = g.DpiY / 96f; // account for DPI
                return (int)(offset * dpiYFactor);
            }
        }
    }


Then for the richtextbox/spellchecker

Code:

RichTextBox rtb = new RichTextBox();
RapidSpellAsYouType spellcheck = new RapidSpellAsYouType();
spellCheck.TextComponent = new WpfAsYouTypeAdapter(rtb, spellcheck.ShowCutCopyPasteMenuOnTextBoxBase);


this will have the squiggles appear below the text in 100/125/150 DPI
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.