WPCubed Product Support

Characters shifting around

I have a TWPRichEdit on a form, with Align set to alClient, WordWrap turned on and LayoutMode set to wplayNormal. When I resize the form, random characters within the text will shift back and forth one pixel. I can't find a pattern to which characters will suffer this shifting. Anyone run into this?

#1 ♥ 0
11.1k Views 3 links 2 users read 5 min
support

Hi,

This "shifting" is caused by the GDI - rounding errors when converting the internal render resolution to the screen resolution. You also see it when scaling a metafile.

Set the flag wpfAlwaysFormatWithScreenRes in property FormatOptions and it should be alright.

Also see: [](http://www.wpcubed.com/manuals/wp5man/index.html?wysiwyg.htm)

Julian

#2 ♥ 0

Still getting the problem with the flag turned on. Is there any way that the flag might be reset by methods called on the component?

#3 ♥ 0
support

Hi,

try to add it in code. Which version are you using ?

Julian

#4 ♥ 0

Okay, I added this line right after loading my content into the control. Same issue:

FWPRich.FormatOptions := FWPRich.FormatOptions +
    [wpfAlwaysFormatWithScreenRes];

I am evaluating with 5.18.6d +premium Demo version

#5 ♥ 0
support

Hi,

Maybe that is in the demo - since the production of it several changes were introduced to the painting code.

Julian

#6 ♥ 0

That's all you guys got for me? Unless I can see this working in my application there is no way I am going to pay the license fee. I would have already purchased the license if this issue had not been there.

#7 ♥ 0

I really need a resolution on this, or I will be moving on to another Rich Editing package. How can anyone use WP Tools as a RTF editor replacement if this is the kind of behavior it has? There must be a way to fix this, so many people use it.

#8 ♥ 0
support

Hi,

I re-posted the EXE demo [](http://www.wpcubed.com/ftp/wp5demo.zip). It
now has in demo 1. under "View" the menu item "Toggle Wordwrap Mode".

If I select this here there is no jittering at all, if, and only if,
you don't use justified text. If you use justified text that
repositioning is normal, it is caused by the added pixels between
word.

The character distance can only change because of the internal
rendering, wpfAlwaysFormatWithScreenRes fixes this.

The code for this menu item is:

procedure TWPTBXForm.ToggleWordWrapClick(Sender: TObject);
begin
  if WPRichText1.WordWrap then
  begin
    WPRichText1.WordWrap := FALSE;
    WPRichText1.LayoutMode := wplayFullLayout;
    WPRichText1.FormatOptions := WPRichText1.FormatOptions -
           [wpfAlwaysFormatWithScreenRes];
    WPRichText1.ScrollBars := ssBoth;
  end else
  begin
    WPRichText1.WordWrap := TRUE;
    WPRichText1.LayoutMode := wplayNormal;
    WPRichText1.FormatOptions := WPRichText1.FormatOptions +
           [wpfAlwaysFormatWithScreenRes];
    WPRichText1.ScrollBars := ssVertical;
    WPPreview1.DelayedReformat;
  end;
end;

Please verify with the named EXE demo. It was built with the current
version

With Kind Regards,
Julian Ziersch

#9 ♥ 0

Just a note, this is not yet resolved. Please take a look at this file [](http://www.blueapples.org/gems/Home.rtf)

It must contain something that is causing my jittering problem. When the control is created and then this text is loaded into it, the problem appears. I think that perhaps whatever is in this file "contaminated" the rest of my data--loading any other data retains the rendering error.

If I copy and paste this text into Notepad--removing formatting instructions--then close the demo and reopen it, I can paste the text into a new, blank document and there is no rendering error.

Well, now I'm even more confused. I tried saving the text as a TXT file then loading it with the demo--the rendering error shows up again.

#10 ♥ 0
support

Hi,

Your text does not use justification, that is good. Justification would always cause this effect when varying the page size dynamically (using WordWrap=true)

In my demo I do only see a minimum of character relocation effect when I select
a) WordWrap = true (Menu item: View/Toggle "WordWrap" mode)
b) use Info/Change FormatMode

What you can do is to not use WordWrap=true and instead modify the page size in your own code. You can recalculate Header.PageWidth according the width of the editor when your form is resized.

WPTools always paints using a coordinate tranformation matrix - this is required to support zooming. The character placement is calculated by windows GID (inside words) so the relocation already happens there.

Julian

#11 ♥ 0

Thank you for your help so far but still no dice...

Tried changing the Header.PageWidth in my own resize handler...I get the same effect though, random characters shift within words. I also was a bit confused as to what unit Header.PageWidth is in, it doesn't appear to be twips (15 to a pixel if I remember correctly).

At any rate, at lower multiplication values (such as Control.Header.PageWidth := Contol.Width 5 as opposed to 20) the error is more pronounced: more characters appear to move when the value is smaller. I don't know if this has anything to do with why it's happening.

I really think this is a bug in the matrix code.

#12 ♥ 0
This category is archived. No new posts are possible.