From f0cc75b8a9ee095296dd467dc9a54d75a38d1e06 Mon Sep 17 00:00:00 2001 From: andryblack Date: Tue, 4 Oct 2011 01:02:54 +0400 Subject: [PATCH] move to src folder --- .gitignore | 5 + FontBuilder.pro | 156 ++++++------ .../abstractexporter.cpp | 0 abstractexporter.h => src/abstractexporter.h | 0 .../abstractimagewriter.cpp | 0 .../abstractimagewriter.h | 0 .../abstractlayouter.cpp | 0 abstractlayouter.h => src/abstractlayouter.h | 0 .../charactersframe.cpp | 0 charactersframe.h => src/charactersframe.h | 0 charactersframe.ui => src/charactersframe.ui | 0 charmapdialog.cpp => src/charmapdialog.cpp | 0 charmapdialog.h => src/charmapdialog.h | 0 charmapdialog.ui => src/charmapdialog.ui | 0 .../charsselectwidget.cpp | 0 .../charsselectwidget.h | 0 colorbutton.cpp => src/colorbutton.cpp | 0 colorbutton.h => src/colorbutton.h | 0 .../exporterfactory.cpp | 0 exporterfactory.h => src/exporterfactory.h | 0 {exporters => src/exporters}/divoexporter.cpp | 0 {exporters => src/exporters}/divoexporter.h | 0 {exporters => src/exporters}/ghlexporter.cpp | 0 {exporters => src/exporters}/ghlexporter.h | 0 {exporters => src/exporters}/luaexporter.cpp | 224 +++++++++--------- {exporters => src/exporters}/luaexporter.h | 98 ++++---- {exporters => src/exporters}/nglexporter.cpp | 0 {exporters => src/exporters}/nglexporter.h | 0 {exporters => src/exporters}/zfiexporter.cpp | 0 {exporters => src/exporters}/zfiexporter.h | 0 fontbuilder.cpp => src/fontbuilder.cpp | 0 fontbuilder.h => src/fontbuilder.h | 0 fontbuilder.ui => src/fontbuilder.ui | 0 fontconfig.cpp => src/fontconfig.cpp | 0 fontconfig.h => src/fontconfig.h | 0 fontdrawwidget.cpp => src/fontdrawwidget.cpp | 0 fontdrawwidget.h => src/fontdrawwidget.h | 0 fontloader.cpp => src/fontloader.cpp | 0 fontloader.h => src/fontloader.h | 0 .../fontoptionsframe.cpp | 0 fontoptionsframe.h => src/fontoptionsframe.h | 0 .../fontoptionsframe.ui | 0 fontrenderer.cpp => src/fontrenderer.cpp | 0 fontrenderer.h => src/fontrenderer.h | 0 .../fontselectframe.cpp | 0 fontselectframe.h => src/fontselectframe.h | 0 fontselectframe.ui => src/fontselectframe.ui | 0 fonttestframe.cpp => src/fonttestframe.cpp | 0 fonttestframe.h => src/fonttestframe.h | 0 fonttestframe.ui => src/fonttestframe.ui | 0 fonttestwidget.cpp => src/fonttestwidget.cpp | 0 fonttestwidget.h => src/fonttestwidget.h | 0 {image => src/image}/builtinimagewriter.cpp | 0 {image => src/image}/builtinimagewriter.h | 0 {image => src/image}/targawriter.cpp | 0 {image => src/image}/targawriter.h | 0 .../imagewriterfactory.cpp | 0 .../imagewriterfactory.h | 0 layoutchar.h => src/layoutchar.h | 0 layoutconfig.cpp => src/layoutconfig.cpp | 0 layoutconfig.h => src/layoutconfig.h | 0 .../layoutconfigframe.cpp | 0 .../layoutconfigframe.h | 0 .../layoutconfigframe.ui | 0 layoutdata.cpp => src/layoutdata.cpp | 0 layoutdata.h => src/layoutdata.h | 0 .../layouterfactory.cpp | 0 layouterfactory.h => src/layouterfactory.h | 0 {layouters => src/layouters}/boxlayouter.cpp | 0 {layouters => src/layouters}/boxlayouter.h | 0 {layouters => src/layouters}/linelayouter.cpp | 0 {layouters => src/layouters}/linelayouter.h | 0 main.cpp => src/main.cpp | 0 mainwindow.cpp => src/mainwindow.cpp | 0 mainwindow.h => src/mainwindow.h | 0 mainwindow.ui => src/mainwindow.ui | 0 outputconfig.cpp => src/outputconfig.cpp | 0 outputconfig.h => src/outputconfig.h | 0 outputframe.cpp => src/outputframe.cpp | 0 outputframe.h => src/outputframe.h | 0 outputframe.ui => src/outputframe.ui | 0 rendererdata.h => src/rendererdata.h | 0 82 files changed, 244 insertions(+), 239 deletions(-) create mode 100644 .gitignore rename abstractexporter.cpp => src/abstractexporter.cpp (100%) rename abstractexporter.h => src/abstractexporter.h (100%) rename abstractimagewriter.cpp => src/abstractimagewriter.cpp (100%) rename abstractimagewriter.h => src/abstractimagewriter.h (100%) rename abstractlayouter.cpp => src/abstractlayouter.cpp (100%) rename abstractlayouter.h => src/abstractlayouter.h (100%) rename charactersframe.cpp => src/charactersframe.cpp (100%) rename charactersframe.h => src/charactersframe.h (100%) rename charactersframe.ui => src/charactersframe.ui (100%) rename charmapdialog.cpp => src/charmapdialog.cpp (100%) rename charmapdialog.h => src/charmapdialog.h (100%) rename charmapdialog.ui => src/charmapdialog.ui (100%) rename charsselectwidget.cpp => src/charsselectwidget.cpp (100%) rename charsselectwidget.h => src/charsselectwidget.h (100%) rename colorbutton.cpp => src/colorbutton.cpp (100%) rename colorbutton.h => src/colorbutton.h (100%) rename exporterfactory.cpp => src/exporterfactory.cpp (100%) rename exporterfactory.h => src/exporterfactory.h (100%) rename {exporters => src/exporters}/divoexporter.cpp (100%) rename {exporters => src/exporters}/divoexporter.h (100%) rename {exporters => src/exporters}/ghlexporter.cpp (100%) rename {exporters => src/exporters}/ghlexporter.h (100%) rename {exporters => src/exporters}/luaexporter.cpp (97%) rename {exporters => src/exporters}/luaexporter.h (97%) rename {exporters => src/exporters}/nglexporter.cpp (100%) rename {exporters => src/exporters}/nglexporter.h (100%) rename {exporters => src/exporters}/zfiexporter.cpp (100%) rename {exporters => src/exporters}/zfiexporter.h (100%) rename fontbuilder.cpp => src/fontbuilder.cpp (100%) rename fontbuilder.h => src/fontbuilder.h (100%) rename fontbuilder.ui => src/fontbuilder.ui (100%) rename fontconfig.cpp => src/fontconfig.cpp (100%) rename fontconfig.h => src/fontconfig.h (100%) rename fontdrawwidget.cpp => src/fontdrawwidget.cpp (100%) rename fontdrawwidget.h => src/fontdrawwidget.h (100%) rename fontloader.cpp => src/fontloader.cpp (100%) rename fontloader.h => src/fontloader.h (100%) rename fontoptionsframe.cpp => src/fontoptionsframe.cpp (100%) rename fontoptionsframe.h => src/fontoptionsframe.h (100%) rename fontoptionsframe.ui => src/fontoptionsframe.ui (100%) rename fontrenderer.cpp => src/fontrenderer.cpp (100%) rename fontrenderer.h => src/fontrenderer.h (100%) rename fontselectframe.cpp => src/fontselectframe.cpp (100%) rename fontselectframe.h => src/fontselectframe.h (100%) rename fontselectframe.ui => src/fontselectframe.ui (100%) rename fonttestframe.cpp => src/fonttestframe.cpp (100%) rename fonttestframe.h => src/fonttestframe.h (100%) rename fonttestframe.ui => src/fonttestframe.ui (100%) rename fonttestwidget.cpp => src/fonttestwidget.cpp (100%) rename fonttestwidget.h => src/fonttestwidget.h (100%) rename {image => src/image}/builtinimagewriter.cpp (100%) rename {image => src/image}/builtinimagewriter.h (100%) rename {image => src/image}/targawriter.cpp (100%) rename {image => src/image}/targawriter.h (100%) rename imagewriterfactory.cpp => src/imagewriterfactory.cpp (100%) rename imagewriterfactory.h => src/imagewriterfactory.h (100%) rename layoutchar.h => src/layoutchar.h (100%) rename layoutconfig.cpp => src/layoutconfig.cpp (100%) rename layoutconfig.h => src/layoutconfig.h (100%) rename layoutconfigframe.cpp => src/layoutconfigframe.cpp (100%) rename layoutconfigframe.h => src/layoutconfigframe.h (100%) rename layoutconfigframe.ui => src/layoutconfigframe.ui (100%) rename layoutdata.cpp => src/layoutdata.cpp (100%) rename layoutdata.h => src/layoutdata.h (100%) rename layouterfactory.cpp => src/layouterfactory.cpp (100%) rename layouterfactory.h => src/layouterfactory.h (100%) rename {layouters => src/layouters}/boxlayouter.cpp (100%) rename {layouters => src/layouters}/boxlayouter.h (100%) rename {layouters => src/layouters}/linelayouter.cpp (100%) rename {layouters => src/layouters}/linelayouter.h (100%) rename main.cpp => src/main.cpp (100%) rename mainwindow.cpp => src/mainwindow.cpp (100%) rename mainwindow.h => src/mainwindow.h (100%) rename mainwindow.ui => src/mainwindow.ui (100%) rename outputconfig.cpp => src/outputconfig.cpp (100%) rename outputconfig.h => src/outputconfig.h (100%) rename outputframe.cpp => src/outputframe.cpp (100%) rename outputframe.h => src/outputframe.h (100%) rename outputframe.ui => src/outputframe.ui (100%) rename rendererdata.h => src/rendererdata.h (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00c9b65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +Makefile +Makefile.* +object_script.* +.obj +bin \ No newline at end of file diff --git a/FontBuilder.pro b/FontBuilder.pro index 862e427..febc2df 100644 --- a/FontBuilder.pro +++ b/FontBuilder.pro @@ -32,83 +32,83 @@ # ------------------------------------------------- TARGET = FontBuilder TEMPLATE = app -SOURCES += main.cpp \ - fontbuilder.cpp \ - colorbutton.cpp \ - fontselectframe.cpp \ - fontoptionsframe.cpp \ - fontrenderer.cpp \ - charactersframe.cpp \ - fontconfig.cpp \ - abstractlayouter.cpp \ - layoutconfig.cpp \ - layoutdata.cpp \ - layouters/linelayouter.cpp \ - layouterfactory.cpp \ - layouters/boxlayouter.cpp \ - layoutconfigframe.cpp \ - outputconfig.cpp \ - outputframe.cpp \ - abstractexporter.cpp \ - exporters/ghlexporter.cpp \ - exporterfactory.cpp \ - abstractimagewriter.cpp \ - imagewriterfactory.cpp \ - image/builtinimagewriter.cpp \ - exporters/zfiexporter.cpp \ - image/targawriter.cpp \ - fonttestframe.cpp \ - fonttestwidget.cpp \ - exporters/divoexporter.cpp \ - charmapdialog.cpp \ - charsselectwidget.cpp \ - exporters/nglexporter.cpp \ - exporters/luaexporter.cpp \ - fontdrawwidget.cpp \ - fontloader.cpp -HEADERS += fontbuilder.h \ - colorbutton.h \ - fontselectframe.h \ - fontoptionsframe.h \ - fontrenderer.h \ - charactersframe.h \ - fontconfig.h \ - rendererdata.h \ - abstractlayouter.h \ - layoutconfig.h \ - layoutdata.h \ - layouters/linelayouter.h \ - layouterfactory.h \ - layoutchar.h \ - layouters/boxlayouter.h \ - layoutconfigframe.h \ - outputconfig.h \ - outputframe.h \ - abstractexporter.h \ - exporters/ghlexporter.h \ - exporterfactory.h \ - abstractimagewriter.h \ - imagewriterfactory.h \ - image/builtinimagewriter.h \ - exporters/zfiexporter.h \ - image/targawriter.h \ - fonttestframe.h \ - fonttestwidget.h \ - exporters/divoexporter.h \ - charmapdialog.h \ - charsselectwidget.h \ - exporters/nglexporter.h \ - exporters/luaexporter.h \ - fontdrawwidget.h \ - fontloader.h -FORMS += fontbuilder.ui \ - fontselectframe.ui \ - fontoptionsframe.ui \ - charactersframe.ui \ - layoutconfigframe.ui \ - outputframe.ui \ - fonttestframe.ui \ - charmapdialog.ui +SOURCES += src/main.cpp \ + src/fontbuilder.cpp \ + src/colorbutton.cpp \ + src/fontselectframe.cpp \ + src/fontoptionsframe.cpp \ + src/fontrenderer.cpp \ + src/charactersframe.cpp \ + src/fontconfig.cpp \ + src/abstractlayouter.cpp \ + src/layoutconfig.cpp \ + src/layoutdata.cpp \ + src/layouters/linelayouter.cpp \ + src/layouterfactory.cpp \ + src/layouters/boxlayouter.cpp \ + src/layoutconfigframe.cpp \ + src/outputconfig.cpp \ + src/outputframe.cpp \ + src/abstractexporter.cpp \ + src/exporters/ghlexporter.cpp \ + src/exporterfactory.cpp \ + src/abstractimagewriter.cpp \ + src/imagewriterfactory.cpp \ + src/image/builtinimagewriter.cpp \ + src/exporters/zfiexporter.cpp \ + src/image/targawriter.cpp \ + src/fonttestframe.cpp \ + src/fonttestwidget.cpp \ + src/exporters/divoexporter.cpp \ + src/charmapdialog.cpp \ + src/charsselectwidget.cpp \ + src/exporters/nglexporter.cpp \ + src/exporters/luaexporter.cpp \ + src/fontdrawwidget.cpp \ + src/fontloader.cpp +HEADERS += src/fontbuilder.h \ + src/colorbutton.h \ + src/fontselectframe.h \ + src/fontoptionsframe.h \ + src/fontrenderer.h \ + src/charactersframe.h \ + src/fontconfig.h \ + src/rendererdata.h \ + src/abstractlayouter.h \ + src/layoutconfig.h \ + src/layoutdata.h \ + src/layouters/linelayouter.h \ + src/layouterfactory.h \ + src/layoutchar.h \ + src/layouters/boxlayouter.h \ + src/layoutconfigframe.h \ + src/outputconfig.h \ + src/outputframe.h \ + src/abstractexporter.h \ + src/exporters/ghlexporter.h \ + src/exporterfactory.h \ + src/abstractimagewriter.h \ + src/imagewriterfactory.h \ + src/image/builtinimagewriter.h \ + src/exporters/zfiexporter.h \ + src/image/targawriter.h \ + src/fonttestframe.h \ + src/fonttestwidget.h \ + src/exporters/divoexporter.h \ + src/charmapdialog.h \ + src/charsselectwidget.h \ + src/exporters/nglexporter.h \ + src/exporters/luaexporter.h \ + src/fontdrawwidget.h \ + src/fontloader.h +FORMS += src/fontbuilder.ui \ + src/fontselectframe.ui \ + src/fontoptionsframe.ui \ + src/charactersframe.ui \ + src/layoutconfigframe.ui \ + src/outputframe.ui \ + src/fonttestframe.ui \ + src/charmapdialog.ui TRANSLATIONS = fontbuilder_en.ts \ fontbuilder_ru.ts QT += xml @@ -119,7 +119,7 @@ MOC_DIR = .obj UI_DIR = .obj TARGET = FontBuilder -INCLUDEPATH+=./ +INCLUDEPATH+=src/ mac { INCLUDEPATH += ../include INCLUDEPATH += ../include/freetype2 diff --git a/abstractexporter.cpp b/src/abstractexporter.cpp similarity index 100% rename from abstractexporter.cpp rename to src/abstractexporter.cpp diff --git a/abstractexporter.h b/src/abstractexporter.h similarity index 100% rename from abstractexporter.h rename to src/abstractexporter.h diff --git a/abstractimagewriter.cpp b/src/abstractimagewriter.cpp similarity index 100% rename from abstractimagewriter.cpp rename to src/abstractimagewriter.cpp diff --git a/abstractimagewriter.h b/src/abstractimagewriter.h similarity index 100% rename from abstractimagewriter.h rename to src/abstractimagewriter.h diff --git a/abstractlayouter.cpp b/src/abstractlayouter.cpp similarity index 100% rename from abstractlayouter.cpp rename to src/abstractlayouter.cpp diff --git a/abstractlayouter.h b/src/abstractlayouter.h similarity index 100% rename from abstractlayouter.h rename to src/abstractlayouter.h diff --git a/charactersframe.cpp b/src/charactersframe.cpp similarity index 100% rename from charactersframe.cpp rename to src/charactersframe.cpp diff --git a/charactersframe.h b/src/charactersframe.h similarity index 100% rename from charactersframe.h rename to src/charactersframe.h diff --git a/charactersframe.ui b/src/charactersframe.ui similarity index 100% rename from charactersframe.ui rename to src/charactersframe.ui diff --git a/charmapdialog.cpp b/src/charmapdialog.cpp similarity index 100% rename from charmapdialog.cpp rename to src/charmapdialog.cpp diff --git a/charmapdialog.h b/src/charmapdialog.h similarity index 100% rename from charmapdialog.h rename to src/charmapdialog.h diff --git a/charmapdialog.ui b/src/charmapdialog.ui similarity index 100% rename from charmapdialog.ui rename to src/charmapdialog.ui diff --git a/charsselectwidget.cpp b/src/charsselectwidget.cpp similarity index 100% rename from charsselectwidget.cpp rename to src/charsselectwidget.cpp diff --git a/charsselectwidget.h b/src/charsselectwidget.h similarity index 100% rename from charsselectwidget.h rename to src/charsselectwidget.h diff --git a/colorbutton.cpp b/src/colorbutton.cpp similarity index 100% rename from colorbutton.cpp rename to src/colorbutton.cpp diff --git a/colorbutton.h b/src/colorbutton.h similarity index 100% rename from colorbutton.h rename to src/colorbutton.h diff --git a/exporterfactory.cpp b/src/exporterfactory.cpp similarity index 100% rename from exporterfactory.cpp rename to src/exporterfactory.cpp diff --git a/exporterfactory.h b/src/exporterfactory.h similarity index 100% rename from exporterfactory.h rename to src/exporterfactory.h diff --git a/exporters/divoexporter.cpp b/src/exporters/divoexporter.cpp similarity index 100% rename from exporters/divoexporter.cpp rename to src/exporters/divoexporter.cpp diff --git a/exporters/divoexporter.h b/src/exporters/divoexporter.h similarity index 100% rename from exporters/divoexporter.h rename to src/exporters/divoexporter.h diff --git a/exporters/ghlexporter.cpp b/src/exporters/ghlexporter.cpp similarity index 100% rename from exporters/ghlexporter.cpp rename to src/exporters/ghlexporter.cpp diff --git a/exporters/ghlexporter.h b/src/exporters/ghlexporter.h similarity index 100% rename from exporters/ghlexporter.h rename to src/exporters/ghlexporter.h diff --git a/exporters/luaexporter.cpp b/src/exporters/luaexporter.cpp similarity index 97% rename from exporters/luaexporter.cpp rename to src/exporters/luaexporter.cpp index 590e006..cc91644 100644 --- a/exporters/luaexporter.cpp +++ b/src/exporters/luaexporter.cpp @@ -1,112 +1,112 @@ -/** - * Copyright (c) 2010-2011 Andrey AndryBlack Kunitsyn - * email:support.andryblack@gmail.com - * - * Report bugs and download new versions at http://code.google.com/p/fontbuilder - * - * This software is distributed under the MIT License. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "luaexporter.h" -#include "../fontconfig.h" -#include "../layoutdata.h" - -#include -LuaExporter::LuaExporter(QObject *parent) : - AbstractExporter(parent) -{ - setExtension("lua"); -} -static QString charCode(uint code) { - if (code=='\"') return QString().append('\'').append(code).append('\''); - if (code=='\\') return QString("\"\\\\\""); - return QString().append('\"').append(code).append('\"'); -} - -bool LuaExporter::Export(QByteArray& out) { - QString res = "return {\n"; - res+=QString("\tfile=\"")+texFilename()+QString("\",\n"); - res+=QString("\theight=")+QString().number(metrics().height)+QString(",\n"); - res+=QString("\tdescription={\n"); - res+=QString("\t\tfamily=\"")+fontConfig()->family()+QString("\",\n"); - res+=QString("\t\tstyle=\"")+fontConfig()->style()+QString("\",\n"); - res+=QString("\t\tsize=")+QString().number(fontConfig()->size())+QString("\n"); - res+=QString("\t},\n"); - - res+=QString("\tmetrics={\n"); - res+=QString("\t\tascender=")+QString().number(metrics().ascender)+QString(",\n"); - res+=QString("\t\tdescender=")+QString().number(metrics().descender)+QString(",\n"); - res+=QString("\t\theight=")+QString().number(metrics().height)+QString("\n"); - res+=QString("\t},\n"); - - res+=QString("\ttexture={\n"); - res+=QString("\t\tfile=\"")+texFilename()+QString("\",\n"); - res+=QString("\t\twidth=")+QString().number(texWidth())+QString(",\n"); - res+=QString("\t\theight=")+QString().number(texHeight())+QString("\n"); - res+=QString("\t},\n"); - - res+=QString("\tchars={\n"); - foreach (const Symbol& c , symbols()) { - QString charDef="{char="; - charDef+=charCode(c.id); - charDef+=QString(","); - charDef+=QString("width=")+QString().number(c.advance)+QString(","); - charDef+=QString("x=")+QString().number(c.placeX)+QString(","); - charDef+=QString("y=")+QString().number(c.placeY)+QString(","); - charDef+=QString("w=")+QString().number(c.placeW)+QString(","); - charDef+=QString("h=")+QString().number(c.placeH)+QString(","); - - charDef+=QString("ox=")+QString().number(c.offsetX)+QString(","); - charDef+=QString("oy=")+QString().number(c.offsetY)+QString("}"); - - res+=QString("\t\t")+charDef+QString(",\n"); - } - res+=QString("\t},\n"); - QString kernings; - foreach (const Symbol& c , symbols()) { - QString charDef="{from="; - charDef+=charCode(c.id); - charDef+=QString(",to="); - typedef QMap::ConstIterator Kerning; - for ( Kerning k = c.kerning.begin();k!=c.kerning.end();k++) { - QString def = charDef; - def+=charCode(k.key()); - def+=QString(",offset=")+QString().number(k.value())+QString("}"); - kernings+=QString("\t\t")+def+QString(",\n"); - } - } - if (kernings.length()>2) { - res+=QString("\tkernings={\n"); - res+=kernings; - res+=QString("\t}\n"); - } - res+=QString("}\n"); - out = res.toUtf8(); - return true; -} - - -AbstractExporter* LuaExporterFactoryFunc (QObject* parent) { - return new LuaExporter(parent); -} +/** + * Copyright (c) 2010-2011 Andrey AndryBlack Kunitsyn + * email:support.andryblack@gmail.com + * + * Report bugs and download new versions at http://code.google.com/p/fontbuilder + * + * This software is distributed under the MIT License. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "luaexporter.h" +#include "../fontconfig.h" +#include "../layoutdata.h" + +#include +LuaExporter::LuaExporter(QObject *parent) : + AbstractExporter(parent) +{ + setExtension("lua"); +} +static QString charCode(uint code) { + if (code=='\"') return QString().append('\'').append(code).append('\''); + if (code=='\\') return QString("\"\\\\\""); + return QString().append('\"').append(code).append('\"'); +} + +bool LuaExporter::Export(QByteArray& out) { + QString res = "return {\n"; + res+=QString("\tfile=\"")+texFilename()+QString("\",\n"); + res+=QString("\theight=")+QString().number(metrics().height)+QString(",\n"); + res+=QString("\tdescription={\n"); + res+=QString("\t\tfamily=\"")+fontConfig()->family()+QString("\",\n"); + res+=QString("\t\tstyle=\"")+fontConfig()->style()+QString("\",\n"); + res+=QString("\t\tsize=")+QString().number(fontConfig()->size())+QString("\n"); + res+=QString("\t},\n"); + + res+=QString("\tmetrics={\n"); + res+=QString("\t\tascender=")+QString().number(metrics().ascender)+QString(",\n"); + res+=QString("\t\tdescender=")+QString().number(metrics().descender)+QString(",\n"); + res+=QString("\t\theight=")+QString().number(metrics().height)+QString("\n"); + res+=QString("\t},\n"); + + res+=QString("\ttexture={\n"); + res+=QString("\t\tfile=\"")+texFilename()+QString("\",\n"); + res+=QString("\t\twidth=")+QString().number(texWidth())+QString(",\n"); + res+=QString("\t\theight=")+QString().number(texHeight())+QString("\n"); + res+=QString("\t},\n"); + + res+=QString("\tchars={\n"); + foreach (const Symbol& c , symbols()) { + QString charDef="{char="; + charDef+=charCode(c.id); + charDef+=QString(","); + charDef+=QString("width=")+QString().number(c.advance)+QString(","); + charDef+=QString("x=")+QString().number(c.placeX)+QString(","); + charDef+=QString("y=")+QString().number(c.placeY)+QString(","); + charDef+=QString("w=")+QString().number(c.placeW)+QString(","); + charDef+=QString("h=")+QString().number(c.placeH)+QString(","); + + charDef+=QString("ox=")+QString().number(c.offsetX)+QString(","); + charDef+=QString("oy=")+QString().number(c.offsetY)+QString("}"); + + res+=QString("\t\t")+charDef+QString(",\n"); + } + res+=QString("\t},\n"); + QString kernings; + foreach (const Symbol& c , symbols()) { + QString charDef="{from="; + charDef+=charCode(c.id); + charDef+=QString(",to="); + typedef QMap::ConstIterator Kerning; + for ( Kerning k = c.kerning.begin();k!=c.kerning.end();k++) { + QString def = charDef; + def+=charCode(k.key()); + def+=QString(",offset=")+QString().number(k.value())+QString("}"); + kernings+=QString("\t\t")+def+QString(",\n"); + } + } + if (kernings.length()>2) { + res+=QString("\tkernings={\n"); + res+=kernings; + res+=QString("\t}\n"); + } + res+=QString("}\n"); + out = res.toUtf8(); + return true; +} + + +AbstractExporter* LuaExporterFactoryFunc (QObject* parent) { + return new LuaExporter(parent); +} diff --git a/exporters/luaexporter.h b/src/exporters/luaexporter.h similarity index 97% rename from exporters/luaexporter.h rename to src/exporters/luaexporter.h index 684b5da..6e07e26 100644 --- a/exporters/luaexporter.h +++ b/src/exporters/luaexporter.h @@ -1,49 +1,49 @@ -/** - * Copyright (c) 2010-2011 Andrey AndryBlack Kunitsyn - * email:support.andryblack@gmail.com - * - * Report bugs and download new versions at http://code.google.com/p/fontbuilder - * - * This software is distributed under the MIT License. - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, - * copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following - * conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES - * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT - * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef LUAEXPORTER_H -#define LUAEXPORTER_H - -#include "../abstractexporter.h" - -class LuaExporter : public AbstractExporter -{ -Q_OBJECT -public: - explicit LuaExporter(QObject *parent = 0); -protected: - virtual bool Export(QByteArray& out); -signals: - -public slots: - -}; - -#endif // LUAEXPORTER_H +/** + * Copyright (c) 2010-2011 Andrey AndryBlack Kunitsyn + * email:support.andryblack@gmail.com + * + * Report bugs and download new versions at http://code.google.com/p/fontbuilder + * + * This software is distributed under the MIT License. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LUAEXPORTER_H +#define LUAEXPORTER_H + +#include "../abstractexporter.h" + +class LuaExporter : public AbstractExporter +{ +Q_OBJECT +public: + explicit LuaExporter(QObject *parent = 0); +protected: + virtual bool Export(QByteArray& out); +signals: + +public slots: + +}; + +#endif // LUAEXPORTER_H diff --git a/exporters/nglexporter.cpp b/src/exporters/nglexporter.cpp similarity index 100% rename from exporters/nglexporter.cpp rename to src/exporters/nglexporter.cpp diff --git a/exporters/nglexporter.h b/src/exporters/nglexporter.h similarity index 100% rename from exporters/nglexporter.h rename to src/exporters/nglexporter.h diff --git a/exporters/zfiexporter.cpp b/src/exporters/zfiexporter.cpp similarity index 100% rename from exporters/zfiexporter.cpp rename to src/exporters/zfiexporter.cpp diff --git a/exporters/zfiexporter.h b/src/exporters/zfiexporter.h similarity index 100% rename from exporters/zfiexporter.h rename to src/exporters/zfiexporter.h diff --git a/fontbuilder.cpp b/src/fontbuilder.cpp similarity index 100% rename from fontbuilder.cpp rename to src/fontbuilder.cpp diff --git a/fontbuilder.h b/src/fontbuilder.h similarity index 100% rename from fontbuilder.h rename to src/fontbuilder.h diff --git a/fontbuilder.ui b/src/fontbuilder.ui similarity index 100% rename from fontbuilder.ui rename to src/fontbuilder.ui diff --git a/fontconfig.cpp b/src/fontconfig.cpp similarity index 100% rename from fontconfig.cpp rename to src/fontconfig.cpp diff --git a/fontconfig.h b/src/fontconfig.h similarity index 100% rename from fontconfig.h rename to src/fontconfig.h diff --git a/fontdrawwidget.cpp b/src/fontdrawwidget.cpp similarity index 100% rename from fontdrawwidget.cpp rename to src/fontdrawwidget.cpp diff --git a/fontdrawwidget.h b/src/fontdrawwidget.h similarity index 100% rename from fontdrawwidget.h rename to src/fontdrawwidget.h diff --git a/fontloader.cpp b/src/fontloader.cpp similarity index 100% rename from fontloader.cpp rename to src/fontloader.cpp diff --git a/fontloader.h b/src/fontloader.h similarity index 100% rename from fontloader.h rename to src/fontloader.h diff --git a/fontoptionsframe.cpp b/src/fontoptionsframe.cpp similarity index 100% rename from fontoptionsframe.cpp rename to src/fontoptionsframe.cpp diff --git a/fontoptionsframe.h b/src/fontoptionsframe.h similarity index 100% rename from fontoptionsframe.h rename to src/fontoptionsframe.h diff --git a/fontoptionsframe.ui b/src/fontoptionsframe.ui similarity index 100% rename from fontoptionsframe.ui rename to src/fontoptionsframe.ui diff --git a/fontrenderer.cpp b/src/fontrenderer.cpp similarity index 100% rename from fontrenderer.cpp rename to src/fontrenderer.cpp diff --git a/fontrenderer.h b/src/fontrenderer.h similarity index 100% rename from fontrenderer.h rename to src/fontrenderer.h diff --git a/fontselectframe.cpp b/src/fontselectframe.cpp similarity index 100% rename from fontselectframe.cpp rename to src/fontselectframe.cpp diff --git a/fontselectframe.h b/src/fontselectframe.h similarity index 100% rename from fontselectframe.h rename to src/fontselectframe.h diff --git a/fontselectframe.ui b/src/fontselectframe.ui similarity index 100% rename from fontselectframe.ui rename to src/fontselectframe.ui diff --git a/fonttestframe.cpp b/src/fonttestframe.cpp similarity index 100% rename from fonttestframe.cpp rename to src/fonttestframe.cpp diff --git a/fonttestframe.h b/src/fonttestframe.h similarity index 100% rename from fonttestframe.h rename to src/fonttestframe.h diff --git a/fonttestframe.ui b/src/fonttestframe.ui similarity index 100% rename from fonttestframe.ui rename to src/fonttestframe.ui diff --git a/fonttestwidget.cpp b/src/fonttestwidget.cpp similarity index 100% rename from fonttestwidget.cpp rename to src/fonttestwidget.cpp diff --git a/fonttestwidget.h b/src/fonttestwidget.h similarity index 100% rename from fonttestwidget.h rename to src/fonttestwidget.h diff --git a/image/builtinimagewriter.cpp b/src/image/builtinimagewriter.cpp similarity index 100% rename from image/builtinimagewriter.cpp rename to src/image/builtinimagewriter.cpp diff --git a/image/builtinimagewriter.h b/src/image/builtinimagewriter.h similarity index 100% rename from image/builtinimagewriter.h rename to src/image/builtinimagewriter.h diff --git a/image/targawriter.cpp b/src/image/targawriter.cpp similarity index 100% rename from image/targawriter.cpp rename to src/image/targawriter.cpp diff --git a/image/targawriter.h b/src/image/targawriter.h similarity index 100% rename from image/targawriter.h rename to src/image/targawriter.h diff --git a/imagewriterfactory.cpp b/src/imagewriterfactory.cpp similarity index 100% rename from imagewriterfactory.cpp rename to src/imagewriterfactory.cpp diff --git a/imagewriterfactory.h b/src/imagewriterfactory.h similarity index 100% rename from imagewriterfactory.h rename to src/imagewriterfactory.h diff --git a/layoutchar.h b/src/layoutchar.h similarity index 100% rename from layoutchar.h rename to src/layoutchar.h diff --git a/layoutconfig.cpp b/src/layoutconfig.cpp similarity index 100% rename from layoutconfig.cpp rename to src/layoutconfig.cpp diff --git a/layoutconfig.h b/src/layoutconfig.h similarity index 100% rename from layoutconfig.h rename to src/layoutconfig.h diff --git a/layoutconfigframe.cpp b/src/layoutconfigframe.cpp similarity index 100% rename from layoutconfigframe.cpp rename to src/layoutconfigframe.cpp diff --git a/layoutconfigframe.h b/src/layoutconfigframe.h similarity index 100% rename from layoutconfigframe.h rename to src/layoutconfigframe.h diff --git a/layoutconfigframe.ui b/src/layoutconfigframe.ui similarity index 100% rename from layoutconfigframe.ui rename to src/layoutconfigframe.ui diff --git a/layoutdata.cpp b/src/layoutdata.cpp similarity index 100% rename from layoutdata.cpp rename to src/layoutdata.cpp diff --git a/layoutdata.h b/src/layoutdata.h similarity index 100% rename from layoutdata.h rename to src/layoutdata.h diff --git a/layouterfactory.cpp b/src/layouterfactory.cpp similarity index 100% rename from layouterfactory.cpp rename to src/layouterfactory.cpp diff --git a/layouterfactory.h b/src/layouterfactory.h similarity index 100% rename from layouterfactory.h rename to src/layouterfactory.h diff --git a/layouters/boxlayouter.cpp b/src/layouters/boxlayouter.cpp similarity index 100% rename from layouters/boxlayouter.cpp rename to src/layouters/boxlayouter.cpp diff --git a/layouters/boxlayouter.h b/src/layouters/boxlayouter.h similarity index 100% rename from layouters/boxlayouter.h rename to src/layouters/boxlayouter.h diff --git a/layouters/linelayouter.cpp b/src/layouters/linelayouter.cpp similarity index 100% rename from layouters/linelayouter.cpp rename to src/layouters/linelayouter.cpp diff --git a/layouters/linelayouter.h b/src/layouters/linelayouter.h similarity index 100% rename from layouters/linelayouter.h rename to src/layouters/linelayouter.h diff --git a/main.cpp b/src/main.cpp similarity index 100% rename from main.cpp rename to src/main.cpp diff --git a/mainwindow.cpp b/src/mainwindow.cpp similarity index 100% rename from mainwindow.cpp rename to src/mainwindow.cpp diff --git a/mainwindow.h b/src/mainwindow.h similarity index 100% rename from mainwindow.h rename to src/mainwindow.h diff --git a/mainwindow.ui b/src/mainwindow.ui similarity index 100% rename from mainwindow.ui rename to src/mainwindow.ui diff --git a/outputconfig.cpp b/src/outputconfig.cpp similarity index 100% rename from outputconfig.cpp rename to src/outputconfig.cpp diff --git a/outputconfig.h b/src/outputconfig.h similarity index 100% rename from outputconfig.h rename to src/outputconfig.h diff --git a/outputframe.cpp b/src/outputframe.cpp similarity index 100% rename from outputframe.cpp rename to src/outputframe.cpp diff --git a/outputframe.h b/src/outputframe.h similarity index 100% rename from outputframe.h rename to src/outputframe.h diff --git a/outputframe.ui b/src/outputframe.ui similarity index 100% rename from outputframe.ui rename to src/outputframe.ui diff --git a/rendererdata.h b/src/rendererdata.h similarity index 100% rename from rendererdata.h rename to src/rendererdata.h