HU/dxGetFontHeight

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Ez a function visszaadja egy bizonyos szövegrész elméleti magasságát, ha a dxDrawText használatával lett rajzolva.

[[{{{image}}}|link=|]] Megjegyzés: A visszakapott magasság 1.75 szerese a tényleges pixelmagasságnak.

Szintaxis

int dxGetFontHeight ( [float scale=1, mixed font="default"] )

OOP Syntax Help! I don't understand this!

Note: This syntax requires you to ignore the font argument above
Method: font:getHeight(...)

Kötelező paraméterek

Nincs

Tetszőleges paraméterek

Megjegyzés: Amikor tetszőleges paramétereket használ, előfordulhat, hogy az összes paramétert meg kell adnia, mielőtt egyet is használna. További információkért látogassa meg a tetszőleges paraméterek oldalt.

  • scale: A szöveg mérete.
  • font: Vagy egy egyedi DX font elem, vagy egy beépített DX betűtípus neve:
    • "default": Tahoma
    • "default-bold": Tahoma Bold
    • "clear": Verdana
    • "arial": Arial
    • "sans": Microsoft Sans Serif
    • "pricedown": Pricedown (GTA's theme text)
    • "bankgothic": Bank Gothic Medium
    • "diploma": Diploma Regular
    • "beckett": Beckett Regular
    • "unifont": Unifont

Visszatérési értéke

Visszaadja a szöveg magasságát egészszámként.

Példa

A kövekező példa két szöveget fog kirajzolni, egyiket a másik fölé.

Click to collapse [-]
Client
screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution
scale = 2  -- The scale of both texts

-- We add an event handler to keep drawing the text 
addEventHandler("onClientRender",root,function()

   -- Draw the first text 400 pixels from the top and left of the screen
   dxDrawText("Hello!", 400, 400, screenWidth,screenHeight,tocolor(255,255,255,255),scale,"pricedown")

   -- Draw the second text above the first one.
   -- The variable "offset" will return the height of the first text, so we can position the second text above the first one. 
   -- If we changed the scale, the second text would still be above the first one, since we calculated the height of the font. 
   offset = dxGetFontHeight(scale,"pricedown")
   dxDrawText("Hello!", 400, 400 - offset, screenWidth, screenHeight,tocolor(255,255,255,255),scale,"pricedown")
end)

Lásd még

Fordította

2018.11.27. Surge