include face index numbers in table

This commit is contained in:
David Rose 2004-01-29 22:23:10 +00:00
parent 24dd0bcb43
commit e5a2973e65
2 changed files with 17 additions and 7 deletions

View File

@ -34,12 +34,13 @@ static Loader model_loader;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool FontPool:: bool FontPool::
ns_has_font(const string &str) { ns_has_font(const string &str) {
string index_str;
Filename filename; Filename filename;
int face_index; int face_index;
lookup_filename(str, filename, face_index); lookup_filename(str, index_str, filename, face_index);
Fonts::const_iterator ti; Fonts::const_iterator ti;
ti = _fonts.find(filename); ti = _fonts.find(index_str);
if (ti != _fonts.end()) { if (ti != _fonts.end()) {
// This font was previously loaded. // This font was previously loaded.
return true; return true;
@ -55,12 +56,13 @@ ns_has_font(const string &str) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
TextFont *FontPool:: TextFont *FontPool::
ns_load_font(const string &str) { ns_load_font(const string &str) {
string index_str;
Filename filename; Filename filename;
int face_index; int face_index;
lookup_filename(str, filename, face_index); lookup_filename(str, index_str, filename, face_index);
Fonts::const_iterator ti; Fonts::const_iterator ti;
ti = _fonts.find(filename); ti = _fonts.find(index_str);
if (ti != _fonts.end()) { if (ti != _fonts.end()) {
// This font was previously loaded. // This font was previously loaded.
return (*ti).second; return (*ti).second;
@ -189,10 +191,14 @@ ns_list_contents(ostream &out) {
// filename followed by an optional colon and a face // filename followed by an optional colon and a face
// index, and splits it out into its two components. // index, and splits it out into its two components.
// Then it looks up the filename on the model path. // Then it looks up the filename on the model path.
// Sets the filename and face index accordingly. // Sets the filename and face index accordingly. Also
// sets index_str to be the concatenation of the
// found filename with the face index, thus restoring
// the original input (but normalized to contain the
// full path.)
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
void FontPool:: void FontPool::
lookup_filename(const string &str, lookup_filename(const string &str, string &index_str,
Filename &filename, int &face_index) { Filename &filename, int &face_index) {
int colon = (int)str.length() - 1; int colon = (int)str.length() - 1;
// Scan backwards over digits for a colon. // Scan backwards over digits for a colon.
@ -217,6 +223,10 @@ lookup_filename(const string &str,
} else { } else {
filename.resolve_filename(get_model_path()); filename.resolve_filename(get_model_path());
} }
ostringstream strm;
strm << filename << ":" << face_index;
index_str = strm.str();
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////

View File

@ -61,7 +61,7 @@ private:
int ns_garbage_collect(); int ns_garbage_collect();
void ns_list_contents(ostream &out); void ns_list_contents(ostream &out);
static void lookup_filename(const string &str, static void lookup_filename(const string &str, string &index_str,
Filename &filename, int &face_index); Filename &filename, int &face_index);
static FontPool *get_ptr(); static FontPool *get_ptr();