Zebra API Doc

zebra.ui.Font Class

This class represents a font and provides basic font metrics like height, ascent. Using the class developers can compute string width.

 // plain font 
 var f = new zebra.ui.Font("Arial", 14);

 // bold font
 var f = new zebra.ui.Font("Arial", "bold", 14);

 // defining font with CSS font name
 var f = new zebra.ui.Font("100px Futura, Helvetica, sans-serif");

Constructor

zebra.ui.Font

(
  • name
  • [style]
  • [size]
)

Parameters:

  • name String

    a name of the font. If size and style parameters has not been passed the name is considered as CSS font name that includes size and style

  • [style] String optional

    a style of the font: "bold", "italic", etc

  • [size] Integer optional

    a size of the font

Item Index

Attributes

Methods

charsWidth

(
  • s
  • off
  • len
)
Integer

Calculate the specified substring width

Parameters:

  • s String

    a string

  • off Integer

    fist character index

  • len Integer

    length of substring


Return: Integer

a substring size in pixels

stringWidth

(
  • s
)
Integer

Calculate the given string width in pixels

Parameters:

  • s String

    a string whose width has to be computed


Return: Integer

a string size in pixels

toString

() String

Returns CSS font representation


Return: String

a CSS representation of the given Font

Attributes

ascent

Integer readonly

Ascent of the font

height

Integer readonly

Height of the font