1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-05 14:10:50 +00:00
|
|
|
/**
|
|
|
|
* \file xfont_loader.h
|
2002-09-05 15:14:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
* \author Asger Alstrup
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-09-05 14:10:50 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef FONTLOADER_H_
|
2002-03-21 17:27:08 +00:00
|
|
|
#define FONTLOADER_H_
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-07-03 14:15:39 +00:00
|
|
|
#include <X11/Xlib.h>
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxfont.h"
|
1999-11-22 16:19:48 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
class FontInfo;
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
/** This class takes care of loading fonts. It uses FontInfo to make
|
|
|
|
intelligent guesses about matching font size, and it tries different tags
|
|
|
|
itself in order to match the font loading demands. Later, I plan to extend
|
|
|
|
this with support for T1Lib, probably via a new class building on this.
|
1999-10-23 13:22:09 +00:00
|
|
|
(Asger) */
|
2002-06-12 02:54:19 +00:00
|
|
|
class xfont_loader {
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
|
|
|
///
|
2002-06-12 02:54:19 +00:00
|
|
|
xfont_loader();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2002-06-12 02:54:19 +00:00
|
|
|
~xfont_loader();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Update fonts after zoom, dpi, font names, or norm change
|
|
|
|
void update();
|
|
|
|
|
|
|
|
/// Load font
|
2002-03-21 17:27:08 +00:00
|
|
|
XFontStruct * load(LyXFont::FONT_FAMILY family,
|
|
|
|
LyXFont::FONT_SERIES series,
|
|
|
|
LyXFont::FONT_SHAPE shape,
|
2000-02-04 09:38:32 +00:00
|
|
|
LyXFont::FONT_SIZE size) {
|
|
|
|
if (fontstruct[family][series][shape][size] != 0)
|
1999-09-27 18:44:28 +00:00
|
|
|
return fontstruct[family][series][shape][size];
|
|
|
|
else
|
1999-11-15 12:01:38 +00:00
|
|
|
return doLoad(family, series, shape, size);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2001-08-30 22:42:26 +00:00
|
|
|
/// Do we have anything matching?
|
|
|
|
bool available(LyXFont const & f);
|
2002-03-21 17:27:08 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
|
|
|
/// Array of font structs
|
2001-08-31 21:15:57 +00:00
|
|
|
XFontStruct * fontstruct[LyXFont::NUM_FAMILIES][2][4][10];
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Array of font infos
|
2001-08-31 21:15:57 +00:00
|
|
|
FontInfo * fontinfo[LyXFont::NUM_FAMILIES][2][4];
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Reset font handler
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
/// Unload all fonts
|
|
|
|
void unload();
|
|
|
|
|
|
|
|
/// Get font info
|
2002-03-21 17:27:08 +00:00
|
|
|
void getFontinfo(LyXFont::FONT_FAMILY family,
|
|
|
|
LyXFont::FONT_SERIES series,
|
1999-09-27 18:44:28 +00:00
|
|
|
LyXFont::FONT_SHAPE shape);
|
|
|
|
|
|
|
|
/** Does the actual loading of a font. Updates fontstruct. */
|
2002-03-21 17:27:08 +00:00
|
|
|
XFontStruct * doLoad(LyXFont::FONT_FAMILY family,
|
|
|
|
LyXFont::FONT_SERIES series,
|
|
|
|
LyXFont::FONT_SHAPE shape,
|
2000-02-04 09:38:32 +00:00
|
|
|
LyXFont::FONT_SIZE size);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2000-04-04 00:19:15 +00:00
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
///
|
2002-06-12 02:54:19 +00:00
|
|
|
extern xfont_loader fontloader;
|
2000-04-04 00:19:15 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|