Browse Source

Port plFontConverter to Qt5

Michael Hansen 10 years ago
parent
commit
d4465a2168
  1. 6
      Sources/Plasma/PubUtilLib/plGImage/plFont.cpp
  2. 4
      Sources/Plasma/PubUtilLib/plGImage/plFont.h
  3. 57
      Sources/Tools/plFontConverter/CMakeLists.txt
  4. 605
      Sources/Tools/plFontConverter/plFontConverter.cpp
  5. 86
      Sources/Tools/plFontConverter/plFontConverter.h
  6. 756
      Sources/Tools/plFontConverter/plFontConverterProc.cpp
  7. 8
      Sources/Tools/plFontConverter/plFontFreeType.cpp
  8. 8
      Sources/Tools/plFontConverter/plFontFreeType.h
  9. 115
      Sources/Tools/plFontConverter/plFontPreview.cpp
  10. 54
      Sources/Tools/plFontConverter/plFontPreview.h
  11. 81
      Sources/Tools/plFontConverter/res/FonChooser.ui
  12. 137
      Sources/Tools/plFontConverter/res/FreeType.ui
  13. 159
      Sources/Tools/plFontConverter/res/FreeTypeBatch.ui
  14. 355
      Sources/Tools/plFontConverter/res/MainDialog.ui
  15. 5
      Sources/Tools/plFontConverter/res/plFontConverter.qrc
  16. 269
      Sources/Tools/plFontConverter/res/plFontConverter.rc
  17. 52
      Sources/Tools/plFontConverter/res/resource.h
  18. 10
      Sources/Tools/plLocalizationEditor/CMakeLists.txt
  19. 6
      Sources/Tools/plLocalizationEditor/plAddDlgs.cpp
  20. 15
      Sources/Tools/plLocalizationEditor/res/AddElement.ui
  21. 5
      Sources/Tools/plLocalizationEditor/res/AddLocalization.ui
  22. 9
      Sources/Tools/plLocalizationEditor/res/EditDialog.ui
  23. 1
      Sources/Tools/plLocalizationEditor/res/plLocalizationEditor.rc

6
Sources/Plasma/PubUtilLib/plGImage/plFont.cpp

@ -1253,7 +1253,7 @@ bool plFont::LoadFromP2FFile( const plFileName &path )
// Load this font from the data found in the given Windows FNT file,
// using the format specified in the Windows 3 Developers Notes.
bool plFont::LoadFromFNT( const char *path )
bool plFont::LoadFromFNT( const plFileName &path )
{
hsUNIXStream stream; // Ahh, irony
if( !stream.Open( path, "rb" ) )
@ -2023,9 +2023,9 @@ bool plFont::LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callb
return false;
}
bool plFont::LoadFromBDF( const char *path, plBDFConvertCallback *callback )
bool plFont::LoadFromBDF( const plFileName &path, plBDFConvertCallback *callback )
{
FILE *fp = fopen( path, "rt" );
FILE *fp = fopen( path.AsString().c_str(), "rt" );
if( fp == nil )
return false;
try

4
Sources/Plasma/PubUtilLib/plGImage/plFont.h

@ -293,10 +293,10 @@ class plFont : public hsKeyedObject
void CalcStringExtents( const plString &string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY );
void CalcStringExtents( const wchar_t *string, uint16_t &width, uint16_t &height, uint16_t &ascent, uint32_t &firstClippedChar, uint16_t &lastX, uint16_t &lastY );
bool LoadFromFNT( const char *path );
bool LoadFromFNT( const plFileName &path );
bool LoadFromFNTStream( hsStream *stream );
bool LoadFromBDF( const char *path, plBDFConvertCallback *callback );
bool LoadFromBDF( const plFileName &path, plBDFConvertCallback *callback );
bool LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callback );
bool LoadFromP2FFile( const plFileName &path );

57
Sources/Tools/plFontConverter/CMakeLists.txt

