3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Abdelrazak Younes
8 * Full author contact details are available in file CREDITS.
16 #include "support/types.h"
22 /** A font entry covers a range of positions. Notice that the
23 entries in the list are inserted in random order.
24 I don't think it's worth the effort to implement a more effective
25 datastructure, because the number of different fonts in a paragraph
27 Nevertheless, I decided to store fontlist_ using a sorted vector:
28 fontlist_ = { {pos_1,font_1} , {pos_2,font_2} , ... } where
29 pos_1 < pos_2 < ..., font_{i-1} != font_i for all i,
30 and font_i covers the chars in positions pos_{i-1}+1,...,pos_i
31 (font_1 covers the chars 0,...,pos_1) (Dekel)
37 FontTable(pos_type p
, Font
const & f
)
41 pos_type
pos() const { return pos_
; }
43 void pos(pos_type p
) { pos_
= p
; }
45 Font
const & font() const { return font_
; }
47 void font(Font
const & f
) { font_
= f
;}
50 friend class FontList
;
51 /// End position of paragraph this font attribute covers
53 /** Font. Interpretation of the font values:
54 If a value is Font::INHERIT_*, it means that the font
55 attribute is inherited from either the layout of this
56 paragraph or, in the case of nested paragraphs, from the
57 layout in the environment one level up until completely
59 The values Font::IGNORE_* and FONT_TOGGLE are NOT
60 allowed in these font tables.
71 typedef std::vector
<FontTable
> List
;
73 typedef List::iterator iterator
;
75 typedef List::const_iterator const_iterator
;
77 iterator
begin() { return list_
.begin(); }
79 iterator
end() { return list_
.end(); }
81 const_iterator
begin() const { return list_
.begin(); }
83 const_iterator
end() const { return list_
.end(); }
85 bool empty() const { return list_
.empty(); }
87 void clear() { list_
.clear(); }
89 void erase(pos_type pos
);
91 iterator
fontIterator(pos_type pos
);
93 const_iterator
fontIterator(pos_type pos
) const;
95 Font
& get(pos_type pos
);
97 void set(pos_type pos
, Font
const & font
);
104 void increasePosAfterPos(pos_type pos
);
106 void decreasePosAfterPos(pos_type pos
);
108 /// Returns the height of the highest font in range
109 FontSize
highestInRange(
115 /// is there a font change in middle of the word?
116 bool hasChangeInRange(
117 pos_type pos
, ///< position in the paragraph.
118 int len
///< length of the range to check.
122 void validate(LaTeXFeatures
& features
) const;