Logo Search packages:      
Sourcecode: inkscape version File versions

void Inkscape::Text::Layout::appendText ( Glib::ustring const &  text,
SPStyle style,
void *  source_cookie,
OptionalTextTagAttrs const *  optional_attributes,
unsigned  optional_attributes_offset,
Glib::ustring::const_iterator  text_begin,
Glib::ustring::const_iterator  text_end 
)

adds a new piece of text to the end of the current list of text to be processed. This method can only add text of a consistent style. To add lots of different styles, call it lots of times.

Parameters:
text The text. Note: only a pointer is stored. Do not mess with the text until after you have called calculateFlow().
style The font style. Layout will hold a reference to this object for the duration of its ownership, ie until you call clear() or the class is destroyed. Must not be NULL.
source_cookie This pointer is treated as opaque by Layout but will be passed through the flowing process intact so that callers can use it to refer to the original object that generated a particular glyph. See Layout::iterator. Implementation detail: currently all callers put an SPString in here.
optional_attributes A structure containing additional options for this text. See OptionalTextTagAttrs. The values are copied to internal storage before this method returns.
optional_attributes_offset It is convenient for callers to be able to use the same optional_attributes structure for several sequential text fields, in which case the vectors will need to be offset. This parameter causes the nth element of all the vectors to be read as if it were the first.
text_begin Used for selecting only a substring of text to process.
text_end Used for selecting only a substring of text to process.

Definition at line 31 of file Layout-TNG-Input.cpp.

References _copyInputVector(), _input_stream, Inkscape::Text::Layout::InputStreamTextSource::dx, Inkscape::Text::Layout::OptionalTextTagAttrs::dx, Inkscape::Text::Layout::InputStreamTextSource::dy, Inkscape::Text::Layout::OptionalTextTagAttrs::dy, Inkscape::Text::Layout::InputStreamTextSource::rotate, Inkscape::Text::Layout::OptionalTextTagAttrs::rotate, sp_style_ref(), Inkscape::Text::Layout::InputStreamTextSource::style, Inkscape::Text::Layout::InputStreamTextSource::text, Inkscape::Text::Layout::InputStreamTextSource::text_begin, Inkscape::Text::Layout::InputStreamTextSource::text_end, Inkscape::Text::Layout::InputStreamTextSource::text_length, Inkscape::Text::Layout::InputStreamTextSource::x, Inkscape::Text::Layout::OptionalTextTagAttrs::x, Inkscape::Text::Layout::InputStreamTextSource::y, and Inkscape::Text::Layout::OptionalTextTagAttrs::y.

{
    if (style == NULL) return;

    InputStreamTextSource *new_source = new InputStreamTextSource;

    new_source->source_cookie = source_cookie;
    new_source->text = &text;
    new_source->text_begin = text_begin;
    new_source->text_end = text_end;
    new_source->style = style;
    sp_style_ref(style);

    new_source->text_length = 0;
    for ( ; text_begin != text_end && text_begin != text.end() ; text_begin++)
        new_source->text_length++;        // save this because calculating the length of a UTF-8 string is expensive

    if (optional_attributes) {
        // we need to fill in x and y even if the text is empty so that empty paragraphs can be positioned correctly
        _copyInputVector(optional_attributes->x, optional_attributes_offset, &new_source->x, std::max(1, new_source->text_length));
        _copyInputVector(optional_attributes->y, optional_attributes_offset, &new_source->y, std::max(1, new_source->text_length));
        _copyInputVector(optional_attributes->dx, optional_attributes_offset, &new_source->dx, new_source->text_length);
        _copyInputVector(optional_attributes->dy, optional_attributes_offset, &new_source->dy, new_source->text_length);
        _copyInputVector(optional_attributes->rotate, optional_attributes_offset, &new_source->rotate, new_source->text_length);
    }
    
    _input_stream.push_back(new_source);
}


Generated by  Doxygen 1.6.0   Back to index