@ -5,49 +5,60 @@ include_directories("../../Plasma/PubUtilLib")
include_directories(${FREETYPE_INCLUDE_DIRS})
set(plFontConverter_HEADERS
plFontConverter.h
plFontFreeType.h
plFontPreview.h
)
qt5_wrap_cpp(plFontConverter_MOC ${plFontConverter_HEADERS})
set(plFontConverter_SOURCES
plFontConverter.cpp
plFontConverterProc.cpp
plFontFreeType.cpp
plFontPreview.cpp
)
set(plFontConverter_RESOURCES
res/plFontConverter.rc
res/resource.h
res/icon1.ico
if(WIN32)
set(plFontConverter_SOURCES ${plFontConverter_SOURCES}
res/plFontConverter.rc
)
endif()
set(plFontConverter_RCC_SOURCES
res/plFontConverter.qrc
)
qt5_add_resources(plFontConverter_RCC ${plFontConverter_RCC_SOURCES})
set(plFontConverter_UIC_SOURCES
res/MainDialog.ui
res/FonChooser.ui
res/FreeType.ui
res/FreeTypeBatch.ui
)
add_executable(plFontConverter WIN32 ${plFontConverter_SOURCES} ${plFontConverter_HEADERS} ${plFontConverter_RESOURCES})
qt5_wrap_ui(plFontConverter_UIC ${plFontConverter_UIC_SOURCES})
# For generated ui_*.h files
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(plFontConverter WIN32 ${plFontConverter_HEADERS}
${plFontConverter_SOURCES} ${plFontConverter_RCC}
${plFontConverter_UIC} ${plFontConverter_MOC})
target_link_libraries(plFontConverter CoreLib)
target_link_libraries(plFontConverter pnKeyedObject)
target_link_libraries(plFontConverter pnSceneObject)
target_link_libraries(plFontConverter pnUUID)
target_link_libraries(plFontConverter plGImage)
target_link_libraries(plFontConverter plMessage)
target_link_libraries(plFontConverter plPipeline)
target_link_libraries(plFontConverter plResMgr)
target_link_libraries(plFontConverter ${JPEG_LIBRARY})
target_link_libraries(plFontConverter ${DirectX_LIBRARIES})
target_link_libraries(plFontConverter ${FREETYPE_LIBRARIES})
if (WIN32)
target_link_libraries(plFontConverter rpcrt4)
target_link_libraries(plFontConverter vfw32)
target_link_libraries(plFontConverter ws2_32)
target_link_libraries(plFontConverter winmm)
target_link_libraries(plFontConverter strmiids)
target_link_libraries(plFontConverter comctl32)
target_link_libraries(plFontConverter shlwapi)
endif(WIN32)
target_link_libraries(plFontConverter Qt5::Widgets)
if(USE_VLD)
target_link_libraries(plFontConverter ${VLD_LIBRARY})
endif()
source_group("Source Files" FILES ${plFontConverter_SOURCES})
source_group("Source Files" FILES ${plFontConverter_SOURCES} ${plFontConverter_MOC})
source_group("Header Files" FILES ${plFontConverter_HEADERS})
source_group("Resource Files" FILES ${plFontConverter_RESOURCES})
source_group("Resource Files" FILES ${plFontConverter_RCC_SOURCES} ${plFontConverter_RCC}
${plFontConverter_UIC_SOURCES} ${plFontConverter_UIC})

605
Sources/Tools/plFontConverter/plFontConverter.cpp

@ -39,12 +39,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#define CLASSNAME "plFontConverter" // Used in WinInit()
#define WINDOWNAME "plFontConverter"
#include "plFontConverter.h"
#include "plFontFreeType.h"
#ifdef Q_OS_WIN
#include "HeadSpin.h"
#include "hsWindows.h"
#include "res/resource.h"
#endif
#include "pnAllCreatables.h"
#include "plResMgr/plResManager.h"
@ -61,34 +62,606 @@ REGISTER_CREATABLE(plFont);
REGISTER_NONCREATABLE(plBitmap);
REGISTER_CREATABLE(plMipmap);
#include "pnKeyedObject/plUoid.h"
#include "pnKeyedObject/plKeyImp.h"
#include <QApplication>
#include <QDialog>
#include <QMessageBox>
#include <QFileDialog>
#include <QProgressDialog>
#include <QDragEnterEvent>
#include <QMimeData>
#include "ui_MainDialog.h"
#include "ui_FonChooser.h"
#include "ui_FreeType.h"
#include "ui_FreeTypeBatch.h"
#include <functional>
HINSTANCE gInstance;
char *gCommandLine = nil;
HWND gMainWindow = nil;
BOOL CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam );
static void IAboutDialog(QWidget *parent)
{
QDialog dlg(parent);
QLabel *image = new QLabel(&dlg);
image->setPixmap(QPixmap(":/icon1.ico"));
QLabel *text = new QLabel(QObject::tr(R"(plFontConverter
A simple Plasma 2.0 utility for converting public
font formats into our own bitmap font format.)"), &dlg);
QPushButton *ok = new QPushButton(QObject::tr("OK"), &dlg);
ok->setDefault(true);
QHBoxLayout *layout = new QHBoxLayout(&dlg);
layout->setMargin(8);
layout->setSpacing(10);
layout->addWidget(image);
layout->addWidget(text);
layout->addWidget(ok);
dlg.connect(ok, &QPushButton::clicked, &dlg, &QDialog::accept);
dlg.exec();
}
plFontConverter::plFontConverter()
: QMainWindow(), fFont(nullptr)
{
fUI = new Ui_MainDialog;
fUI->setupUi(this);
setAcceptDrops(true);
connect(fUI->fImportFNTAction, SIGNAL(triggered()), SLOT(OpenFNT()));
connect(fUI->fImportBDFAction, SIGNAL(triggered()), SLOT(OpenBDF()));
connect(fUI->fImportFONAction, SIGNAL(triggered()), SLOT(OpenFON()));
connect(fUI->fImportTTFAction, SIGNAL(triggered()), SLOT(OpenTTF()));
connect(fUI->fOpenAction, SIGNAL(triggered()), SLOT(OpenP2F()));
connect(fUI->fExportAction, SIGNAL(triggered()), SLOT(ExportP2F()));
connect(fUI->fExitAction, SIGNAL(triggered()), SLOT(close()));
connect(fUI->fAboutAction, &QAction::triggered, std::bind(&IAboutDialog, this));
connect(fUI->fExportButton, SIGNAL(clicked()), SLOT(ExportP2F()));
connect(fUI->fSampleText, &QLineEdit::textChanged, [this](const QString &text)
{
fUI->fPreview->Update(fFont, text);
});
}
plFontConverter::~plFontConverter()
{
delete fUI;
}
void plFontConverter::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls())
event->acceptProposedAction();
}
void plFontConverter::dropEvent(QDropEvent *event)
{
QList<QUrl> urls = event->mimeData()->urls();
for (const QUrl &url : urls)
{
if (!url.isLocalFile())
continue;
plFileName fileName = url.toLocalFile().toUtf8().constData();
plString ext = fileName.GetFileExt();
if (ext.CompareI("fnt") == 0)
IImportFNT(fileName);
else if (ext.CompareI("bdf") == 0)
IImportBDF(fileName);
else if (ext.CompareI("fon") == 0 || ext.CompareI("exe") == 0)
IImportFON(fileName);
else if (ext.CompareI("ttf") == 0 || ext.CompareI("ttc") == 0)
IImportFreeType(fileName);
else if (ext.CompareI("p2f") == 0)
IOpenP2F(fileName);
else
{
// Try using our freeType converter
IImportFreeType(fileName);
}
}
IUpdateInfo();
}
void plFontConverter::OpenFNT()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a FNT file to convert"),
QString(), "Windows FNT files (*.fnt);;All files (*.*)");
if (!fileName.isEmpty())
IImportFNT(fileName.toUtf8().constData());
}
void plFontConverter::OpenBDF()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a BDF file to convert"),
QString(), "Adobe BDF files (*.bdf);;All files (*.*)");
if (!fileName.isEmpty())
IImportBDF(fileName.toUtf8().constData());
}
void plFontConverter::OpenFON()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a FON file to convert"),
QString(), "Windows FON files (*.fon *.exe);;All files (*.*)");
if (!fileName.isEmpty())
IImportFON(fileName.toUtf8().constData());
}
void plFontConverter::OpenTTF()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a TrueType font to convert"),
QString(), "TrueType files (*.ttf *.ttc);;All files (*.*)");
if (!fileName.isEmpty())
IImportFreeType(fileName.toUtf8().constData());
}
void plFontConverter::OpenP2F()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a P2F file to open"),
QString(), "Plasma 2 font files (*.p2f);;All files (*.*)");
if (!fileName.isEmpty())
IOpenP2F(fileName.toUtf8().constData());
}
void plFontConverter::ExportP2F()
{
// Grab updated values for the font
plString fileName = fUI->fFaceName->text().toUtf8().constData();
fFont->SetFace(fileName);
fFont->SetSize(fUI->fFontSize->value());
fFont->SetFlag(plFont::kFlagBold, fUI->fBold->isChecked());
fFont->SetFlag(plFont::kFlagItalic, fUI->fItalic->isChecked());
// Write out
QString saveFile = QFileDialog::getSaveFileName(this, tr("Specify a file to export to"),
QString("%1-%2.p2f").arg(fFont->GetFace().c_str()).arg(fFont->GetSize()),
"Plasma 2 font files (*.p2f)");
if (!saveFile.isEmpty())
{
fileName = saveFile.toUtf8().constData();
hsUNIXStream stream;
if (!stream.Open(fileName, "wb"))
QMessageBox::critical(this, tr("Error"), tr("Can't open file for writing"));
else
{
/*
sprintf( fileName, "%s-%d", gFont->GetFace(), gFont->GetSize() );
if( gFont->GetKey() == nil )
hsgResMgr::ResMgr()->NewKey( fileName, gFont, plLocation::kGlobalFixedLoc );
*/
fFont->WriteRaw(&stream);
stream.Close();
}
}
}
void plFontConverter::IMakeFontGoAway()
{
if (fFont != nullptr) {
plKeyImp *imp = (plKeyImp *)(fFont->GetKey());
if (imp != nullptr)
imp->SetObjectPtr(nullptr);
fFont = nullptr;
}
}
void plFontConverter::IMakeNewFont()
{
IMakeFontGoAway();
fFont = new plFont();
}
void plFontConverter::IUpdateInfo()
{
if (fFont != nullptr && fFont->GetNumChars() == 0)
IMakeFontGoAway();
if (fFont == nullptr)
{
fUI->fExportAction->setEnabled(false);
fUI->fExportButton->setEnabled(false);
fUI->fFaceName->setText("");
fUI->fFontSize->setValue(0);
fUI->fStartingGlyph->setText("");
fUI->fGlyphCount->setText("");
fUI->fBitmapWidth->setText("");
fUI->fBitmapHeight->setText("");
fUI->fBPP->setText("");
fUI->fBold->setChecked(false);
fUI->fItalic->setChecked(false);
fUI->fPreview->Update(nullptr, QString());
return;
}
fUI->fExportAction->setEnabled(true);
fUI->fExportButton->setEnabled(true);
fUI->fFaceName->setText(fFont->GetFace().c_str());
fUI->fFontSize->setValue(fFont->GetSize());
fUI->fStartingGlyph->setText(QString::number(fFont->GetFirstChar()));
fUI->fGlyphCount->setText(QString::number(fFont->GetNumChars()));
fUI->fBitmapWidth->setText(QString::number(fFont->GetBitmapWidth()));
fUI->fBitmapHeight->setText(QString::number(fFont->GetBitmapHeight()));
fUI->fBPP->setText(QString::number(fFont->GetBitmapBPP()));
fUI->fBold->setChecked(fFont->IsFlagSet(plFont::kFlagBold));
fUI->fItalic->setChecked(fFont->IsFlagSet(plFont::kFlagItalic));
fUI->fPreview->Update(fFont, fUI->fSampleText->text());
}
void plFontConverter::IImportFNT(const plFileName &path)
{
IMakeNewFont();
if (!fFont->LoadFromFNT(path))
QMessageBox::critical(this, tr("ERROR"), tr("Failure converting FNT file"));
IUpdateInfo();
}
class ProgressRAII
{
QWidget *fParent;
QProgressDialog *fProgress;
public:
ProgressRAII(QWidget *parent)
: fParent(parent)
{
fProgress = new QProgressDialog(parent->tr("Importing Font..."), QString(), 0, 100, parent);
fProgress->setAttribute(Qt::WA_DeleteOnClose);
fParent->setEnabled(false);
}
~ProgressRAII()
{
fProgress->close();
fParent->setEnabled(true);
}
void SetRange(int max) { fProgress->setRange(0, max); }
void SetValue(int val) { fProgress->setValue(val); }
};
class plMyBDFCallback : public plBDFConvertCallback
{
ProgressRAII fProgress;
uint16_t fPoint;
public:
plMyBDFCallback(QWidget *parent) : fProgress(parent) { }
virtual void NumChars(uint16_t chars) override
{
fProgress.SetRange(chars);
}
virtual void CharDone() override
{
fPoint++;
fProgress.SetValue(fPoint);
qApp->processEvents();
}
};
void plFontConverter::IImportBDF(const plFileName &path)
{
IMakeNewFont();
plMyBDFCallback callback(this);
if (!fFont->LoadFromBDF(path, &callback))
QMessageBox::critical(this, tr("ERROR"), tr("Failure converting BDF file"));
IUpdateInfo();
}
struct ResRecord
{
HRSRC fHandle;
QString fName;
ResRecord() : fHandle(nullptr) { }
ResRecord(HRSRC h, const QString &n) : fHandle(h), fName(n) { }
};
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
BOOL CALLBACK ResEnumProc(HMODULE module, LPCTSTR type, LPTSTR name, LONG_PTR lParam)
{
HACCEL accelTable = LoadAccelerators( hInstance, MAKEINTRESOURCE( IDR_ACCELERATOR1 ) );
HRSRC res = FindResource(module, name, type);
if (res != nullptr)
{
QList<ResRecord> *array = reinterpret_cast<QList<ResRecord> *>(lParam);
array->append(ResRecord(res, name));
}
return true;
}
static ResRecord DoSelectResource(const QList<ResRecord> &resources)
{
QDialog dlg;
Ui_FonChooser ui;
ui.setupUi(&dlg);
gCommandLine = (char *)lpCmdLine;
for (const auto &rec : resources)
ui.fResourceList->addItem(rec.fName);
if (dlg.exec() == QDialog::Accepted && ui.fResourceList->currentRow() >= 0)
return resources[ui.fResourceList->currentRow()];
return ResRecord();
}
void plFontConverter::IImportFON(const plFileName &path)
{
// TODO: Get rid of the Windows-y stuff and parse this shit by hand
#if !defined(Q_OS_WIN) || defined(Q_OS_WIN64)
QMessageBox::critical(this, tr("ERROR"),
tr("FON import is currently only available on 32-bit Windows OSes"));
return;
#else
BOOL isWow64;
if (IsWow64Process(GetCurrentProcess(), &isWow64) && isWow64) {
// Nope, even WoW64 doesn't count... Win64 can't import a Win16
// image, regardless of whether we're running in 32- or 64-bit mode.
QMessageBox::critical(this, tr("ERROR"),
tr("FON import is currently only available on 32-bit Windows OSes"));
return;
}
// FON files are really just resource modules
IMakeNewFont();
HMODULE file = LoadLibraryExA(path.AsString().c_str(), nil, LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES);
if (file == nullptr)
{
char msg[512];
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nil, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)msg, sizeof(msg), nil);
QMessageBox::critical(this, tr("Error"),
tr("Failure importing FON file: can't open as resource library (%1)").arg(msg));
}
else
{
QList<ResRecord> resList;
if (EnumResourceNames(file, "Font", ResEnumProc, (LPARAM)&resList))
{
// Put up a list of the resources so the user can choose which one
ResRecord res = DoSelectResource(resList);
if (res.fHandle != nullptr)
{
// Load the resource into a ram stream
hsRAMStream stream;
HGLOBAL glob = LoadResource(file, res.fHandle);
if (glob != nullptr)
{
void *data = LockResource(glob);
if (data != nullptr)
{
stream.Write(SizeofResource(file, res.fHandle), data);
stream.Rewind();
if (!fFont->LoadFromFNTStream(&stream))
{
QMessageBox::critical(this, tr("Error"),
tr("Failure importing FON file: can't parse resource as FNT"));
}
}
}
}
}
else
{
char msg[512];
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nil, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)msg, sizeof(msg), nil);
QMessageBox::critical(this, tr("Error"),
tr("Failure importing FON file: can't enumerate resources (%1)").arg(msg));
}
FreeLibrary(file);
}
IUpdateInfo();
#endif
}
class NumListValidator : public QValidator
{
public:
NumListValidator(QObject *parent = nullptr) : QValidator(parent) { }
gInstance = hInstance;
virtual State validate(QString &input, int &pos) const override
{
for (int ch = 0; ch < input.size(); ++ch)
{
ushort theChar = input[ch].unicode();
if ((theChar < '0' || theChar > '9') && (theChar != ' '))
return Invalid;
}
return Acceptable;
}
};
void plFontConverter::IBatchFreeType(const plFileName &path, void *init)
{
plFontFreeType::Options info;
if (init != nullptr)
info = *reinterpret_cast<plFontFreeType::Options*>(init);
QDialog dlg;
Ui_FreeTypeBatch ui;
ui.setupUi(&dlg);
dlg.layout()->setSizeConstraint(QLayout::SetFixedSize);
ui.fPointSizes->setValidator(new NumListValidator(&dlg));
ui.fPointSizes->setText(QString::number(info.fSize));
ui.fFontName->setText(path.GetFileNameNoExt().c_str());
ui.fResolution->setValue(info.fScreenRes);
ui.fMaxChar->setValue(info.fMaxCharLimit);
if (info.fBitDepth == 1)
ui.fMonochrome->setChecked(true);
else
ui.fGrayscale->setChecked(true);
if (dlg.exec() == QDialog::Rejected)
return;
QStringList sSizes = ui.fPointSizes->text().split(' ', QString::SkipEmptyParts);
QList<int> iSizes;
for (const QString &s : sSizes)
iSizes.append(s.toInt());
info.fScreenRes = ui.fResolution->value();
info.fMaxCharLimit = ui.fMaxChar->value();
info.fBitDepth = (ui.fMonochrome->isChecked() ? 1 : 8);
QString outPath = QFileDialog::getExistingDirectory(this,
tr("Select a path to write the P2F fonts to:"),
QDir::current().absolutePath(), QFileDialog::ShowDirsOnly);
if (outPath.isEmpty())
return;
plString fontName = ui.fFontName->text().toUtf8().constData();
plString destPath = outPath.toUtf8().constData();
plMyBDFCallback callback(this);
callback.NumChars(iSizes.size());
for (int size : iSizes)
{
IMakeNewFont();
plFontFreeType *ft2Convert = reinterpret_cast<plFontFreeType *>(fFont);
info.fSize = size;
if (!ft2Convert->ImportFreeType(path, &info, nil))
{
QMessageBox::critical(this, tr("ERROR"), tr("Failure converting TrueType file"));
continue;
}
fFont->SetFace(fontName);
plFileName fileName = plFileName::Join(destPath,
plString::Format("%s-%d.p2f", fFont->GetFace().c_str(), fFont->GetSize()));
hsUNIXStream stream;
if (!stream.Open(fileName, "wb"))
QMessageBox::critical(this, tr("ERROR"), tr("Can't open file for writing"));
else
{
fFont->WriteRaw(&stream);
stream.Close();
}
callback.CharDone();
}
IUpdateInfo();
}
void plFontConverter::IImportFreeType(const plFileName &path)
{
enum { kBatchConvertAction = 100 };
plFontFreeType::Options info;
QDialog dlg;
Ui_FreeType ui;
ui.setupUi(&dlg);
dlg.layout()->setSizeConstraint(QLayout::SetFixedSize);
// Designer can't do this...
QPushButton *batchButton = new QPushButton(tr("&Batch..."), ui.fButtons);
ui.fButtons->addButton(batchButton, QDialogButtonBox::ResetRole);
connect(batchButton, &QPushButton::clicked, &dlg,
std::bind(&QDialog::done, &dlg, kBatchConvertAction));
ui.fPointSize->setValue(info.fSize);
ui.fResolution->setValue(info.fScreenRes);
ui.fMaxChar->setValue(info.fMaxCharLimit);
if (info.fBitDepth == 1)
ui.fMonochrome->setChecked(true);
else
ui.fGrayscale->setChecked(true);
int ret = dlg.exec();
info.fSize = ui.fPointSize->value();
info.fScreenRes = ui.fResolution->value();
info.fMaxCharLimit = ui.fMaxChar->value();
info.fBitDepth = (ui.fMonochrome->isChecked() ? 1 : 8);
if (ret == QDialog::Rejected)
return;
else if (ret == kBatchConvertAction)
{
IBatchFreeType(path);
return;
}
IMakeNewFont();
plMyBDFCallback callback(this);
plFontFreeType *ft2Convert = reinterpret_cast<plFontFreeType *>(fFont);
if (!ft2Convert->ImportFreeType(path, &info, &callback))
QMessageBox::critical(this, tr("ERROR"), tr("Failure converting TrueType file"));
IUpdateInfo();
}
void plFontConverter::IOpenP2F(const plFileName &path)
{
IMakeNewFont();
if (!fFont->LoadFromP2FFile(path))
QMessageBox::critical(this, tr("ERROR"), tr("Failure opening P2F file"));
IUpdateInfo();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationName("plFontConverter");
app.setWindowIcon(QIcon(":/icon1.ico"));
plResManager *rMgr = new plResManager;
hsgResMgr::Init( rMgr );
hsgResMgr::Init(rMgr);
DialogBox( gInstance, MAKEINTRESOURCE( IDD_MAINDIALOG ), nil, WndProc );
plFontConverter mainDialog;
mainDialog.show();
int retn = app.exec();
hsgResMgr::Shutdown();
return 0;
return retn;
}
/* Enable themes in Windows XP and later */
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")

