Initial commit
This commit is contained in:
140
tools/fonttool/Getopt.cc
Executable file
140
tools/fonttool/Getopt.cc
Executable file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
** Slab NG - The Next Generation of Slab
|
||||
** (c) Copyright 2002-2004 Tom Bampton
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** $Id: Getopt.cpp,v 1.1 2003/10/30 23:55:29 tom Exp $
|
||||
**
|
||||
** Filename: Getopt.cpp
|
||||
** Author: Tom Bampton
|
||||
** Created: 30/10/2003
|
||||
** Purpose:
|
||||
** Command Line Parser
|
||||
**
|
||||
*/
|
||||
|
||||
/*
|
||||
* Based on getopt.c from FreeBSD, bearing the following copyright message:
|
||||
*
|
||||
* Copyright (c) 1987, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "Getopt.h"
|
||||
|
||||
|
||||
#define EMSG ""
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Getopt::Getopt(char *sOptions)
|
||||
{
|
||||
m_sOptions = sOptions;
|
||||
m_sPlace = EMSG;
|
||||
m_nOptInd = 1;
|
||||
}
|
||||
|
||||
Getopt::~Getopt()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int Getopt::getopt(int nargc, char **nargv)
|
||||
{
|
||||
char *oli; /* option letter list index */
|
||||
|
||||
m_nargc = nargc;
|
||||
m_nargv = nargv;
|
||||
|
||||
if (!*m_sPlace) { /* update scanning pointer */
|
||||
if (m_nOptInd >= nargc || *(m_sPlace = nargv[m_nOptInd]) != '-') {
|
||||
m_sPlace = EMSG;
|
||||
return -1;
|
||||
}
|
||||
if (m_sPlace[1] && *++m_sPlace == '-') { /* found "--" */
|
||||
++m_nOptInd;
|
||||
m_sPlace = EMSG;
|
||||
return -1;
|
||||
}
|
||||
} /* option letter okay? */
|
||||
if ((m_nOptOpt = (int)*m_sPlace++) == (int)':' ||
|
||||
!(oli = dStrchr(m_sOptions, m_nOptOpt))) {
|
||||
/*
|
||||
* if the user didn't specify '-' as an option,
|
||||
* assume it means -1.
|
||||
*/
|
||||
if (m_nOptOpt == (int)'-')
|
||||
return (-1);
|
||||
if (!*m_sPlace)
|
||||
++m_nOptInd;
|
||||
if (*m_sOptions != ':' && m_nOptOpt != GO_BAD_CHAR)
|
||||
return GO_INVALID_CHAR;
|
||||
return (GO_BAD_CHAR);
|
||||
}
|
||||
if (*++oli != ':') { /* don't need argument */
|
||||
m_sOptArg = NULL;
|
||||
if (!*m_sPlace)
|
||||
++m_nOptInd;
|
||||
}
|
||||
else { /* need an argument */
|
||||
if (*m_sPlace) /* no white space */
|
||||
m_sOptArg = m_sPlace;
|
||||
else if (nargc <= ++m_nOptInd) { /* no arg */
|
||||
m_sPlace = EMSG;
|
||||
//if (*m_sOptions == ':')
|
||||
return (GO_BAD_ARG);
|
||||
//return (GO_BAD_CHAR);
|
||||
}
|
||||
else /* white space */
|
||||
m_sOptArg = nargv[m_nOptInd];
|
||||
m_sPlace = EMSG;
|
||||
++m_nOptInd;
|
||||
}
|
||||
return (m_nOptOpt); /* dump back option letter */
|
||||
}
|
||||
|
||||
void Getopt::Reset(void)
|
||||
{
|
||||
if (!*m_sPlace) { /* update scanning pointer */
|
||||
if (m_nOptInd >= m_nargc || *(m_sPlace = m_nargv[m_nOptInd]) != '-') {
|
||||
m_sPlace = EMSG;
|
||||
return;
|
||||
}
|
||||
if (m_sPlace[1] && *++m_sPlace == '-') { /* found "--" */
|
||||
++m_nOptInd;
|
||||
m_sPlace = EMSG;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
115
tools/fonttool/Getopt.h
Executable file
115
tools/fonttool/Getopt.h
Executable file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
** Slab NG - The Next Generation of Slab
|
||||
** (c) Copyright 2002-2004 Tom Bampton
|
||||
** All Rights Reserved.
|
||||
**
|
||||
** $Id: Getopt.h,v 1.1 2003/10/30 23:55:29 tom Exp $
|
||||
**
|
||||
** Filename: Getopt.h
|
||||
** Author: Tom Bampton
|
||||
** Created: 30/10/2003
|
||||
** Purpose:
|
||||
** Command Line Parser
|
||||
**
|
||||
*/
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// \file Getopt.h
|
||||
/// \brief Header for Getopt
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SLAB_GETOPT_H
|
||||
#define SLAB_GETOPT_H
|
||||
|
||||
#define GO_BAD_CHAR '?'
|
||||
#define GO_BAD_ARG ':'
|
||||
#define GO_INVALID_CHAR '!'
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/// \brief Command Line Parser
|
||||
///
|
||||
/// Getopt provides a command line parser similar to Unix's getopt()
|
||||
///
|
||||
/// Note that this version of getopt() will not print any messages to
|
||||
/// the terminal, you will need to manage this yourself.
|
||||
///
|
||||
/// Parts of this section have been lifted from the getopt() manual page.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
class Getopt
|
||||
{
|
||||
private:
|
||||
char *m_sOptions;
|
||||
char *m_sPlace;
|
||||
int m_nargc;
|
||||
char **m_nargv;
|
||||
|
||||
public:
|
||||
/*! \brief Current argv Index
|
||||
*/
|
||||
int m_nOptInd;
|
||||
/*! \brief Current Option
|
||||
*/
|
||||
int m_nOptOpt;
|
||||
/*! \brief Argument to current option if applicable
|
||||
*/
|
||||
char *m_sOptArg;
|
||||
|
||||
/*! \brief Construct a Getopt
|
||||
|
||||
The string tells Getopt what arguments this program takes. It may
|
||||
contain the following elements: individual characters, and characters
|
||||
followed by a colon to indicate an option argument is to follow. For
|
||||
example, an option string "x" recognizes an option ``-x'', and an
|
||||
option string "x:" recognizes an option and argu- ment ``-x argument''.
|
||||
It does not matter to Getopt if a following argument has leading
|
||||
white space.
|
||||
|
||||
\param sOptions Option string
|
||||
\sa getopt(), Reset()
|
||||
*/
|
||||
Getopt(char *sOptions);
|
||||
virtual ~Getopt();
|
||||
|
||||
/*! \brief Parse arguments
|
||||
|
||||
On return from getopt(), m_sOptArg points to an option argument, if it
|
||||
is anticipated, and the variable m_nOptInd contains the index to the
|
||||
next argv argument for a subsequent call to getopt(). The variable
|
||||
m_nOptOpt saves the last known option character returned by getopt().
|
||||
|
||||
The m_nOptInd variable is set to 1, but may be set to another value
|
||||
before a set of calls to getopt() in order to skip over more or less
|
||||
argv entries.
|
||||
|
||||
In order to use getopt() to evaluate multiple sets of arguments, or to
|
||||
evaluate a single set of arguments multiple times, call Reset() before
|
||||
the second and each additional set of calls to getopt()
|
||||
|
||||
The getopt() function returns -1 when the argument list is exhausted,
|
||||
or GO_INVALID_CHAR if a non-recognized option is encountered. You may
|
||||
use m_nOptOpt to find the invalid character, and display a warning. If
|
||||
an option takes an argument, but the user did not supply one on the
|
||||
command line, getopt() returns GO_BAD_ARG. m_nOptOpt will then contain
|
||||
the option, for printing of warning messages. The interpretation of
|
||||
options in the argument list may be cancelled by the option `--'
|
||||
(double dash) which causes getopt() to signal the end of argument
|
||||
processing and return -1. When all options have been processed (i.e.,
|
||||
up to the first non-option argument), getopt() returns -1.
|
||||
|
||||
\param nargc The argc from your main() function
|
||||
\param nargv The argv from your main() function
|
||||
\return -1 on end of processing, the character of the current option
|
||||
or one of the error values as described above.
|
||||
\sa Reset(), Getopt(char *sOptions)
|
||||
*/
|
||||
int getopt(int nargc, char **nargv);
|
||||
/*! \brief Reset getopt() for subsequent calls
|
||||
|
||||
See the description of getopt() for information on Reset()
|
||||
|
||||
\sa getopt()
|
||||
*/
|
||||
void Reset(void);
|
||||
};
|
||||
|
||||
#endif // SLAB_GETOPT_H
|
380
tools/fonttool/fonttool.cc
Executable file
380
tools/fonttool/fonttool.cc
Executable file
@ -0,0 +1,380 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "platform/event.h"
|
||||
#include "platform/platformAssert.h"
|
||||
#include "console/console.h"
|
||||
#include "console/consoleTypes.h"
|
||||
#include "math/mathTypes.h"
|
||||
#include "dgl/gNewFont.h"
|
||||
#include "core/frameAllocator.h"
|
||||
#include "core/unicode.h"
|
||||
|
||||
#include "core/fileStream.h"
|
||||
|
||||
#include "fonttool.h"
|
||||
#include "Getopt.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FontToolGame GameObject;
|
||||
|
||||
// FOR SILLY LINK DEPENDANCY. REMOVE THIS AT YOUR PERIL.
|
||||
bool gEditingMission = false;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool initLibraries()
|
||||
{
|
||||
// asserts should be created FIRST
|
||||
PlatformAssert::create();
|
||||
_StringTable::create();
|
||||
Con::init();
|
||||
Math::init();
|
||||
Platform::init();
|
||||
FrameAllocator::init(3 * 1024 * 1024);
|
||||
TextureManager::create();
|
||||
return(true);
|
||||
}
|
||||
|
||||
static void shutdownLibraries()
|
||||
{
|
||||
Platform::shutdown();
|
||||
Con::shutdown();
|
||||
_StringTable::destroy();
|
||||
PlatformAssert::destroy();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void usage()
|
||||
{
|
||||
dPrintf("Usage: fonttool [options] <font> <size> <cachefile>\n\n");
|
||||
|
||||
dPrintf("Where options is one or more of:\n\n");
|
||||
|
||||
dPrintf(" -r Populate cache with range. Followup parameters are:\n");
|
||||
dPrintf(" fonttool [options] <font> <size> <cachefile> <beginChar> <endChar>\n");
|
||||
dPrintf(" Note that characters are provided in decimal.\n\n");
|
||||
|
||||
dPrintf(" -s Populate cache with strings. You provide a file; the\n");
|
||||
dPrintf(" cache is populated with all the characters that the\n");
|
||||
dPrintf(" file contains. Followup parameters are:\n");
|
||||
dPrintf(" fonttool [options] <font> <size> <cachefile> <stringFile>\n\n");
|
||||
|
||||
dPrintf(" -i Get info about a cache file. Only parameter is a cache file.\n\n");
|
||||
|
||||
dPrintf("fonttool ONLY supports UTF8 encoded files. Extended ASCII characters\n");
|
||||
dPrintf("and other encodings will not work and may result in strange results!\n\n");
|
||||
|
||||
dPrintf("\nMore information can be found in the documentation at:\n %s\n", FONTTOOL_DOC_URL);
|
||||
}
|
||||
|
||||
static void printfConsumer(ConsoleLogEntry::Level level, const char *consoleLine)
|
||||
{
|
||||
char *pref = "";
|
||||
switch(level)
|
||||
{
|
||||
case ConsoleLogEntry::Error:
|
||||
pref="[error] ";
|
||||
break;
|
||||
|
||||
case ConsoleLogEntry::Warning:
|
||||
pref = "[warn] ";
|
||||
break;
|
||||
}
|
||||
dPrintf("%s%s\n", pref, consoleLine);
|
||||
}
|
||||
|
||||
S32 FontToolGame::main(S32 argc, const char **argv)
|
||||
{
|
||||
S32 i, ch;
|
||||
Getopt opts("rsi:");
|
||||
|
||||
if(! initLibraries())
|
||||
{
|
||||
dPrintf("Failed to initialize libraries.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Con::addConsumer(printfConsumer);
|
||||
|
||||
FontToolMode mode = FTM_SHOW_USAGE;
|
||||
const char *paramFile = NULL;
|
||||
|
||||
Con::printf("fonttool v1.0.1");
|
||||
|
||||
while((ch = opts.getopt(argc, (char **)argv)) != -1)
|
||||
{
|
||||
switch(ch)
|
||||
{
|
||||
case 'r':
|
||||
mode = FTM_CACHE_RANGE;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
mode = FTM_CACHE_STRINGS;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
paramFile = opts.m_sOptArg;
|
||||
mode = FTM_CACHE_INFO;
|
||||
break;
|
||||
|
||||
case GO_BAD_ARG:
|
||||
dPrintf("option %c requires an argument\n", opts.m_nOptOpt);
|
||||
break;
|
||||
|
||||
case GO_INVALID_CHAR:
|
||||
dPrintf("%c is an invalid option\n", opts.m_nOptOpt);
|
||||
break;
|
||||
|
||||
case GO_BAD_CHAR:
|
||||
usage();
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= opts.m_nOptInd;
|
||||
argv += opts.m_nOptInd;
|
||||
|
||||
|
||||
if(mode == FTM_SHOW_USAGE)
|
||||
{
|
||||
usage();
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(mode == FTM_CACHE_RANGE || mode == FTM_CACHE_STRINGS)
|
||||
{
|
||||
// Get the cache file.
|
||||
Con::printf("Loading cache file '%s' for processing...", argv[2]);
|
||||
|
||||
GFont infoFont;
|
||||
|
||||
{
|
||||
FileStream fs;
|
||||
|
||||
if(!fs.open(argv[2], FileStream::Read))
|
||||
{
|
||||
Con::errorf(" - Could not open '%s'!", argv[2]);
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!infoFont.read(fs))
|
||||
{
|
||||
Con::errorf(" - Could not parse GFT file!!\n");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs.close();
|
||||
}
|
||||
|
||||
// Ok, now we've got a font file. So let's load the appropriate
|
||||
// platform font and do the cache population.
|
||||
Con::printf("Creating platform font '%s' %d...", argv[0], dAtoi(argv[1]));
|
||||
PlatformFont *pf = createPlatformFont(argv[0], dAtoi(argv[1]));
|
||||
|
||||
if(!pf)
|
||||
{
|
||||
Con::errorf(" - Could not create font %s (%dpt)", argv[0], dAtoi(argv[1]));
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Stuff the platform font into the GFont...
|
||||
infoFont.forcePlatformFont(pf);
|
||||
|
||||
// Now do the appropriate caching logic.
|
||||
if(mode == FTM_CACHE_RANGE)
|
||||
{
|
||||
if(argc < 5)
|
||||
{
|
||||
Con::errorf("Too few arguments!");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
U32 rangeStart = dAtoi(argv[3]);
|
||||
U32 rangeEnd = dAtoi(argv[4]);
|
||||
|
||||
if(rangeStart > rangeEnd)
|
||||
{
|
||||
Con::errorf("populateFontCacheRange - range start is after end!");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Con::printf("Populating cache with characters from %d to %d", rangeStart, rangeEnd);
|
||||
|
||||
// This has the side effect of generating character info, including the bitmaps.
|
||||
for(U32 i=rangeStart; i<=rangeEnd; i++)
|
||||
{
|
||||
if(infoFont.isValidChar(i))
|
||||
infoFont.getCharWidth(i);
|
||||
else
|
||||
Con::warnf("populateFontCacheRange - skipping invalid char 0x%x", i);
|
||||
}
|
||||
|
||||
// Ok, all done.
|
||||
Con::printf("Done populating cache!");
|
||||
}
|
||||
else if(mode == FTM_CACHE_STRINGS)
|
||||
{
|
||||
if(argc < 4)
|
||||
{
|
||||
Con::errorf("Too few arguments!");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Ok, we want to open the file, read every line, and run it
|
||||
// through the cache.
|
||||
FileStream fs;
|
||||
|
||||
if(!fs.open(argv[3], FileStream::Read))
|
||||
{
|
||||
Con::errorf(" - Could not open string file '%s'!", argv[3]);
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Peek the first 4 chars so we can check the BOM.
|
||||
// Bytes Encoding Form
|
||||
// 00 00 FE FF UTF-32, big-endian
|
||||
// FF FE 00 00 UTF-32, little-endian
|
||||
// FE FF UTF-16, big-endian
|
||||
// FF FE UTF-16, little-endian
|
||||
// EF BB BF UTF-8
|
||||
|
||||
U8 bom[4];
|
||||
fs.read(&bom[0]);
|
||||
fs.read(&bom[1]);
|
||||
fs.read(&bom[2]);
|
||||
fs.read(&bom[3]);
|
||||
|
||||
// And reset the position...
|
||||
fs.setPosition(0);
|
||||
|
||||
// Is it a BOM?
|
||||
if(bom[0] == 0)
|
||||
{
|
||||
// Could be UTF32BE
|
||||
if(bom[1] == 0 && bom[2] == 0xFE && bom[3] == 0xFF)
|
||||
Con::warnf("Encountered a UTF32 BE BOM in this file; fonttool does NOT support this file encoding. Use UTF8!");
|
||||
}
|
||||
else if(bom[0] == 0xFF)
|
||||
{
|
||||
// It's little endian, either UTF16 or UTF 32
|
||||
if(bom[1] == 0xFE)
|
||||
{
|
||||
if(bom[2] == 0 && bom[3] == 0)
|
||||
Con::warnf("Encountered a UTF32 LE BOM in this file; fonttool does NOT support this file encoding. Use UTF8!");
|
||||
else
|
||||
Con::warnf("Encountered a UTF16 LE BOM in this file; fonttool does NOT support this file encoding. Use UTF8!");
|
||||
}
|
||||
}
|
||||
else if(bom[0] == 0xFE && bom[1] == 0xFF)
|
||||
Con::warnf("Encountered a UTF16 BE BOM in this file; fonttool does NOT support this file encoding. Use UTF8!");
|
||||
else if(bom[0] == 0xEF && bom[1] == 0xBB && bom[2] == 0xBF)
|
||||
Con::printf("Encountered a UTF8 BOM. Fonttool supports this.");
|
||||
|
||||
// Ok, read each line and run it through.
|
||||
const U32 buffSize = 64 * 1024;
|
||||
UTF8 lineBuff[buffSize];
|
||||
UTF16 convBuffer[buffSize];
|
||||
|
||||
Con::printf("Populating cache with strings from %s", argv[3]);
|
||||
|
||||
U32 lineCount = 0;
|
||||
while(fs.getStatus() != FileStream::EOS)
|
||||
{
|
||||
fs.readLine((U8*)lineBuff, buffSize);
|
||||
convertUTF8toUTF16(lineBuff, convBuffer, buffSize);
|
||||
infoFont.getStrNWidth(convBuffer, dStrlen(convBuffer));
|
||||
lineCount++;
|
||||
}
|
||||
|
||||
fs.close();
|
||||
|
||||
Con::printf("Done populating cache! Processed %d line(s).", lineCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
AssertISV(false, "FontToolGame::main - unknown mode!");
|
||||
}
|
||||
|
||||
// Ok, now write it back out.
|
||||
{
|
||||
FileStream fs;
|
||||
|
||||
if(!fs.open(argv[2], FileStream::Write))
|
||||
{
|
||||
Con::errorf(" - Could not open '%s' for writing!", argv[2]);
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!infoFont.write(fs))
|
||||
{
|
||||
Con::errorf(" - Could not write GFT file!");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(mode == FTM_CACHE_INFO)
|
||||
{
|
||||
Con::printf("Getting info on cache file '%s'...", paramFile);
|
||||
|
||||
// Get a stream to the file.
|
||||
GFont infoFont;
|
||||
FileStream fs;
|
||||
|
||||
if(!fs.open(paramFile, FileStream::Read))
|
||||
{
|
||||
Con::errorf(" - Could not open file!\n");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!infoFont.read(fs))
|
||||
{
|
||||
Con::errorf(" - Could not load GFT!\n");
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs.close();
|
||||
|
||||
infoFont.dumpInfo();
|
||||
// All done.
|
||||
}
|
||||
|
||||
|
||||
shutdownLibraries();
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GameReactivate()
|
||||
{
|
||||
}
|
||||
|
||||
void GameDeactivate( bool )
|
||||
{
|
||||
}
|
27
tools/fonttool/fonttool.h
Executable file
27
tools/fonttool/fonttool.h
Executable file
@ -0,0 +1,27 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Torque Game Engine
|
||||
// Copyright (C) GarageGames.com, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _FONTTOOL_H_
|
||||
#define _FONTTOOL_H_
|
||||
|
||||
#include "platform/gameInterface.h"
|
||||
|
||||
#define FONTTOOL_DOC_URL "http://tdn.garagegames.com/wiki/TorqueUnicode#Caching.2C_.gft_.2F_.uft"
|
||||
|
||||
class FontToolGame : public GameInterface
|
||||
{
|
||||
public:
|
||||
enum FontToolMode
|
||||
{
|
||||
FTM_SHOW_USAGE,
|
||||
FTM_CACHE_RANGE,
|
||||
FTM_CACHE_STRINGS,
|
||||
FTM_CACHE_INFO
|
||||
};
|
||||
|
||||
S32 main(S32 argc, const char **argv);
|
||||
};
|
||||
|
||||
#endif // _FONTTOOL_H_
|
Reference in New Issue
Block a user