Module: HexaPDF::Content::TextRenderingMode

Defined in:
lib/hexapdf/content/graphics_state.rb

Overview

Defines all available text rendering modes as constants. Each text rendering mode is an instance of NamedValue. For use with Content::GraphicsState#text_rendering_mode.

See: PDF1.7 s9.3.6

Constant Summary collapse

FILL =

Fill text

NamedValue.new(:fill, 0)
STROKE =

Stroke text

NamedValue.new(:stroke, 1)
FILL_STROKE =

Fill, then stroke text

NamedValue.new(:fill_stroke, 2)
INVISIBLE =

Neither fill nor stroke text (invisible)

NamedValue.new(:invisible, 3)
FILL_CLIP =

Fill text and add to path for clipping

NamedValue.new(:fill_clip, 4)
STROKE_CLIP =

Stroke text and add to path for clipping

NamedValue.new(:stroke_clip, 5)
FILL_STROKE_CLIP =

Fill, then stroke text and add to path for clipping

NamedValue.new(:fill_stroke_clip, 6)
CLIP =

Add text to path for clipping

NamedValue.new(:clip, 7)

Class Method Summary collapse

Class Method Details

.normalize(style) ⇒ Object

Returns the argument normalized to a valid text rendering mode.

  • 0 or :fill can be used for the FILL mode.

  • 1 or :stroke can be used for the STROKE mode.

  • 2 or :fill_stroke can be used for the FILL_STROKE mode.

  • 3 or :invisible can be used for the INVISIBLE mode.

  • 4 or :fill_clip can be used for the FILL_CLIP mode.

  • 5 or :stroke_clip can be used for the STROKE_CLIP mode.

  • 6 or :fill_stroke_clip can be used for the FILL_STROKE_CLIP mode.

  • 7 or :clip can be used for the CLIP mode.

  • Otherwise an error is raised.



247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/hexapdf/content/graphics_state.rb', line 247

def self.normalize(style)
  case style
  when :fill, 0 then FILL
  when :stroke, 1 then STROKE
  when :fill_stroke, 2 then FILL_STROKE
  when :invisible, 3 then INVISIBLE
  when :fill_clip, 4 then FILL_CLIP
  when :stroke_clip, 5 then STROKE_CLIP
  when :fill_stroke_clip, 6 then FILL_STROKE_CLIP
  when :clip, 7 then CLIP
  else
    raise ArgumentError, "Unknown text rendering mode: #{style}"
  end
end