Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Layout-TNG-Scanline-Maker.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Inkscape::Text::Layout::ScanlineMaker - text layout engine shape measurers
4 *
5 * Authors:
6 * Richard Hughes <cyreve@users.sf.net>
7 *
8 * Copyright (C) 2005 Richard Hughes
9 *
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12#ifndef LAYOUT_TNG_SCANLINE_MAKER_H
13#define LAYOUT_TNG_SCANLINE_MAKER_H
14
15#include <vector>
16#include <cmath>
18
19class Shape;
20
21namespace Inkscape {
22namespace Text {
23
34{
35public:
36 virtual ~ScanlineMaker() = default;
37
38 struct ScanRun
39 {
40 double y;
41 double x_start; // these are not flipped according to the text direction
42 double x_end;
43 inline double width() const {return std::abs(x_start - x_end);}
44 };
45
52 virtual std::vector<ScanRun> makeScanline(Layout::FontMetrics const &line_height) = 0;
53
58 virtual void completeLine() = 0;
59
62 virtual double yCoordinate() = 0;
63
67 virtual void setNewYCoordinate(double new_y) = 0;
68
76 virtual bool canExtendCurrentScanline(Layout::FontMetrics const &line_height) = 0;
77
81 virtual void setLineHeight(Layout::FontMetrics const &line_height) = 0;
82};
83
94{
95public:
96 InfiniteScanlineMaker(double initial_x, double initial_y, Layout::Direction block_progression);
98
100 std::vector<ScanRun> makeScanline(Layout::FontMetrics const &line_height) override;
101
103 void completeLine() override;
104
105 double yCoordinate() override { return _y; }
106
108 void setNewYCoordinate(double new_y) override;
109
111 bool canExtendCurrentScanline(Layout::FontMetrics const &line_height) override;
112
116 void setLineHeight(Layout::FontMetrics const &line_height) override;
117
118private:
119 double _x, _y;
122};
123
131{
132public:
133 ShapeScanlineMaker(Shape const *shape, Layout::Direction block_progression);
134 ~ShapeScanlineMaker() override;
135
136 std::vector<ScanRun> makeScanline(Layout::FontMetrics const &line_height) override;
137
138 void completeLine() override;
139
140 double yCoordinate() override;
141
142 void setNewYCoordinate(double new_y) override;
143
145 bool canExtendCurrentScanline(Layout::FontMetrics const &line_height) override;
146
150 void setLineHeight(Layout::FontMetrics const &line_height) override;
151
152private:
158
161
162 // Shape::BeginRaster() needs floats rather than doubles
164 float _y;
168
170};
171
172} // namespace Text
173} // namespace Inkscape
174
175#endif // LAYOUT_TNG_SCANLINE_MAKER_H
176
177/*
178 Local Variables:
179 mode:c++
180 c-file-style:"stroustrup"
181 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
182 indent-tabs-mode:nil
183 fill-column:99
184 End:
185*/
186// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Keep track of font metrics.
Definition Layout-TNG.h:624
std::vector< ScanRun > makeScanline(Layout::FontMetrics const &line_height) override
Returns a single infinite run at the current location.
double yCoordinate() override
Returns the y coordinate of the top of the scanline that will be returned by the next call to makeSca...
void setNewYCoordinate(double new_y) override
Just changes y.
void setLineHeight(Layout::FontMetrics const &line_height) override
Sets current line block height.
bool canExtendCurrentScanline(Layout::FontMetrics const &line_height) override
Always true, but has to save the new height.
void completeLine() override
Increments the current y by the current line height.
virtual void completeLine()=0
Indicates that the caller has successfully filled the current line and hence that the next call to ma...
virtual bool canExtendCurrentScanline(Layout::FontMetrics const &line_height)=0
Tests whether the caller can fit a new line with the given metrics into exactly the space returned by...
virtual void setLineHeight(Layout::FontMetrics const &line_height)=0
Sets current line block height.
virtual void setNewYCoordinate(double new_y)=0
Forces an arbitrary change in the stored y coordinate of the object.
virtual std::vector< ScanRun > makeScanline(Layout::FontMetrics const &line_height)=0
Returns a list of chunks on the current line which can fit text with the given properties.
virtual double yCoordinate()=0
Returns the y coordinate of the top of the scanline that will be returned by the next call to makeSca...
void setLineHeight(Layout::FontMetrics const &line_height) override
Sets current line block height.
std::vector< ScanRun > makeScanline(Layout::FontMetrics const &line_height) override
Returns a list of chunks on the current line which can fit text with the given properties.
bool canExtendCurrentScanline(Layout::FontMetrics const &line_height) override
never true
double yCoordinate() override
Returns the y coordinate of the top of the scanline that will be returned by the next call to makeSca...
void setNewYCoordinate(double new_y) override
Forces an arbitrary change in the stored y coordinate of the object.
void completeLine() override
Indicates that the caller has successfully filled the current line and hence that the next call to ma...
Shape * _rotated_shape
To generate scanlines for top-to-bottom text it is easiest if we simply rotate the given shape by a m...
Direction
Used to specify any particular text direction required.
Definition Layout-TNG.h:159
A class to store/manipulate directed graphs.
Definition Shape.h:65
Helper class to stream background task notifications as a series of messages.
double x_start
that's the top of the scan run, not the baseline