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