Rev 24826 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
21563 | jghali | 1 | #ifndef TEXTSHAPER_H |
2 | #define TEXTSHAPER_H |
||
3 | |||
4 | #include <QList> |
||
5 | #include <QMap> |
||
6 | #include <QString> |
||
7 | #include <QStringList> |
||
8 | |||
9 | #include <unicode/uscript.h> |
||
22463 | jghali | 10 | |
21563 | jghali | 11 | #include "itextsource.h" |
12 | #include "itextcontext.h" |
||
13 | #include "shapedtext.h" |
||
14 | |||
15 | class GlyphCluster; |
||
16 | class StoryText; |
||
17 | class PageItem; |
||
18 | |||
22463 | jghali | 19 | using namespace icu; |
21563 | jghali | 20 | |
21 | class TextShaper |
||
22 | { |
||
23 | public: |
||
24 | TextShaper(ITextContext* context, ITextSource& story, int firstChar, bool singlePar=false); |
||
25 | TextShaper(ITextSource &story, int firstChar); |
||
26 | |||
27 | ShapedText shape(int fromPos, int toPos); |
||
28 | |||
29 | private: |
||
30 | struct TextRun { |
||
31 | TextRun(int s, int l, int d) |
||
32 | : start(s), len(l), dir(d), script(USCRIPT_INVALID_CODE) |
||
33 | { } |
||
34 | |||
35 | TextRun(int s, int l, int d, UScriptCode sc) |
||
36 | : start(s), len(l), dir(d), script(sc) |
||
37 | { } |
||
38 | |||
39 | int start; |
||
40 | int len; |
||
41 | int dir; |
||
42 | UScriptCode script; |
||
43 | }; |
||
44 | |||
45 | struct FeaturesRun { |
||
46 | FeaturesRun(int s, int l, QStringList f) |
||
47 | : start(s), len(l), features(f) |
||
48 | { |
||
49 | } |
||
50 | |||
51 | int start; |
||
52 | int len; |
||
53 | QStringList features; |
||
54 | }; |
||
55 | |||
56 | void buildText(int fromPos, int toPos, QVector<int>& smallCaps); |
||
57 | |||
25209 | jghali | 58 | QList<TextRun> itemizeBiDi(int fromPos) const; |
24754 | jghali | 59 | QList<TextRun> itemizeScripts(const QList<TextRun> &runs) const; |
60 | QList<TextRun> itemizeStyles(const QList<TextRun> &runs) const; |
||
61 | QList<FeaturesRun> itemizeFeatures(const TextRun &run) const; |
||
21563 | jghali | 62 | |
24754 | jghali | 63 | ITextContext* m_context { nullptr }; |
64 | bool m_contextNeeded { false }; |
||
21563 | jghali | 65 | ITextSource& m_story; |
24754 | jghali | 66 | int m_firstChar { 0 }; |
67 | bool m_singlePar { false }; |
||
21563 | jghali | 68 | QString m_text; |
69 | QMap<int, int> m_textMap; |
||
70 | }; |
||
71 | |||
72 | #endif // TEXTSHAPER_H |