Page 1 of 1

Which fonts work DC_GraQueryTextbox()

Posted: Fri Jul 17, 2015 1:29 pm
by Eugene Lutsenko
Which fonts work function works DC_GraQueryTextbox()? I would like to display the symbol to know the width and height in pixels of the area in which it will be displayed. I would like to display it on a different background than the surrounding. Fill the box with one color using the GraBox(). Then another color fills the area to display a character with the same function. And then in this area with another icon is displayed in the background. Like anything complex. But I have a function DC_GraQueryTextbox() incorrectly determines the width and height of the area needed to display the symbol.

Code: Select all

   aFonts := XbpFont():new():list()                    // Все доступные шрифты

   oFont := XbpFont():new():create(cFont)
   GraSetFont(oPS , oFont)                             // установить шрифт
   aAttrF := ARRAY( GRA_AS_COUNT ) 
   aAttrF [ GRA_AS_COLOR      ] := GRA_CLR_BLACK 
   aAttrF [ GRA_AS_HORIZALIGN ] := GRA_HALIGN_LEFT     // Выравнивание символов по горизонтали по левому краю
   aAttrF [ GRA_AS_VERTALIGN  ] := GRA_VALIGN_BOTTOM   // Выравнивание символов по вертикали   по низу
   GraSetAttrString( oPS, aAttrF )                     // Установить символьные атрибуты

*****************************************

          *** Стереть окно, т.е. нарисовать белый прямоугольник с белыми границами
          *** Стереть окно, т.е. нарисовать светло-желтый прямоугольник с такими же границами

*         GraSetColor( oPS, GRA_CLR_WHITE, GRA_CLR_WHITE )
          GraSetColor( oPS, aColor[163], aColor[163] )
          GraBox( oPS, { 0, 0 }, { X_MaxW, Y_MaxW }, GRA_FILL ) 

          *** Символ нарисовать черным на на белом фоне

          aTxtPar = DC_GraQueryTextbox(CHR(mSimb), oFont)                       // {101,16} Определяет длину и высоту текста в пикселях для некоторых шрифтов

          GraSetColor( oPS, GRA_CLR_WHITE, GRA_CLR_WHITE )
          GraBox( oPS, { 0, 0 }, { aTxtPar[1], aTxtPar[2] }, GRA_FILL ) 
          GraSetColor( oPS, GRA_CLR_BLACK, GRA_CLR_BLACK )

          GraStringAt( oPS, { 0, 0 }, CHR(mSimb))                               // Отобразить символ
[/size]
The result - a small white rectangle around the origin. A 9 should be on a white background surrounded by a light yellow background:
Image

Re: Which fonts work DC_GraQueryTextbox()

Posted: Fri Jul 17, 2015 2:46 pm
by rdonnay
This is correct.
A font must have an area for lower case letters such as j, g, p, q, y.

That is what is causing the blank space.

Any font that is installed on your computer can be used.

Re: Which fonts work DC_GraQueryTextbox()

Posted: Sat Jul 18, 2015 12:37 am
by Eugene Lutsenko
The fact that character 9 font printed "400.@ Arial Unicode MS". I was hoping that he would be on a white background. So to me it would be easier to select an area of the image: the image - this is all that is not the background. And how do you know the width and height in pixels of text to display it?

Re: Which fonts work DC_GraQueryTextbox()

Posted: Sat Jul 18, 2015 9:57 am
by rdonnay
Please give me some code that i can compile and run.
This is taking me too long to write a sample.

Re: Which fonts work DC_GraQueryTextbox()

Posted: Sat Jul 18, 2015 11:39 am
by Eugene Lutsenko
rdonnay wrote:Please give me some code that i can compile and run.
This is taking me too long to write a sample.
it's here:
http://lc.kubagro.ru/Dima/LC_GenFontsEng.zip

Re: Which fonts work DC_GraQueryTextbox()

Posted: Sat Jul 18, 2015 1:59 pm
by Auge_Ohr
Eugene Lutsenko wrote:

Code: Select all

   aTxtPar = DC_GraQueryTextbox(CHR(mSimb), oFont)
   ...
   GraBox( oPS, { 0, 0 }, { aTxtPar[1], aTxtPar[2] }, GRA_FILL ) 
The result - a small white rectangle around the origin. A 9 should be on a white background surrounded by a light yellow background:
GraQueryTextBox() does return a 2-Dim Array :!:

Code: Select all

   oPS      := ::LockPS()
   GraSetFont( oPS, oSelf:oFont )
   aBox     := GraQueryTextBox( oPS, cText )
   //
   // wide of Item (Text)
   //
   IF NIL <> aBox
      nTextwidth := (aBox[3][1] - aBox[1][1])
      nTextheigh := (aBox[4][1] - aBox[2][1])
      ...
      GraBox( oPS, { 0, 0 }, { nTextwidth, nTextheigh }, GRA_FILL ) 
   ENDIF
   ...
   ::UnlockPS()
   oPS      := NIL

Re: Which fonts work DC_GraQueryTextbox()

Posted: Sat Jul 18, 2015 10:38 pm
by Eugene Lutsenko
Hi, Jimmy!

Unfortunately it is not. You gave an example not function: DC_GraQueryTextBox(), and with the function: GraQueryTextBox()
This is not a two-dimensional and one-dimensional array:
Image
Look: c:\exp20\Source\Dclipx\_dcfunct.prg

Code: Select all

FUNCTION DC_GraQueryTextBox( cCaption, cFont, nOption, nMode )

LOCAL oXbp , aArray, nWidth, nHeight

DEFAULT nMode := 2

oXbp := XbpStatic():new(AppDeskTop())
IF Valtype(nOption) == 'N'
  oXbp:option := nOption
ENDIF

IF nMode == 1
  oXbp:create()
ENDIF

IF Valtype(cFont) = 'C'
  oXbp:setFontCompoundName(cFont)
ENDIF

IF nMode == 2
  oXbp:create()
ENDIF

aArray := GraQueryTextBox( oXbp:lockPS(), cCaption )
nWidth := aArray[3,1] - aArray[1,1] // width
nHeight := aArray[1,2] - aArray[2,2] // height
oXbp:unlockPS()
oXbp:destroy()

RETURN {nWidth, nHeight}
[/size]
But now I will try as you suggested, probably will.

Re: Which fonts work DC_GraQueryTextbox()

Posted: Sat Jul 18, 2015 10:47 pm
by Eugene Lutsenko