headers/bsd: Add sys/queue.h.
[haiku.git] / src / servers / app / ServerFont.h
blob8d63cbfef50fd8696f096def2650f5710eeecf66
1 /*
2 * Copyright 2001-2008, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Jérôme Duval, jerome.duval@free.fr
8 * Axel Dörfler, axeld@pinc-software.de
9 * Stephan Aßmus <superstippi@gmx.de>
11 #ifndef SERVER_FONT_H
12 #define SERVER_FONT_H
15 #include <Font.h>
16 #include <Rect.h>
18 #include "FontFamily.h"
19 #include "GlobalSubpixelSettings.h"
20 #include "Transformable.h"
22 class BShape;
23 class BString;
26 class ServerFont {
27 public:
28 ServerFont();
29 ServerFont(FontStyle& style,
30 float size = 12.0,
31 float rotation = 0.0,
32 float shear = 90.0,
33 float falseBoldWidth = 0.0,
34 uint16 flags = 0,
35 uint8 spacing = B_BITMAP_SPACING);
36 ServerFont(const ServerFont& font);
37 virtual ~ServerFont();
39 ServerFont &operator=(const ServerFont& font);
40 bool operator==(const ServerFont& other) const;
42 font_direction Direction() const
43 { return fDirection; }
44 uint32 Encoding() const
45 { return fEncoding; }
46 uint32 Flags() const
47 { return fFlags; }
48 uint32 Spacing() const
49 { return fSpacing; }
50 float Shear() const
51 { return fShear; }
52 float Rotation() const
53 { return fRotation; }
54 float FalseBoldWidth() const
55 { return fFalseBoldWidth; }
56 float Size() const
57 { return fSize; }
58 uint16 Face() const
59 { return fFace; }
60 uint32 CountGlyphs()
61 { return fStyle->GlyphCount(); }
62 int32 CountTuned();
64 font_file_format FileFormat();
66 const char* Style() const;
67 const char* Family() const;
68 const char* Path() const
69 { return fStyle->Path(); }
71 void SetStyle(FontStyle* style);
72 status_t SetFamilyAndStyle(uint16 familyID,
73 uint16 styleID);
74 status_t SetFamilyAndStyle(uint32 fontID);
76 uint16 StyleID() const
77 { return fStyle->ID(); }
78 uint16 FamilyID() const
79 { return fStyle->Family()->ID(); }
80 uint32 GetFamilyAndStyle() const;
82 void SetDirection(font_direction dir)
83 { fDirection = dir; }
84 void SetEncoding(uint32 encoding)
85 { fEncoding = encoding; }
86 void SetFlags(uint32 value)
87 { fFlags = value; }
88 void SetSpacing(uint32 value)
89 { fSpacing = value; }
90 void SetShear(float value)
91 { fShear = value; }
92 void SetSize(float value)
93 { fSize = value; }
94 void SetRotation(float value)
95 { fRotation = value; }
96 void SetFalseBoldWidth(float value)
97 { fFalseBoldWidth = value; }
98 status_t SetFace(uint16 face);
100 bool IsFixedWidth() const
101 { return fStyle->IsFixedWidth(); }
102 bool IsScalable() const
103 { return fStyle->IsScalable(); }
104 bool HasKerning() const
105 { return fStyle->HasKerning(); }
106 bool HasTuned() const
107 { return fStyle->HasTuned(); }
108 int32 TunedCount() const
109 { return fStyle->TunedCount(); }
110 uint16 GlyphCount() const
111 { return fStyle->GlyphCount(); }
112 uint16 CharMapCount() const
113 { return fStyle->CharMapCount(); }
114 inline bool Hinting() const;
116 status_t GetGlyphShapes(const char charArray[],
117 int32 numChars, BShape *shapeArray[]) const;
119 status_t GetHasGlyphs(const char charArray[],
120 int32 numBytes, bool hasArray[]) const;
122 status_t GetEdges(const char charArray[], int32 numBytes,
123 edge_info edgeArray[]) const;
125 status_t GetEscapements(const char charArray[],
126 int32 numBytes, int32 numChars,
127 escapement_delta delta,
128 BPoint escapementArray[],
129 BPoint offsetArray[]) const;
131 status_t GetEscapements(const char charArray[],
132 int32 numBytes, int32 numChars,
133 escapement_delta delta,
134 float widthArray[]) const;
136 status_t GetBoundingBoxes(const char charArray[],
137 int32 numBytes, BRect rectArray[],
138 bool stringEscapement,
139 font_metric_mode mode,
140 escapement_delta delta,
141 bool asString);
143 status_t GetBoundingBoxesForStrings(char *charArray[],
144 int32 lengthArray[], int32 numStrings,
145 BRect rectArray[], font_metric_mode mode,
146 escapement_delta deltaArray[]);
148 float StringWidth(const char *string,
149 int32 numBytes,
150 const escapement_delta* delta = NULL) const;
152 bool Lock() const { return fStyle->Lock(); }
153 void Unlock() const { fStyle->Unlock(); }
155 // FT_Face GetFTFace() const
156 // { return fStyle->FreeTypeFace(); };
158 BRect BoundingBox();
159 void GetHeight(font_height& height) const;
161 void TruncateString(BString* inOut,
162 uint32 mode,
163 float width) const;
165 Transformable EmbeddedTransformation() const;
166 status_t GetUnicodeBlocks(unicode_block &blocksForFont);
167 status_t IncludesUnicodeBlock(uint32 start, uint32 end, bool &hasBlock);
169 protected:
170 friend class FontStyle;
171 FT_Face GetTransformedFace(bool rotate,
172 bool shear) const;
173 void PutTransformedFace(FT_Face face) const;
175 FontStyle* fStyle;
176 float fSize;
177 float fRotation;
178 float fShear;
179 float fFalseBoldWidth;
180 BRect fBounds;
181 uint32 fFlags;
182 uint32 fSpacing;
183 font_direction fDirection;
184 uint16 fFace;
185 uint32 fEncoding;
188 inline bool ServerFont::Hinting() const
190 switch (gDefaultHintingMode) {
191 case HINTING_MODE_OFF:
192 return false;
193 default:
194 case HINTING_MODE_ON:
195 return true;
196 case HINTING_MODE_MONOSPACED_ONLY:
197 return IsFixedWidth();
201 #endif /* SERVER_FONT_H */