Which fonts work 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:

Which fonts work DC_GraQueryTextbox()

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

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

Re: Which fonts work DC_GraQueryTextbox()

#2 Post 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.
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: Which fonts work DC_GraQueryTextbox()

#3 Post 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?

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

Re: Which fonts work DC_GraQueryTextbox()

#4 Post by rdonnay »

Please give me some code that i can compile and run.
This is taking me too long to write a sample.
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: Which fonts work DC_GraQueryTextbox()

#5 Post 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

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

Re: Which fonts work DC_GraQueryTextbox()

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

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

Re: Which fonts work DC_GraQueryTextbox()

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


Post Reply