class Object

Constants

WindowsRx

Public Class Methods

new(*_args) click to toggle source
Calls superclass method
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb, line 4
def initialize *_args
  super
  @dummy_text = ?\u0000
end

Public Instance Methods

analyze_glyphs_for_fallback_font_support(fragment_hash) click to toggle source
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb, line 20
def analyze_glyphs_for_fallback_font_support fragment_hash
  fragment_font = fragment_hash[:font] || (original_font = @document.font.family)
  if (fragment_font_styles = fragment_hash[:styles])
    if fragment_font_styles.include? :bold
      fragment_font_opts = { style: (fragment_font_styles.include? :italic) ? :bold_italic : :bold }
    elsif fragment_font_styles.include? :italic
      fragment_font_opts = { style: :italic }
    end
  end
  fallback_fonts = @fallback_fonts.dup
  font_glyph_pairs = []
  @document.save_font do
    fragment_hash[:text].each_char do |char|
      font_glyph_pairs << [(find_font_for_this_glyph char, fragment_font, fragment_font_opts || {}, fallback_fonts.dup), char]
    end
  end
  # NOTE: don't add a :font to fragment if it wasn't there originally
  font_glyph_pairs.each {|pair| pair[0] = nil if pair[0] == original_font } if original_font
  form_fragments_from_like_font_glyph_pairs font_glyph_pairs, fragment_hash
end
ascender=(val) click to toggle source

Modify the built-in ascender write method to allow an override value to be specified using the format_state hash.

# File lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb, line 19
def ascender= val
  @ascender = (format_state.key? :ascender) ? format_state[:ascender] : val
end
conceal() click to toggle source

Prevent fragment from being written by discarding the text.

# File lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb, line 7
def conceal
  @text = ''
end
descender=(val) click to toggle source

Modify the built-in ascender write method to allow an override value to be specified using the format_state hash.

# File lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb, line 25
def descender= val
  @descender = (format_state.key? :descender) ? format_state[:descender] : val
end
draw_fragment_overlay_styles(fragment) click to toggle source
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb, line 6
def draw_fragment_overlay_styles fragment
  if (underline = (styles = fragment.styles).include? :underline) || (styles.include? :strikethrough)
    (doc = fragment.document).save_graphics_state do
      if (text_decoration_width = (fs = fragment.format_state)[:text_decoration_width] || doc.text_decoration_width)
        doc.line_width = text_decoration_width
      end
      if (text_decoration_color = fs[:text_decoration_color])
        doc.stroke_color = text_decoration_color
      end
      underline ? (doc.stroke_line fragment.underline_points) : (doc.stroke_line fragment.strikethrough_points)
    end
  end
end
find_font_for_this_glyph(char, current_font, current_font_opts = {}) click to toggle source
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb, line 41
def find_font_for_this_glyph char, current_font, current_font_opts = {}, fallback_fonts_to_check = [], original_font = current_font
  (doc = @document).font current_font, current_font_opts
  if doc.font.glyph_present? char
    current_font
  elsif fallback_fonts_to_check.empty?
    if logger.info? && !doc.scratch?
      fonts_checked = @fallback_fonts.dup.unshift original_font
      missing_chars = (doc.instance_variable_defined? :@missing_chars) ?
          (doc.instance_variable_get :@missing_chars) : (doc.instance_variable_set :@missing_chars, {})
      previous_fonts_checked = (missing_chars[char] ||= [])
      if previous_fonts_checked.empty? && !(previous_fonts_checked.include? fonts_checked)
        logger.warn %(Could not locate the character `#{char}' in the following fonts: #{fonts_checked.join ', '})
        previous_fonts_checked << fonts_checked
      end
    end
    original_font
  else
    find_font_for_this_glyph char, fallback_fonts_to_check.shift, current_font_opts, fallback_fonts_to_check, original_font
  end
end
include_trailing_white_space!() click to toggle source

Don’t strip soft hyphens when repacking unretrieved fragments

Calls superclass method
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb, line 12
def include_trailing_white_space!
  @format_state.delete :normalized_soft_hyphen
  super
end
next_string() click to toggle source
Calls superclass method
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/arranger.rb, line 9
def next_string
  if (string = super) == @dummy_text
    def string.lstrip!; end
  end
  string
end
process_vertical_alignment(text) click to toggle source
Calls superclass method
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb, line 62
def process_vertical_alignment text
  return super if ::Symbol === (valign = @vertical_align)

  return if defined? @vertical_alignment_processed
  @vertical_alignment_processed = true

  valign, offset = valign

  if valign == :top
    @at[1] -= offset
    return
  end

  wrap text
  h = height

  case valign
  when :center
    @at[1] -= (@height - h + @descender) * 0.5 + offset
  when :bottom
    @at[1] -= (@height - h) + offset
  end

  @height = h
end
run() click to toggle source
# File lib/asciidoctor/pdf/optimizer.rb, line 16
def run
  RGhost::Config.config_platform unless File.exist? RGhost::Config::GS[:path].to_s
  (cmd = @params.slice 1, @params.length).unshift RGhost::Config::GS[:path].to_s
  #puts cmd if @debug
  system(*cmd)
end
shellescape(str) click to toggle source
# File lib/asciidoctor/pdf/optimizer.rb, line 25
def shellescape str
  str
end
to_pdf_object() click to toggle source

Convert the object to a serialized PDF object.

# File lib/asciidoctor/pdf/ext/core/object.rb, line 5
def to_pdf_object
  ::PDF::Core.pdf_object self
end
warning(*args;) click to toggle source
# File lib/asciidoctor/pdf/ext/prawn/extensions.rb, line 7
def warning *args; end
width() click to toggle source
Calls superclass method
# File lib/asciidoctor/pdf/ext/prawn/formatted_text/fragment.rb, line 29
def width
  if (val = format_state[:width])
    val = (val.end_with? 'em') ? val.to_f * @document.font_size : (@document.str_to_pt val) if ::String === val
  else
    val = super
  end
  if (border_offset = format_state[:border_offset])
    val += border_offset * 2
  end
  val
end