Page 1 of 1

For which fonts the function works: DC_GraQueryTextbox()

Posted: Tue Apr 10, 2018 1:00 pm
by Eugene Lutsenko
The DC_GraQueryTextbox() function description States that It does not work for all fonts. What fonts does it work for?

Code: Select all

       aTxtPar = DC_GraQueryTextbox(aNameCls[aClustClsNum[j]], oFont)      // {101,16} Определяет длину и высоту текста в пикселях для некоторых шрифтов
       mMaxlen = MAX(mMaxlen, aTxtPar[1])
This is not working correctly. When you output text, it hits other elements of the image, because its length is determined incorrectly.

Re: For which fonts the function works: DC_GraQueryTextbox()

Posted: Tue Apr 10, 2018 2:17 pm
by Auge_Ohr
Eugene Lutsenko wrote:The DC_GraQueryTextbox() function description States that It does not work for all fonts. What fonts does it work for?

Code: Select all

       aTxtPar = DC_GraQueryTextbox(aNameCls[aClustClsNum[j]], oFont) 
is oFont a Object ?

i think it must be a String here
Arguments:
<cString> is a text string.

<cFont> is a character string containing the name of the font
which conforms to a standard Xbase++ font definition, such as
'12.Arial Bold'.
or look into _dcfunct.prg

Code: Select all

FUNCTION DC_GraQueryTextBox( cCaption, cFont, nOption, nMode )
...
IF Valtype(cFont) = 'C'
  oXbp:setFontCompoundName(cFont)
ENDIF
...

Re: For which fonts the function works: DC_GraQueryTextbox()

Posted: Tue Apr 10, 2018 7:30 pm
by rdonnay
Below is the documentation for the function.
I don't see where it says that some fonts do not work.

dc_graquerytextbox()
Get the width and height of a text string based on a font
DC_GraQueryTextBox() is used to calculate the width and height, in pixels, of a text string based on a specified font. This is basically a wrapper function for the Xbase++ function GraQueryTextBox() which is simpler to use.


Syntax:
DC_GraQueryTextBox( <cString>, ;
<cFont> ) -> aSize


Returns:
A two element array of numeric values.

[1] - Width
[2] - Height

Arguments:
<cString> is a text string.

<cFont> is a character string containing the name of the font
which conforms to a standard Xbase++ font definition, such as
'12.Arial Bold'.


Examples:
PROCEDURE XTest( )

LOCAL i, j, cFont, nRow, lOk, GetList := {}, nHeight

FOR i := 8 TO 22 STEP 2
cFont := Alltrim(Str(i)) + '.Arial'
nHeight := DC_GraQueryTextBox( 'Text', cFont )[2]
nRow := 1
FOR j := 1 TO 10
@ nRow, 0 DCSAY 'This is line ' + Alltrim(Str(j)) ;
FONT cFont SAYSIZE 0 PIXEL
nRow += nHeight
NEXT
DCREAD GUI FIT ADDBUTTONS TO lOk
IF !lOk
EXIT
ENDIF
NEXT

RETURN



Files:
_DCFUNCT.PRG, DCLIPX.DLL

Re: For which fonts the function works: DC_GraQueryTextbox()

Posted: Wed Apr 11, 2018 1:25 am
by Eugene Lutsenko
Thank You! I know all about it. But the function sometimes does not work correctly. Try a proportional font

Re: For which fonts the function works: DC_GraQueryTextbox()

Posted: Wed Apr 11, 2018 2:13 am
by Tom
Proportional fonts are the native base for this function - they are the reason why this function exists. I do use it a lot to preformat labels, calculate font sizes for ownerdrawing and that kind of stuff. I never faced a problem, no matter what font was used.