aboutsummaryrefslogtreecommitdiff
path: root/src/renderers/textstyleinstance.cpp
blob: 0a996253a2b7b1c4a5de9b5684e5cbe153567b3a (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
#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(2);
  block_quote_format.setBackground(themed_style.blockquote_color);

  // Other alignments
  standard_format.setAlignment(Qt::AlignJustify);
  standard_format.setLineHeight(5, QTextBlockFormat::LineDistanceHeight);
  standard_format.setIndent(1);

  link_format.setLineHeight(5, QTextBlockFormat::LineDistanceHeight);

  block_quote_format.setAlignment(Qt::AlignJustify);
  block_quote_format.setLineHeight(5, QTextBlockFormat::LineDistanceHeight);

  list_format.setAlignment(Qt::AlignJustify);
  list_format.setLineHeight(5, QTextBlockFormat::LineDistanceHeight);
  list_format.setIndent(2);

  preformatted_format.setIndent(1);

  heading_format.setLineHeight(0, QTextBlockFormat::LineDistanceHeight);
}