Перейти к основному содержимому

ASCFManager

Like the FontManager but instead of drawing Bitmap fonts, it draws Outline fonts (eg, TTF, OTF and etc). This means it can draw with rotation, any font scale and etc!

And unlike the FontManager, It also lets you convert colors inside text into actual colors!


Functions

addFont

sm.scrapcomputers.ascfManager.addFont( fontPath )

Adds a font.

NOTE 1: Caches instead of loading it!

This will NOT load the font, but instead cache it to improve loading performance.

NOTE 2: Dont use $CONTENT_DATA!

FontPath should be the full path where the font your adding would be, and do not use $CONTENT_DATA but instead $CONTENT_[YOUR_MOD_UUID] to prevent confusion!

Arguments:

  • fontPath [ string ] Path to the font.

getFontInfo

sm.scrapcomputers.ascfManager.loadFont( fontName )

Loads a font.

Arguments:

  • fontName [ string ] Name of the font

Returns:

  • [ boolean ] if it succeeded
  • [ string? ] The error message (if any)

calcTextSize

sm.scrapcomputers.ascfManager.calcTextSize( fontName, text, fontSize, rotation )

Calculates text size, No error handling provided.

Arguments:

  • fontName [ string ] The name of the font
  • text [ string ] The text
  • fontSize [ number ] The size of the font
  • rotation [ number ] The rotation

Returns:

  • [ number ] width The width the font consumes
  • [ number ] hegiht The height the font consumes

drawText

sm.scrapcomputers.ascfManager.drawText( display, xOffset, yOffset, text, fontName, color, rotation, fontSize, colorToggled )

Draws text to a display

Warning

This does NOT provide any error handling and should only be used in performance crtical senarios!

Arguments:

  • display [ Display ] The display
  • xOffset [ number ] The x-coordinate
  • yOffset [ number ] The y-coordinate
  • text [ string ] The text to draw
  • fontName [ string ] The name of the font
  • color [ string|Color ] The color of the text to set
  • rotation [ number? ] The rotation
  • fontSize [ number ] The size of the font to use
  • colorToggled [ boolean? ] If it should support colors or not in text.

drawTextSafe

sm.scrapcomputers.ascfManager.drawTextSafe( display, xOffset, yOffset, text, fontName, color, rotation, fontSize, colorToggled )

Draws text to a display

Arguments:

  • display [ Display ] The display
  • xOffset [ number ] The x-coordinate
  • yOffset [ number ] The y-coordinate
  • text [ string ] The text to draw
  • fontName [ string ] The name of the font
  • color [ string|Color ] The color of the text to set
  • rotation [ number? ] The rotation
  • fontSize [ number ] The size of the font to use
  • colorToggled [ boolean? ] If it should support colors or not in text.