Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.


It seems SRP_String is for screen display.
Is there any way to convert this to print width, as the Get_Printer function is too slow in OI9.
Or any SRP utility for the same?


  • Since SRP_String is for the screen, you can get the screen's DPI and use that to convert to the Printer's DPI.

    Declare function GetDC, GetDeviceCaps Declare subroutine ReleaseDC Equ LOGPIXELSX$ to 88 Equ LOGPIXELSY$ to 90 hDC = GetDC(0) DpiX = GetDeviceCaps(hDC, LOGPIXELSX$) DpiY = GetDeviceCaps(hDC, LOGPIXELSY$) ReleaseDC( 0, hDC )

    Use DpiX to adjust width and DpiY to adjust height.
  • The DPI returns a value of 96.
    When I divide the returned string width by the DPI, I get a value approx 1.3 times less than what I get with the OIPI calc text function. Is there some relationship I am not seeing.

    I can factor this by the 1.3 (1.2996etc) to get a good approximation however.

    This is exciting, as it is 50+ times faster than doing it in OIPI.

  • If you know the font face and size beforehand (which you should if you are printing), you may want to look into Utility("TEXTRECT"). We wrote a wrapper around this that determines the printed font width for the given text string and where to word wrap based on a passed in imperial width.
  • Thanks Frank, I will check it out.
    The help text is less that useful.
    Any idea what unit the Wrap width and the return values are in. Pixels?
  • Also, the DrawText documentation online states DT_WORDBREAK should do the break for you.
    Looking at some old SRP documentation examples this does not seem to be the case.
    Would be great if this did it for you as it suggests. Do you have a working example?
  • edited November 2018
    If we do something like this...

    TextRect = Utility("TEXTRECT", "", Text :@FM: (0 + 1024 + 16) :@FM: 640 :@FM: Font)

    ... where 'Text' is the text you'd like to compute, and 'Font' is a normal @SVM delimited font description array, TextRect<1> will be the width in 'units'.

    The conversion is 70.612 units per inch.
  • Thanks for the conversion.

    I tried the command but it does not return CRLF delimiters in the text, despite the DT_WORDBREAK (16) set.
    I will continue testing
  • DT_WORDBREAK does not modify the text you pass into it. It should be called DT_WORDWRAP, as it wraps whole words onto the next line when drawing or measuring text. It does not insert CRLF delimiters for you.
  • AH, shame, I was hoping for the easy way out (as always) , which would have been much faster.
Sign In or Register to comment.