86
Sources/Tools/plFontConverter/plFontConverter.h

@ -0,0 +1,86 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _plFontConverter_h
#define _plFontConverter_h
#include <QMainWindow>
class plFont;
class plFileName;
class plFontConverter : public QMainWindow
{
Q_OBJECT
public:
plFontConverter();
virtual ~plFontConverter();
private slots:
void OpenFNT();
void OpenBDF();
void OpenFON();
void OpenTTF();
void OpenP2F();
void ExportP2F();
protected:
virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event);
private:
class Ui_MainDialog *fUI;
plFont *fFont;
void IMakeFontGoAway();
void IMakeNewFont();
void IUpdateInfo();
void IImportFNT(const plFileName &path);
void IImportBDF(const plFileName &path);
void IImportFON(const plFileName &path);
void IBatchFreeType(const plFileName &path, void *init = nullptr);
void IImportFreeType(const plFileName &path);
void IOpenP2F(const plFileName &path);
};
#endif

756
Sources/Tools/plFontConverter/plFontConverterProc.cpp

@ -1,756 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "HeadSpin.h"
#include "hsWindows.h"
#include "res/resource.h"
#include <shlwapi.h>
#include <shellapi.h>
#include <shlobj.h>
#include <commdlg.h>
#include <commctrl.h>
#include <ctime>
#include "hsStream.h"
#include "hsResMgr.h"
#include "plFontFreeType.h"
#include "plGImage/plFont.h"
#include "plGImage/plMipmap.h"
#include "pnKeyedObject/plUoid.h"
#include "pnKeyedObject/plKeyImp.h"
extern HINSTANCE gInstance;
// My global font that i'm working on
plFont *gFont = nil;
// Preview bitmap
HDC gPreviewHDC = nil;
HBITMAP gPreviewBitmap = nil;
void IMakeFontGoAway( void )
{
if( gFont != nil )
{
plKeyImp *imp = (plKeyImp *)(gFont->GetKey());
if( imp != nil )
imp->SetObjectPtr( nil );
gFont = nil;
}
}
void IMakeNewFont( void )
{
IMakeFontGoAway();
gFont = new plFont();
}
BOOL CALLBACK AboutDialogProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
if( msg == WM_COMMAND )
EndDialog( hWnd, 0 );
return 0;
}
bool PromptForFile( HWND parent, const char *prompt, const char *filter, char *fileName, int fileNameMax, bool save )
{
OPENFILENAME openInfo;
memset( &openInfo, 0, sizeof( OPENFILENAME ) );
openInfo.hInstance = gInstance;
openInfo.hwndOwner = parent;
openInfo.lStructSize = sizeof( OPENFILENAME );
openInfo.lpstrFile = fileName;
openInfo.nMaxFile = fileNameMax;
openInfo.lpstrFilter = filter;
openInfo.lpstrTitle = prompt;
openInfo.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
if( !save )
openInfo.Flags |= OFN_READONLY;
if( save )
return GetSaveFileName( &openInfo ) ? true : false;
return GetOpenFileName( &openInfo ) ? true : false;
}
void IUpdateInfo( HWND hDlg )
{
const int TEST_STRING_SIZE = 512;
static wchar_t testString[ TEST_STRING_SIZE ] = L"The quick brown fox jumped over the lazy dog! ABCabc012345;,.";
if( gFont == nil )
{
SetDlgItemText( hDlg, IDC_FACE, "" );
SetDlgItemText( hDlg, IDC_FSIZE, "" );
SetDlgItemText( hDlg, IDC_STARTG, "" );
SetDlgItemText( hDlg, IDC_GCOUNT, "" );
SetDlgItemText( hDlg, IDC_WIDTH, "" );
SetDlgItemText( hDlg, IDC_HEIGHT, "" );
SetDlgItemText( hDlg, IDC_BPP, "" );
CheckDlgButton( hDlg, IDC_BOLD, false );
CheckDlgButton( hDlg, IDC_ITALIC, false );
return;
}
SetDlgItemText( hDlg, IDC_FACE, gFont->GetFace().c_str() );
SetDlgItemInt( hDlg, IDC_FSIZE, gFont->GetSize(), false );
SetDlgItemInt( hDlg, IDC_STARTG, gFont->GetFirstChar(), false );
SetDlgItemInt( hDlg, IDC_GCOUNT, gFont->GetNumChars(), false );
SetDlgItemInt( hDlg, IDC_WIDTH, gFont->GetBitmapWidth(), false );
SetDlgItemInt( hDlg, IDC_HEIGHT, gFont->GetBitmapHeight(), false );
SetDlgItemInt( hDlg, IDC_BPP, gFont->GetBitmapBPP(), false );
CheckDlgButton( hDlg, IDC_BOLD, gFont->IsFlagSet( plFont::kFlagBold ) );
CheckDlgButton( hDlg, IDC_ITALIC, gFont->IsFlagSet( plFont::kFlagItalic ) );
if( gPreviewHDC != nil )
{
DeleteObject( gPreviewHDC );
DeleteObject( gPreviewBitmap );
gPreviewHDC = nil;
gPreviewBitmap = nil;
}
// Get the size of our preview
RECT r;
GetClientRect( GetDlgItem( hDlg, IDC_PREVIEW ), &r );
MapWindowPoints( GetDlgItem( hDlg, IDC_PREVIEW ), hDlg, (POINT *)&r, 2 );
InvalidateRect( hDlg, &r, false );
if( gFont->GetNumChars() == 0 )
return;
// Our preview bitmap
HDC deskDC = GetDC( nil );
gPreviewHDC = CreateCompatibleDC( deskDC );
gPreviewBitmap = CreateCompatibleBitmap( deskDC, r.right - r.left, r.bottom - r.top );
SelectObject( gPreviewHDC, gPreviewBitmap );
ReleaseDC( nil, deskDC );
::GetDlgItemTextW( hDlg, IDC_PREVTEXT, testString, TEST_STRING_SIZE );
// Create us a mipmap to render onto, render onto it, then copy that to our DC
plMipmap *mip = new plMipmap( r.right - r.left, r.bottom - r.top, plMipmap::kARGB32Config, 1 );
memset( mip->GetImage(), 0xff, mip->GetWidth() * mip->GetHeight() * 4 );
gFont->SetRenderColor( 0xff000000 );
gFont->SetRenderFlag( plFont::kRenderClip, true );
gFont->SetRenderClipRect( 0, 0, (int16_t)(r.right - r.left), (int16_t)(r.bottom - r.top) );
uint16_t w, h, a, lastX, lastY;
uint32_t firstCC;
gFont->CalcStringExtents( testString, w, h, a, firstCC, lastX, lastY );
int cY = ( ( ( r.bottom - r.top ) - h ) >> 1 ) + a;
if( cY < 0 )
cY = 0;
else if( cY > r.bottom - r.top - 1 )
cY = r.bottom - r.top - 1;
memset( mip->GetAddr32( 8, cY ), 0xc0, ( r.right - r.left - 8 ) * 4 );
gFont->RenderString( mip, 8, cY, testString );
int x, y;
for( y = 0; y < r.bottom - r.top; y++ )
{
for( x = 0; x < r.right - r.left; x++ )
{
uint32_t color = *mip->GetAddr32( x, y );
hsColorRGBA rgba;
rgba.FromARGB32( color );
if( color != 0xffffffff && color != 0xff000000 )
{
int q = 0;
}
SetPixel( gPreviewHDC, x, y, RGB( rgba.r * 255.f, rgba.g * 255.f, rgba.b * 255.f) );
}
}
delete mip;
}
class plSetKeyObj : public hsKeyedObject
{
public:
void SetMyKey( const plKey &key )
{
SetKey( key );
}
};
class plMyBDFCallback : public plBDFConvertCallback
{
protected:
HWND fDlg;
clock_t fLastTime;
uint16_t fPoint;
void IPumpMessageQueue( void )
{
MSG msg;
while( PeekMessage( &msg, fDlg, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
public:
plMyBDFCallback( HWND dlg ) : fDlg( dlg ) {}
virtual void NumChars( uint16_t chars )
{
::SendDlgItemMessage( fDlg, IDC_PROGRESS, PBM_SETRANGE, 0, MAKELPARAM( 0, chars ) );
IPumpMessageQueue();
fLastTime = clock();
fPoint = 0;
}
virtual void CharDone( void )
{
fPoint++;
if( clock() - fLastTime > CLOCKS_PER_SEC / 16 )
{
::SendDlgItemMessage( fDlg, IDC_PROGRESS, PBM_SETPOS, fPoint, 0 );
IPumpMessageQueue();
fLastTime = clock();
}
}
};
BOOL CALLBACK ProgressWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
return 0;
}
void IImportFNT( HWND hWnd, const char *path )
{
IMakeNewFont();
if( !gFont->LoadFromFNT( path ) )
MessageBox( hWnd, "Failure converting FNT file", "ERROR", MB_OK | MB_ICONEXCLAMATION );
IUpdateInfo( hWnd );
}
void IImportBDF( HWND hWnd, const char *path )
{
IMakeNewFont();
HWND dialog = CreateDialog( gInstance, MAKEINTRESOURCE( IDD_PROGRESS ), hWnd, ProgressWndProc );
ShowWindow( dialog, SW_SHOW );
EnableWindow( hWnd, false );
plMyBDFCallback callback( dialog );
if( !gFont->LoadFromBDF( path, &callback ) )
MessageBox( hWnd, "Failure converting BDF file", "ERROR", MB_OK | MB_ICONEXCLAMATION );
DestroyWindow( dialog );
EnableWindow( hWnd, true );
IUpdateInfo( hWnd );
}
void IOpenP2F( HWND hWnd, const char *path )
{
IMakeNewFont();
if( !gFont->LoadFromP2FFile( path ) )
MessageBox( hWnd, "Failure opening P2F file", "ERROR", MB_OK | MB_ICONEXCLAMATION );
IUpdateInfo( hWnd );
}
struct ResRecord
{
HRSRC fHandle;
char fName[ 512 ];
ResRecord() { fHandle = nil; fName[ 0 ] = 0; }
ResRecord( HRSRC h, const char *n ) { fHandle = h; strncpy( fName, n, sizeof( fName ) ); }
};
BOOL CALLBACK ResEnumProc( HMODULE module, LPCTSTR type, LPTSTR name, LONG_PTR lParam )
{
HRSRC res = FindResource( module, name, type );
if( res != nil )
{
hsTArray<ResRecord *> *array = (hsTArray<ResRecord *> *)lParam;
array->Append( new ResRecord( res, name ) );
}
return true;
}
BOOL CALLBACK ResListWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
switch( message )
{
case WM_INITDIALOG:
{
SendDlgItemMessage( hWnd, IDC_RESLIST, LB_RESETCONTENT, 0, 0 );
hsTArray<ResRecord *> *array = (hsTArray<ResRecord *> *)lParam;
for( uint32_t i = 0; i < array->GetCount(); i++ )
{
ResRecord *rec = array->Get( i );
int idx = SendDlgItemMessage( hWnd, IDC_RESLIST, LB_ADDSTRING, 0, (LPARAM)rec->fName );
SendDlgItemMessage( hWnd, IDC_RESLIST, LB_SETITEMDATA, idx, (LPARAM)rec );
}
}
return 0;
case WM_COMMAND:
if( wParam == IDCANCEL )
EndDialog( hWnd, 0 );
else
{
int idx = SendDlgItemMessage( hWnd, IDC_RESLIST, LB_GETCURSEL, 0, 0 );
if( idx == LB_ERR )
EndDialog( hWnd, 0 );
else
{
ResRecord *rec = (ResRecord *)SendDlgItemMessage( hWnd, IDC_RESLIST, LB_GETITEMDATA, idx, 0 );
EndDialog( hWnd, (int)rec );
}
}
return true;
}
return 0;
}
void IImportFON( HWND hWnd, const char *path )
{
// FON files are really just resource modules
IMakeNewFont();
HMODULE file = LoadLibraryEx( path, nil, LOAD_LIBRARY_AS_DATAFILE | DONT_RESOLVE_DLL_REFERENCES );
if( file == nil )
{
char msg[ 512 ], msg2[ 1024 ];
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nil, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)msg, sizeof( msg ), nil );
sprintf( msg2, "Failure importing FON file: can't open as resource library (%s)", msg );
MessageBox( hWnd, msg2, "Error", MB_OK | MB_ICONEXCLAMATION );
}
else
{
hsTArray<ResRecord *> resList;
if( EnumResourceNames( file, "Font", ResEnumProc, (LPARAM)&resList ) )
{
// Put up a list of the resources so the user can choose which one
ResRecord *res = (ResRecord *)DialogBoxParam( gInstance, MAKEINTRESOURCE( IDD_FONCHOOSER ), hWnd,
ResListWndProc, (LPARAM)&resList );
if( res != nil )
{
// Load the resource into a ram stream
hsRAMStream stream;
HGLOBAL glob = LoadResource( file, res->fHandle );
if( glob != nil )
{
void *data = LockResource( glob );
if( data != nil )
{
stream.Write( SizeofResource( file, res->fHandle ), data );
stream.Rewind();
if( !gFont->LoadFromFNTStream( &stream ) )
MessageBox( hWnd, "Failure importing FON file: can't parse resource as FNT",
"Error", MB_OK | MB_ICONEXCLAMATION );
}
}
}
}
else
{
char msg[ 512 ], msg2[ 1024 ];
FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nil, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)msg, sizeof( msg ), nil );
sprintf( msg2, "Failure importing FON file: can't enumerate resources (%s)", msg );
MessageBox( hWnd, msg2, "Error", MB_OK | MB_ICONEXCLAMATION );
}
uint32_t i;
for( i = 0; i < resList.GetCount(); i++ )
delete resList[ i ];
resList.Reset();
FreeLibrary( file );
}
IUpdateInfo( hWnd );
}
BOOL CALLBACK FreeTypeDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
static plFontFreeType::Options *info;
switch( message )
{
case WM_INITDIALOG:
info = (plFontFreeType::Options *)lParam;
SetDlgItemInt( hWnd, IDC_PSIZE, info->fSize, false );
SetDlgItemInt( hWnd, IDC_RES, info->fScreenRes, false );
SetDlgItemInt( hWnd, IDC_MAXCHAR, info->fMaxCharLimit, false );
CheckRadioButton( hWnd, IDC_BITDEPTH, IDC_BITDEPTH2, info->fBitDepth == 1 ? IDC_BITDEPTH : IDC_BITDEPTH2 );
return 0;
case WM_COMMAND:
if( wParam == IDOK || wParam == IDCANCEL || wParam == IDC_BATCH )
{
info->fSize = GetDlgItemInt( hWnd, IDC_PSIZE, nil, false );
info->fScreenRes = GetDlgItemInt( hWnd, IDC_RES, nil, false );
info->fMaxCharLimit = GetDlgItemInt( hWnd, IDC_MAXCHAR, nil, false );
if( IsDlgButtonChecked( hWnd, IDC_BITDEPTH ) )
info->fBitDepth = 1;
else
info->fBitDepth = 8;
EndDialog( hWnd, wParam );
}
return 1;
}
return 0;
}
void IBatchFreeType( HWND hWnd, const char *path );
void IImportFreeType( HWND hWnd, const char *path )
{
static plFontFreeType::Options info;
int ret = DialogBoxParam( gInstance, MAKEINTRESOURCE( IDD_FREETYPE ), hWnd, FreeTypeDlgProc, (LPARAM)&info );
if( ret == IDCANCEL )
return;
else if( ret == IDC_BATCH )
{
IBatchFreeType( hWnd, path );
return;
}
IMakeNewFont();
HWND dialog = CreateDialog( gInstance, MAKEINTRESOURCE( IDD_PROGRESS ), hWnd, ProgressWndProc );
ShowWindow( dialog, SW_SHOW );
EnableWindow( hWnd, false );
plMyBDFCallback callback( dialog );
plFontFreeType *ft2Convert = (plFontFreeType *)gFont;
if( !ft2Convert->ImportFreeType( path, &info, &callback ) )
MessageBox( hWnd, "Failure converting TrueType file", "ERROR", MB_OK | MB_ICONEXCLAMATION );
DestroyWindow( dialog );
EnableWindow( hWnd, true );
IUpdateInfo( hWnd );
}
static uint8_t sNumSizes = 0;
static uint8_t sSizeArray[ 256 ];
static char sFontName[ 256 ]; // desired font name for FreeType conversions
BOOL CALLBACK FreeTypeBatchDlgProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
static plFontFreeType::Options *info;
switch( message )
{
case WM_INITDIALOG:
info = (plFontFreeType::Options *)lParam;
SetDlgItemText( hWnd, IDC_PSIZE, "12" );
SetDlgItemText( hWnd, IDC_FONTNAME, "Untitled" );
SetDlgItemInt( hWnd, IDC_RES, info->fScreenRes, false );
SetDlgItemInt( hWnd, IDC_MAXCHAR, info->fMaxCharLimit, false );
CheckRadioButton( hWnd, IDC_BITDEPTH, IDC_BITDEPTH2, info->fBitDepth == 1 ? IDC_BITDEPTH : IDC_BITDEPTH2 );
return 0;
case WM_COMMAND:
if( wParam == IDOK || wParam == IDCANCEL )
{
sNumSizes = 0;
char *c, *lastC, str[ 1024 ];
GetDlgItemText( hWnd, IDC_PSIZE, str, sizeof( str ) );
lastC = str;
while( ( c = strchr( lastC, ',' ) ) != nil && sNumSizes < 255 )
{
*c = 0;
sSizeArray[ sNumSizes++ ] = atoi( lastC );
lastC = c + 1;
}
sSizeArray[ sNumSizes++ ] = atoi( lastC );
info->fScreenRes = GetDlgItemInt( hWnd, IDC_RES, nil, false );
info->fMaxCharLimit = GetDlgItemInt( hWnd, IDC_MAXCHAR, nil, false );
if( IsDlgButtonChecked( hWnd, IDC_BITDEPTH ) )
info->fBitDepth = 1;
else
info->fBitDepth = 8;
GetDlgItemText( hWnd, IDC_FONTNAME, sFontName, sizeof(sFontName) );
EndDialog( hWnd, wParam );
}
return 1;
}
return 0;
}
void IBatchFreeType( HWND hWnd, const char *path )
{
static plFontFreeType::Options info;
if( DialogBoxParam( gInstance, MAKEINTRESOURCE( IDD_FREETYPEBATCH ), hWnd, FreeTypeBatchDlgProc, (LPARAM)&info ) == IDCANCEL )
return;
BROWSEINFO bInfo;
LPITEMIDLIST itemList;
LPMALLOC shMalloc;
static char destPath[ MAX_PATH ] = "";
memset( &bInfo, 0, sizeof( bInfo ) );
bInfo.hwndOwner = hWnd;
bInfo.pidlRoot = NULL;
bInfo.pszDisplayName = destPath;
bInfo.lpszTitle = "Select a path to write the P2F fonts to:";
bInfo.ulFlags = BIF_EDITBOX;
itemList = SHBrowseForFolder( &bInfo );
if( itemList != NULL )
{
SHGetPathFromIDList( itemList, destPath );
SHGetMalloc( &shMalloc );
shMalloc->Free( itemList );
shMalloc->Release();
}
else
return;
HWND dialog = CreateDialog( gInstance, MAKEINTRESOURCE( IDD_PROGRESS ), hWnd, ProgressWndProc );
ShowWindow( dialog, SW_SHOW );
EnableWindow( hWnd, false );
plMyBDFCallback callback( dialog );
callback.NumChars( sNumSizes );
uint8_t i;
for( i = 0; i < sNumSizes; i++ )
{
IMakeNewFont();
plFontFreeType *ft2Convert = (plFontFreeType *)gFont;
info.fSize = sSizeArray[ i ];
if( !ft2Convert->ImportFreeType( path, &info, nil ) )
{
MessageBox( hWnd, "Failure converting TrueType file", "ERROR", MB_OK | MB_ICONEXCLAMATION );
continue;
}
gFont->SetFace(sFontName);
char fileName[ MAX_PATH ];
sprintf( fileName, "%s\\%s-%d.p2f", destPath, gFont->GetFace().c_str(), gFont->GetSize() );
hsUNIXStream stream;
if( !stream.Open( fileName, "wb" ) )
MessageBox( hWnd, "Can't open file for writing", "Error", MB_OK | MB_ICONEXCLAMATION );
else
{
gFont->WriteRaw( &stream );
stream.Close();
}
callback.CharDone();
}
DestroyWindow( dialog );
EnableWindow( hWnd, true );
IUpdateInfo( hWnd );
}
BOOL CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
char fileName[ MAX_PATH ];
PAINTSTRUCT paintInfo;
HDC myDC;
RECT r;
switch( message )
{
case WM_PAINT:
myDC = BeginPaint( hWnd, &paintInfo );
GetClientRect( GetDlgItem( hWnd, IDC_PREVIEW ), &r );
MapWindowPoints( GetDlgItem( hWnd, IDC_PREVIEW ), hWnd, (POINT *)&r, 2 );
if( gPreviewHDC != nil )
BitBlt( myDC, r.left, r.top, r.right - r.left, r.bottom - r.top, gPreviewHDC, 0, 0, SRCCOPY );
else
FillRect( myDC, &r, GetSysColorBrush( COLOR_3DFACE ) );
DrawEdge( myDC, &r, EDGE_SUNKEN, BF_RECT );
EndPaint( hWnd, &paintInfo );
return 0;
case WM_INITDIALOG:
SendMessage( hWnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon( gInstance, MAKEINTRESOURCE( IDI_APPICON ) ) );
SetDlgItemTextW( hWnd, IDC_PREVTEXT, L"The quick brown fox jumped over the lazy dog! ABCabc012345;,." );
return 0;
case WM_COMMAND:
if( wParam == ID_FILE_ABOUT )
{
DialogBox( gInstance, MAKEINTRESOURCE( IDD_ABOUT ), hWnd, AboutDialogProc );
}
else if( wParam == ID_FILE_EXIT )
PostQuitMessage( 0 );
else if( wParam == ID_FILE_FNT )
{
fileName[ 0 ] = 0;
if( PromptForFile( hWnd, "Choose a FNT file to convert", "Windows FNT files\0*.fnt\0All files\0*.*\0", fileName, sizeof( fileName ), false ) )
IImportFNT( hWnd, fileName );
}
else if( wParam == ID_FILE_P2F )
{
fileName[ 0 ] = 0;
if( PromptForFile( hWnd, "Choose a P2F file to open", "Plasma 2 font files\0*.p2f\0All files\0*.*\0", fileName, sizeof( fileName ), false ) )
IOpenP2F( hWnd, fileName );
}
else if( wParam == ID_FILE_FON )
{
fileName[ 0 ] = 0;
if( PromptForFile( hWnd, "Choose a FON file to convert", "Windows FON files\0*.fon\0All files\0*.*\0", fileName, sizeof( fileName ), false ) )
IImportFON( hWnd, fileName );
}
else if( wParam == ID_FILE_TRUETYPE )
{
fileName[ 0 ] = 0;
if( PromptForFile( hWnd, "Choose a TrueType font to convert", "TrueType files\0*.ttf\0TrueType Collections\0*.ttc\0All files\0*.*\0", fileName, sizeof( fileName ), false ) )
IBatchFreeType( hWnd, fileName );
}
else if( wParam == ID_FILE_EXPORT )
{
// Grab updated values for the font
GetDlgItemText( hWnd, IDC_FACE, fileName, sizeof( fileName ) );
gFont->SetFace( fileName );
gFont->SetSize( GetDlgItemInt( hWnd, IDC_FSIZE, nil, false ) );
gFont->SetFlag( plFont::kFlagBold, IsDlgButtonChecked( hWnd, IDC_BOLD ) == BST_CHECKED );
gFont->SetFlag( plFont::kFlagItalic, IsDlgButtonChecked( hWnd, IDC_ITALIC ) == BST_CHECKED );
// Write out
sprintf( fileName, "%s-%d.p2f", gFont->GetFace().c_str(), gFont->GetSize() );
if( PromptForFile( hWnd, "Specify a file to export to", "Plasma 2 font files\0*.p2f\0", fileName, sizeof( fileName ), true ) )
{
hsUNIXStream stream;
if( !stream.Open( fileName, "wb" ) )
MessageBox( hWnd, "Can't open file for writing", "Error", MB_OK | MB_ICONEXCLAMATION );
else
{
/* sprintf( fileName, "%s-%d", gFont->GetFace(), gFont->GetSize() );
if( gFont->GetKey() == nil )
hsgResMgr::ResMgr()->NewKey( fileName, gFont, plLocation::kGlobalFixedLoc );
*/
gFont->WriteRaw( &stream );
stream.Close();
}
}
}
else if( LOWORD( wParam ) == IDC_PREVTEXT && HIWORD( wParam ) == EN_CHANGE )
{
IUpdateInfo( hWnd );
}
return true;
case WM_CLOSE:
PostQuitMessage( 0 );
return true;
case WM_DROPFILES:
{
int i, fileCount = DragQueryFile( (HDROP)wParam, -1, nil, 0 );
char path[ MAX_PATH ];
for( i = 0; i < fileCount; i++ )
{
if( DragQueryFile( (HDROP)wParam, i, path, sizeof( path ) ) > 0 )
{
char *ext = PathFindExtension( path );
if( stricmp( ext, ".fnt" ) == 0 )
IImportFNT( hWnd, path );
else if( stricmp( ext, ".bdf" ) == 0 )
IImportBDF( hWnd, path );
else if( stricmp( ext, ".fon" ) == 0 )
IImportFON( hWnd, path );
else if( stricmp( ext, ".exe" ) == 0 )
IImportFON( hWnd, path );
else if(( stricmp( ext, ".ttf" ) == 0 ) || ( stricmp( ext, ".ttc" ) == 0 ))
IImportFreeType( hWnd, path );
else if( stricmp( ext, ".p2f" ) == 0 )
IOpenP2F( hWnd, path );
else
// Try using our freeType converter
IImportFreeType( hWnd, path );
}
}
IUpdateInfo( hWnd );
}
break;
}
return 0;//DefWindowProc( hWnd, message, wParam, lParam );
}

