Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
drawing-text.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
6 * Authors:
7 * Krzysztof KosiƄski <tweenk.pl@gmail.com>
8 *
9 * Copyright (C) 2011 Authors
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#ifndef INKSCAPE_DISPLAY_DRAWING_TEXT_H
14#define INKSCAPE_DISPLAY_DRAWING_TEXT_H
15
16#include <memory>
18#include "display/nr-style.h"
19
20class SPStyle;
21class FontInstance;
22
23namespace Inkscape {
24
25class Pixbuf;
26
28 : public DrawingItem
29{
30public:
32 int tag() const override { return tag_of<decltype(*this)>; }
33
34 void setGlyph(std::shared_ptr<FontInstance> font, unsigned int glyph, Geom::Affine const &trans);
35 void setStyle(SPStyle const *style, SPStyle const *context_style = nullptr) override; // Not to be used
37
38protected:
39 ~DrawingGlyphs() override = default;
40
41 unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override;
42 DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags) override;
43
44 std::shared_ptr<void const> _font_data; // keeps alive pathvec, pathvec_ref, and pixbuf
45 unsigned int _glyph;
46 float _width; // These three are used to set up bounding box
47 float _asc; //
48 float _dsc; //
49 float _pl; // phase length
50
52 Geom::PathVector const *pathvec = nullptr; // pathvector of glyph.
53 Inkscape::Pixbuf const *pixbuf = nullptr; // pixbuf, if SVG font
54 Geom::Rect bbox_exact; // Exact bounding box of glyph.
55 Geom::Rect bbox_pick; // Pick bounding box of glyph.
56 Geom::Rect bbox_draw; // Draw bounding box of glyph (adds space for text decorations)
57 // Geom::IntRect bbox_exact_scaled;
60
61 char* font_descr; // For debugging
62
63 friend class DrawingText;
64};
65
67 : public DrawingGroup
68{
69public:
71 int tag() const override { return tag_of<decltype(*this)>; }
72
73 bool addComponent(std::shared_ptr<FontInstance> const &font, int unsigned glyph,
74 Geom::Affine const &trans, float width, float ascent, float descent, float phase_length);
75 void setStyle(SPStyle const *style, SPStyle const *context_style = nullptr) override;
76 void setChildrenStyle(SPStyle const *context_style) override;
77
78protected:
79 ~DrawingText() override = default;
80
81 unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override;
82 unsigned _renderItem(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, unsigned flags, DrawingItem const *stop_at) const override;
83 void _clipItem(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area) const override;
84 DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags) override;
85 bool _canClip() const override { return true; }
86
87 void decorateItem(DrawingContext &dc, double phase_length, bool under) const;
88 void decorateStyle(DrawingContext &dc, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2, double thickness) const;
90
94
95 friend class DrawingGlyphs;
96};
97
98} // namespace Inkscape
99
100#endif // INKSCAPE_DISPLAY_DRAWING_TEXT_H
101
102/*
103 Local Variables:
104 mode:c++
105 c-file-style:"stroustrup"
106 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
107 indent-tabs-mode:nil
108 fill-column:99
109 End:
110*/
111// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
constexpr int tag_of
Convenience function to retrieve the tag (class id) of a given type.
Definition cast.h:26
FontInstance provides metrics, OpenType data, and glyph curves/pixbufs for a font.
3x3 matrix representing an affine transformation.
Definition affine.h:70
Axis aligned, non-empty, generic rectangle.
Sequence of subpaths.
Definition pathvector.h:122
Two-dimensional point that doubles as a vector.
Definition point.h:66
Axis aligned, non-empty rectangle.
Definition rect.h:92
Minimal wrapper over Cairo.
Geom::IntRect bbox_draw_scaled
void setGlyph(std::shared_ptr< FontInstance > font, unsigned int glyph, Geom::Affine const &trans)
Geom::IntRect bbox_pick_scaled
void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr) override
Process information related to the new style.
unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override
int tag() const override
Unlink this node and its subtree from the rendering tree and destroy.
std::shared_ptr< void const > _font_data
Inkscape::Pixbuf const * pixbuf
~DrawingGlyphs() override=default
Geom::PathVector const * pathvec
DrawingItem * _pickItem(Geom::Point const &p, double delta, unsigned flags) override
Geom::IntRect getPickBox() const
SVG drawing item for display.
Drawing & drawing() const
int tag() const override
Unlink this node and its subtree from the rendering tree and destroy.
void decorateItem(DrawingContext &dc, double phase_length, bool under) const
void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr) override
Process information related to the new style.
void setChildrenStyle(SPStyle const *context_style) override
Recursively update children style.
unsigned _renderItem(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, unsigned flags, DrawingItem const *stop_at) const override
bool _canClip() const override
unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override
SPWindRule style_clip_rule
void decorateStyle(DrawingContext &dc, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2, double thickness) const
~DrawingText() override=default
void _clipItem(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area) const override
bool style_stroke_extensions_hairline
bool addComponent(std::shared_ptr< FontInstance > const &font, int unsigned glyph, Geom::Affine const &trans, float width, float ascent, float descent, float phase_length)
DrawingItem * _pickItem(Geom::Point const &p, double delta, unsigned flags) override
Class to hold image data for raster images.
Definition cairo-utils.h:31
An SVG style object.
Definition style.h:45
RectangularCluster rc
Group belonging to an SVG drawing element.
Helper class to stream background task notifications as a series of messages.
Style information for rendering.
SPWindRule
Definition style-enums.h:23
int delta
double width