class Hpdf::Font

Included Modules

Defined in:

hpdf/font.cr

Constructors

Instance Method Summary

Instance methods inherited from module Hpdf::Helper

bool(val : Bool) : Int32 bool, nilable_str(v : Pointer(UInt8)) : String | Nil nilable_str, real(val : Number) : LibHaru::Real real, uint(val : Number) : LibHaru::UInt uint, uint16(val : Number) : UInt16 uint16

Constructor Detail

def self.new(font : LibHaru::Font, doc : Doc) #

[View source]

Instance Method Detail

def ascent(font_size : Number) : Float32 #

the vertical ascent of the font in points calculated based on the given font_size.

  • font_size the size to calculate the height with.

[View source]
def ascent : Int32 #

the vertical ascent of the font in UPM (units per eM).


[View source]
def b_box : Rectangle #

the bounding box of the font.


[View source]
def cap_height(font_size : Number) : Float32 #

the distance from the baseline of uppercase letters in points calculated based on the given font_size.

  • font_size the size to calculate the height with.

[View source]
def cap_height : UInt32 #

the distance from the baseline of uppercase letters in UPM (units per eM).


[View source]
def descent(font_size : Number) : Float32 #

the vertical descent of the font in points calculated based on the given font_size.

  • font_size the size to calculate the height with.

[View source]
def descent : Int32 #

the vertical descent of the font in UPM (units per eM).


[View source]
def encoding_name : String #

the encoding name of the font.


[View source]
def measure_text(text : String | Bytes, *, width : Number, font_size : Number, char_space : Number, word_space : Number, word_wrap : Bool = true) : MeasuredText #

calculates the byte length which can be included within the specified width.

  • width The width of the area to put the text.
  • font_size The size of the font.
  • char_space The character spacing.
  • word_space The word spacing.
  • word_wrap When there are three words of "ABCDE FGH IJKL", and the substring until "J" can be included within the width, if word_wrap parameter is false it returns 12, and if word_wrap parameter is false word_wrap parameter is false it returns 10 (the end of the previous word).

[View source]
def name : String #

the name of the font.


[View source]
def text_width(text : String | Bytes) #

total width of the text, number of charactors and number of the words.


[View source]
def to_unsafe : LibHaru::Font #

[View source]
def unicode_width(char : UInt16) : Int32 #

the width of a charactor in the font.


[View source]
def x_height(font_size : Number) : Float32 #

the distance from the baseline of lowercase letters in points calculated based on the given font_size.

  • font_size the size to calculate the height with.

[View source]
def x_height : UInt32 #

the distance from the baseline of lowercase letters in UPM (units per eM).


[View source]