8
Sources/Tools/plFontConverter/plFontFreeType.cpp

@ -58,7 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
bool plFontFreeType::ImportFreeType( const char *fontPath, Options *options, plBDFConvertCallback *callback )
bool plFontFreeType::ImportFreeType( const plFileName &fontPath, Options *options, plBDFConvertCallback *callback )
{
FT_Library ftLibrary;
@ -77,7 +77,7 @@ bool plFontFreeType::ImportFreeType( const char *fontPath, Options *options,
// Load our font that we're converting
FT_Face ftFace;
error = FT_New_Face( ftLibrary, fontPath, 0, &ftFace );
error = FT_New_Face( ftLibrary, fontPath.AsString().c_str(), 0, &ftFace );
if( error == FT_Err_Unknown_File_Format )
{
// Unsupported inport format
@ -100,9 +100,9 @@ bool plFontFreeType::ImportFreeType( const char *fontPath, Options *options,
FT_GlyphSlot ftSlot = ftFace->glyph;
FT_ULong ftChar;
FT_UInt ftIndex;
uint32_t numGlyphs = 0, totalHeight = 0, maxChar = 0, i;
uint32_t numGlyphs = 0, totalHeight = 0, maxChar = 0, i;
FT_Glyph ftGlyphs[ kMaxGlyphs ];
uint16_t glyphChars[ kMaxGlyphs ];
uint16_t glyphChars[ kMaxGlyphs ];
FT_Vector ftAdvances[ kMaxGlyphs ];
FT_BBox ftGlyphBox, ftFontBox;
FT_UInt previous = 0;

8
Sources/Tools/plFontConverter/plFontFreeType.h

@ -56,13 +56,13 @@ class plFontFreeType : public plFont
struct Options
{
uint8_t fSize;
bool fUseKerning;
bool fUseKerning;
uint8_t fBitDepth;
uint32_t fScreenRes;
uint32_t fMaxCharLimit;
Options() { fSize = 12; fUseKerning = false; fBitDepth = 1; fScreenRes = 96; fMaxCharLimit = 255; }
Options() : fSize(12), fUseKerning(false), fBitDepth(1), fScreenRes(96), fMaxCharLimit(255) { }
};
bool ImportFreeType( const char *fontPath, Options *options, plBDFConvertCallback *callback );
};
bool ImportFreeType( const plFileName &fontPath, Options *options, plBDFConvertCallback *callback );
};

115
Sources/Tools/plFontConverter/plFontPreview.cpp

@ -0,0 +1,115 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plFontPreview.h"
#include "plGImage/plFont.h"
#include "plGImage/plMipmap.h"
#include <QPainter>
#include <QPicture>
#include <memory>
void plFontPreview::Update(plFont *font, const QString &text)
{
fFont = font;
fText = text;
fPreview = QImage(width(), height(), QImage::Format_ARGB32);
if (fFont == nullptr) {
QPainter p(&fPreview);
p.fillRect(0, 0, width(), height(), Qt::white);
update();
return;
}
plString testString = text.toUtf8().constData();
// Create us a mipmap to render onto, render onto it, then copy that to our DC
plMipmap *mip = new plMipmap(width(), height(), plMipmap::kARGB32Config, 1);
memset(mip->GetImage(), 0xff, mip->GetWidth() * mip->GetHeight() * 4);
fFont->SetRenderColor(0xff000000);
fFont->SetRenderFlag(plFont::kRenderClip, true);
fFont->SetRenderClipRect(0, 0, (int16_t)width(), (int16_t)height());
uint16_t w, h, a, lastX, lastY;
uint32_t firstCC;
fFont->CalcStringExtents(testString, w, h, a, firstCC, lastX, lastY);
int cY = ((height() - h) >> 1) + a;
if (cY < 0)
cY = 0;
else if (cY > height() - 1)
cY = height() - 1;
memset(mip->GetAddr32(8, cY), 0xc0, (width() - 8) * 4);
fFont->RenderString(mip, 8, cY, testString);
int x, y;
for (y = 0; y < height(); y++) {
for (x = 0; x < width(); x++) {
uint32_t color = *mip->GetAddr32(x, y);
if (color != 0xffffffff && color != 0xff000000)
{
int q = 0;
}
// One pixel at a time? Surely we can do better...
// But for now this is a pure port
fPreview.setPixel(x, y, color | 0xff000000);
}
}
delete mip;
update();
}
void plFontPreview::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.drawImage(0, 0, fPreview);
QFrame::paintEvent(event);
}

54
Sources/Tools/plFontConverter/hsCodecManagerStub.cpp → Sources/Tools/plFontConverter/plFontPreview.h

@ -39,45 +39,33 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
#include "hsCodecManager.h"
#include "plMipmap.h"
#ifndef _plFontPreview_h
#define _plFontPreview_h
#include <QFrame>
hsCodecManager& hsCodecManager::Instance()
{
static hsCodecManager the_instance;
static bool initialized = false;
if (!initialized)
{
initialized = true;
}
return the_instance;
}
hsCodecManager::hsCodecManager()
{
}
class plFont;
plMipmap *hsCodecManager::CreateCompressedMipmap(uint32_t compressionFormat, plMipmap *uncompressed)
class plFontPreview : public QFrame
{
return nil;
}
public:
plFontPreview(QWidget *parent = nullptr) : QFrame(parent), fFont(nullptr) { }
plMipmap *hsCodecManager::CreateUncompressedMipmap(plMipmap *compressed, uint8_t bitDepth)
{
return nil;
void Update(plFont *font, const QString &text);
}
protected:
virtual void paintEvent(QPaintEvent *event);
bool hsCodecManager::ColorizeCompMipmap( plMipmap *bMap, const uint8_t *colorMask )
{
return false;
}
virtual void resizeEvent(QResizeEvent *event)
{
QFrame::resizeEvent(event);
Update(fFont, fText);
}
bool hsCodecManager::Register(hsCodec *codec, uint32_t compressionFormat, hsScalar priority)
{
return true;
}
private:
plFont *fFont;
QString fText;
QImage fPreview;
};
#endif

