For which fonts the function works: DC_GraQueryTextbox()

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

For which fonts the function works: DC_GraQueryTextbox()

#1 Post 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.

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

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

#2 Post 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
...
greetings by OHR
Jimmy

User avatar
rdonnay
Site Admin
Posts: 4813
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#3 Post 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
The eXpress train is coming - and it has more cars.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

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

#4 Post by Eugene Lutsenko »

Thank You! I know all about it. But the function sometimes does not work correctly. Try a proportional font

User avatar
Tom
Posts: 1234
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

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

#5 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Post Reply