3 * \file xftFontLoader.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef XFT_FONT_LOADER_H
13 #define XFT_FONT_LOADER_H
15 #include "frontends/FontLoader.h"
17 #include "xftFontMetrics.h"
22 #include <X11/Xft/Xft.h>
27 class xftFontLoader: public lyx::frontend::FontLoader {
33 virtual ~xftFontLoader();
35 /// Update fonts after zoom, dpi, font names, or norm change
36 virtual void update();
38 virtual bool available(LyXFont const & f);
39 virtual lyx::frontend::FontMetrics const & metrics(LyXFont const & f)
41 if (f.realShape() != LyXFont::SMALLCAPS_SHAPE)
42 return font_metrics(load(f.family(), f.series(), f.realShape(), f.size()), 0);
44 scf.decSize().decSize().setShape(LyXFont::UP_SHAPE);
45 return font_metrics(load(f.family(), f.series(), f.realShape(), f.size()),
46 load(scf.family(), scf.series(), scf.realShape(), scf.size()));
50 XftFont * load(LyXFont::FONT_FAMILY family,
51 LyXFont::FONT_SERIES series,
52 LyXFont::FONT_SHAPE shape,
53 LyXFont::FONT_SIZE size)
55 if (fonts_[family][series][shape][size])
56 return fonts_[family][series][shape][size];
58 return doLoad(family, series, shape, size);
61 bool isSpecial(LyXFont const & f)
64 case LyXFont::CMR_FAMILY:
65 case LyXFont::EUFRAK_FAMILY:
70 return f.isSymbolFont();
74 XftFont * fonts_[LyXFont::NUM_FAMILIES][2][4][10];
75 XftPattern * getFontPattern(LyXFont::FONT_FAMILY family,
76 LyXFont::FONT_SERIES series,
77 LyXFont::FONT_SHAPE shape,
78 LyXFont::FONT_SIZE size);
79 std::string familyString(LyXFont::FONT_FAMILY family);
80 /// Reset font handler
86 /** Does the actual loading of a font. Updates fontstruct. */
87 XftFont * doLoad(LyXFont::FONT_FAMILY family,
88 LyXFont::FONT_SERIES series,
89 LyXFont::FONT_SHAPE shape,
90 LyXFont::FONT_SIZE size);
94 extern xftFontLoader fontLoader;