Method: RTF::CharacterStyle#prefix

Defined in:
lib/rtf/style.rb

#prefix(fonts, colours) ⇒ Object

This method generates a string containing the prefix associated with a style object.

Parameters

fonts

A reference to a FontTable containing any fonts used by the style (may be nil if no fonts used).

colours

A reference to a ColourTable containing any colours used by the style (may be nil if no colours used).



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/rtf/style.rb', line 113

def prefix(fonts, colours)
   text = StringIO.new

   text << '\b' if @bold
   text << '\i' if @italic
   text << '\ul' if @underline
   text << '\super' if @superscript
   text << '\ccaps' if @capitalise
   text << '\strike' if @strike
   text << '\sub' if @subscript
   text << '\v' if @hidden
   text << "\\cf#{colours.index(@foreground)}" if @foreground != nil
   text << "\\cb#{colours.index(@background)}" if @background != nil
   text << "\\f#{fonts.index(@font)}" if @font != nil
   text << "\\fs#{@font_size.to_i}" if @font_size != nil
   text << '\rtlch' if @flow == RIGHT_TO_LEFT

   text.string.length > 0 ? text.string : nil
end