3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup
9 * Full author contact details are available in file CREDITS
15 #pragma implementation
18 #include "qfont_loader.h"
22 #include "BufferView.h"
26 qfont_loader::qfont_loader()
31 qfont_loader::~qfont_loader()
36 void qfont_loader::update()
42 for (i1 = 0; i1 < LyXFont::NUM_FAMILIES; ++i1) {
43 for (i2 = 0; i1 < 2; ++i2) {
44 for (i3 = 0; i1 < 4; ++i3) {
45 for (i4 = 0; i1 < 10; ++i4) {
46 fontinfo_[i1][i2][i3][i4].reset(0);
54 QFont const & qfont_loader::get(LyXFont const & f)
56 QFont const & ret(getfontinfo(f)->font);
58 if (lyxerr.debugging(Debug::FONT)) {
59 lyxerr[Debug::FONT] << "Font '" << f.stateText(0)
60 << "' matched by\n" << ret.rawName().latin1() << endl;
66 qfont_loader::font_info::font_info(LyXFont const & f)
70 case LyXFont::SYMBOL_FAMILY:
71 font.setRawName("-*-symbol-*-*-*-*-*-*-*-*-*-*-adobe-fontspecific");
73 case LyXFont::CMR_FAMILY:
74 font.setRawName("-*-cmr10-medium-*-*-*-*-*-*-*-*-*-*-*");
76 case LyXFont::CMSY_FAMILY:
77 font.setRawName("-*-cmsy10-*-*-*-*-*-*-*-*-*-*-*-*");
79 case LyXFont::CMM_FAMILY:
80 font.setRawName("-*-cmmi10-medium-*-*-*-*-*-*-*-*-*-*-*");
82 case LyXFont::CMEX_FAMILY:
83 font.setRawName("-*-cmex10-*-*-*-*-*-*-*-*-*-*-*-*");
85 case LyXFont::MSA_FAMILY:
86 font.setRawName("-*-msam10-*-*-*-*-*-*-*-*-*-*-*-*");
88 case LyXFont::MSB_FAMILY:
89 font.setRawName("-*-msbm10-*-*-*-*-*-*-*-*-*-*-*-*");
91 case LyXFont::EUFRAK_FAMILY:
92 font.setRawName("-*-eufm10-medium-*-*-*-*-*-*-*-*-*-*-*");
94 case LyXFont::ROMAN_FAMILY:
95 font.setFamily("times");
97 case LyXFont::SANS_FAMILY:
98 font.setFamily("helvetica");
100 case LyXFont::TYPEWRITER_FAMILY:
101 font.setFamily("courier");
105 font.setPointSize(int((lyxrc.font_sizes[f.size()] * lyxrc.dpi *
106 (lyxrc.zoom / 100.0)) / 72.27 + 0.5));
108 // FIXME: lyxrc, check for failure etc.
110 switch (f.series()) {
111 case LyXFont::MEDIUM_SERIES:
112 font.setWeight(QFont::Normal);
114 case LyXFont::BOLD_SERIES:
115 font.setWeight(QFont::Bold);
119 switch (f.realShape()) {
120 case LyXFont::ITALIC_SHAPE:
121 case LyXFont::SLANTED_SHAPE:
122 font.setItalic(true);
126 metrics = QFontMetrics(font);
130 qfont_loader::font_info const * qfont_loader::getfontinfo(LyXFont const & f)
132 if (!lyxrc.use_gui) {
136 font_info * fi = fontinfo_[f.family()][f.series()][f.realShape()][f.size()].get();
140 fi = new font_info(f);
141 fontinfo_[f.family()][f.series()][f.realShape()][f.size()].reset(fi);
147 bool qfont_loader::available(LyXFont const &)
149 // FIXME (see getRawName docs)