1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-06-12 02:54:19 +00:00
|
|
|
/**
|
|
|
|
* \file FontInfo.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-06-12 02:54:19 +00:00
|
|
|
* \author Asger Alstrup
|
2002-12-01 22:59:25 +00:00
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-06-12 02:54:19 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 12:01:38 +00:00
|
|
|
#ifndef FONTINFO_H
|
2002-03-21 17:27:08 +00:00
|
|
|
#define FONTINFO_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include "LString.h"
|
|
|
|
|
2002-05-22 01:16:37 +00:00
|
|
|
#include <boost/scoped_array.hpp>
|
2001-12-18 03:30:35 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/** This class manages a font.
|
2002-03-21 17:27:08 +00:00
|
|
|
The idea is to create a FontInfo object with a font name pattern with a
|
2000-08-07 20:58:24 +00:00
|
|
|
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
|
|
|
|
is chosen instead. If the font is scalable, the flag
|
|
|
|
lyxrc.use_scalable_fonts determines whether to allow scalable fonts to
|
|
|
|
give an exact match.
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
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
|
|
|
|
|
|
|
/// Does any font match our pattern?
|
|
|
|
bool exist() {
|
|
|
|
query();
|
|
|
|
return matches != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Is this font scalable?
|
|
|
|
bool isScalable() {
|
|
|
|
query();
|
|
|
|
return scalable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get existing pattern
|
2001-12-18 03:30:35 +00:00
|
|
|
string const & 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 */
|
2000-09-14 17:53:12 +00:00
|
|
|
string const 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
|
2001-12-18 03:30:35 +00:00
|
|
|
boost::scoped_array<int> sizes;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Corresponding name list
|
2001-12-18 03:30:35 +00:00
|
|
|
boost::scoped_array<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
|
|
|
|
|
|
|
/// Ask X11 about this font pattern
|
|
|
|
void query();
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
/// Build newly sized font string
|
2000-09-14 17:53:12 +00:00
|
|
|
string const resize(string const &, int size) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2002-06-12 03:16:41 +00:00
|
|
|
|
|
|
|
#endif // FONTINFO_H
|