81
Sources/Tools/plFontConverter/res/FonChooser.ui

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FonChooser</class>
<widget class="QDialog" name="FonChooser">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>260</height>
</rect>
</property>
<property name="windowTitle">
<string>FON Resource List</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Choose which resource to import:</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="fResourceList"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>FonChooser</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>FonChooser</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

137
Sources/Tools/plFontConverter/res/FreeType.ui

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FreeType</class>
<widget class="QDialog" name="FreeType">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>95</height>
</rect>
</property>
<property name="windowTitle">
<string>FreeType Import Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Render Point &amp;Size:</string>
</property>
<property name="buddy">
<cstring>fPointSize</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="fPointSize">
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Max &amp;Character:</string>
</property>
<property name="buddy">
<cstring>fMaxChar</cstring>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="fMaxChar">
<property name="maximum">
<number>1114111</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Screen &amp;Resolution:</string>
</property>
<property name="buddy">
<cstring>fResolution</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="fResolution">
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="fMonochrome">
<property name="text">
<string>&amp;Monochrome</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="fGrayscale">
<property name="text">
<string>&amp;Grayscale</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="fButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>fButtons</sender>
<signal>accepted()</signal>
<receiver>FreeType</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>fButtons</sender>
<signal>rejected()</signal>
<receiver>FreeType</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

