Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Inkscape::Text::Layout Class Reference

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::PointbaselineAnchorPoint () 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::LineSegmentgetBaselines () 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::PointcreateSelectionShape (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.
 

Detailed Description

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:

  1. Construct
  2. Set the text using appendText() and appendControlCode()
  3. If you want text wrapping, call appendWrapShape() a few times
  4. Call calculateFlow()
  5. You can go several directions from here, but the most interesting things start with creating a Layout::iterator with begin() or end().

Terminology, in descending order of size:

  • Flow: Not often used, but when it is it means all the text
  • Shape: A Shape object which is used to represent one of the regions inside which to flow the text. Can overlap with...
  • Paragraph: Err...A paragraph. Contains one or more...
  • Line: An entire horizontal line with a common baseline. Contains one or more...
  • Chunk: You only get more than one of these when a shape is sufficiently complex that the text has to flow either side of some obstruction in the middle. A chunk is the base unit for wrapping. Contains one or more...
  • Span: A convenient subset of a chunk with the same font, style, directionality, block progression and input stream. Fill and outline need not be constant because that's a later rendering stage.
  • This is where it gets weird because a span will contain one or more elements of both of the following, which can overlap with each other in any way:
    • Character: a single Unicode codepoint from an input stream. Many arabic characters contain multiple glyphs
    • Glyph: a rendering primitive for font engines. A ligature glyph will represent multiple characters.

Other terminology:

  • Input stream: An object representing a single call to appendText() or appendControlCode().
  • Control code: Metadata in the text stream to signify items that occupy real space (unlike style changes) but don't belong in the text string. Paragraph breaks are in this category. See Layout::TextControlCode.
  • SVG1.1: The W3C Recommendation "Scalable Vector Graphics (SVG) 1.1" http://www.w3.org/TR/SVG11/
  • 'left', 'down', etc: These terms are generally used to mean what they mean in left-to-right, top-to-bottom text but rotated or reflected for the current directionality. Thus, the 'width' of a ttb line is actually its height, and the (internally stored) y coordinate of a glyph is actually its x coordinate. Confusing to the reader but much simpler in the code. All public methods use real x and y.

Comments:

  • There's a strong emphasis on international support in this class, but that's primarily because once you can display all the insane things required by various languages, simple things like styling text are almost trivial.
  • There are a few places (appendText() is one) where pointers are held to caller-owned objects and used for quite a long time. This is messy but is safe for our usage scenario and in many cases the cost of copying the objects is quite high.
  • "Why isn't foo here?": Ask yourself if it's possible to implement foo externally using iterators. However this may not mean that it doesn't belong as a member, though.
  • I've used floats rather than doubles to store relative distances in some places (internal only) where it would save significant amounts of memory. The SVG spec allows you to do this as long as intermediate calculations are done double. Very very long lines might not finish precisely where you want, but that's to be expected with any typesetting. Also, SVGLength only uses floats.
  • If you look at the six arrays for holding the output data you'll realise that there's no O(1) way to drill down from a paragraph to find its starting glyph. This was a conscious decision to reduce complexity and to save memory. Drilling down isn't actually that slow because a binary chop will work nicely. Add this to the realisation that most of the times you do this will be in response to user actions and hence you only need to be faster than the user and I think the design makes sense.
  • There are a massive number of functions acting on Layout::iterator. A large number are trivial and will be inline, but is it really necessary to have all these, especially when some can be implemented by the caller using the others?
  • The separation of methods between Layout and Layout::iterator is a bit arbitrary, because many methods could go in either. I've used the STL model where the iterator itself can only move around; the base class is required to do anything interesting.
  • I use Pango internally, not Pangomm. The reason for this is lots of Pangomm methods take Glib::ustrings as input and then output byte offsets within the strings. There's simply no way to use byte offsets with ustrings without some very entertaining reinterpret_cast<>s. The Pangomm docs seem to be lacking quite a lot of things mentioned in the Pango docs, too.

Definition at line 144 of file Layout-TNG.h.

Member Enumeration Documentation

◆ Alignment

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.

◆ Direction

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.

◆ DisplayAlign

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.

◆ InputStreamItemType

Enumerator
TEXT_SOURCE 
CONTROL_CODE 

Definition at line 689 of file Layout-TNG.h.

◆ LengthAdjust

lengthAdjust values

Enumerator
LENGTHADJUST_SPACING 
LENGTHADJUST_SPACINGANDGLYPHS 

Definition at line 169 of file Layout-TNG.h.

◆ Orientation

Used to specify orientation of glyphs in vertical text.

Enumerator
ORIENTATION_UPRIGHT 
ORIENTATION_SIDEWAYS 

Definition at line 162 of file Layout-TNG.h.

◆ TextControlCode

Control codes which can be embedded in the text to be flowed.

See appendControlCode().

Enumerator
PARAGRAPH_BREAK 
SHAPE_BREAK 

forces the flow to move on to the next line

ARBITRARY_GAP 

forces the flow to ignore the remainder of the current shape (from #flow_inside_shapes) and continue at the top of the one after.

inserts an arbitrarily-sized hole in the flow in line with the current text.

Definition at line 196 of file Layout-TNG.h.

◆ WrapMode

Enumerator
WRAP_NONE 
WRAP_WHITE_SPACE 
WRAP_INLINE_SIZE 
WRAP_SHAPE_INSIDE 

Definition at line 171 of file Layout-TNG.h.

Constructor & Destructor Documentation

◆ Layout()

Inkscape::Text::Layout::Layout ( )
default

◆ ~Layout()

Inkscape::Text::Layout::~Layout ( )
virtual

Definition at line 22 of file Layout-TNG.cpp.

References clear().

Member Function Documentation

◆ _blockBaseline()

SPCSSBaseline Inkscape::Text::Layout::_blockBaseline ( ) const
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.

◆ _blockProgression()

Direction Inkscape::Text::Layout::_blockProgression ( ) const
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().

◆ _blockTextOrientation()

SPCSSTextOrientation Inkscape::Text::Layout::_blockTextOrientation ( ) const
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.

◆ _calculateBaselines()

void Inkscape::Text::Layout::_calculateBaselines ( )
private

Definition at line 331 of file Layout-TNG-OutIter.cpp.

References _baselines, begin(), characterAnchorPoint(), Geom::Path::clear(), and end().

Referenced by calculateFlow().

◆ _calculateCursorShapeForEmpty()

◆ _clearInputObjects()

void Inkscape::Text::Layout::_clearInputObjects ( )
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().

◆ _clearOutputObjects()

void Inkscape::Text::Layout::_clearOutputObjects ( )
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().

◆ _copyInputVector()

void Inkscape::Text::Layout::_copyInputVector ( std::vector< SVGLength > const &  input_vector,
unsigned  input_offset,
std::vector< SVGLength > *  output_vector,
size_t  max_length 
)
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().

◆ _cursorXOnLineToIterator()

Layout::iterator Inkscape::Text::Layout::_cursorXOnLineToIterator ( unsigned  line_index,
double  local_x,
double  local_y = 0 
) const
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().

◆ _directions_are_orthogonal()

bool Inkscape::Text::Layout::_directions_are_orthogonal ( Direction  d1,
Direction  d2 
)
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().

◆ _getChunkWidth()

double Inkscape::Text::Layout::_getChunkWidth ( unsigned  chunk_index) const
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().

◆ _lineToCharacter()

unsigned Inkscape::Text::Layout::_lineToCharacter ( unsigned  line_index) const
inlineprivate

Definition at line 920 of file Layout-TNG.h.

References _characters, and index.

Referenced by _cursorXOnLineToIterator().

◆ _lineToSpan()

unsigned Inkscape::Text::Layout::_lineToSpan ( unsigned  line_index) const
inlineprivate

Definition at line 911 of file Layout-TNG.h.

References _spans, and index.

Referenced by _getChunkWidth().

◆ _sourceToCharacter()

unsigned Inkscape::Text::Layout::_sourceToCharacter ( unsigned  source_index) const
inlineprivate

Definition at line 938 of file Layout-TNG.h.

References _characters, and index.

Referenced by sourceToIterator().

◆ _spanToCharacter()

unsigned Inkscape::Text::Layout::_spanToCharacter ( unsigned  span_index) const
inlineprivate

Definition at line 929 of file Layout-TNG.h.

References _characters, and index.

◆ appendControlCode()

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.

Parameters
codeA member of the TextFlowControlCode enumeration.
widthThe width in pixels that this item occupies.
ascentThe number of pixels above the text baseline that this control code occupies.
descentThe number of pixels below the text baseline that this control code occupies.
sourcePointer 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().

◆ appendText() [1/2]

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.

Parameters
textThe text. Note: only a pointer is stored. Do not mess with the text until after you have called calculateFlow().
styleThe 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.
sourcePointer to object that is source of text.
optional_attributesA structure containing additional options for this text. See OptionalTextTagAttrs. The values are copied to internal storage before this method returns.
optional_attributes_offsetIt 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_beginUsed for selecting only a substring of text to process.
text_endUsed 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().

◆ appendText() [2/2]

void Inkscape::Text::Layout::appendText ( Glib::ustring const &  text,
SPStyle style,
SPObject source,
OptionalTextTagAttrs const *  optional_attributes = nullptr,
unsigned  optional_attributes_offset = 0 
)
inline

Definition at line 259 of file Layout-TNG.h.

References appendText().

◆ appendWrapShape()

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.

Parameters
shapeThe Shape to use next in the flow.
display_alignThe 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().

◆ baseline()

Geom::Path Inkscape::Text::Layout::baseline ( ) const

◆ baselineAnchorPoint()

std::optional< Geom::Point > Inkscape::Text::Layout::baselineAnchorPoint ( ) const

◆ begin()

◆ bounds()

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.

Parameters
bounding_boxWhere to store the box
transformThe 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().

◆ calculateFlow()

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.

Returns
false on failure.

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().

◆ characterAnchorPoint()

◆ characterAt()

gunichar Inkscape::Text::Layout::characterAt ( iterator const &  it) const
inline

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().

◆ characterBoundingBox()

Geom::Rect Inkscape::Text::Layout::characterBoundingBox ( iterator const &  it,
double *  rotation = nullptr 
) const

◆ charIndexToIterator()

Layout::iterator Inkscape::Text::Layout::charIndexToIterator ( int  char_index) const
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().

◆ chunkAnchorPoint()

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().

◆ clear()

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().

◆ convertToCurves() [1/2]

SPCurve Inkscape::Text::Layout::convertToCurves ( ) const

Definition at line 822 of file Layout-TNG-Output.cpp.

References begin(), convertToCurves(), and end().

Referenced by convertToCurves().

◆ convertToCurves() [2/2]

SPCurve Inkscape::Text::Layout::convertToCurves ( iterator const &  from_glyph,
iterator const &  to_glyph 
) const

◆ createSelectionShape()

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().

◆ dumpAsText()

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().

◆ end()

◆ fitToPathAlign()

void Inkscape::Text::Layout::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.

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().

◆ getActualLength()

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().

◆ getBaselines()

std::vector< Geom::LineSegment > Inkscape::Text::Layout::getBaselines ( ) const
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().

◆ getFontFamily()

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().

◆ getLetterAt() [1/2]

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().

◆ getLetterAt() [2/2]

Layout::iterator Inkscape::Text::Layout::getLetterAt ( Geom::Point point) const
inline

Definition at line 1143 of file Layout-TNG.h.

References getLetterAt().

◆ getNearestCursorPositionTo() [1/2]

Layout::iterator Inkscape::Text::Layout::getNearestCursorPositionTo ( double  x,
double  y 
) const

◆ getNearestCursorPositionTo() [2/2]

Layout::iterator Inkscape::Text::Layout::getNearestCursorPositionTo ( Geom::Point const &  point) const
inline

Definition at line 1140 of file Layout-TNG.h.

References getNearestCursorPositionTo().

◆ getSourceOfCharacter()

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().

◆ getTextLengthIncrementDue()

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().

◆ getTextLengthMultiplierDue()

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().

◆ glyphBoundingBox()

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.

◆ glyphs()

std::vector< Layout::Glyph > const & Inkscape::Text::Layout::glyphs ( ) const
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().

◆ input_stream()

std::vector< InputStreamItem * > const & Inkscape::Text::Layout::input_stream ( ) const
inline

◆ inputExists()

bool Inkscape::Text::Layout::inputExists ( ) const
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().

◆ inputTruncated()

bool Inkscape::Text::Layout::inputTruncated ( ) const
inline

Definition at line 231 of file Layout-TNG.h.

References _input_truncated.

Referenced by SPFlowtext::description(), and SPText::description().

◆ isCursorPosition()

bool Inkscape::Text::Layout::isCursorPosition ( iterator const &  it) const
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.

◆ isEndOfSentence()

bool Inkscape::Text::Layout::isEndOfSentence ( iterator const &  it) const
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.

◆ isEndOfWord()

bool Inkscape::Text::Layout::isEndOfWord ( iterator const &  it) const
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.

◆ isHidden()

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().

◆ isStartOfSentence()

bool Inkscape::Text::Layout::isStartOfSentence ( iterator const &  it) const
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.

◆ isStartOfWord()

bool Inkscape::Text::Layout::isStartOfWord ( iterator const &  it) const
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().

◆ isWhitespace()

bool Inkscape::Text::Layout::isWhitespace ( iterator const &  it) const
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.

◆ iteratorToCharIndex()

int Inkscape::Text::Layout::iteratorToCharIndex ( Layout::iterator const &  it) const
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().

◆ lineIndex()

unsigned Inkscape::Text::Layout::lineIndex ( iterator const &  it) const
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().

◆ outputExists()

bool Inkscape::Text::Layout::outputExists ( ) const
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().

◆ paragraphAlignment()

Layout::Alignment Inkscape::Text::Layout::paragraphAlignment ( iterator const &  it) const
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().

◆ paragraphIndex()

unsigned Inkscape::Text::Layout::paragraphIndex ( iterator const &  it) const
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().

◆ print()

◆ queryCursorShape()

void Inkscape::Text::Layout::queryCursorShape ( iterator const &  it,
Geom::Point position,
double &  height,
double &  rotation 
) const

◆ shapeIndex()

unsigned Inkscape::Text::Layout::shapeIndex ( iterator const &  it) const
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.

◆ show()

void Inkscape::Text::Layout::show ( DrawingGroup in_arena,
StyleAttachments style_attachments,
Geom::OptRect const &  paintbox 
) const

◆ showGlyphs()

◆ simulateLayoutUsingKerning()

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().

◆ sourceToIterator()

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().

◆ spans()

std::vector< Layout::Span > const & Inkscape::Text::Layout::spans ( ) const
inline

◆ transform()

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().

◆ validateIterator()

void Inkscape::Text::Layout::validateIterator ( Layout::iterator it) const
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().

Friends And Related Symbol Documentation

◆ Calculator

friend class Calculator
friend

Definition at line 149 of file Layout-TNG.h.

Referenced by calculateFlow().

◆ iterator

friend class iterator
friend

Definition at line 147 of file Layout-TNG.h.

Member Data Documentation

◆ _baselines

std::vector<Geom::LineSegment> Inkscape::Text::Layout::_baselines
private

Definition at line 909 of file Layout-TNG.h.

Referenced by _calculateBaselines(), and getBaselines().

◆ _characters

◆ _chunks

◆ _empty_cursor_shape

struct Inkscape::Text::Layout::CursorShape Inkscape::Text::Layout::_empty_cursor_shape
private

◆ _glyphs

◆ _input_stream

◆ _input_truncated

bool Inkscape::Text::Layout::_input_truncated = false

Definition at line 230 of file Layout-TNG.h.

Referenced by fitToPathAlign(), and inputTruncated().

◆ _input_wrap_shapes

std::vector<InputWrapShape> Inkscape::Text::Layout::_input_wrap_shapes
private

◆ _lines

◆ _paragraphs

◆ _path_fitted

Path const* Inkscape::Text::Layout::_path_fitted = nullptr
private

◆ _spans

◆ lengthAdjust

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().

◆ LINE_HEIGHT_NORMAL

const double Inkscape::Text::Layout::LINE_HEIGHT_NORMAL = 1.25
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().

◆ strut

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().

◆ textLength

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().

◆ textLengthIncrement

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().

◆ textLengthMultiplier

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().

◆ UNICODE_SOFT_HYPHEN

const gunichar Inkscape::Text::Layout::UNICODE_SOFT_HYPHEN = 0x00AD
staticprivate

Definition at line 684 of file Layout-TNG.h.

◆ wrap_mode


The documentation for this class was generated from the following files: