Panda3D
eggMakeFont.h
1 // Filename: eggMakeFont.h
2 // Created by: drose (16Feb01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef EGGMAKEFONT_H
16 #define EGGMAKEFONT_H
17 
18 #include "pandatoolbase.h"
19 #include "rangeDescription.h"
20 
21 #include "eggWriter.h"
22 #include "eggTexture.h"
23 #include "pmap.h"
24 #include "pvector.h"
25 #include "vector_string.h"
26 
27 class PNMTextMaker;
28 class PNMTextGlyph;
29 class EggVertexPool;
30 class EggGroup;
31 class TextureImage;
32 
33 ////////////////////////////////////////////////////////////////////
34 // Class : EggMakeFont
35 // Description : This program uses FreeType to generate an egg file
36 // and a series of texture images from a font file
37 // input, such as a TTF file. The resulting egg file
38 // can be loaded in Panda as a StaticTextFont object for
39 // rendering text, even if FreeType is not compiled into
40 // the executing Panda.
41 ////////////////////////////////////////////////////////////////////
42 class EggMakeFont : public EggWriter {
43 public:
44  EggMakeFont();
45 
46 protected:
47  virtual bool handle_args(Args &args);
48 
49 public:
50  void run();
51 
52 private:
53  static bool dispatch_range(const string &, const string &arg, void *var);
54  EggVertex *make_vertex(const LPoint2d &xy);
55 
56  void add_character(int code);
57  void make_geom(PNMTextGlyph *glyph, int character);
58  EggTexture *get_tref(PNMTextGlyph *glyph, int character);
59  EggTexture *make_tref(PNMTextGlyph *glyph, int character);
60  void add_extra_glyphs(const Filename &extra_filename);
61  void r_add_extra_glyphs(EggGroupNode *egg_group);
62  static bool is_numeric(const string &str);
63 
64 
65 private:
66  LColor _fg, _bg, _interior;
67  bool _got_interior;
68  RangeDescription _range;
69  vector_string _extra_filenames;
70  double _pixels_per_unit;
71  double _point_size;
72  double _poly_margin;
73  int _tex_margin;
74  double _render_margin;
75  bool _got_scale_factor;
76  double _scale_factor;
77  bool _no_reduce;
78  bool _no_native_aa;
79  bool _no_palettize;
80  int _palette_size[2];
81 
82  double _palettize_scale_factor;
83  Filename _input_font_filename;
84  int _face_index;
85  string _output_glyph_pattern;
86  string _output_palette_pattern;
87 
88  PNMTextMaker *_text_maker;
89 
90  EggTexture::Format _format;
91  int _num_channels;
92  EggVertexPool *_vpool;
93  EggGroup *_group;
94 
96  TRefs _trefs;
97 
99  Textures _textures;
100 };
101 
102 
103 #endif
104 
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:33
This is a two-component point in space.
Definition: lpoint2.h:424
This program uses FreeType to generate an egg file and a series of texture images from a font file in...
Definition: eggMakeFont.h:42
This object uses the Freetype library to generate text directly into an image.
Definition: pnmTextMaker.h:39
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
Definition: eggVertex.h:41
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
A single glyph in a PNMTextMaker.
Definition: pnmTextGlyph.h:27
This is the base class for a program that generates an egg file output, but doesn&#39;t read any for inpu...
Definition: eggWriter.h:30
This represents a single source texture that is referenced by one or more egg files.
Definition: textureImage.h:51
A collection of vertices.
Definition: eggVertexPool.h:46
This describes a sparse range of Unicode character codes for conversion that may be specified on the ...