WPCubed Product Support

When pasting text it is garbled because of unsupported font

When our customer paste mails from Notes directly into our app. the text is reduced to dots and what have you. If he pastes into Word and then into our program, it works.

It seems that TWPRichText doesn't have a fall back font, or what?

I have found this code snippet and wonder if this is something to try: [](http://wpcubed.com/forum/viewtopic.php?t=5119&highlight=font) ... but where should it be run? The BeforePasteText-event? Is this the best solution or can I choose a fall back font somewhere?

Something like this?

procedure TfrmWordProcessor.WPRichText1BeforePasteText(Sender: TObject;
  RTFData: TWPRTFDataCollection; par: TParagraph; Stream: TStream;
  Reader: TWPCustomTextReader; OnlyBodyText: Boolean;
  var LoadedText: TWPRTFDataBlock);
var
  i,j : Integer;
  ca : TWPCHarAttr;
begin
  for i := 0 to RTFData.RTFProps.FontMaxAnz-1 do
    if Screen.Fonts.IndexOf(RTFData.RTFProps.Fontname[i]) < 0 then
    begin
      RTFData.RTFProps.Fontname[i] := 'Arial'; // Choose default!

      for j := 0 to RTFData.RTFProps.Attributes.CharAttrCount-1 do
      begin
        RTFData.RTFProps.Attributes.GetCharAttr(j,ca);
        if ((ca.MaskHash and BitMask[WPAT_CharFont]) <> 0) and (ca.Values[WPAT_CharFont] = i) then
        begin
          ca.MaskHash := ca.MaskHash and not BitMask[WPAT_CharCharset];
          ca.Values[WPAT_CharCharset] := 0;
          RTFData.RTFProps.Attributes.OverrideCharAttr(j,ca);
        end;
      end;
    end;

  //  WPRichText1.ReformatAll(true, true); // Not used here?
end;

If I instead use the AfterLoadText I expect things already are garbled.

#1 ♥ 0
7.1k Views 1 links 3 users read 3 min
support

Hi,

an unknown font usually does not do the harm. Maybe you can activate cliboard debugging (see wpctrmemo) and paste me the data it writes.

Julian

#2 ♥ 0

I see. Thanks Julian for the answer. I am bothered with this thing because I also encountered it few days ago.

#3 ♥ 0

Hi Julian. Hope you see this even after so long. The problem is still here but has never been a big issue to our customers. They would like to see it fixed though.

It is not just Notes but also a browser specific problem. Copying data from the IE9 is garbled whereas Chrome data is fine.

I have dumped the clipboard contents to files as you suggested, one directly from the IE9, one doing a "touch and go" at MS-Word and one from from Chrome. The last two works fine. It seems that the IE9 copy pastes rtf-code with no line breaks. Chrome and Word inserts <CrLf> for every 300 chars and so.

Is there a way I can issue a break-command before inserting into the document?

#4 ♥ 0
support

Hi,

missing line breaks would not do any harm. You can mail me your clipboard dump.

Julian

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