#include <State.hh>
Collaboration diagram for pdf::text::CState:
in the PDF specs, the formatting of a text segment is called the text state. this class represents a text state. it stores information like font, font size, leading and spacing.
when writing a CState object to an output stream, the previous state must be given for comparison. only the individual properties that are difference from the previous state will be written.
|
default constructor will set everything to default values. scale is set to 1.0f which means no scale. default values are given by the PDF specs. when calling Write() for the first text state in the start of an "BI" operator section, there is no such "previous" state. a default constructed CState object can be used as its previous state.
00051 : m_font( 0 ), m_font_size( 0 ), m_char_space( 0 ), 00052 m_word_space( 0 ), m_scale( 1.0f ), m_leading( 0 ), 00053 m_render( 0 ), m_rise( 0 ) 00054 { 00055 } |
|
construct a text state with the given parameters. if the leading is zero, it will be set to the font size.
00076 : m_font( font ), m_font_size( font_size ), 00077 m_char_space( char_space ), m_word_space( word_space ), 00078 m_scale( scale ), m_leading( leading == 0 ? font_size : leading ), 00079 m_render( render ), m_rise( rise ) 00080 { 00081 assert( m_font != 0 ) ; 00082 } |
|
copy constructor.
00087 : m_font( text.m_font ), m_font_size( text.m_font_size ), 00088 m_char_space( text.m_char_space ), m_word_space( text.m_word_space ), 00089 m_scale( text.m_scale ), m_leading( text.m_leading ), 00090 m_render( text.m_render ), m_rise( text.m_rise ), 00091 m_colour( text.m_colour ) 00092 { 00093 } |
|
assignment operator. calls copy constructor and Swap()
|
|
swap two objects. swaps all members.
00153 { 00154 using namespace std ; 00155 00156 swap( m_font, state.m_font ) ; 00157 swap( m_font_size, state.m_font_size ) ; 00158 swap( m_char_space, state.m_char_space ) ; 00159 swap( m_word_space, state.m_word_space ) ; 00160 swap( m_scale, state.m_scale ) ; 00161 swap( m_leading, state.m_leading ) ; 00162 swap( m_render, state.m_render ) ; 00163 swap( m_rise, state.m_rise ) ; 00164 } |
|
write the text state to the output. only those parameter which is different from the previous state will be output, in order to save spaces.
00103 { 00104 assert( m_font != 0 ) ; 00105 00106 if ( m_font->Name( ).empty( ) ) 00107 throw CFontError( CFontError::invalid_font ) ; 00108 00109 if ( m_font != prev.m_font || m_font_size != prev.m_font_size ) 00110 { 00111 assert( m_font != 0 ) ; 00112 os << core::CName( m_font->Name( ) ) << ' ' << m_font_size << " Tf " ; 00113 } 00114 00115 if ( m_char_space != prev.m_char_space ) 00116 os << m_char_space << " Tc " ; 00117 00118 if ( m_word_space != prev.m_word_space ) 00119 os << m_word_space << " Tw " ; 00120 00121 // according to the PDF spec, normal width is 100. 00122 // but we store the ratio. 00123 if ( m_scale != prev.m_scale ) 00124 os << m_scale * 100 << " Tz " ; 00125 00126 if ( m_leading != prev.m_leading ) 00127 os << m_leading << " TL " ; 00128 00129 if ( m_render != prev.m_render ) 00130 os << m_render << " Tr " ; 00131 00132 if ( m_rise != prev.m_rise ) 00133 os << m_rise << " Ts " ; 00134 00135 if ( m_colour != prev.m_colour ) 00136 os << m_colour << "rg " ; 00137 00138 return os ; 00139 } |
|
return the leading size
00091 { return m_leading ; } |
|
change the text colour.
00169 { 00170 m_colour = colour ; 00171 } |
|
return the current text colour.
00176 { 00177 return m_colour ; 00178 } |
|
text font. the font object is NOT owned by this class. |
|
font size
|
|
character spacing
|
|
word spacing
|
|
horizonal spacing
|
|
leading size
|
|
rendering mode
|
|
text rise
|
|
text colour
|