1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
1999-09-27 18:44:28 +00:00
|
|
|
* LyX, The Document Processor
|
2002-03-21 17:27:08 +00:00
|
|
|
*
|
2000-02-04 09:38:32 +00:00
|
|
|
* Copyright 1997 Asger Alstrup
|
2002-03-21 17:27:08 +00:00
|
|
|
* and the LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 12:01:38 +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
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#include "LString.h"
|
|
|
|
|
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) */
|
1999-09-27 18:44:28 +00:00
|
|
|
class FontLoader {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
FontLoader();
|
|
|
|
|
|
|
|
///
|
|
|
|
~FontLoader();
|
|
|
|
|
|
|
|
/// 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
|
|
|
///
|
2000-04-04 00:19:15 +00:00
|
|
|
extern FontLoader fontloader;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|