This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / FontInfo.h
blobba856eb19cecf175d0621e98fdfd9b0bc4ed4e37
1 // -*- C++ -*-
2 /* This file is part of
3 * ======================================================
4 *
5 * LyX, The Document Processor
6 *
7 * Copyright (C) 1997 Asger Alstrup
8 * and the LyX Team.
10 *======================================================*/
12 #ifndef _FONTINFO_H_
13 #define _FONTINFO_H_
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
19 #include "LString.h"
21 /** This class manages a font.
22 The idea is to create a FontInfo object with a font name pattern with a
23 wildcard at the size field. Then this object can host request for font-
24 instances of any given size. If no exact match is found, the closest size
25 is chosen instead. If the font is scalable, the flag lyxrc->use_scalable_fonts
26 determines whether to allow scalable fonts to give an exact match. */
27 class FontInfo {
28 public:
29 ///
30 FontInfo() { init(); }
32 ///
33 FontInfo(string const & pat)
34 : pattern(pat) { init(); }
36 /// Destructor
37 ~FontInfo() { release(); }
39 /// Does any font match our pattern?
40 bool exist() {
41 query();
42 return matches != 0;
45 /// Is this font scalable?
46 bool isScalable() {
47 query();
48 return scalable;
51 /// Get existing pattern
52 string getPattern() const { return pattern; }
54 /// Set new pattern
55 void setPattern(string const & pat);
57 /** Return full name of font close to this size.
58 If impossible, result is the empty string */
59 string getFontname(int size);
60 private:
61 /// Font pattern (with wildcard for size)
62 string pattern;
64 /// Available size list
65 int * sizes;
67 /// Corresponding name list
68 string * strings;
70 /// Number of matches
71 int matches;
73 /// Did we query X about this font?
74 bool queried;
76 /// Is this font scalable?
77 bool scalable;
79 /// Which index points to scalable font entry?
80 int scaleindex;
82 /// Initialize empty record
83 void init()
85 sizes = 0;
86 strings = 0;
87 matches = 0;
88 queried = false;
89 scalable = false;
90 scaleindex = -1;
93 /// Release allocated stuff
94 void release();
96 /// Ask X11 about this font pattern
97 void query();
99 /// Build newly sized font string
100 string resize(string const &, int size) const;
102 #endif