1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-04 09:38:32 +00:00
|
|
|
* Copyright 1997 Asger Alstrup
|
1999-09-27 18:44:28 +00:00
|
|
|
* and the LyX Team.
|
|
|
|
*
|
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 FONTINFO_H
|
|
|
|
#define FONTINFO_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
|
|
|
/** This class manages a font.
|
|
|
|
The idea is to create a FontInfo object with a font name pattern with a
|
|
|
|
wildcard at the size field. Then this object can host request for font-
|
|
|
|
instances of any given size. If no exact match is found, the closest size
|
2000-03-12 10:35:05 +00:00
|
|
|
is chosen instead. If the font is scalable, the flag lyxrc.use_scalable_fonts
|
1999-09-27 18:44:28 +00:00
|
|
|
determines whether to allow scalable fonts to give an exact match. */
|
|
|
|
class FontInfo {
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
FontInfo() { init(); }
|
|
|
|
|
|
|
|
///
|
2000-04-08 17:02:02 +00:00
|
|
|
explicit FontInfo(string const & pat)
|
|
|
|
: pattern(pat) { init(); }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Destructor
|
|
|
|
~FontInfo() { release(); }
|
|
|
|
|
|
|
|
/// Does any font match our pattern?
|
|
|
|
bool exist() {
|
|
|
|
query();
|
|
|
|
return matches != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Is this font scalable?
|
|
|
|
bool isScalable() {
|
|
|
|
query();
|
|
|
|
return scalable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get existing pattern
|
1999-10-02 16:21:10 +00:00
|
|
|
string getPattern() const { return pattern; }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Set new pattern
|
1999-10-02 16:21:10 +00:00
|
|
|
void setPattern(string const & pat);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/** Return full name of font close to this size.
|
|
|
|
If impossible, result is the empty string */
|
1999-10-02 16:21:10 +00:00
|
|
|
string getFontname(int size);
|
1999-09-27 18:44:28 +00:00
|
|
|
private:
|
|
|
|
/// Font pattern (with wildcard for size)
|
1999-10-02 16:21:10 +00:00
|
|
|
string pattern;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Available size list
|
|
|
|
int * sizes;
|
|
|
|
|
|
|
|
/// Corresponding name list
|
1999-10-02 16:21:10 +00:00
|
|
|
string * strings;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Number of matches
|
|
|
|
int matches;
|
|
|
|
|
|
|
|
/// Did we query X about this font?
|
|
|
|
bool queried;
|
|
|
|
|
|
|
|
/// Is this font scalable?
|
|
|
|
bool scalable;
|
|
|
|
|
|
|
|
/// Which index points to scalable font entry?
|
|
|
|
int scaleindex;
|
|
|
|
|
|
|
|
/// Initialize empty record
|
2000-04-04 00:19:15 +00:00
|
|
|
void init();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Release allocated stuff
|
|
|
|
void release();
|
|
|
|
|
|
|
|
/// Ask X11 about this font pattern
|
|
|
|
void query();
|
|
|
|
|
|
|
|
/// Build newly sized font string
|
1999-10-02 16:21:10 +00:00
|
|
|
string resize(string const &, int size) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
#endif
|