text (PDF::Writer)

          # File lib/pdf/writer.rb, line 2334
    2334:   def text(text, options = {})
    2335:       # Apply the filtering which will make underlining (and other items)
    2336:       # function.
    2337:     text = preprocess_text(text)
    2338:
    2339:     options ||= {}
    2340:
    2341:     new_page_required = false
    2342:     __y = @y
    2343:
    2344:     if options[:absolute_left]
    2345:       left = options[:absolute_left]
    2346:     else
    2347:       left = @left_margin
    2348:       left += options[:left] if options[:left]
    2349:     end
    2350:
    2351:     if options[:absolute_right]
    2352:       right = options[:absolute_right]
    2353:     else
    2354:       right = absolute_right_margin
    2355:       right -= options[:right] if options[:right]
    2356:     end
    2357:
    2358:     size = options[:font_size] || 0
    2359:     if size <= 0
    2360:       size = @font_size
    2361:     else
    2362:       @font_size = size
    2363:     end
    2364:
    2365:     just = options[:justification] || :left
    2366:
    2367:     if options[:leading] # leading instead of spacing
    2368:       height = options[:leading]
    2369:     elsif options[:spacing]
    2370:       height = options[:spacing] * font_height(size)
    2371:     else
    2372:       height = font_height(size)
    2373:     end
    2374:
    2375:     text.each do |line|
    2376:       start = true
    2377:       loop do # while not line.empty? or start
    2378:         break if (line.nil? or line.empty?) and not start
    2379:
    2380:         start = false
    2381:
    2382:         @y -= height
    2383:
    2384:         if @y < @bottom_margin
    2385:           if options[:test]
    2386:             new_page_required = true
    2387:           else
    2388:               # and then re-calc the left and right, in case they have
    2389:               # changed due to columns
    2390:             start_new_page
    2391:             @y -= height
    2392:
    2393:             if options[:absolute_left]
    2394:               left = options[:absolute_left]
    2395:             else
    2396:               left = @left_margin
    2397:               left += options[:left] if options[:left]
    2398:             end
    2399:
    2400:             if options[:absolute_right]
    2401:               right = options[:absolute_right]
    2402:             else
    2403:               right = absolute_right_margin
    2404:               right -= options[:right] if options[:right]
    2405:             end
    2406:           end
    2407:         end
    2408:
    2409:         line = add_text_wrap(left, @y, right - left, line, size, just, 0, options[:test])
    2410:       end
    2411:     end
    2412:
    2413:     if options[:test]
    2414:       @y = __y
    2415:       new_page_required
    2416:     else
    2417:       @y
    2418:     end
    2419:   end