text (PDF::Writer)

          # File lib/pdf/writer.rb, line 2398
    2398:   def text(text, options = {})
    2399:       # Apply the filtering which will make underlining (and other items)
    2400:       # function.
    2401:     text = preprocess_text(text)
    2402:
    2403:     options ||= {}
    2404:
    2405:     new_page_required = false
    2406:     __y = @y
    2407:
    2408:     if options[:absolute_left]
    2409:       left = options[:absolute_left]
    2410:     else
    2411:       left = @left_margin
    2412:       left += options[:left] if options[:left]
    2413:     end
    2414:
    2415:     if options[:absolute_right]
    2416:       right = options[:absolute_right]
    2417:     else
    2418:       right = absolute_right_margin
    2419:       right -= options[:right] if options[:right]
    2420:     end
    2421:
    2422:     size = options[:font_size] || 0
    2423:     if size <= 0
    2424:       size = @font_size
    2425:     else
    2426:       @font_size = size
    2427:     end
    2428:
    2429:     just = options[:justification] || :left
    2430:
    2431:     if options[:leading] # leading instead of spacing
    2432:       height = options[:leading]
    2433:     elsif options[:spacing]
    2434:       height = options[:spacing] * font_height(size)
    2435:     else
    2436:       height = font_height(size)
    2437:     end
    2438:
    2439:     text.each do |line|
    2440:       start = true
    2441:       loop do # while not line.empty? or start
    2442:         break if (line.nil? or line.empty?) and not start
    2443:
    2444:         start = false
    2445:
    2446:         @y -= height
    2447:
    2448:         if @y < @bottom_margin
    2449:           if options[:test]
    2450:             new_page_required = true
    2451:           else
    2452:               # and then re-calc the left and right, in case they have
    2453:               # changed due to columns
    2454:             start_new_page
    2455:             @y -= height
    2456:
    2457:             if options[:absolute_left]
    2458:               left = options[:absolute_left]
    2459:             else
    2460:               left = @left_margin
    2461:               left += options[:left] if options[:left]
    2462:             end
    2463:
    2464:             if options[:absolute_right]
    2465:               right = options[:absolute_right]
    2466:             else
    2467:               right = absolute_right_margin
    2468:               right -= options[:right] if options[:right]
    2469:             end
    2470:           end
    2471:         end
    2472:
    2473:         line = add_text_wrap(left, @y, right - left, line, size, just, 0, options[:test])
    2474:       end
    2475:     end
    2476:
    2477:     if options[:test]
    2478:       @y = __y
    2479:       new_page_required
    2480:     else
    2481:       @y
    2482:     end
    2483:   end