• Hi Julian,

    I've been very quiet so far this year but here goes :)

    I want to get the absolute text width of an RTF for other purposes.

    I am using the following code:

    WP:=TWPCustomRichText.CreateDynamic;
    WP.Header.PageWidth:=280000;
    WP.Header.LeftMargin:=0;
    WP.Header.RightMargin:=0;
    // WP.LayoutMode:=wpLayNormal;
    WP.AsString:=S;
    WP.ReformatAll;
    WPWidth:=WP.Memo.TextWidth/WP.Memo.CurrentXPixelsPerInch;
    WPHeight:=WP.Memo.TextHeight/WP.Memo.CurrentXPixelsPerInch;
    WPLineCount:=WP.Memo.FirstPar.LineCount;
    WP.Free;

    My problem is that in some instances the LineCount is more than 1 even though there are no CR in the text. There are multiple fonts. I have set the PageWidth very large to try and avoid this.

    Any help greatly appreciated.

    Ken

    • Offizieller Beitrag

    Hi,

    I cannot tell why the text is breaking in your case. I assume the text exceeds the maximum width. 280000 is certainly outside of the range which is possible and internally handled.

    The xoffset values used for each character are in WPT5 words, so depending on the rendering resolution (default 600) the maximum width is 2.56 meter which is maybe too small. You can switch to screen resolution in FormatOptions, that multiplies the available width roughly by 6.

    Julian