make it easier to see the available characters in a font

This commit is contained in:
David Rose 2001-07-13 23:55:30 +00:00
parent db5f690597
commit 12e4575200
2 changed files with 118 additions and 19 deletions

View File

@ -19,11 +19,13 @@
#include "textFont.h" #include "textFont.h"
#include "config_text.h" #include "config_text.h"
#include <geom.h> #include "geom.h"
#include <geomPoint.h> #include "geomPoint.h"
#include <geomNode.h> #include "geomNode.h"
#include <namedNode.h> #include "namedNode.h"
#include <renderRelation.h> #include "renderRelation.h"
#include "ctype.h"
TypeHandle TextFont::_type_handle; TypeHandle TextFont::_type_handle;
@ -233,7 +235,97 @@ void TextFont::
write(ostream &out, int indent_level) const { write(ostream &out, int indent_level) const {
indent(out, indent_level) indent(out, indent_level)
<< "TextFont " << get_name() << "; " << "TextFont " << get_name() << "; "
<< _defs.size() << " characters available in font.\n"; << _defs.size() << " characters available in font:\n";
CharDefs::const_iterator di;
// Figure out which symbols we have. We collect lowercase letters,
// uppercase letters, and digits together for the user's
// convenience.
static const int num_letters = 26;
static const int num_digits = 10;
bool lowercase[num_letters];
bool uppercase[num_letters];
bool digits[num_digits];
memset(lowercase, 0, sizeof(bool) * num_letters);
memset(uppercase, 0, sizeof(bool) * num_letters);
memset(digits, 0, sizeof(bool) * num_digits);
int count_lowercase = 0;
int count_uppercase = 0;
int count_digits = 0;
for (di = _defs.begin(); di != _defs.end(); ++di) {
int ch = (*di).first;
if (islower(ch)) {
count_lowercase++;
lowercase[ch - 'a'] = true;
} else if (isupper(ch)) {
count_uppercase++;
uppercase[ch - 'A'] = true;
} else if (isdigit(ch)) {
count_digits++;
digits[ch - '0'] = true;
}
}
if (count_lowercase == num_letters) {
indent(out, indent_level + 2)
<< "All lowercase letters\n";
} else if (count_lowercase > 0) {
indent(out, indent_level + 2)
<< "Some lowercase letters: ";
for (int i = 0; i < num_letters; i++) {
if (lowercase[i]) {
out << (char)(i + 'a');
}
}
out << "\n";
}
if (count_uppercase == num_letters) {
indent(out, indent_level + 2)
<< "All uppercase letters\n";
} else if (count_uppercase > 0) {
indent(out, indent_level + 2)
<< "Some uppercase letters: ";
for (int i = 0; i < num_letters; i++) {
if (uppercase[i]) {
out << (char)(i + 'A');
}
}
out << "\n";
}
if (count_digits == num_digits) {
indent(out, indent_level + 2)
<< "All digits\n";
} else if (count_digits > 0) {
indent(out, indent_level + 2)
<< "Some digits: ";
for (int i = 0; i < num_digits; i++) {
if (digits[i]) {
out << (char)(i + '0');
}
}
out << "\n";
}
for (di = _defs.begin(); di != _defs.end(); ++di) {
int ch = (*di).first;
if (!isalnum(ch)) {
indent(out, indent_level + 2)
<< ch;
if (isprint(ch)) {
out << " = '" << (char)ch << "'\n";
}
}
}
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -18,19 +18,19 @@
#include "textNode.h" #include "textNode.h"
#include "config_text.h" #include "config_text.h"
#include <compose_matrix.h> #include "compose_matrix.h"
#include <transformTransition.h> #include "transformTransition.h"
#include <colorTransition.h> #include "colorTransition.h"
#include <geom.h> #include "geom.h"
#include <geomprimitives.h> #include "geomprimitives.h"
#include <renderRelation.h> #include "renderRelation.h"
#include <notify.h> #include "notify.h"
#include <sceneGraphReducer.h> #include "sceneGraphReducer.h"
#include <geomBinTransition.h> #include "geomBinTransition.h"
#include <indent.h> #include "indent.h"
#include <stdio.h> #include "stdio.h"
#include <ctype.h> #include "ctype.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Static variables // Static variables
@ -450,7 +450,14 @@ assemble_row(const char *&source, Node *dest) {
const TextFont::CharDef *def = _font->get_char(character); const TextFont::CharDef *def = _font->get_char(character);
if (def == (const TextFont::CharDef *)NULL) { if (def == (const TextFont::CharDef *)NULL) {
text_cat.warning() text_cat.warning()
<< "No definition for character " << character << endl; << "No definition in " << _font->get_name()
<< " for character " << character;
if (isprint(character)) {
text_cat.warning(false)
<< " ('" << (char)character << "')";
}
text_cat.warning(false)
<< "\n";
} else { } else {
Geom *char_geom = def->_geom; Geom *char_geom = def->_geom;