3 * Copyright 1997 the LyX Team
4 * Read the file COPYING
6 * \author Asger Alstrup
7 * \author John Levon <moz@compsoc.man.ac.uk>
13 #pragma implementation
16 #include "qfont_loader.h"
20 #include "BufferView.h"
24 qfont_loader::qfont_loader()
29 qfont_loader::~qfont_loader()
34 void qfont_loader::update()
40 for (i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) {
41 for (i2 = 0; i1 < 2; ++i2) {
42 for (i3 = 0; i1 < 4; ++i3) {
43 for (i4 = 0; i1 < 10; ++i4) {
44 fontinfo_[i1][i2][i3][i4].reset(0);
52 QFont const & qfont_loader::get(LyXFont const & f)
54 QFont const & ret(getfontinfo(f)->font);
56 if (lyxerr.debugging(Debug::FONT)) {
57 lyxerr[Debug::FONT] << "Font '" << f.stateText(0)
58 << "' matched by\n" << ret.rawName().latin1() << endl;
64 qfont_loader::font_info::font_info(LyXFont const & f)
67 font.setPointSize(int((lyxrc.font_sizes[f.size()] * lyxrc.dpi *
68 (lyxrc.zoom / 100.0)) / 72.27 + 0.5));
70 // FIXME: lyxrc, check for failure etc.
73 case LyXFont::SYMBOL_FAMILY:
74 font.setRawName("-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific");
76 case LyXFont::CMR_FAMILY:
77 font.setRawName("-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*");
79 case LyXFont::CMSY_FAMILY:
80 font.setRawName("-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*");
82 case LyXFont::CMM_FAMILY:
83 font.setRawName("-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*");
85 case LyXFont::CMEX_FAMILY:
86 font.setRawName("-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*");
88 case LyXFont::MSA_FAMILY:
89 font.setRawName("-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*");
91 case LyXFont::MSB_FAMILY:
92 font.setRawName("-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*");
94 case LyXFont::EUFRAK_FAMILY:
95 font.setRawName("-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*");
97 case LyXFont::ROMAN_FAMILY:
98 font.setFamily("times");
100 case LyXFont::SANS_FAMILY:
101 font.setFamily("helvetica");
103 case LyXFont::TYPEWRITER_FAMILY:
104 font.setFamily("courier");
108 switch (f.series()) {
109 case LyXFont::MEDIUM_SERIES:
110 font.setWeight(QFont::Normal);
112 case LyXFont::BOLD_SERIES:
113 font.setWeight(QFont::Bold);
118 case LyXFont::ITALIC_SHAPE:
119 case LyXFont::SLANTED_SHAPE:
120 font.setItalic(true);
124 metrics = QFontMetrics(font);
128 qfont_loader::font_info const * qfont_loader::getfontinfo(LyXFont const & f)
130 if (!lyxrc.use_gui) {
134 font_info * fi = fontinfo_[f.family()][f.series()][f.shape()][f.size()].get();
138 fi = new font_info(f);
139 fontinfo_[f.family()][f.series()][f.shape()][f.size()].reset(fi);
145 bool qfont_loader::available(LyXFont const &)
147 // FIXME (see getRawName docs)