2 * Copyright 2001-2008, Haiku.
3 * Distributed under the terms of the MIT License.
6 * DarkWyrm <bpmagic@columbus.rr.com>
7 * Axel Dörfler, axeld@pinc-software.de
16 #include <ObjectList.h>
22 #include FT_FREETYPE_H
23 #include "ReferenceCounting.h"
24 #include "HashTable.h"
32 class FontKey
: public Hashable
{
34 FontKey(uint16 familyID
, uint16 styleID
)
35 : fHash(familyID
| (styleID
<< 16UL))
38 virtual ~FontKey() {};
40 virtual uint32
Hash() const
42 virtual bool CompareTo(Hashable
& other
) const
43 { return fHash
== other
.Hash(); }
51 \class FontStyle FontStyle.h
52 \brief Object used to represent a font style
54 FontStyle objects help abstract a lot of the font engine details while
55 still offering plenty of information the style in question.
57 class FontStyle
: public ReferenceCounting
, public Hashable
{
59 FontStyle(node_ref
& nodeRef
, const char* path
,
63 virtual uint32
Hash() const;
64 virtual bool CompareTo(Hashable
& other
) const;
66 const node_ref
& NodeRef() const { return fNodeRef
; }
72 \fn bool FontStyle::IsFixedWidth(void)
73 \brief Determines whether the font's character width is fixed
74 \return true if fixed, false if not
76 bool IsFixedWidth() const
77 { return FT_IS_FIXED_WIDTH(fFreeTypeFace
); }
80 /* \fn bool FontStyle::IsFullAndHalfFixed()
81 \brief Determines whether the font has 2 different, fixed, widths.
82 \return false (for now)
84 bool IsFullAndHalfFixed() const
88 \fn bool FontStyle::IsScalable(void)
89 \brief Determines whether the font can be scaled to any size
90 \return true if scalable, false if not
92 bool IsScalable() const
93 { return FT_IS_SCALABLE(fFreeTypeFace
); }
95 \fn bool FontStyle::HasKerning(void)
96 \brief Determines whether the font has kerning information
97 \return true if kerning info is available, false if not
99 bool HasKerning() const
100 { return FT_HAS_KERNING(fFreeTypeFace
); }
102 \fn bool FontStyle::HasTuned(void)
103 \brief Determines whether the font contains strikes
104 \return true if it has strikes included, false if not
106 bool HasTuned() const
107 { return FT_HAS_FIXED_SIZES(fFreeTypeFace
); }
109 \fn bool FontStyle::TunedCount(void)
110 \brief Returns the number of strikes the style contains
111 \return The number of strikes the style contains
113 int32
TunedCount() const
114 { return fFreeTypeFace
->num_fixed_sizes
; }
116 \fn bool FontStyle::GlyphCount(void)
117 \brief Returns the number of glyphs in the style
118 \return The number of glyphs the style contains
120 uint16
GlyphCount() const
121 { return fFreeTypeFace
->num_glyphs
; }
123 \fn bool FontStyle::CharMapCount(void)
124 \brief Returns the number of character maps the style contains
125 \return The number of character maps the style contains
127 uint16
CharMapCount() const
128 { return fFreeTypeFace
->num_charmaps
; }
130 const char* Name() const
131 { return fName
.String(); }
132 FontFamily
* Family() const
136 uint32
Flags() const;
140 uint16
PreservedFace(uint16
) const;
142 const char* Path() const;
143 void UpdatePath(const node_ref
& parentNodeRef
);
145 void GetHeight(float size
, font_height
&heigth
) const;
146 font_direction
Direction() const
147 { return B_FONT_LEFT_TO_RIGHT
; }
148 font_file_format
FileFormat() const
149 { return B_TRUETYPE_WINDOWS
; }
151 FT_Face
FreeTypeFace() const
152 { return fFreeTypeFace
; }
154 status_t
UpdateFace(FT_Face face
);
157 friend class FontFamily
;
158 uint16
_TranslateStyleToFace(const char *name
) const;
159 void _SetFontFamily(FontFamily
* family
, uint16 id
);
162 FT_Face fFreeTypeFace
;
176 #endif // FONT_STYLE_H_