HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Font.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GU_Font.h (C++)
7  *
8  * COMMENTS:
9  *
10  */
11 
12 #ifndef __GU_Font_h__
13 #define __GU_Font_h__
14 
15 #include "GU_API.h"
16 #include <UT/UT_Vector2.h>
17 #include <UT/UT_Vector3.h>
18 
19 class GU_Detail;
20 class UT_IStream;
21 class UT_String;
22 class gu_Font;
23 
25 {
26 public:
28  {
31  HALIGN_RIGHT
32  };
33 
35  {
39  VALIGN_BOTTOM
40  };
41 
42 public:
44  {
45  myOrigin.assign(0,0,0);
46  myScale.assign(1,1);
47  myTracking.assign(0,0);
48  myAutoKerning = true;
49  myOblique = 0;
50  myHAlign = HALIGN_LEFT;
51  myVAlign = VALIGN_TOP;
52  myAlignDescender = false;
53  myAddAttributes = true;
54  }
55 
56  void setOrigin(const UT_Vector3 &origin) { myOrigin = origin; }
57  void setScale(const UT_Vector2 &scale) { myScale = scale; }
58  void setTracking(const UT_Vector2 &track) { myTracking = track; }
59  void setAutoKerning(bool enable) { myAutoKerning = enable; }
60  void setOblique(fpreal oblique) { myOblique = oblique; }
61  void setHAlignment(HAlignment h_align) { myHAlign = h_align; }
62  void setVAlignment(VAlignment v_align) { myVAlign = v_align; }
63  void setVAlignOnDescender(bool ad) { myAlignDescender = ad; }
64  void setAddAttributes(bool add_attribs) { myAddAttributes = add_attribs; }
65 
66 private:
67  friend class gu_Font;
68 
69  UT_Vector3 myOrigin;
70  UT_Vector2 myScale;
71  UT_Vector2 myTracking;
72  fpreal myOblique;
73 
74  HAlignment myHAlign;
75  VAlignment myVAlign;
76 
77  bool myAlignDescender;
78  bool myAutoKerning;
79 
80  bool myAddAttributes; // Add primitive attributes
81 };
82 
84 {
85 public:
86  GU_Font();
87  ~GU_Font();
88 
89  /// Loads a TrueType, OpenType or Adobe Type-1 font from the given stream
90  /// and initializes with the given face index. Usually this index should be
91  /// left at zero, but for font collections (.ttc / .otc) this value refers
92  /// to the index of the font within the collection
93  /// (see \c FONT_Info::faceIndex)
94  bool loadFont(UT_IStream &is, int face_index = 0);
95  void buildText(GU_Detail &gdp, const UT_String &text,
96  const GU_FontBuildOptions &opts);
97 
98  bool isValid() const;
99  const char *getFontName() const;
100 
101 private:
102  gu_Font *myFont;
103 };
104 
105 #endif
void setVAlignOnDescender(bool ad)
Definition: GU_Font.h:63
void setHAlignment(HAlignment h_align)
Definition: GU_Font.h:61
void setTracking(const UT_Vector2 &track)
Definition: GU_Font.h:58
GA_API const UT_StringHolder scale
void setScale(const UT_Vector2 &scale)
Definition: GU_Font.h:57
void setVAlignment(VAlignment v_align)
Definition: GU_Font.h:62
#define GU_API
Definition: GU_API.h:14
void setOblique(fpreal oblique)
Definition: GU_Font.h:60
fpreal64 fpreal
Definition: SYS_Types.h:277
void setOrigin(const UT_Vector3 &origin)
Definition: GU_Font.h:56
void setAutoKerning(bool enable)
Definition: GU_Font.h:59
void setAddAttributes(bool add_attribs)
Definition: GU_Font.h:64