Class: GTK::Console::FontStyle

Inherits:
Object
  • Object
show all
Defined in:
dragon/console_font_style.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(font:, size_enum:, line_height:) ⇒ FontStyle

Returns a new instance of FontStyle.


13
14
15
16
17
# File 'dragon/console_font_style.rb', line 13

def initialize(font:, size_enum:, line_height:)
  @font = font
  @size_enum = size_enum
  @line_height = line_height
end

Instance Attribute Details

#fontObject (readonly)

Returns the value of attribute font


11
12
13
# File 'dragon/console_font_style.rb', line 11

def font
  @font
end

#line_heightObject (readonly)

Returns the value of attribute line_height


11
12
13
# File 'dragon/console_font_style.rb', line 11

def line_height
  @line_height
end

#size_enumObject (readonly)

Returns the value of attribute size_enum


11
12
13
# File 'dragon/console_font_style.rb', line 11

def size_enum
  @size_enum
end

Instance Method Details

#label(x:, y:, text:, color:, alignment_enum: 0) ⇒ Object


27
28
29
30
31
32
33
34
35
36
37
# File 'dragon/console_font_style.rb', line 27

def label(x:, y:, text:, color:, alignment_enum: 0)
  {
    x: x,
    y: y.shift_up(line_height_px),  # !!! FIXME: remove .shift_up(line_height_px) when we fix coordinate origin on labels.
    text: text,
    font: font,
    size_enum: size_enum,
    alignment_enum: alignment_enum,
    **color.to_h,
  }.label
end

#letter_sizeObject


19
20
21
# File 'dragon/console_font_style.rb', line 19

def letter_size
  @letter_size ||= $gtk.calcstringbox 'W', size_enum, font
end

#line_height_pxObject


23
24
25
# File 'dragon/console_font_style.rb', line 23

def line_height_px
  @line_height_px ||= letter_size.y * line_height
end