aboutsummaryrefslogtreecommitdiff
path: root/src/renderers/textstyleinstance.cpp
blob: aaf7ee66dc4ae94ca18cbd5c5f72ae7d0e4de68a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "textstyleinstance.hpp"

TextStyleInstance::TextStyleInstance(DocumentStyle const & themed_style)
{
  preformatted.setFont(themed_style.preformatted_font);
  preformatted.setForeground(themed_style.preformatted_color);

  standard.setFont(themed_style.standard_font);
  standard.setForeground(themed_style.standard_color);

  standard_link.setFont(themed_style.standard_font);
  standard_link.setForeground(QBrush(themed_style.internal_link_color));

  external_link.setFont(themed_style.standard_font);
  external_link.setForeground(QBrush(themed_style.external_link_color));

  cross_protocol_link.setFont(themed_style.standard_font);
  cross_protocol_link.setForeground(QBrush(themed_style.cross_scheme_link_color));

  standard_h1.setFont(themed_style.h1_font);
  standard_h1.setForeground(QBrush(themed_style.h1_color));

  standard_h2.setFont(themed_style.h2_font);
  standard_h2.setForeground(QBrush(themed_style.h2_color));

  standard_h3.setFont(themed_style.h3_font);
  standard_h3.setForeground(QBrush(themed_style.h3_color));

  preformatted_format.setNonBreakableLines(true);

  block_quote_format.setIndent(themed_style.indent_bq);
  block_quote_format.setBackground(themed_style.blockquote_color);

  // Other alignments
  auto align = themed_style.justify_text ? Qt::AlignJustify : Qt::AlignLeft;

  standard_format.setAlignment(align);
  standard_format.setLineHeight(themed_style.line_height_p,
    QTextBlockFormat::LineDistanceHeight);
  standard_format.setIndent(themed_style.indent_p);

  link_format.setLineHeight(themed_style.line_height_p,
    QTextBlockFormat::LineDistanceHeight);

  block_quote_format.setAlignment(align);
  block_quote_format.setLineHeight(themed_style.line_height_p,
    QTextBlockFormat::LineDistanceHeight);

  list_format.setStyle(QTextListFormat::ListDisc);
  list_format.setIndent(themed_style.indent_l);

  preformatted_format.setIndent(themed_style.indent_p);

  heading_format.setLineHeight(themed_style.line_height_h,
    QTextBlockFormat::LineDistanceHeight);
  heading_format.setIndent(themed_style.indent_h);
}