22 #ifndef STLL_LAYOUTER_H
23 #define STLL_LAYOUTER_H
33 #include <boost/icl/split_interval_map.hpp>
34 #include <boost/icl/closed_interval.hpp>
69 std::shared_ptr<FontFace_c>
font;
88 command(
CMD_GLYPH), x(x_), y(y_), glyphIndex(i), font(f), w(0), h(0), c(c_), blurr(rad) {}
92 CommandData_c(
const std::string & i, int32_t x_, int32_t y_, uint32_t w_, uint32_t h_) :
93 command(
CMD_IMAGE), x(x_), y(y_), glyphIndex(0), w(w_), h(h_), blurr(0), imageURL(i) {}
98 command(
CMD_RECT), x(x_), y(y_), glyphIndex(0), w(w_), h(h_), c(c_), blurr(rad) {}
113 int32_t firstBaseline;
115 std::vector<CommandData_c> data;
121 const std::vector<CommandData_c>
getData(
void)
const {
return data; }
142 std::vector<LinkInformation_c>
links;
151 template <
class... Args>
154 data.emplace_back(std::forward<Args>(args)...);
175 template <
class... Args>
178 data.emplace(data.begin(), std::forward<Args>(args)...);
189 data.insert(data.begin(), d);
212 firstBaseline = l.firstBaseline;
213 swap(links, l.links);
224 firstBaseline = l.firstBaseline;
247 void shift(int32_t dx, int32_t dy);
337 return c == rhs.
c && dx == rhs.
dx && dy == rhs.
dy && blurr == rhs.
blurr;
359 std::shared_ptr<TextLayout_c>
inlay;
383 return c == rhs.
c && font == rhs.
font && lang == rhs.
lang
384 && flags == rhs.
flags && shadows.size() && rhs.
shadows.size()
385 && std::equal(shadows.begin(), shadows.end(), rhs.
shadows.begin())
420 boost::icl::interval_map<size_t, CodepointAttributes_c> attr;
433 attr += std::make_pair(boost::icl::interval<size_t>::closed(0, SIZE_MAX), a);
442 attr += std::make_pair(boost::icl::interval<size_t>::closed(i, i), a);
452 attr += std::make_pair(boost::icl::interval<size_t>::closed(start, end), a);
461 return attr.find(i)->second;
466 return attr.find(i) != attr.end();
486 virtual int32_t
getLeft(int32_t top, int32_t bottom)
const = 0;
493 virtual int32_t
getRight(int32_t top, int32_t bottom)
const = 0;
500 virtual int32_t
getLeft2(int32_t top, int32_t bottom)
const = 0;
507 virtual int32_t
getRight2(int32_t top, int32_t bottom)
const = 0;
524 virtual int32_t
getLeft(int32_t , int32_t )
const {
return 0; }
525 virtual int32_t
getLeft2(int32_t , int32_t )
const {
return 0; }
526 virtual int32_t
getRight(int32_t , int32_t )
const {
return w; }
527 virtual int32_t
getRight2(int32_t , int32_t )
const {
return w; }
int8_t dy
offset of the shadow in 1/64th pixels relative to the position of the normal glyph ...
Definition: layouter.h:327
CommandData_c(std::shared_ptr< FontFace_c > f, glyphIndex_t i, int32_t x_, int32_t y_, Color_c c_, uint16_t rad)
constructor to create an glyph command
Definition: layouter.h:87
virtual int32_t getLeft(int32_t top, int32_t bottom) const =0
get the left edge
int8_t dx
offset of the shadow in 1/64th pixels relative to the position of the normal glyph ...
Definition: layouter.h:322
one element of the shadow
Definition: layouter.h:311
void setFirstBaseline(int32_t r)
set the y position of the first baseline
Definition: layouter.h:276
std::vector< std::string > links
link URLs for the links used in the CodepointAttribute_c
Definition: layouter.h:558
int32_t getLeft(void) const
get the left edge of the layout in 1/64th pixels
Definition: layouter.h:260
Font_c font
font of the letter
Definition: layouter.h:295
a little class representing an RGBA colour value, an a value of 255 is assumed to be opaque ...
Definition: color.h:36
bool operator==(const struct Shadow_c &rhs) const
comparison operator for one shadow
Definition: layouter.h:335
collection of codepointAttributes for the layouter.
Definition: layouter.h:417
int32_t x
x position
Definition: layouter.h:61
AttributeIndex_c(void)
create an empty index
Definition: layouter.h:426
uint32_t glyphIndex_t
type used for all glyph indices. Right now there is no font with more than 2^16 fonts, so 2^32 should be on the safe side. Also HarfBuzz also uses only 2^32 codepoints.
Definition: layouterFont.h:53
AttributeIndex_c(const CodepointAttributes_c &a)
create an index where all entries have the same attribute
Definition: layouter.h:431
contains all the FontFaces_c of one FontRessource_c
Definition: layouterFont.h:232
CommandData_c(int32_t x_, int32_t y_, uint32_t w_, uint32_t h_, Color_c c_, uint16_t rad)
constructor to create an rectangle command
Definition: layouter.h:97
bool hasAttribute(size_t i) const
Definition: layouter.h:464
void setRight(int32_t r)
get the right edge in 1/64th pixels
Definition: layouter.h:272
static const uint8_t FL_UNDERLINE
bit for the flags variable, if set the glyph will be underlined
Definition: layouter.h:303
const std::vector< CommandData_c > getData(void) const
get the command vector
Definition: layouter.h:121
bool ltr
is the base direction of the text left to right?
Definition: layouter.h:546
Color_c c
colour of the glyph or the rectangle
Definition: layouter.h:78
base class to define the shape to layout text into
Definition: layouter.h:478
Color_c c
colour of the letter
Definition: layouter.h:291
std::vector< Shadow_c > shadows
the shadows to draw behind the real glyph. The shadows are drawn in the order within this vector and ...
Definition: layouter.h:345
Color_c c
the colour to use for this shadow element
Definition: layouter.h:317
void addCommandStart(Args &&...args)
add a single drawing command to the start of the command list
Definition: layouter.h:176
void addCommand(const CommandData_c &c)
add a single drawing command to the end of the command list
Definition: layouter.h:163
virtual int32_t getLeft2(int32_t, int32_t) const
get the left edge
Definition: layouter.h:525
std::shared_ptr< TextLayout_c > inlay
sometimes you want to place something different instead of a glyph (e.g. an image). This can be done with an inlay.
Definition: layouter.h:359
uint8_t flags
some flags for the glyph, use FL_xxx constants to change the value
Definition: layouter.h:307
void shift(int32_t dx, int32_t dy)
shift all the commands within the layout by the given amount
RectangleShape_c(int32_t width)
construct the shape such that the area goes from 0 to width on the x-axis
Definition: layouter.h:522
glyphIndex_t glyphIndex
which glyph to draw
Definition: layouter.h:66
int16_t blurr
radius of the shadow in 1/64th pixel size
Definition: layouter.h:331
int w
Definition: layouter.h:127
TextLayout_c layoutParagraph(const std::u32string &txt32, const AttributeIndex_c &attr, const Shape_c &shape, const LayoutProperties_c &prop, int32_t ystart=0)
layout left adjusted
Definition: layouter.h:537
void operator=(TextLayout_c &&l)
move assignment
Definition: layouter.h:206
enum STLL::LayoutProperties_c::@1 align
alignment that the text is supposed to have
layout justified and the last line right adjusted
Definition: layouter.h:541
int32_t y
y position
Definition: layouter.h:62
int x
Definition: layouter.h:127
std::shared_ptr< FontFace_c > font
which front to take the glyph from
Definition: layouter.h:69
void setLeft(int32_t l)
set the left edge in 1/64th pixels
Definition: layouter.h:264
int32_t getRight(void) const
get the right edge of the layout in 1/64th pixels
Definition: layouter.h:268
CodepointAttributes_c(void)
create an empty attribute, no font, no language, no flags, no inlay, no baseline shift ...
Definition: layouter.h:377
draw a rectangle
Definition: layouter.h:55
int32_t baseline_shift
do you want to move the baseline of this character or inlay relative to the baseline of the line...
Definition: layouter.h:365
std::string imageURL
URL of image to draw.
Definition: layouter.h:83
a little structure to hold information for one rectangle
Definition: layouter.h:124
void set(size_t i, CodepointAttributes_c a)
set attributes for a single indices
Definition: layouter.h:440
virtual int32_t getRight2(int32_t top, int32_t bottom) const =0
get the right edge
this structure contains all attributes that a single glyph can get assigned
Definition: layouter.h:285
~TextLayout_c(void)
Definition: layouter.h:228
The namespace for the library. Every function and class is within this namespace. ...
Definition: color.h:31
TextLayout_c(void)
create empty layout
uint32_t w
width of block
Definition: layouter.h:73
bool hyphenate
automatically find hyphenation points
Definition: layouter.h:574
Font_c underlineFont
The font that defines the underline parameters.
Definition: layouter.h:555
virtual int32_t getRight(int32_t, int32_t) const
get the right edge
Definition: layouter.h:526
std::string url
the url for the link
Definition: layouter.h:136
virtual int32_t getRight(int32_t top, int32_t bottom) const =0
get the right edge
virtual int32_t getRight2(int32_t, int32_t) const
get the right edge
Definition: layouter.h:527
encapsulates a finished layout.
Definition: layouter.h:105
this structure contains information for the layouter how to layout the text
Definition: layouter.h:532
concrete implementation of the shape that will allow layouting inside a rectangular with a certain wi...
Definition: layouter.h:513
void operator=(const TextLayout_c &l)
copy assignment
Definition: layouter.h:218
CommandData_c(const std::string &i, int32_t x_, int32_t y_, uint32_t w_, uint32_t h_)
constructor to create an image command
Definition: layouter.h:92
std::vector< LinkInformation_c > links
information for all links TODO this interface is bad
Definition: layouter.h:142
uint16_t blurr
blurr radius to use for this command
Definition: layouter.h:81
this file contains just a little helper class for a 4-value colour
void setHeight(uint32_t h)
set the height in 1/64th pixels
Definition: layouter.h:256
a helper structure to contain information about the interactive area for a link
Definition: layouter.h:132
void addCommandStart(const CommandData_c &d)
add a single drawing command to the start of the command list
Definition: layouter.h:187
void addCommand(Args &&...args)
add a single drawing command to the end of the command list
Definition: layouter.h:152
layout right adjusted
Definition: layouter.h:538
size_t link
which link does this letter belong to
Definition: layouter.h:373
void append(const TextLayout_c &l, int dx=0, int dy=0)
append a layout to this layout, which means that the drawing commands of the 2nd layout are copied in...
enum STLL::CommandData_c::@0 command
specifies what to draw
uint32_t getHeight(void) const
the height of the layout. This is supposed to be the vertical space that this layout takes up in 1/64...
Definition: layouter.h:252
bool optimizeLinebreaks
Choose between fast and optimizing linebreak algorithm.
Definition: layouter.h:566
virtual int32_t getLeft2(int32_t top, int32_t bottom) const =0
get the left edge
int y
Definition: layouter.h:127
This structure encapsulates a drawing command.
Definition: layouter.h:49
layout justified and the last line left adjusted
Definition: layouter.h:540
bool operator==(const CodepointAttributes_c &rhs) const
comparison operator
Definition: layouter.h:381
uint32_t h
height of block
Definition: layouter.h:74
void set(size_t start, size_t end, CodepointAttributes_c a)
set attributes for a range of indices
Definition: layouter.h:450
virtual int32_t getLeft(int32_t, int32_t) const
get the left edge
Definition: layouter.h:524
int32_t indent
indentation of the first line in pixel
Definition: layouter.h:544
CodepointAttributes_c operator+=(const CodepointAttributes_c &rhs)
this operator is required for the interval container within the attributeIndex_c class, do not use it
Definition: layouter.h:395
layout centred
Definition: layouter.h:539
std::string lang
current language at this letter
Definition: layouter.h:299
int32_t getFirstBaseline(void) const
get the y position of the first baseline
Definition: layouter.h:280
std::vector< Rectangle_c > areas
the areas where the link is found
Definition: layouter.h:138
draw an image
Definition: layouter.h:56
int h
Definition: layouter.h:127
draw a glyph from a font
Definition: layouter.h:54