class HexaPDF::Layout::Style

already been used.
property_name?
Tester method to see if a value has been set or if the default value has
property_name(*args) and property_name=
Setter method.
property_name

Getter method.
Each property has three associated methods:
changed.
Each property except #font has a default value, so only the desired properties need to be
A Style is a container for properties that describe the appearance of text or graphics.

def self.create(style)

* If +style+ is +nil+, a new Style object with only default values is created.

* is created.
* If +style+ is a hash, a new Style object with the style properties specified by the hash

* If +style+ is already a Style object, it is just returned.

Creates a Style object based on the +style+ argument and returns it:

Style.create(properties_hash) -> style
Style.create(style) -> style
:call-seq:
def self.create(style)
  case style
  when self then style
  when Hash then new(**style)
  when nil then new
  else raise ArgumentError, "Invalid argument class #{style.class}"
  end
end

def calculated_font_size

The calculated font size, taking superscript and subscript into account.
def calculated_font_size
  (superscript || subscript ? 0.583 : 1) * font_size
end

def calculated_strikeout_position

Returns the correct offset from the baseline for the strikeout line.
def calculated_strikeout_position
  calculated_text_rise +
    font.wrapped_font.strikeout_position * font.scaling_factor *
    font.pdf_object.glyph_scaling_factor * calculated_font_size -
    calculated_strikeout_thickness / 2.0
end

def calculated_strikeout_thickness

Returns the correct thickness for the strikeout line.
def calculated_strikeout_thickness
  font.wrapped_font.strikeout_thickness * font.scaling_factor *
    font.pdf_object.glyph_scaling_factor * calculated_font_size
end

def calculated_text_rise

The calculated text rise, taking superscript and subscript into account.
def calculated_text_rise
  if superscript
    text_rise + font_size * 0.33
  elsif subscript
    text_rise - font_size * 0.20
  else
    text_rise
  end
end

def calculated_underline_position

Returns the correct offset from the baseline for the underline.
def calculated_underline_position
  calculated_text_rise +
    font.wrapped_font.underline_position * font.scaling_factor *
    font.pdf_object.glyph_scaling_factor * calculated_font_size -
    calculated_underline_thickness / 2.0
end

def calculated_underline_thickness

Returns the correct thickness for the underline.
def calculated_underline_thickness
  font.wrapped_font.underline_thickness * font.scaling_factor *
    font.pdf_object.glyph_scaling_factor * calculated_font_size
end

def clear_cache

ascender, descender.
already cached: font, font_size, character_spacing, word_spacing, horizontal_scaling,
This method needs to be called if the following style properties are changed and values were

Clears all cached values.
def clear_cache
  @scaled_font_size = @scaled_character_spacing = @scaled_word_spacing = nil
  @scaled_horizontal_scaling = @scaled_font_ascender = @scaled_font_descender = nil
  @scaled_y_min = @scaled_y_max = nil
  @scaled_item_widths.clear
end

def default_color

Returns the default color for an empty PDF page, i.e. black.
def default_color
  GlobalConfiguration.constantize('color_space.map', :DeviceGray).new.default_color
end

def initialize(**properties)

Style.new(font_size: 15, align: :center, valign: center)
Example:

equivalent to the property names.
The +properties+ hash may be used to set the initial values of properties by using keys

Creates a new Style object.
def initialize(**properties)
  update(**properties)
  @scaled_item_widths = {}.compare_by_identity
end

def initialize_copy(other)

Duplicates the complex properties that can be modified, as well as the cache.
def initialize_copy(other)
  super
  @scaled_item_widths = {}.compare_by_identity
  clear_cache
  @font_features = @font_features.dup if defined?(@font_features)
  @padding = @padding.dup if defined?(@padding)
  @margin = @margin.dup if defined?(@margin)
  @border = @border.dup if defined?(@border)
  @overlays = @overlays.dup if defined?(@overlays)
  @underlays = @underlays.dup if defined?(@underlays)
end

def scaled_character_spacing

The character spacing scaled appropriately.
def scaled_character_spacing
  @scaled_character_spacing ||= character_spacing * scaled_horizontal_scaling
end

def scaled_font_ascender

The ascender of the font scaled appropriately.
def scaled_font_ascender
  @scaled_font_ascender ||= font.wrapped_font.ascender * font.scaling_factor *
    font.pdf_object.glyph_scaling_factor * font_size
end

def scaled_font_descender

The descender of the font scaled appropriately.
def scaled_font_descender
  @scaled_font_descender ||= font.wrapped_font.descender * font.scaling_factor *
    font.pdf_object.glyph_scaling_factor * font_size
end

def scaled_font_size

The font size scaled appropriately.
def scaled_font_size
  @scaled_font_size ||= calculated_font_size * font.pdf_object.glyph_scaling_factor *
    scaled_horizontal_scaling
end

def scaled_horizontal_scaling

The horizontal scaling scaled appropriately.
def scaled_horizontal_scaling
  @scaled_horizontal_scaling ||= horizontal_scaling / 100.0
end

def scaled_item_width(item)

inside a TextFragment.
The item may be a (singleton) glyph object or an integer/float, i.e. items that can appear

word spacing and horizontal scaling into account).
Returns the width of the item scaled appropriately (by taking font size, characters spacing,
def scaled_item_width(item)
  @scaled_item_widths[item] ||=
    if item.kind_of?(Numeric)
      -item * scaled_font_size
    else
      item.width * scaled_font_size + scaled_character_spacing +
        (item.apply_word_spacing? ? scaled_word_spacing : 0)
    end
end

def scaled_word_spacing

The word spacing scaled appropriately.
def scaled_word_spacing
  @scaled_word_spacing ||= word_spacing * scaled_horizontal_scaling
end

def scaled_y_max

height or font size.
The maximum y-coordinate, calculated using the scaled ascender of the font and the line
def scaled_y_max
  @scaled_y_max ||= scaled_font_ascender * (line_height || font_size) / font_size.to_f +
    calculated_text_rise
end

def scaled_y_min

height or font size.
The minimum y-coordinate, calculated using the scaled descender of the font and the line
def scaled_y_min
  @scaled_y_min ||= scaled_font_descender * (line_height || font_size) / font_size.to_f +
    calculated_text_rise
end

def update(**properties)

Updates the style's properties using the key-value pairs specified by the +properties+ hash.

style.update(**properties) -> style
:call-seq:
def update(**properties)
  properties.each {|key, value| send(key, value) }
  self
end