Inkscape
Vector Graphics Editor
|
Generates the layout for either wrapped or non-wrapped text and stores the result. More...
#include <Layout-TNG.h>
Classes | |
struct | Character |
struct | Chunk |
struct | CursorShape |
class | FontMetrics |
Keep track of font metrics. More... | |
struct | Glyph |
class | InfiniteScanlineMaker |
private to Layout. More... | |
class | InputStreamControlCode |
Represents a control code item in the input stream. More... | |
class | InputStreamItem |
class | InputStreamTextSource |
Represents a text item in the input stream. More... | |
struct | InputWrapShape |
class | iterator |
Holds a position within the glyph output of Layout. More... | |
struct | Line |
struct | OptionalTextTagAttrs |
The optional attributes which can be applied to a SVG text or related tag. More... | |
struct | Paragraph |
class | ScanlineMaker |
private to Layout. More... | |
class | ShapeScanlineMaker |
private to Layout. More... | |
struct | Span |
Public Types | |
enum | Direction { LEFT_TO_RIGHT , RIGHT_TO_LEFT , TOP_TO_BOTTOM , BOTTOM_TO_TOP } |
Used to specify any particular text direction required. More... | |
enum | Orientation { ORIENTATION_UPRIGHT , ORIENTATION_SIDEWAYS } |
Used to specify orientation of glyphs in vertical text. More... | |
enum | DisplayAlign { DISPLAY_ALIGN_BEFORE , DISPLAY_ALIGN_CENTER , DISPLAY_ALIGN_AFTER } |
Display alignment for shapes. More... | |
enum | LengthAdjust { LENGTHADJUST_SPACING , LENGTHADJUST_SPACINGANDGLYPHS } |
lengthAdjust values More... | |
enum | WrapMode { WRAP_NONE , WRAP_WHITE_SPACE , WRAP_INLINE_SIZE , WRAP_SHAPE_INSIDE } |
enum | TextControlCode { PARAGRAPH_BREAK , SHAPE_BREAK , ARBITRARY_GAP } |
Control codes which can be embedded in the text to be flowed. More... | |
enum | Alignment { LEFT , CENTER , RIGHT , FULL , NONE } |
For expressing paragraph alignment. More... | |
Public Member Functions | |
Layout () | |
virtual | ~Layout () |
Processing | |
The method to do the actual work of converting text into glyphs. | |
bool | calculateFlow () |
Takes all the stuff you set with the members above here and creates a load of glyphs for use with the members below here. | |
Output | |
Methods for reading and interpreting the output glyphs. See also Layout::iterator. | |
bool | outputExists () const |
Returns true if there are some glyphs in this object, ie whether computeFlow() has been called on a non-empty input since the object was created or the last call to clear(). | |
void | show (DrawingGroup *in_arena, StyleAttachments &style_attachments, Geom::OptRect const &paintbox) const |
Adds all the output glyphs to in_arena using the given paintbox. | |
Geom::OptRect | bounds (Geom::Affine const &transform, bool with_stroke=false, int start=-1, int length=-1) const |
Calculates the smallest rectangle completely enclosing all the glyphs. | |
void | print (SPPrintContext *ctx, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox, Geom::Affine const &ctm) const |
Sends all the glyphs to the given print context. | |
void | showGlyphs (CairoRenderContext *ctx) const |
Renders all the glyphs to the given Cairo rendering context. | |
Glib::ustring | getFontFamily (unsigned span_index) const |
Returns the font family of the indexed span. | |
Glib::ustring | dumpAsText () const |
debug and unit test method. | |
void | fitToPathAlign (SVGLength const &startOffset, Path const &path) |
Moves all the glyphs in the structure so that the baseline of all the characters sits neatly along the path specified. | |
SPCurve | convertToCurves (iterator const &from_glyph, iterator const &to_glyph) const |
Convert the specified range of characters into their bezier outlines. | |
SPCurve | convertToCurves () const |
void | transform (Geom::Affine const &transform) |
Apply the given transform to all the output presently stored in this object. | |
Public Attributes | |
enum Inkscape::Text::Layout::WrapMode | wrap_mode = WRAP_NONE |
Static Public Attributes | |
static const double | LINE_HEIGHT_NORMAL = 1.25 |
The CSS spec allows line-height:normal to be whatever the user agent thinks will look good. | |
Friends | |
class | iterator |
class | Calculator |
Output (Iterators) | |
Methods for operating with the Layout::iterator class. The method names ending with 'Index' return 0-based offsets of the number of items since the beginning of the flow. | |
enum | InputStreamItemType { TEXT_SOURCE , CONTROL_CODE } |
FontMetrics | strut |
The strut is the minimum value used in calculating line height. | |
static const gunichar | UNICODE_SOFT_HYPHEN = 0x00AD |
std::vector< InputStreamItem * > | _input_stream |
This is our internal storage for all the stuff passed to the appendText() and appendControlCode() functions. | |
struct Inkscape::Text::Layout::CursorShape | _empty_cursor_shape |
std::vector< InputWrapShape > | _input_wrap_shapes |
Path const * | _path_fitted = nullptr |
as passed to fitToPathAlign() | |
std::vector< Paragraph > | _paragraphs |
std::vector< Line > | _lines |
std::vector< Chunk > | _chunks |
std::vector< Span > | _spans |
std::vector< Character > | _characters |
std::vector< Glyph > | _glyphs |
std::vector< Geom::LineSegment > | _baselines |
iterator | begin () const |
Returns an iterator pointing at the first glyph of the flowed output. | |
iterator | end () const |
Returns an iterator pointing just past the end of the last glyph, which is also just past the end of the last chunk, span, etc, etc. | |
iterator | charIndexToIterator (int char_index) const |
Returns an iterator pointing at the given character index. | |
int | iteratorToCharIndex (iterator const &it) const |
Returns the character index from the start of the flow represented by the given iterator. | |
void | validateIterator (iterator *it) const |
Checks the validity of the given iterator over the current layout. | |
iterator | getNearestCursorPositionTo (double x, double y) const |
Returns an iterator pointing to the cursor position for a mouse click at the given coordinates. | |
iterator | getNearestCursorPositionTo (Geom::Point const &point) const |
iterator | getLetterAt (double x, double y) const |
Returns an iterator pointing to the letter whose bounding box contains the given coordinates. | |
iterator | getLetterAt (Geom::Point &point) const |
iterator | sourceToIterator (SPObject *source) const |
Returns an iterator pointing to the first character in the output which was created from the given source. | |
Geom::OptRect | glyphBoundingBox (iterator const &it, double *rotation) const |
Returns the bounding box of the given glyph, and its rotation. | |
unsigned | lineIndex (iterator const &it) const |
Returns the zero-based line number of the character pointed to by it. | |
unsigned | shapeIndex (iterator const &it) const |
Returns the zero-based number of the shape which contains the character pointed to by it. | |
bool | isWhitespace (iterator const &it) const |
Returns true if the character at it is a whitespace, as defined by Pango. | |
gunichar | characterAt (iterator const &it) const |
Returns character pointed to by it. | |
bool | isHidden (iterator const &it) const |
Returns true if the text at it is hidden (i.e. | |
void | getSourceOfCharacter (iterator const &it, SPObject **source, Glib::ustring::iterator *text_iterator=nullptr) const |
Discovers where the character pointed to by it came from, by retrieving the object that was passed to the call to appendText() or appendControlCode() which generated that output. | |
Geom::Point | characterAnchorPoint (iterator const &it) const |
For latin text, the left side of the character, on the baseline. | |
std::optional< Geom::Point > | baselineAnchorPoint () const |
For left aligned text, the leftmost end of the baseline For rightmost text, the rightmost... you probably got it by now ;-) | |
Geom::Path | baseline () const |
std::vector< Geom::LineSegment > | getBaselines () const |
Returns all the baselines of a text element. | |
Geom::Point | chunkAnchorPoint (iterator const &it) const |
This is that value to apply to the x,y attributes of tspan role=line elements, and hence it takes alignment into account. | |
Geom::Rect | characterBoundingBox (iterator const &it, double *rotation=nullptr) const |
Returns the box extents (not ink extents) of the given character. | |
std::vector< Geom::Point > | createSelectionShape (iterator const &it_start, iterator const &it_end, Geom::Affine const &transform) const |
Basically uses characterBoundingBox() on all the characters from start to end and returns the union of these boxes. | |
bool | isCursorPosition (iterator const &it) const |
Returns true if it points to a character which is a valid cursor position, as defined by Pango. | |
void | queryCursorShape (iterator const &it, Geom::Point &position, double &height, double &rotation) const |
Gets the ideal cursor shape for a given iterator. | |
bool | isStartOfWord (iterator const &it) const |
Returns true if it points to a character which is a the start of a word, as defined by Pango. | |
bool | isEndOfWord (iterator const &it) const |
Returns true if it points to a character which is a the end of a word, as defined by Pango. | |
bool | isStartOfSentence (iterator const &it) const |
Returns true if it points to a character which is a the start of a sentence, as defined by Pango. | |
bool | isEndOfSentence (iterator const &it) const |
Returns true if it points to a character which is a the end of a sentence, as defined by Pango. | |
unsigned | paragraphIndex (iterator const &it) const |
Returns the zero-based number of the paragraph containing the character pointed to by it. | |
Alignment | paragraphAlignment (iterator const &it) const |
Returns the actual alignment used for the paragraph containing the character pointed to by it. | |
void | simulateLayoutUsingKerning (iterator const &from, iterator const &to, OptionalTextTagAttrs *result) const |
Returns kerning information which could cause the current output to be exactly reproduced if the letter and word spacings were zero and full justification was not used. | |
std::vector< Layout::Glyph > const & | glyphs () const |
Publically allow access to the Layout::show logic outside of the Layout engine. | |
std::vector< Layout::Span > const & | spans () const |
std::vector< InputStreamItem * > const & | input_stream () const |
void | _clearInputObjects () |
Erases all the stuff set by the owner as input, ie _input_stream and _input_wrap_shapes. | |
void | _clearOutputObjects () |
Erases all the stuff output by computeFlow(). | |
Direction | _blockProgression () const |
The overall block-progression of the whole flow. | |
SPCSSTextOrientation | _blockTextOrientation () const |
The overall text-orientation of the whole flow. | |
SPCSSBaseline | _blockBaseline () const |
The overall text-orientation of the whole flow. | |
void | _calculateCursorShapeForEmpty () |
If the output is empty callers still want to be able to call queryCursorShape() and get a valid answer so, while _input_wrap_shapes can still be considered valid, we need to precompute the cursor shape for this case. | |
unsigned | _lineToSpan (unsigned line_index) const |
unsigned | _lineToCharacter (unsigned line_index) const |
unsigned | _spanToCharacter (unsigned span_index) const |
unsigned | _sourceToCharacter (unsigned source_index) const |
iterator | _cursorXOnLineToIterator (unsigned line_index, double local_x, double local_y=0) const |
given an x and y coordinate and a line number, returns an iterator pointing to the closest cursor position on that line to the coordinate. | |
double | _getChunkWidth (unsigned chunk_index) const |
calculates the width of a chunk, which is the largest x coordinate (start or end) of the spans contained within it. | |
void | _calculateBaselines () |
static void | _copyInputVector (std::vector< SVGLength > const &input_vector, unsigned input_offset, std::vector< SVGLength > *output_vector, size_t max_length) |
The parameters to appendText() are allowed to be a little bit complex. | |
static bool | _directions_are_orthogonal (Direction d1, Direction d2) |
so that LEFT_TO_RIGHT == RIGHT_TO_LEFT but != TOP_TO_BOTTOM | |
Input | |
Methods for describing the text you want to flow, its style, and the shapes to flow in to. | |
bool | _input_truncated = false |
SVGLength | textLength |
Gives the length target of this layout, as given by textLength attribute. | |
LengthAdjust | lengthAdjust = LENGTHADJUST_SPACING |
How do we meet textLength if specified: by letterspacing or by scaling horizontally. | |
double | textLengthMultiplier = 1 |
By how much each character needs to be wider or narrower, using the specified lengthAdjust strategy, for the layout to meet its textLength target. | |
double | textLengthIncrement = 0 |
This one is used by letterspacing strategy: to each glyph width, this is added. | |
void | clear () |
Empties everything stored in this class and resets it to its original state, like when it was created. | |
bool | inputExists () const |
Queries whether any calls have been made to appendText() or appendControlCode() since the object was last cleared. | |
bool | inputTruncated () const |
void | appendText (Glib::ustring const &text, SPStyle *style, SPObject *source, 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. | |
void | appendText (Glib::ustring const &text, SPStyle *style, SPObject *source, OptionalTextTagAttrs const *optional_attributes=nullptr, unsigned optional_attributes_offset=0) |
void | appendControlCode (TextControlCode code, SPObject *source, double width=0.0, double ascent=0.0, double descent=0.0) |
Control codes are metadata in the text stream to signify items that occupy real space (unlike style changes) but don't belong in the text string. | |
void | appendWrapShape (std::unique_ptr< Shape > shape, DisplayAlign display_align=DISPLAY_ALIGN_BEFORE) |
Stores another shape inside which to flow the text. | |
double | getTextLengthIncrementDue () const |
Get the actual spacing increment if it's due with the current values of above stuff, otherwise 0. | |
double | getTextLengthMultiplierDue () const |
Get the actual scale multiplier if it's due with the current values of above stuff, otherwise 1. | |
double | getActualLength () const |
Get actual length of layout, by summing span lengths. | |
Generates the layout for either wrapped or non-wrapped text and stores the result.
Use this class for all your text output needs. It takes text with formatting markup as input and turns that into the glyphs and their necessary positions. It stores the glyphs internally, but maintains enough information to both retrieve your own rendering information if you wish and to perform visual text editing where the output refers back to where it came from.
Usage:
Terminology, in descending order of size:
Other terminology:
Comments:
Definition at line 144 of file Layout-TNG.h.
For expressing paragraph alignment.
These values are rotated in the case of vertical text, but are not dependent on whether the paragraph is rtl or ltr, thus LEFT is always either left or top.
Enumerator | |
---|---|
LEFT | |
CENTER | |
RIGHT | |
FULL | |
NONE |
Definition at line 205 of file Layout-TNG.h.
Used to specify any particular text direction required.
Used for both the 'direction' and 'block-progression' CSS attributes.
Enumerator | |
---|---|
LEFT_TO_RIGHT | |
RIGHT_TO_LEFT | |
TOP_TO_BOTTOM | |
BOTTOM_TO_TOP |
Definition at line 159 of file Layout-TNG.h.
Display alignment for shapes.
See appendWrapShape().
Enumerator | |
---|---|
DISPLAY_ALIGN_BEFORE | |
DISPLAY_ALIGN_CENTER | |
DISPLAY_ALIGN_AFTER |
Definition at line 166 of file Layout-TNG.h.
Enumerator | |
---|---|
TEXT_SOURCE | |
CONTROL_CODE |
Definition at line 689 of file Layout-TNG.h.
lengthAdjust values
Enumerator | |
---|---|
LENGTHADJUST_SPACING | |
LENGTHADJUST_SPACINGANDGLYPHS |
Definition at line 169 of file Layout-TNG.h.
Used to specify orientation of glyphs in vertical text.
Enumerator | |
---|---|
ORIENTATION_UPRIGHT | |
ORIENTATION_SIDEWAYS |
Definition at line 162 of file Layout-TNG.h.
Control codes which can be embedded in the text to be flowed.
See appendControlCode().
Definition at line 196 of file Layout-TNG.h.
Enumerator | |
---|---|
WRAP_NONE | |
WRAP_WHITE_SPACE | |
WRAP_INLINE_SIZE | |
WRAP_SHAPE_INSIDE |
Definition at line 171 of file Layout-TNG.h.
|
default |
|
virtual |
Definition at line 22 of file Layout-TNG.cpp.
References clear().
|
inlineprivate |
The overall text-orientation of the whole flow.
Definition at line 770 of file Layout-TNG.h.
References _input_stream, and SP_CSS_BASELINE_AUTO.
|
inlineprivate |
The overall block-progression of the whole flow.
Definition at line 754 of file Layout-TNG.h.
References _input_stream, and TOP_TO_BOTTOM.
Referenced by characterAnchorPoint(), characterBoundingBox(), chunkAnchorPoint(), createSelectionShape(), fitToPathAlign(), getNearestCursorPositionTo(), print(), and queryCursorShape().
|
inlineprivate |
The overall text-orientation of the whole flow.
Definition at line 762 of file Layout-TNG.h.
References _input_stream, and SP_CSS_TEXT_ORIENTATION_MIXED.
|
private |
Definition at line 331 of file Layout-TNG-OutIter.cpp.
References _baselines, begin(), characterAnchorPoint(), Geom::Path::clear(), and end().
Referenced by calculateFlow().
|
private |
If the output is empty callers still want to be able to call queryCursorShape() and get a valid answer so, while _input_wrap_shapes can still be considered valid, we need to precompute the cursor shape for this case.
Definition at line 2328 of file Layout-TNG-Compute.cpp.
References _empty_cursor_shape, _input_stream, _input_wrap_shapes, Inkscape::Text::Layout::FontMetrics::ascent, SVGLength::computed, Inkscape::Text::Layout::FontMetrics::descent, Inkscape::Text::Layout::FontMetrics::FontMetrics(), Inkscape::Text::Layout::CursorShape::height, LEFT_TO_RIGHT, Inkscape::Text::Layout::ShapeScanlineMaker::makeScanline(), Inkscape::Text::Layout::CursorShape::position, RIGHT_TO_LEFT, Inkscape::Text::Layout::CursorShape::rotation, Inkscape::Text::Layout::InputStreamTextSource::styleGetFontInstance(), TEXT_SOURCE, WRAP_INLINE_SIZE, wrap_mode, and Inkscape::Text::Layout::FontMetrics::xheight.
Referenced by calculateFlow().
|
private |
Erases all the stuff set by the owner as input, ie _input_stream and _input_wrap_shapes.
Definition at line 30 of file Layout-TNG-Input.cpp.
References _input_stream, and _input_wrap_shapes.
Referenced by clear().
|
private |
Erases all the stuff output by computeFlow().
Glyphs and things.
Definition at line 79 of file Layout-TNG-Output.cpp.
References _characters, _chunks, _glyphs, _lines, _paragraphs, _path_fitted, and _spans.
Referenced by clear().
|
staticprivate |
The parameters to appendText() are allowed to be a little bit complex.
This copies them to be the right length and starting at zero. We also don't want to write five bits of identical code just with different variable names.
Definition at line 94 of file Layout-TNG-Input.cpp.
Referenced by appendText().
|
private |
given an x and y coordinate and a line number, returns an iterator pointing to the closest cursor position on that line to the coordinate.
('y' is needed to handle cases where multiline text is simulated via the 'y' attribute.)
Definition at line 36 of file Layout-TNG-OutIter.cpp.
References _characters, _chunks, _lineToCharacter(), _spans, and end().
Referenced by getNearestCursorPositionTo().
|
staticprivate |
so that LEFT_TO_RIGHT == RIGHT_TO_LEFT but != TOP_TO_BOTTOM
Definition at line 38 of file Layout-TNG.cpp.
References BOTTOM_TO_TOP, LEFT_TO_RIGHT, RIGHT_TO_LEFT, and TOP_TO_BOTTOM.
Referenced by characterAnchorPoint(), characterBoundingBox(), chunkAnchorPoint(), createSelectionShape(), fitToPathAlign(), getNearestCursorPositionTo(), and queryCursorShape().
|
private |
calculates the width of a chunk, which is the largest x coordinate (start or end) of the spans contained within it.
Definition at line 101 of file Layout-TNG-OutIter.cpp.
References _chunks, _lineToSpan(), and _spans.
Referenced by chunkAnchorPoint(), and fitToPathAlign().
|
inlineprivate |
Definition at line 920 of file Layout-TNG.h.
References _characters, and index.
Referenced by _cursorXOnLineToIterator().
|
inlineprivate |
Definition at line 911 of file Layout-TNG.h.
Referenced by _getChunkWidth().
|
inlineprivate |
Definition at line 938 of file Layout-TNG.h.
References _characters, and index.
Referenced by sourceToIterator().
|
inlineprivate |
Definition at line 929 of file Layout-TNG.h.
References _characters, and index.
void Inkscape::Text::Layout::appendControlCode | ( | TextControlCode | code, |
SPObject * | source, | ||
double | width = 0.0 , |
||
double | ascent = 0.0 , |
||
double | descent = 0.0 |
||
) |
Control codes are metadata in the text stream to signify items that occupy real space (unlike style changes) but don't belong in the text string.
See TextControlCode for the types available.
A control code cannot be the first item in the input stream. Use appendText() with an empty string to set up the paragraph properties.
code | A member of the TextFlowControlCode enumeration. |
width | The width in pixels that this item occupies. |
ascent | The number of pixels above the text baseline that this control code occupies. |
descent | The number of pixels below the text baseline that this control code occupies. |
source | Pointer to object that is source of control code. Note that for some control codes (eg tab) the values of the width, ascender and descender are implied by the surrounding text (and in the case of tabs, the values set in tab_stops) so the values you pass here are ignored. |
Definition at line 109 of file Layout-TNG-Input.cpp.
References _input_stream, Inkscape::Text::Layout::InputStreamControlCode::ascent, Inkscape::Text::Layout::InputStreamControlCode::code, Inkscape::Text::Layout::InputStreamControlCode::descent, Inkscape::Text::Layout::InputStreamItem::source, width, and Inkscape::Text::Layout::InputStreamControlCode::width.
Referenced by SPText::_buildLayoutInput(), and SPFlowtext::_buildLayoutInput().
void Inkscape::Text::Layout::appendText | ( | Glib::ustring const & | text, |
SPStyle * | style, | ||
SPObject * | source, | ||
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.
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 | Pointer to object that is source of text. |
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 41 of file Layout-TNG-Input.cpp.
References _copyInputVector(), _input_stream, SVGLength::_set, clear(), SVGLength::computed, SPObject::connectRelease(), Inkscape::Text::Layout::OptionalTextTagAttrs::dx, Inkscape::Text::Layout::InputStreamTextSource::dx, Inkscape::Text::Layout::OptionalTextTagAttrs::dy, Inkscape::Text::Layout::InputStreamTextSource::dy, Inkscape::Text::Layout::OptionalTextTagAttrs::lengthAdjust, Inkscape::Text::Layout::InputStreamTextSource::lengthAdjust, SPStyle::object, Inkscape::Text::Layout::OptionalTextTagAttrs::rotate, Inkscape::Text::Layout::InputStreamTextSource::rotate, Inkscape::Text::Layout::InputStreamItem::source, Inkscape::Text::Layout::InputStreamTextSource::style, Inkscape::Text::Layout::InputStreamTextSource::style_conn, 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::OptionalTextTagAttrs::textLength, Inkscape::Text::Layout::InputStreamTextSource::textLength, SVGLength::unit, SVGLength::value, Inkscape::Text::Layout::OptionalTextTagAttrs::x, Inkscape::Text::Layout::InputStreamTextSource::x, Inkscape::Text::Layout::OptionalTextTagAttrs::y, and Inkscape::Text::Layout::InputStreamTextSource::y.
Referenced by SPText::_buildLayoutInput(), SPFlowtext::_buildLayoutInput(), and appendText().
|
inline |
Definition at line 259 of file Layout-TNG.h.
References appendText().
void Inkscape::Text::Layout::appendWrapShape | ( | std::unique_ptr< Shape > | shape, |
DisplayAlign | display_align = DISPLAY_ALIGN_BEFORE |
||
) |
Stores another shape inside which to flow the text.
If this method is never called then no automatic wrapping is done and lines will continue to infinity if necessary. Text can be flowed inside multiple shapes in sequence, like with frames in a DTP package. If the text flows past the end of the last shape all remaining text is ignored.
shape | The Shape to use next in the flow. |
display_align | The vertical alignment of the text within this shape. See XSL1.0 section 7.13.4. The behaviour of settings other than DISPLAY_ALIGN_BEFORE when using non-rectangular shapes is undefined. |
Definition at line 123 of file Layout-TNG-Input.cpp.
References _input_wrap_shapes.
Referenced by SPText::_buildLayoutInit(), and SPFlowtext::_buildLayoutInput().
Geom::Path Inkscape::Text::Layout::baseline | ( | ) | const |
Definition at line 317 of file Layout-TNG-OutIter.cpp.
References Geom::Path::appendNew(), baseline(), begin(), characterAnchorPoint(), Geom::Path::start(), and Inkscape::Text::Layout::iterator::thisEndOfLine().
Referenced by baseline().
std::optional< Geom::Point > Inkscape::Text::Layout::baselineAnchorPoint | ( | ) | const |
For left aligned text, the leftmost end of the baseline For rightmost text, the rightmost... you probably got it by now ;-)
Definition at line 290 of file Layout-TNG-OutIter.cpp.
References _spans, begin(), CENTER, characterAnchorPoint(), FULL, LEFT, paragraphAlignment(), RIGHT, RIGHT_TO_LEFT, and Inkscape::Text::Layout::iterator::thisEndOfLine().
Referenced by SPFlowtext::getBaselinePoint(), SPText::getBaselinePoint(), object_align_text(), object_distribute_text(), SPFlowtext::snappoints(), SPText::snappoints(), and Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render().
|
inline |
Returns an iterator pointing at the first glyph of the flowed output.
The first glyph is also the first character, line, paragraph, etc.
Definition at line 1114 of file Layout-TNG.h.
Referenced by _calculateBaselines(), Inkscape::UI::Toolbar::TextToolbar::_cursorMoved(), baseline(), baselineAnchorPoint(), charIndexToIterator(), convertToCurves(), SPFlowtext::getAsText(), getLetterAt(), getNearestCursorPositionTo(), Inkscape::LivePathEffect::getNodes(), getSourceOfCharacter(), insert_text_fallback(), SPText::newline_to_sodipodi(), Inkscape::UI::Dialog::SpellCheck::nextText(), Inkscape::UI::Tools::MeasureTool::showCanvasItems(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_flowtext_render(), sp_te_get_average_linespacing(), sp_te_output_is_empty(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render(), text_flow_into_shape(), and text_put_on_path().
Geom::OptRect Inkscape::Text::Layout::bounds | ( | Geom::Affine const & | transform, |
bool | with_stroke = false , |
||
int | start = -1 , |
||
int | length = -1 |
||
) | const |
Calculates the smallest rectangle completely enclosing all the glyphs.
bounding_box | Where to store the box |
transform | The transform to be applied to the entire object prior to calculating its bounds. |
Definition at line 237 of file Layout-TNG-Output.cpp.
References _characters, _glyphs, _input_stream, _spans, Inkscape::Text::Layout::Span::in_input_stream_item, scale, start, transform(), and Geom::GenericOptRect< C >::unionWith().
Referenced by SPFlowtext::bbox(), and SPText::bbox().
bool Inkscape::Text::Layout::calculateFlow | ( | ) |
Takes all the stuff you set with the members above here and creates a load of glyphs for use with the members below here.
All iterators on this object will be invalidated (but can be fixed with validateIterator(). The implementation just creates a new Layout::Calculator and calls its Calculator::Calculate() method, so if you want more details on the internals, go there.
Definition at line 2380 of file Layout-TNG-Compute.cpp.
References _calculateBaselines(), _calculateCursorShapeForEmpty(), _characters, Calculator, result, and textLengthIncrement.
Referenced by SPFlowtext::rebuildLayout(), and SPText::rebuildLayout().
Geom::Point Inkscape::Text::Layout::characterAnchorPoint | ( | iterator const & | it | ) | const |
For latin text, the left side of the character, on the baseline.
Definition at line 269 of file Layout-TNG-OutIter.cpp.
References _blockProgression(), Inkscape::Text::Layout::iterator::_char_index, _characters, _chunks, _directions_are_orthogonal(), _empty_cursor_shape, _lines, _spans, Inkscape::Text::Layout::CursorShape::position, TOP_TO_BOTTOM, Geom::X, and Geom::Y.
Referenced by _calculateBaselines(), baseline(), baselineAnchorPoint(), SPFlowtext::getAsText(), insert_text_fallback(), and sp_te_get_average_linespacing().
Returns character pointed to by it.
If it == end() the result is undefined.
Definition at line 1155 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
Referenced by SPText::newline_to_sodipodi().
Geom::Rect Inkscape::Text::Layout::characterBoundingBox | ( | iterator const & | it, |
double * | rotation = nullptr |
||
) | const |
Returns the box extents (not ink extents) of the given character.
The centre of rotation is at the horizontal centre of the box on the text baseline.
Definition at line 376 of file Layout-TNG-OutIter.cpp.
References _blockProgression(), Inkscape::Text::Layout::iterator::_char_index, _characters, _chunks, _directions_are_orthogonal(), Inkscape::Text::Layout::iterator::_glyph_index, _glyphs, _path_fitted, _spans, Inkscape::Text::Layout::FontMetrics::ascent, Inkscape::Text::Layout::Span::baseline_shift, Geom::Point::cw(), Inkscape::Text::Layout::FontMetrics::descent, Inkscape::Text::Layout::Span::line_height, TOP_TO_BOTTOM, unused, Geom::X, Geom::Point::x(), and Geom::Y.
Referenced by createSelectionShape(), and getLetterAt().
|
inline |
Returns an iterator pointing at the given character index.
This index should be related to the result from a prior call to iteratorToCharIndex().
Definition at line 1120 of file Layout-TNG.h.
References _characters, begin(), and end().
Referenced by Inkscape::UI::Toolbar::TextToolbar::_cursorMoved(), fix_blank_line(), Inkscape::UI::Dialog::Find::item_text_match(), sp_te_insert(), and sp_te_insert_line().
Geom::Point Inkscape::Text::Layout::chunkAnchorPoint | ( | iterator const & | it | ) | const |
This is that value to apply to the x,y attributes of tspan role=line elements, and hence it takes alignment into account.
Definition at line 346 of file Layout-TNG-OutIter.cpp.
References _blockProgression(), Inkscape::Text::Layout::iterator::_char_index, _characters, _chunks, _directions_are_orthogonal(), _getChunkWidth(), _lines, _paragraphs, CENTER, RIGHT, and TOP_TO_BOTTOM.
Referenced by queryCursorShape(), and SPText::rebuildLayout().
void Inkscape::Text::Layout::clear | ( | ) |
Empties everything stored in this class and resets it to its original state, like when it was created.
All iterators on this object will be invalidated (but can be revalidated using validateIterator().
Definition at line 27 of file Layout-TNG.cpp.
References _clearInputObjects(), _clearOutputObjects(), SVGLength::_set, lengthAdjust, LENGTHADJUST_SPACING, textLength, textLengthIncrement, and textLengthMultiplier.
Referenced by appendText(), SPFlowtext::rebuildLayout(), SPText::rebuildLayout(), and ~Layout().
SPCurve Inkscape::Text::Layout::convertToCurves | ( | ) | const |
Definition at line 822 of file Layout-TNG-Output.cpp.
References begin(), convertToCurves(), and end().
Referenced by convertToCurves().
SPCurve Inkscape::Text::Layout::convertToCurves | ( | iterator const & | from_glyph, |
iterator const & | to_glyph | ||
) | const |
Convert the specified range of characters into their bezier outlines.
Definition at line 827 of file Layout-TNG-Output.cpp.
References Inkscape::Text::Layout::iterator::_glyph_index, _glyphs, and Inkscape::Text::Layout::Span::font.
Referenced by curve_for_item(), curve_for_item_before_LPE(), Inkscape::LivePathEffect::getNodes(), SPFlowtext::getNormalizedBpath(), SPText::getNormalizedBpath(), and Inkscape::UI::Tools::MeasureTool::showCanvasItems().
std::vector< Geom::Point > Inkscape::Text::Layout::createSelectionShape | ( | iterator const & | it_start, |
iterator const & | it_end, | ||
Geom::Affine const & | transform | ||
) | const |
Basically uses characterBoundingBox() on all the characters from start to end and returns the union of these boxes.
The return value is a list of zero or more quadrilaterals specified by a group of four points for each, thus size() is always a multiple of four.
Definition at line 447 of file Layout-TNG-OutIter.cpp.
References _blockProgression(), Inkscape::Text::Layout::iterator::_char_index, _characters, _directions_are_orthogonal(), _glyphs, _path_fitted, _spans, characterBoundingBox(), Geom::GenericRect< C >::corner(), Geom::GenericRect< C >::dimensions(), Geom::GenericRect< C >::max(), Geom::GenericRect< C >::min(), TOP_TO_BOTTOM, transform(), Geom::X, Geom::Point::x(), and Geom::Y.
Referenced by Inkscape::UI::Dialog::SpellCheck::nextWord(), and sp_te_create_selection_quads().
Glib::ustring Inkscape::Text::Layout::dumpAsText | ( | ) | const |
debug and unit test method.
Creates a textual representation of the contents of this object. The output is designed to be both human-readable and comprehensible when diffed with a known-good dump.
Definition at line 593 of file Layout-TNG-Output.cpp.
References _characters, _chunks, _glyphs, _input_stream, _lines, _paragraphs, _spans, Inkscape::Text::direction_to_text(), result, sp_font_description_get_family(), Inkscape::Text::style_to_text(), TEXT_SOURCE, Inkscape::Text::weight_to_text(), and width.
Referenced by SPFlowtext::rebuildLayout(), and SPText::rebuildLayout().
|
inline |
Returns an iterator pointing just past the end of the last glyph, which is also just past the end of the last chunk, span, etc, etc.
Definition at line 1117 of file Layout-TNG.h.
References _characters, and _glyphs.
Referenced by _calculateBaselines(), Inkscape::UI::Toolbar::TextToolbar::_cursorMoved(), _cursorXOnLineToIterator(), charIndexToIterator(), convertToCurves(), SPFlowtext::description(), SPFlowtext::getAsText(), getLetterAt(), insert_text_fallback(), SPText::newline_to_sodipodi(), Inkscape::UI::Dialog::SpellCheck::nextWord(), sourceToIterator(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_flowtext_render(), sp_te_adjust_linespacing_screen(), sp_te_get_average_linespacing(), sp_te_insert(), sp_te_insert_line(), sp_te_output_is_empty(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render(), and text_flow_into_shape().
Moves all the glyphs in the structure so that the baseline of all the characters sits neatly along the path specified.
If the text has more than one line the results are undefined. The 'align' means to use the SVG align method as documented in SVG1.1 section 10.13.2. NB: njh has suggested that it would be cool if we could flow from shape to path and back again. This is possible, so this method will be removed at some point. A pointer to path is retained by the class for use by the cursor positioning functions.
Definition at line 674 of file Layout-TNG-Output.cpp.
References _blockProgression(), _characters, _directions_are_orthogonal(), _empty_cursor_shape, _getChunkWidth(), _glyphs, _input_truncated, _lines, _paragraphs, _path_fitted, SVGLength::_set, _spans, CENTER, Inkscape::Text::Layout::Span::chunk(), SVGLength::computed, Inkscape::Text::Layout::Span::direction, LEFT, Inkscape::Text::Layout::Chunk::left_x, Geom::Point::normalize(), offset, SVGLength::PERCENT, Path::cut_position::piece, polyline_moveto, Inkscape::Text::Layout::CursorShape::position, Path::pts, RIGHT, RIGHT_TO_LEFT, Inkscape::Text::Layout::CursorShape::rotation, TOP_TO_BOTTOM, SVGLength::unit, unused, Geom::X, Inkscape::Text::Layout::Span::x_start, Geom::Y, and Geom::Point::y().
Referenced by SPText::rebuildLayout().
double Inkscape::Text::Layout::getActualLength | ( | ) | const |
Get actual length of layout, by summing span lengths.
For one-line non-flowed text, just the width; for multiline non-flowed, sum of lengths of all lines; for flowed text, sum of scanline widths for all non-last lines plus text width of last line.
Definition at line 873 of file Layout-TNG-Output.cpp.
References _spans.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::clip_text_layout(), Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_text_layout(), and Inkscape::Extension::Internal::LaTeXTextRenderer::sp_text_render().
|
inline |
Returns all the baselines of a text element.
Definition at line 539 of file Layout-TNG.h.
References _baselines.
Referenced by Inkscape::ObjectSnapper::_collectPaths().
Glib::ustring Inkscape::Text::Layout::getFontFamily | ( | unsigned | span_index | ) | const |
Returns the font family of the indexed span.
Definition at line 580 of file Layout-TNG-Output.cpp.
References _spans, and sp_font_description_get_family().
Layout::iterator Inkscape::Text::Layout::getLetterAt | ( | double | x, |
double | y | ||
) | const |
Returns an iterator pointing to the letter whose bounding box contains the given coordinates.
end() if the point is not over any letter. The iterator will not point at the specific glyph within the character.
Definition at line 214 of file Layout-TNG-OutIter.cpp.
References begin(), characterBoundingBox(), Geom::GenericRect< C >::contains(), and end().
Referenced by getLetterAt().
|
inline |
Definition at line 1143 of file Layout-TNG.h.
References getLetterAt().
Layout::iterator Inkscape::Text::Layout::getNearestCursorPositionTo | ( | double | x, |
double | y | ||
) | const |
Returns an iterator pointing to the cursor position for a mouse click at the given coordinates.
Definition at line 134 of file Layout-TNG-OutIter.cpp.
References _blockProgression(), _chunks, _cursorXOnLineToIterator(), _directions_are_orthogonal(), _lines, _path_fitted, _spans, Inkscape::Text::Layout::FontMetrics::ascent, begin(), Inkscape::Text::Layout::FontMetrics::descent, Inkscape::Text::Layout::FontMetrics::max(), Path::cut_position::piece, Path::cut_position::t, and TOP_TO_BOTTOM.
Referenced by getNearestCursorPositionTo(), and sp_te_get_position_by_coords().
|
inline |
Definition at line 1140 of file Layout-TNG.h.
References getNearestCursorPositionTo().
void Inkscape::Text::Layout::getSourceOfCharacter | ( | iterator const & | it, |
SPObject ** | source, | ||
Glib::ustring::iterator * | text_iterator = nullptr |
||
) | const |
Discovers where the character pointed to by it came from, by retrieving the object that was passed to the call to appendText() or appendControlCode() which generated that output.
If it == end() then NULL is returned as the object. If the character was generated from a call to appendText() then the optional text_iterator parameter is set to point to the actual character, otherwise text_iterator is unaltered.
Definition at line 644 of file Layout-TNG-OutIter.cpp.
References Inkscape::Text::Layout::iterator::_char_index, _characters, _input_stream, _spans, begin(), Inkscape::Text::Layout::InputStreamItem::source, Inkscape::Text::Layout::InputStreamTextSource::text, TEXT_SOURCE, and Inkscape::Text::Layout::InputStreamItem::Type().
Referenced by SPFlowtext::getAsText(), insert_text_fallback(), Inkscape::UI::Dialog::SpellCheck::nextWord(), sp_te_adjust_rotation_screen(), sp_te_adjust_tspan_letterspacing_screen(), sp_te_apply_style(), sp_te_delete(), sp_te_get_string_multiline(), sp_te_insert(), sp_te_insert_line(), and sp_te_object_at_position().
double Inkscape::Text::Layout::getTextLengthIncrementDue | ( | ) | const |
Get the actual spacing increment if it's due with the current values of above stuff, otherwise 0.
Definition at line 856 of file Layout-TNG-Output.cpp.
References SVGLength::_set, lengthAdjust, LENGTHADJUST_SPACING, textLength, and textLengthIncrement.
Referenced by simulateLayoutUsingKerning().
double Inkscape::Text::Layout::getTextLengthMultiplierDue | ( | ) | const |
Get the actual scale multiplier if it's due with the current values of above stuff, otherwise 1.
Definition at line 865 of file Layout-TNG-Output.cpp.
References SVGLength::_set, lengthAdjust, LENGTHADJUST_SPACINGANDGLYPHS, textLength, and textLengthMultiplier.
Referenced by simulateLayoutUsingKerning().
Geom::OptRect Inkscape::Text::Layout::glyphBoundingBox | ( | iterator const & | it, |
double * | rotation | ||
) | const |
Returns the bounding box of the given glyph, and its rotation.
The centre of rotation is the horizontal centre of the box at the text baseline.
Definition at line 263 of file Layout-TNG-OutIter.cpp.
References Inkscape::Text::Layout::iterator::_glyph_index, and _glyphs.
|
inline |
Publically allow access to the Layout::show logic outside of the Layout engine.
Definition at line 898 of file Layout-TNG.h.
References _glyphs.
Referenced by Inkscape::Extension::Internal::PdfBuilder::TextContext::render_text().
|
inline |
Definition at line 900 of file Layout-TNG.h.
References _input_stream.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::clip_text_layout(), and Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_text_layout().
|
inline |
Queries whether any calls have been made to appendText() or appendControlCode() since the object was last cleared.
Definition at line 227 of file Layout-TNG.h.
References _input_stream.
Referenced by SPText::_buildLayoutInput().
|
inline |
Definition at line 231 of file Layout-TNG.h.
References _input_truncated.
Referenced by SPFlowtext::description(), and SPText::description().
|
inline |
Returns true if it points to a character which is a valid cursor position, as defined by Pango.
Definition at line 1160 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
|
inline |
Returns true if it points to a character which is a the end of a sentence, as defined by Pango.
Definition at line 1172 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
|
inline |
Returns true if it points to a character which is a the end of a word, as defined by Pango.
Definition at line 1166 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
bool Inkscape::Text::Layout::isHidden | ( | iterator const & | it | ) | const |
Returns true if the text at it is hidden (i.e.
overflowed).
Definition at line 638 of file Layout-TNG-OutIter.cpp.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
Referenced by insert_text_fallback().
|
inline |
Returns true if it points to a character which is a the start of a sentence, as defined by Pango.
Definition at line 1169 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
|
inline |
Returns true if it points to a character which is a the start of a word, as defined by Pango.
Definition at line 1163 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
Referenced by Inkscape::UI::Dialog::SpellCheck::nextWord().
|
inline |
Returns true if the character at it is a whitespace, as defined by Pango.
This is not meant to be used for picking out words from the output, use iterator::nextStartOfWord() and friends instead.
Definition at line 1152 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, and _characters.
|
inline |
Returns the character index from the start of the flow represented by the given iterator.
This number isn't very useful, except for when editing text it will stay valid across calls to computeFlow() and will change in predictable ways when characters are added and removed. It's also useful when transitioning old code.
Definition at line 1127 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index.
Referenced by Inkscape::UI::Toolbar::TextToolbar::_cursorMoved(), SPFlowtext::description(), SPFlowtext::getAsText(), insert_text_fallback(), sp_te_adjust_tspan_letterspacing_screen(), sp_te_insert(), and sp_te_insert_line().
|
inline |
Returns the zero-based line number of the character pointed to by it.
Definition at line 1146 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, _characters, and _lines.
Referenced by sp_te_adjust_linespacing_screen(), and sp_te_get_average_linespacing().
|
inline |
Returns true if there are some glyphs in this object, ie whether computeFlow() has been called on a non-empty input since the object was created or the last call to clear().
Definition at line 362 of file Layout-TNG.h.
References _characters.
Referenced by Inkscape::ObjectSnapper::_collectPaths(), SPFlowtext::getAsText(), SPFlowtext::getBaselinePoint(), SPText::getBaselinePoint(), SPFlowtext::snappoints(), and SPText::snappoints().
|
inline |
Returns the actual alignment used for the paragraph containing the character pointed to by it.
This means that the CSS 'start' and 'end' are correctly translated into LEFT or RIGHT according to the paragraph's directionality. For vertical text, LEFT is top alignment and RIGHT is bottom.
Definition at line 1178 of file Layout-TNG.h.
References _paragraphs, NONE, and paragraphIndex().
Referenced by baselineAnchorPoint(), Inkscape::Extension::Internal::LaTeXTextRenderer::sp_flowtext_render(), and text_put_on_path().
|
inline |
Returns the zero-based number of the paragraph containing the character pointed to by it.
Definition at line 1175 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, _characters, and _paragraphs.
Referenced by Inkscape::UI::Toolbar::TextToolbar::_cursorMoved(), and paragraphAlignment().
void Inkscape::Text::Layout::print | ( | SPPrintContext * | ctx, |
Geom::OptRect const & | pbox, | ||
Geom::OptRect const & | dbox, | ||
Geom::OptRect const & | bbox, | ||
Geom::Affine const & | ctm | ||
) | const |
Sends all the glyphs to the given print context.
ctx | I have |
pbox | no idea |
dbox | what these |
bbox | parameters |
ctm | do yet |
Definition at line 276 of file Layout-TNG-Output.cpp.
References _blockProgression(), _characters, _glyphs, _input_stream, _path_fitted, _spans, Inkscape::Text::Layout::Span::baseline_shift, Inkscape::Text::Layout::Line::baseline_y, SPPrintContext::bind(), BOTTOM_TO_TOP, CanUTN(), Inkscape::Text::Layout::Span::chunk(), Inkscape::Text::Layout::Span::direction, SPPrintContext::fill(), SPStyle::fill, Inkscape::Text::Layout::Span::font, Inkscape::Text::Layout::Span::in_input_stream_item, Inkscape::Text::Layout::Span::input_stream_first_character, LEFT_TO_RIGHT, Inkscape::Text::Layout::Chunk::left_x, Inkscape::Text::Layout::Span::line(), SPPrintContext::release(), RIGHT_TO_LEFT, SingleUnicodeToNon(), Inkscape::Text::smuggle_adxkyrtl_in(), SPPrintContext::stroke(), SPStyle::stroke, Inkscape::Text::Layout::InputStreamTextSource::style, SPPrintContext::text(), TOP_TO_BOTTOM, and Inkscape::Text::Layout::Span::x_start.
Referenced by SPFlowtext::print(), and SPText::print().
void Inkscape::Text::Layout::queryCursorShape | ( | iterator const & | it, |
Geom::Point & | position, | ||
double & | height, | ||
double & | rotation | ||
) | const |
Gets the ideal cursor shape for a given iterator.
The result is undefined if it is not at a valid cursor position.
it | The location in the output |
position | The pixel location of the centre of the 'bottom' of the cursor. |
height | The height in pixels of the surrounding text |
rotation | The angle to draw from position. Radians, zero up, increasing clockwise. |
Definition at line 512 of file Layout-TNG-OutIter.cpp.
References _blockProgression(), Inkscape::Text::Layout::iterator::_char_index, _characters, _chunks, _directions_are_orthogonal(), _empty_cursor_shape, Inkscape::Text::Layout::iterator::_glyph_index, _glyphs, _path_fitted, _spans, Inkscape::Text::Layout::Span::baseline_shift, Inkscape::Text::Layout::Line::baseline_y, chunkAnchorPoint(), Inkscape::Text::Layout::FontMetrics::descent, Path::descr_cmd, Inkscape::Text::Layout::FontMetrics::emSize(), Inkscape::Text::Layout::Span::font, height, Inkscape::Text::Layout::CursorShape::height, Inkscape::Text::Layout::Span::in_chunk, Inkscape::Text::Layout::Span::line(), Inkscape::Text::Layout::Span::line_height, Path::cut_position::piece, Inkscape::Text::Layout::CursorShape::position, Inkscape::Text::Layout::CursorShape::rotation, Path::cut_position::t, TOP_TO_BOTTOM, unused, Geom::X, Inkscape::Text::Layout::Span::x_end, Inkscape::Text::Layout::Span::x_start, Geom::Y, and Inkscape::Text::Layout::Span::y_offset.
Referenced by sp_te_get_cursor_coords().
|
inline |
Returns the zero-based number of the shape which contains the character pointed to by it.
Definition at line 1149 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, _characters, and _input_wrap_shapes.
void Inkscape::Text::Layout::show | ( | DrawingGroup * | in_arena, |
StyleAttachments & | style_attachments, | ||
Geom::OptRect const & | paintbox | ||
) | const |
Adds all the output glyphs to in_arena using the given paintbox.
in_arena | The arena to add the glyphs group to |
paintbox | The current rendering tile |
Definition at line 148 of file Layout-TNG-Output.cpp.
References _characters, _chunks, _glyphs, _input_stream, _spans, Inkscape::Text::StyleAttachments::attachFill(), Inkscape::Text::StyleAttachments::attachFilter(), Inkscape::Text::StyleAttachments::attachStroke(), parent, Inkscape::Text::Layout::InputStreamTextSource::style, SPStyle::text_decoration_data, TEXT_SOURCE, Geom::Affine::translation(), SPITextDecorationData::tspan_width, and Geom::Point::x().
Referenced by SPFlowtext::modified(), SPText::modified(), SPFlowtext::show(), SPText::show(), SPFlowtext::update(), and SPText::update().
void Inkscape::Text::Layout::showGlyphs | ( | CairoRenderContext * | ctx | ) | const |
Renders all the glyphs to the given Cairo rendering context.
ctx | The Cairo rendering context to be used |
Definition at line 446 of file Layout-TNG-Output.cpp.
References _characters, _glyphs, _input_stream, _path_fitted, _spans, Inkscape::Text::Layout::Span::font, Inkscape::Text::Layout::Span::in_input_stream_item, Inkscape::Extension::Internal::CairoGlyphInfo::index, Inkscape::Text::Layout::Span::input_stream_first_character, Geom::Affine::inverse(), SPStyle::opacity, Inkscape::Extension::Internal::CairoRenderContext::popLayer(), Inkscape::Extension::Internal::CairoRenderContext::popState(), Inkscape::Extension::Internal::CairoRenderContext::pushLayer(), Inkscape::Extension::Internal::CairoRenderContext::pushState(), Inkscape::Extension::Internal::CairoRenderContext::renderGlyphtext(), Geom::Affine::setIdentity(), Inkscape::Extension::Internal::CairoRenderContext::setStateForStyle(), Inkscape::Text::Layout::InputStreamTextSource::style, Inkscape::Extension::Internal::CairoGlyphInfo::x, and Inkscape::Extension::Internal::CairoGlyphInfo::y.
Referenced by Inkscape::Extension::Internal::sp_flowtext_render(), and Inkscape::Extension::Internal::sp_text_render().
void Inkscape::Text::Layout::simulateLayoutUsingKerning | ( | iterator const & | from, |
iterator const & | to, | ||
OptionalTextTagAttrs * | result | ||
) | const |
Returns kerning information which could cause the current output to be exactly reproduced if the letter and word spacings were zero and full justification was not used.
The x and y arrays are not used, but they are cleared. The dx applied to the first character in a chunk will always be zero. If the region between from and to crosses a line break then the results may be surprising, and are undefined. Trailing zeros on the returned arrays will be trimmed.
Definition at line 674 of file Layout-TNG-OutIter.cpp.
References Inkscape::Text::Layout::iterator::_char_index, _characters, _glyphs, _input_stream, getTextLengthIncrementDue(), getTextLengthMultiplierDue(), SPStyle::letter_spacing, result, RIGHT_TO_LEFT, TEXT_SOURCE, Inkscape::Text::Layout::InputStreamItem::Type(), and SPStyle::word_spacing.
Referenced by SPFlowtext::getAsText(), and insert_text_fallback().
Layout::iterator Inkscape::Text::Layout::sourceToIterator | ( | SPObject * | source | ) | const |
Returns an iterator pointing to the first character in the output which was created from the given source.
If source object is invalid, end() is returned. If more than one input has the same object, the first one will be used.
Definition at line 227 of file Layout-TNG-OutIter.cpp.
References _characters, _input_stream, _sourceToCharacter(), end(), and TEXT_SOURCE.
Referenced by SPText::rebuildLayout().
|
inline |
Definition at line 899 of file Layout-TNG.h.
References _spans.
Referenced by Inkscape::Extension::Internal::PdfBuilder::DrawContext::clip_text_layout(), and Inkscape::Extension::Internal::PdfBuilder::DrawContext::paint_text_layout().
void Inkscape::Text::Layout::transform | ( | Geom::Affine const & | transform | ) |
Apply the given transform to all the output presently stored in this object.
This only transforms the glyph positions, The glyphs themselves will not be transformed.
Definition at line 844 of file Layout-TNG-Output.cpp.
References _glyphs, transform(), Geom::Point::x(), and Geom::Point::y().
Referenced by bounds(), createSelectionShape(), and transform().
|
inline |
Checks the validity of the given iterator over the current layout.
If it points to a position out of the bounds for this layout it will be corrected to the nearest valid position. If you pass an iterator belonging to a different layout it will be converted to one for this layout.
Definition at line 1130 of file Layout-TNG.h.
References Inkscape::Text::Layout::iterator::_char_index, _characters, Inkscape::Text::Layout::iterator::_glyph_index, _glyphs, and Inkscape::Text::Layout::iterator::_parent_layout.
Referenced by SPText::newline_to_sodipodi(), Inkscape::UI::Dialog::SpellCheck::onObjModified(), and sp_te_delete().
|
friend |
Definition at line 149 of file Layout-TNG.h.
Referenced by calculateFlow().
|
friend |
Definition at line 147 of file Layout-TNG.h.
|
private |
Definition at line 909 of file Layout-TNG.h.
Referenced by _calculateBaselines(), and getBaselines().
|
private |
Definition at line 907 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), _cursorXOnLineToIterator(), _lineToCharacter(), _sourceToCharacter(), _spanToCharacter(), Inkscape::Text::Layout::iterator::beginCursorUpDown(), bounds(), calculateFlow(), characterAnchorPoint(), characterAt(), characterBoundingBox(), Inkscape::Text::Layout::Glyph::characters(), charIndexToIterator(), Inkscape::Text::Layout::Glyph::chunk(), chunkAnchorPoint(), createSelectionShape(), dumpAsText(), end(), fitToPathAlign(), getSourceOfCharacter(), isCursorPosition(), isEndOfSentence(), isEndOfWord(), isHidden(), isStartOfSentence(), isStartOfWord(), isWhitespace(), Inkscape::Text::Layout::Glyph::line(), lineIndex(), Inkscape::Text::Layout::iterator::nextGlyph(), outputExists(), paragraphIndex(), print(), queryCursorShape(), shapeIndex(), show(), showGlyphs(), simulateLayoutUsingKerning(), sourceToIterator(), Inkscape::Text::Layout::Glyph::span(), and validateIterator().
|
private |
Definition at line 905 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), _cursorXOnLineToIterator(), _getChunkWidth(), Inkscape::Text::Layout::iterator::beginCursorUpDown(), characterAnchorPoint(), characterBoundingBox(), Inkscape::Text::Layout::Glyph::chunk(), Inkscape::Text::Layout::Character::chunk(), Inkscape::Text::Layout::Span::chunk(), chunkAnchorPoint(), dumpAsText(), getNearestCursorPositionTo(), Inkscape::Text::Layout::Glyph::line(), Inkscape::Text::Layout::Character::line(), Inkscape::Text::Layout::Span::line(), Inkscape::Text::Layout::Character::paragraph(), Inkscape::Text::Layout::Span::paragraph(), queryCursorShape(), and show().
|
private |
Referenced by _calculateCursorShapeForEmpty(), characterAnchorPoint(), fitToPathAlign(), and queryCursorShape().
|
private |
Definition at line 908 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), bounds(), characterBoundingBox(), convertToCurves(), createSelectionShape(), dumpAsText(), end(), fitToPathAlign(), glyphBoundingBox(), glyphs(), Inkscape::Text::Layout::iterator::nextGlyph(), print(), queryCursorShape(), show(), showGlyphs(), simulateLayoutUsingKerning(), transform(), and validateIterator().
|
private |
This is our internal storage for all the stuff passed to the appendText() and appendControlCode() functions.
Definition at line 745 of file Layout-TNG.h.
Referenced by _blockBaseline(), _blockProgression(), _blockTextOrientation(), _calculateCursorShapeForEmpty(), _clearInputObjects(), appendControlCode(), appendText(), bounds(), dumpAsText(), getSourceOfCharacter(), input_stream(), inputExists(), print(), show(), showGlyphs(), simulateLayoutUsingKerning(), and sourceToIterator().
bool Inkscape::Text::Layout::_input_truncated = false |
Definition at line 230 of file Layout-TNG.h.
Referenced by fitToPathAlign(), and inputTruncated().
|
private |
Definition at line 798 of file Layout-TNG.h.
Referenced by _calculateCursorShapeForEmpty(), _clearInputObjects(), appendWrapShape(), and shapeIndex().
|
private |
Definition at line 904 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), characterAnchorPoint(), chunkAnchorPoint(), dumpAsText(), fitToPathAlign(), getNearestCursorPositionTo(), Inkscape::Text::Layout::Glyph::line(), Inkscape::Text::Layout::Character::line(), Inkscape::Text::Layout::Span::line(), lineIndex(), Inkscape::Text::Layout::Character::paragraph(), and Inkscape::Text::Layout::Span::paragraph().
|
private |
Definition at line 903 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), chunkAnchorPoint(), dumpAsText(), fitToPathAlign(), Inkscape::Text::Layout::Character::paragraph(), Inkscape::Text::Layout::Span::paragraph(), paragraphAlignment(), and paragraphIndex().
|
private |
as passed to fitToPathAlign()
Definition at line 803 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), characterBoundingBox(), createSelectionShape(), fitToPathAlign(), getNearestCursorPositionTo(), print(), queryCursorShape(), and showGlyphs().
|
private |
Definition at line 906 of file Layout-TNG.h.
Referenced by _clearOutputObjects(), _cursorXOnLineToIterator(), _getChunkWidth(), _lineToSpan(), baselineAnchorPoint(), Inkscape::Text::Layout::iterator::beginCursorUpDown(), bounds(), characterAnchorPoint(), characterBoundingBox(), Inkscape::Text::Layout::Glyph::chunk(), Inkscape::Text::Layout::Character::chunk(), createSelectionShape(), dumpAsText(), fitToPathAlign(), getActualLength(), getFontFamily(), getNearestCursorPositionTo(), getSourceOfCharacter(), Inkscape::Text::Layout::Glyph::line(), Inkscape::Text::Layout::Character::line(), Inkscape::Text::Layout::Character::paragraph(), print(), queryCursorShape(), show(), showGlyphs(), Inkscape::Text::Layout::Glyph::span(), Inkscape::Text::Layout::Character::span(), and spans().
LengthAdjust Inkscape::Text::Layout::lengthAdjust = LENGTHADJUST_SPACING |
How do we meet textLength if specified: by letterspacing or by scaling horizontally.
Definition at line 312 of file Layout-TNG.h.
Referenced by SPText::_buildLayoutInput(), clear(), getTextLengthIncrementDue(), and getTextLengthMultiplierDue().
|
static |
The CSS spec allows line-height:normal to be whatever the user agent thinks will look good.
This is our value, as a multiple of font-size.
Definition at line 209 of file Layout-TNG.h.
Referenced by SPText::_buildLayoutInit(), SPFlowtext::_buildLayoutInput(), objects_query_fontnumbers(), and sp_te_adjust_line_height().
FontMetrics Inkscape::Text::Layout::strut |
The strut is the minimum value used in calculating line height.
Definition at line 674 of file Layout-TNG.h.
Referenced by SPText::_buildLayoutInit(), and SPFlowtext::_buildLayoutInput().
SVGLength Inkscape::Text::Layout::textLength |
Gives the length target of this layout, as given by textLength attribute.
FIXME: by putting it here we only support @textLength on text and flowRoot, not on any spans inside. For spans, we will need to add markers of start and end of a textLength span into the _input_stream. These spans can nest (SVG 1.1, section 10.5). After a first layout calculation, we would go through the input stream and, for each end of a textLength span, go through its items, choose those where it wasn't yet set by a nested span, calculate their number of characters, divide the length deficit by it, and set set the textLengthMultiplier for those characters only. For now we do this for the entire layout, without dealing with spans.
Definition at line 309 of file Layout-TNG.h.
Referenced by SPText::_buildLayoutInput(), clear(), getTextLengthIncrementDue(), and getTextLengthMultiplierDue().
double Inkscape::Text::Layout::textLengthIncrement = 0 |
This one is used by letterspacing strategy: to each glyph width, this is added.
Definition at line 320 of file Layout-TNG.h.
Referenced by calculateFlow(), clear(), and getTextLengthIncrementDue().
double Inkscape::Text::Layout::textLengthMultiplier = 1 |
By how much each character needs to be wider or narrower, using the specified lengthAdjust strategy, for the layout to meet its textLength target.
Is set to non-zero after the layout is calculated for the first time, then it is recalculated with each glyph getting its adjustment. This one is used by scaling strategies: each glyph width is multiplied by this
Definition at line 318 of file Layout-TNG.h.
Referenced by clear(), and getTextLengthMultiplierDue().
|
staticprivate |
Definition at line 684 of file Layout-TNG.h.
enum Inkscape::Text::Layout::WrapMode Inkscape::Text::Layout::wrap_mode = WRAP_NONE |