diff options
| author | bulia byak <buliabyak@gmail.com> | 2008-07-18 03:21:52 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2008-07-18 03:21:52 +0000 |
| commit | 5a2f34e66aca5955e548211a7cb694b91ceaeacb (patch) | |
| tree | 154c207458fec35df63cb64c99bc5baa0aefb957 /src/text-editing.cpp | |
| parent | fix artefacts left by text cursor and disappearing cursor on empty canvas (diff) | |
| download | inkscape-5a2f34e66aca5955e548211a7cb694b91ceaeacb.tar.gz inkscape-5a2f34e66aca5955e548211a7cb694b91ceaeacb.zip | |
add utility function for average linespacing
(bzr r6343)
Diffstat (limited to 'src/text-editing.cpp')
| -rw-r--r-- | src/text-editing.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/text-editing.cpp b/src/text-editing.cpp index b103a0108..b92d85b15 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1086,6 +1086,19 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it text->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } +double +sp_te_get_average_linespacing (SPItem *text) +{ + Inkscape::Text::Layout const *layout = te_get_layout(text); + if (!layout) + return 0; + + unsigned line_count = layout->lineIndex(layout->end()); + double all_lines_height = layout->characterAnchorPoint(layout->end())[NR::Y] - layout->characterAnchorPoint(layout->begin())[NR::Y]; + double average_line_height = all_lines_height / (line_count == 0 ? 1 : line_count); + return average_line_height; +} + void sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator const &/*start*/, Inkscape::Text::Layout::iterator const &/*end*/, SPDesktop *desktop, gdouble by) { |
