class

X11::FontStruct

Inherits Reference / Object

Constructors

new(display : Display, font_struct : X::PFontStruct)
Source

Instance methods

display
Source
finalize
Source
font_struct
Source
name

Returns the font's name.

Source
property(atom : Atom | X11::C::Atom) : Atom | X11::C::Atom | Bool

Returns the value of the specified font property.

###Arguments

  • atom Specifies the atom for the property name you want returned.

###Description Given the atom for that property, the property() function returns the value of the specified font property. property() also returns false if the property was not defined or true if it was defined. A set of predefined atoms exists for font properties, which can be found in x11/atom.cr . This set contains the standard properties associated with a font. Although it is not guaranteed, it is likely that the predefined font properties will be present.

###See also Display::create_gc, finalize, Display::fonts, Display::load_font, Display::load_query_font, Display::query_font, Display::set_font_path, Display::unload_font.

Source
property_name(atom : Atom | X11::C::Atom)
Source
text_extents(string : String) : NamedTuple(direction: Int32, font_ascent: Int32, font_descent: Int32, overall: CharStruct, res: Int32)

Performs the size computation locally.

###Arguments

  • string Specifies the character string.

###Returns

  • direction Returns the value of the direction hint (FontLeftToRight or FontRightToLeft).
  • font_ascent Returns the font ascent.
  • font_descent Returns the font descent.
  • overall Returns the overall size in the specified CharStruct structure.

###Description The text_extents function performs the size computation locally and, thereby, avoid the round-trip overhead of query_text_extents and query_text_extents_16. The function returns an CharStruct structure, whose members are set to the values as follows.

The ascent member is set to the maximum of the ascent metrics of all characters in the string. The descent member is set to the maximum of the descent metrics. The width member is set to the sum of the character-width metrics of all characters in the string. For each character in the string, let W be the sum of the character-width metrics of all characters preceding it in the string. Let L be the left-side-bearing metric of the character plus W. Let R be the right-side-bearing metric of the character plus W. The lbearing member is set to the minimum L of all characters in the string. The rbearing member is set to the maximum R.

For fonts defined with linear indexing rather than 2-byte matrix indexing, each X11::C::X::Char2b structure is interpreted as a 16-bit number with byte1 as the most-significant byte. If the font has no defined default character, undefined characters in the string are taken to have all zero metrics.

###See also Display::query_text_extents, Display::query_text_extents_16, text_extents_16.

Source
text_extents_16(string : Array(X11::C::X::Char2b)) : NamedTuple(direction: Int32, font_ascent: Int32, font_descent: Int32, overall: CharStruct, res: Int32)

Performs the size computation locally.

###Arguments

  • string Specifies the character string.

###Returns

  • direction Returns the value of the direction hint (FontLeftToRight or FontRightToLeft).
  • font_ascent Returns the font ascent.
  • font_descent Returns the font descent.
  • overall Returns the overall size in the specified CharStruct structure.

###Description The text_extents_16 function performs the size computation locally and, thereby, avoid the round-trip overhead of query_text_extents and query_text_extents_16. The function returns an CharStruct structure, whose members are set to the values as follows.

The ascent member is set to the maximum of the ascent metrics of all characters in the string. The descent member is set to the maximum of the descent metrics. The width member is set to the sum of the character-width metrics of all characters in the string. For each character in the string, let W be the sum of the character-width metrics of all characters preceding it in the string. Let L be the left-side-bearing metric of the character plus W. Let R be the right-side-bearing metric of the character plus W. The lbearing member is set to the minimum L of all characters in the string. The rbearing member is set to the maximum R.

For fonts defined with linear indexing rather than 2-byte matrix indexing, each X1::C::X::Char2b structure is interpreted as a 16-bit number with byte1 as the most-significant byte. If the font has no defined default character, undefined characters in the string are taken to have all zero metrics.

###See also Display::query_text_extents, Display::query_text_extents_16, text_extents.

Source
text_width(string : String) : Int32

Determines the width of an 8-bit character string.

###Arguments

  • string Specifies the character string.

###See also text_width_16, Display::load_font, text_extents.

Source
text_width_16(string : Array(X11::C::X::Char2b)) : Int32

Determines the width of an 16-bit character string.

###Arguments

  • string Specifies the character string.

###See also text_width, Display::load_font, text_extents.

Source
to_unsafe
Source
to_x
Source