159
Sources/Tools/plFontConverter/res/FreeTypeBatch.ui

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FreeTypeBatch</class>
<widget class="QDialog" name="FreeTypeBatch">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>357</width>
<height>181</height>
</rect>
</property>
<property name="windowTitle">
<string>FreeType Import Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Render Point &amp;Sizes:</string>
</property>
<property name="buddy">
<cstring>fPointSizes</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fPointSizes"/>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Common Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="fMonochrome">
<property name="text">
<string>&amp;Monochrome</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="fGrayscale">
<property name="text">
<string>&amp;Grayscale</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Screen &amp;Resolution:</string>
</property>
<property name="buddy">
<cstring>fResolution</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Max &amp;Character:</string>
</property>
<property name="buddy">
<cstring>fMaxChar</cstring>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QSpinBox" name="fMaxChar">
<property name="maximum">
<number>1114111</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="fResolution">
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Font &amp;Name:</string>
</property>
<property name="buddy">
<cstring>fFontName</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fFontName"/>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>FreeTypeBatch</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>FreeTypeBatch</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

355
Sources/Tools/plFontConverter/res/MainDialog.ui

@ -0,0 +1,355 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainDialog</class>
<widget class="QMainWindow" name="MainDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>316</height>
</rect>
</property>
<property name="windowTitle">
<string>plFontConverter</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout">
<property name="spacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>F&amp;ace:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>fFaceName</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="fFaceName"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="fExportButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Export P2F...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&amp;Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>fFontSize</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSpinBox" name="fFontSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fBold">
<property name="text">
<string>&amp;Bold</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="fItalic">
<property name="text">
<string>&amp;Italic</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<property name="spacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Starting Glyph:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="fStartingGlyph">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Glyph Count:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="fGlyphCount">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bitmap Width:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="fBitmapWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Bitmap Height:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="fBitmapHeight">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>BPP:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QLineEdit" name="fBPP">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="plFontPreview" name="fPreview">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="fSampleText">
<property name="text">
<string>The quick brown fox jumped over the lazy dog! ABCabc012345;,.</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="fImportFNTAction"/>
<addaction name="fImportBDFAction"/>
<addaction name="fImportFONAction"/>
<addaction name="fImportTTFAction"/>
<addaction name="separator"/>
<addaction name="fOpenAction"/>
<addaction name="fExportAction"/>
<addaction name="separator"/>
<addaction name="fExitAction"/>
</widget>
<widget class="QMenu" name="menu_Help">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="fAboutAction"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Help"/>
</widget>
<action name="fImportFNTAction">
<property name="text">
<string>Import &amp;FNT...</string>
</property>
</action>
<action name="fImportBDFAction">
<property name="text">
<string>Import &amp;BDF...</string>
</property>
</action>
<action name="fImportFONAction">
<property name="text">
<string>Import FO&amp;N...</string>
</property>
</action>
<action name="fOpenAction">
<property name="text">
<string>&amp;Open P2F...</string>
</property>
</action>
<action name="fImportTTFAction">
<property name="text">
<string>Import &amp;TrueType...</string>
</property>
</action>
<action name="fExportAction">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>&amp;Export P2F...</string>
</property>
</action>
<action name="fExitAction">
<property name="text">
<string>E&amp;xit</string>
</property>
</action>
<action name="fAboutAction">
<property name="text">
<string>&amp;About...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>plFontPreview</class>
<extends>QFrame</extends>
<header>plFontPreview.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

