CPFIGLetFont

class CPFIGLetFont(flfPath: String) extends CPFont

FIGLet font.

FIGLet fonts allow creating art text out of ordinary letters, for example:


 /$$$$$$                      /$$$$$$$  /$$
/$$__  $$                    | $$__  $$| $$
| $$  \__/  /$$$$$$   /$$$$$$$| $$  \ $$| $$  /$$$$$$  /$$   /$$
| $$       /$$__  $$ /$$_____/| $$$$$$$/| $$ |____  $$| $$  | $$
| $$      | $$  \ $$|  $$$$$$ | $$____/ | $$  /$$$$$$$| $$  | $$
| $$    $$| $$  | $$ \____  $$| $$      | $$ /$$__  $$| $$  | $$
|  $$$$$$/|  $$$$$$/ /$$$$$$$/| $$      | $$|  $$$$$$$|  $$$$$$$
\______/  \______/ |_______/ |__/      |__/ \_______/ \____  $$
  ___  _____  ___  ____  __      __   _  _            /$$  | $$
 / __)(  _  )/ __)(  _ \(  )    /__\ ( \/ )          |  $$$$$$/
( (__  )(_)( \__ \ )___/ )(__  /(__)\ \  /            \______/
 \___)(_____)(___/(__)  (____)(__)(__)(__)
                                       ,,
 .g8"""bgd                 `7MM"""Mq.`7MM
.dP'     `M                   MM   `MM. MM
dM'       ` ,pW"Wq.  ,pP"Ybd  MM   ,M9  MM   ,6"Yb.`7M'   `MF'
MM         6W'   `Wb 8I   `"  MMmmdM9   MM  8)   MM  VA   ,V
MM.        8M     M8 `YMMMa.  MM        MM   ,pm9MM   VA ,V
`Mb.     ,'YA.   ,A9 L.   I8  MM        MM  8M   MM    VVV
 `"bmmmd'  `Ybmd9'  M9mmmP'.JMML.    .JMML.`Moo9^Yo.  ,V
                                                     ,V
                                                  OOb"

You can read the full FIGLet specification here. This class provides relatively full implementation for FIGLet fonts with the following limitations:

  • code tags are NOT supported
  • only UTF-8 and windows-1252 charsets are supported
  • only left-to-right font direction is supported
  • vertical smushing iS NOT supported (ignored)

CosPlay comes with 277 built-in pre-packaged FIGLet fonts. Companion object for this class contains constants for all these fonts.

Here's an example of rendering FIGLet fonts using static image sprites. Note that when invoking render it returns an image that can be rendered or used just like any other image in CosPlay:

val spr1 = CPStaticImageSprite(30, 14, 4, FIG_OGRE.render("CosPlay", C_WHITE).trimBg())
val spr1 = CPStaticImageSprite(30, 20, 4, FIG_OGRE.withKerning().render("CosPlay", C_LIGHT_STEEL_BLUE).trimBg())
val spr1 = CPStaticImageSprite(30, 27, 4, FIG_OGRE.withFullWidth().render("CosPlay", C_LIGHT_CORAL).trimBg())

Here's the list of helpful links when working with FIGLet fonts:

Example:

See CPFontsExample source code for an example of FIGLet font functionality.

Companion:
object
Source:
CPFIGLetFont.scala
class CPFont
trait CPAsset
class Object
trait Matchable
class Any

Type members

Classlikes

case class FIGLet(data: CPArray2D[Char], width: Int, height: Int)

Value members

Concrete methods

override def getBaseline: Int

Gets baseline of this font in standard character.

Gets baseline of this font in standard character.

Definition Classes
Source:
CPFIGLetFont.scala
override def getEncoding: String

Gets encoding used by this font. Note that for the system font it returns "UTF-8".

Gets encoding used by this font. Note that for the system font it returns "UTF-8".

Definition Classes
Source:
CPFIGLetFont.scala
override def getHeight: Int

Gets height of this font in standard characters.

Gets height of this font in standard characters.

Definition Classes
Source:
CPFIGLetFont.scala
override def getWidth: Int

Gets width of this font in standard characters.

Gets width of this font in standard characters.

Definition Classes
Source:
CPFIGLetFont.scala
override def isSystem: Boolean

Whether or not this is a "standard" 1-character height system font.

Whether or not this is a "standard" 1-character height system font.

Definition Classes
Source:
CPFIGLetFont.scala
override def render(s: String, fg: CPColor, bg: Option[CPColor]): CPImage

Renders single line text as an image with this font.

Renders single line text as an image with this font.

Definition Classes
Source:
CPFIGLetFont.scala

Clones this font with controlled smushing.

Clones this font with controlled smushing.

See also:

http://www.jave.de/figlet/figfont.html for FIGLet specification for details.

https://patorjk.com/software/taag for convenient online tester for various FIGLet fonts and their properties.

Source:
CPFIGLetFont.scala

Clones this font with full width

Clones this font with full width

See also:

http://www.jave.de/figlet/figfont.html for FIGLet specification for details.

https://patorjk.com/software/taag for convenient online tester for various FIGLet fonts and their properties.

Source:
CPFIGLetFont.scala

Clones this font with kerning fitting.

Clones this font with kerning fitting.

See also:

http://www.jave.de/figlet/figfont.html for FIGLet specification for details.

https://patorjk.com/software/taag for convenient online tester for various FIGLet fonts and their properties.

Source:
CPFIGLetFont.scala

Clones this font with universal smushing.

Clones this font with universal smushing.

See also:

http://www.jave.de/figlet/figfont.html for FIGLet specification for details.

https://patorjk.com/software/taag for convenient online tester for various FIGLet fonts and their properties.

Source:
CPFIGLetFont.scala

Inherited methods

override def equals(obj: Any): Boolean
Definition Classes
Inherited from:
CPGameObject
Source:
CPGameObject.scala
def getId: String

Gets unique ID of this game object.

Gets unique ID of this game object.

Inherited from:
CPGameObject
Source:
CPGameObject.scala
def getTags: Set[String]

Gets optional set of organizational tags. Note that by default the set of tags is empty.

Gets optional set of organizational tags. Note that by default the set of tags is empty.

See also:
Inherited from:
CPGameObject
Source:
CPGameObject.scala
def renderMulti(s: String, fg: CPColor, bg: Option[CPColor], align: Int): CPImage

Renders given multiline text as an image. Supplied string will be split by system-specific "new line' character sequence ('\n' or '\n\r'). This call is equivalent to:

Renders given multiline text as an image. Supplied string will be split by system-specific "new line' character sequence ('\n' or '\n\r'). This call is equivalent to:

renderSeq(s.split(CPUtils.NL).filter(!_.isBlank).toSeq, fg, bg, align)
Value parameters:
align

Alignment of text. The only allowed values are:

  • -1 - left justified alignment.
  • 0 - centered alignment.
  • 1 - right justified alignment. Default value is 0.
bg

Optional background color to use. Default value is None.

fg

Foreground color to use.

s

Multiline text to render as an image. Must be non-empty.

Returns:

Image as a rendering of the given string with this font.

Inherited from:
CPFont
Source:
CPFont.scala
def renderSeq(ss: Seq[String], fg: CPColor, bg: Option[CPColor], align: Int): CPImage

Renders given multiline text as an image.

Renders given multiline text as an image.

Value parameters:
align

Alignment of text. The only allowed values are:

  • -1 - left justified alignment.
  • 0 - centered alignment.
  • 1 - right justified alignment. Default value is 0.
bg

Optional background color to use. Default value is None.

fg

Foreground color to use.

ss

Sequence of text lines to render as an image. Must be non-empty.

Returns:

Image as a rendering of the given string with this font.

Inherited from:
CPFont
Source:
CPFont.scala

Inherited fields

override val getOrigin: String

Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.

Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.

Inherited from:
CPFont
Source:
CPFont.scala