5
Sources/Tools/plFontConverter/res/plFontConverter.qrc

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>icon1.ico</file>
</qresource>
</RCC>

269
Sources/Tools/plFontConverter/res/plFontConverter.rc

@ -1,270 +1 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define IDC_STATIC (-1) // all static controls
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_APPICON ICON DISCARDABLE "icon1.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 247, 57
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About plFontConverter"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,190,7,50,14
ICON IDI_APPICON,IDC_STATIC,11,8,20,20
LTEXT "plFontConverter\n\nA simple Plasma 2.0 utility for converting public font formats into our own bitmap font format",
IDC_STATIC,40,7,140,43
END
IDD_MAINDIALOG DIALOGEX 100, 100, 241, 170
STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE |
WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "plFontConverter"
MENU IDR_APPMENU
FONT 8, "MS Sans Serif", 0, 0, 0x1
BEGIN
PUSHBUTTON "Export P2F...",ID_FILE_EXPORT,184,7,50,14
LTEXT "Face:",IDC_STATIC,7,9,19,8
LTEXT "Size:",IDC_STATIC,10,26,16,8
EDITTEXT IDC_FACE,27,7,148,14,ES_AUTOHSCROLL
EDITTEXT IDC_FSIZE,27,24,30,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "Starting glyph:",IDC_STATIC,10,43,46,8
LTEXT "Glyph count:",IDC_STATIC,87,43,41,8
LTEXT "0",IDC_STARTG,58,42,22,12,SS_SUNKEN
LTEXT "0",IDC_GCOUNT,130,42,22,12,SS_SUNKEN
LTEXT "Bitmap width:",IDC_STATIC,13,58,43,8
LTEXT "0",IDC_WIDTH,58,57,22,12,SS_SUNKEN
LTEXT "Bitmap height:",IDC_STATIC,83,58,46,8
LTEXT "0",IDC_HEIGHT,130,57,22,12,SS_SUNKEN
LTEXT "BPP:",IDC_STATIC,160,57,17,8
LTEXT "0",IDC_BPP,179,56,22,12,SS_SUNKEN
CONTROL "",IDC_PREVIEW,"Static",SS_WHITEFRAME | SS_SUNKEN | NOT
WS_VISIBLE,7,73,227,73
CONTROL "Bold",IDC_BOLD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,64,
26,30,10
CONTROL "Italic",IDC_ITALIC,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,97,26,31,10
EDITTEXT IDC_PREVTEXT,7,149,227,14,ES_AUTOHSCROLL
END
IDD_FONCHOOSER DIALOG DISCARDABLE 0, 0, 166, 161
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FON Resource List"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,109,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,109,24,50,14
LTEXT "Choose which resource to import:",IDC_STATIC,7,7,93,18
LISTBOX IDC_RESLIST,7,27,97,127,LBS_SORT | LBS_NOINTEGRALHEIGHT |
WS_VSCROLL | WS_TABSTOP
END
IDD_PROGRESS DIALOG DISCARDABLE 0, 0, 230, 25
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Importing font..."
FONT 8, "MS Sans Serif"
BEGIN
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH |
WS_BORDER,7,7,216,11
END
IDD_FREETYPE DIALOG DISCARDABLE 0, 0, 234, 68
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FreeType Import Options"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,177,47,50,14
PUSHBUTTON "Cancel",IDCANCEL,115,47,50,14
LTEXT "Render Point Size:",IDC_STATIC,7,10,60,8
EDITTEXT IDC_PSIZE,70,8,40,14,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Monochrome",IDC_BITDEPTH,"Button",BS_AUTORADIOBUTTON,
120,27,57,10
CONTROL "Grayscale",IDC_BITDEPTH2,"Button",BS_AUTORADIOBUTTON,
180,27,47,10
LTEXT "Screen Resolution:",IDC_STATIC,7,28,61,8
EDITTEXT IDC_RES,70,26,40,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "Max Character:",IDC_STATIC,132,10,49,8
EDITTEXT IDC_MAXCHAR,183,8,40,14,ES_AUTOHSCROLL | ES_NUMBER
PUSHBUTTON "Batch...",IDC_BATCH,7,47,50,14
END
IDD_FREETYPEBATCH DIALOG DISCARDABLE 0, 0, 234, 114
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "FreeType Import Options"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,177,93,50,14
PUSHBUTTON "Cancel",IDCANCEL,115,93,50,14
LTEXT "Render Point Sizes:",IDC_STATIC,7,10,63,8
EDITTEXT IDC_PSIZE,71,8,156,14,ES_AUTOHSCROLL
CONTROL "Monochrome",IDC_BITDEPTH,"Button",BS_AUTORADIOBUTTON,58,
58,57,10
CONTROL "Grayscale",IDC_BITDEPTH2,"Button",BS_AUTORADIOBUTTON,
118,58,47,10
LTEXT "Screen Resolution:",IDC_STATIC,117,41,61,8
EDITTEXT IDC_RES,180,39,40,14,ES_AUTOHSCROLL | ES_NUMBER
LTEXT "Max Character:",IDC_STATIC,15,41,49,8
EDITTEXT IDC_MAXCHAR,67,39,40,14,ES_AUTOHSCROLL | ES_NUMBER
GROUPBOX "Common Settings",IDC_STATIC,7,27,220,45
LTEXT "Font name:",IDC_STATIC,7,77,36,8
EDITTEXT IDC_FONTNAME,49,75,178,14,ES_AUTOHSCROLL
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUT, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 240
TOPMARGIN, 7
BOTTOMMARGIN, 50
END
IDD_MAINDIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 234
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
IDD_FONCHOOSER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 159
TOPMARGIN, 7
BOTTOMMARGIN, 154
END
IDD_PROGRESS, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 223
TOPMARGIN, 7
BOTTOMMARGIN, 18
END
IDD_FREETYPE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 227
TOPMARGIN, 7
BOTTOMMARGIN, 61
END
IDD_FREETYPEBATCH, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 227
TOPMARGIN, 8
BOTTOMMARGIN, 107
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_APPMENU MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "Import FNT...", ID_FILE_FNT
MENUITEM "Import BDF...", ID_FILE_BDF
MENUITEM "Import FON...", ID_FILE_FON
MENUITEM "Open P2F...", ID_FILE_P2F
MENUITEM "Batch Convert TrueType...", ID_FILE_TRUETYPE
MENUITEM SEPARATOR
MENUITEM "Export P2F...", ID_FILE_EXPORT
MENUITEM SEPARATOR
MENUITEM "About...", ID_FILE_ABOUT
MENUITEM "Exit", ID_FILE_EXIT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE
BEGIN
"A", ID_FILE_ABOUT, VIRTKEY, CONTROL, NOINVERT
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

52
Sources/Tools/plFontConverter/res/resource.h

@ -1,52 +0,0 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by plFontConverter.rc
//
#define IDI_APPICON 101
#define IDR_APPMENU 102
#define IDD_MAINDIALOG 103
#define IDD_ABOUT 104
#define IDD_FONCHOOSER 105
#define IDR_ACCELERATOR1 106
#define IDD_PROGRESS 106
#define IDD_FREETYPE 107
#define IDD_FREETYPEBATCH 108
#define IDC_FACE 1002
#define IDC_FSIZE 1003
#define IDC_STARTG 1004
#define IDC_GCOUNT 1005
#define IDC_WIDTH 1006
#define IDC_HEIGHT 1007
#define IDC_BPP 1008
#define IDC_PREVIEW 1010
#define IDC_RESLIST 1011
#define IDC_BOLD 1012
#define IDC_ITALIC 1013
#define IDC_PROGRESS 1014
#define IDC_PREVTEXT 1015
#define IDC_PSIZE 1016
#define IDC_BITDEPTH 1017
#define IDC_BITDEPTH2 1018
#define IDC_RES 1019
#define IDC_MAXCHAR 1020
#define IDC_BATCH 1021
#define IDC_FONTNAME 1022
#define ID_FILE_FNT 40000
#define ID_FILE_EXPORT 40001
#define ID_FILE_EXIT 40002
#define ID_FILE_BDF 40003
#define ID_FILE_ABOUT 40004
#define ID_FILE_P2F 40005
#define ID_FILE_FON 40006
#define ID_FILE_TRUETYPE 40007
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 108
#define _APS_NEXT_COMMAND_VALUE 40008
#define _APS_NEXT_CONTROL_VALUE 1023
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

10
Sources/Tools/plLocalizationEditor/CMakeLists.txt

@ -20,11 +20,11 @@ set(plLocalizationEditor_SOURCES
plLocTreeView.cpp
)
set(plLocalizationEditor_RESOURCES
res/plLocalizationEditor.rc
res/resource.h
res/icon1.ico
)
if(WIN32)
set(plLocalizationEditor_SOURCES ${plLocalizationEditor_SOURCES}
res/plLocalizationEditor.rc
)
endif()
set(plLocalizationEditor_RCC_SOURCES
res/plLocalizationEditor.qrc

6
Sources/Tools/plLocalizationEditor/plAddDlgs.cpp

@ -54,10 +54,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <vector>
// very simple validator for edit controls (and combo boxes) so that they only accept alphanumeric values
class AlphaNumbericValidator : public QValidator
class AlphaNumericValidator : public QValidator
{
public:
AlphaNumbericValidator(QObject *parent = nullptr) : QValidator(parent) { }
AlphaNumericValidator(QObject *parent = nullptr) : QValidator(parent) { }
virtual State validate(QString &input, int &pos) const override
{
@ -79,7 +79,7 @@ plAddElementDlg::plAddElementDlg(const plString &parentPath, QWidget *parent)
fUI->setupUi(this);
layout()->setSizeConstraint(QLayout::SetFixedSize);
AlphaNumbericValidator *validator = new AlphaNumbericValidator(this);
AlphaNumericValidator *validator = new AlphaNumericValidator(this);
fUI->fParentAge->setValidator(validator);
fUI->fParentSet->setValidator(validator);
fUI->fElementName->setValidator(validator);

15
Sources/Tools/plLocalizationEditor/res/AddElement.ui

@ -27,7 +27,10 @@
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Parent Age:</string>
<string>Parent &amp;Age:</string>
</property>
<property name="buddy">
<cstring>fParentAge</cstring>
</property>
</widget>
</item>
@ -47,7 +50,10 @@
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Parent Set:</string>
<string>Parent &amp;Set:</string>
</property>
<property name="buddy">
<cstring>fParentSet</cstring>
</property>
</widget>
</item>
@ -67,7 +73,10 @@
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Element Name:</string>
<string>&amp;Element Name:</string>
</property>
<property name="buddy">
<cstring>fElementName</cstring>
</property>
</widget>
</item>

5
Sources/Tools/plLocalizationEditor/res/AddLocalization.ui

@ -27,7 +27,10 @@
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Language</string>
<string>&amp;Language</string>
</property>
<property name="buddy">
<cstring>fLanguage</cstring>
</property>
</widget>
</item>

9
Sources/Tools/plLocalizationEditor/res/EditDialog.ui

@ -56,7 +56,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Add</string>
<string>&amp;Add</string>
</property>
</widget>
</item>
@ -66,7 +66,7 @@
<bool>false</bool>
</property>
<property name="text">
<string>Delete</string>
<string>&amp;Delete</string>
</property>
</widget>
</item>
@ -82,7 +82,10 @@
<item>
<widget class="QLabel" name="fTextPathLabel">
<property name="text">
<string>Text:</string>
<string>&amp;Text:</string>
</property>
<property name="buddy">
<cstring>fLocalizationText</cstring>
</property>
</widget>
</item>

1
Sources/Tools/plLocalizationEditor/res/plLocalizationEditor.rc

@ -0,0 +1 @@
IDI_APPICON ICON DISCARDABLE "icon1.ico"
Loading…
Cancel
Save