|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
#ifndef __LP64__
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Toonz stuff
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "traster.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfont.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Qt stuff
|
|
Toshihiro Shimizu |
890ddd |
#include <qstring></qstring>
|
|
Toshihiro Shimizu |
890ddd |
#include <qsharedmemory></qsharedmemory>
|
|
Toshihiro Shimizu |
890ddd |
#include <qdebug></qdebug>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//tipc includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tipc.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tipcmsg.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tipcsrv.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "t32fontmsg.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace stuff
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QDataStream &operator<<(QDataStream &ds, const TThickPoint &p)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
ds << p.x << p.y << p.thick;
|
|
Toshihiro Shimizu |
890ddd |
return ds;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace tipc;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace font_io
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void addParsers(tipc::Server *srv)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new LoadFontNamesParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new GetAllFamiliesParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new GetAllTypefacesParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new SetFamilyParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new SetTypefaceParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new SetSizeParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new GetCurrentFamilyParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new GetCurrentTypefaceParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new GetDistanceParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new DrawCharVIParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new DrawCharGRParser);
|
|
Toshihiro Shimizu |
890ddd |
srv->addParser(new DrawCharCMParser);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// LoadFontNames Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void LoadFontNamesParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
TFontManager::instance()->loadFontNames();
|
|
Toshihiro Shimizu |
890ddd |
msg << clr << QString("ok");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GetAllFamilies Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GetAllFamiliesParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<std::wstring> families;</std::wstring>
|
|
Toshihiro Shimizu |
890ddd |
TFontManager::instance()->getAllFamilies(families);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg << clr << QString("ok") << families;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GetAllTypefaces Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GetAllTypefacesParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::vector<std::wstring> typefaces;</std::wstring>
|
|
Toshihiro Shimizu |
890ddd |
TFontManager::instance()->getAllTypefaces(typefaces);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg << clr << QString("ok") << typefaces;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// SetFamily Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SetFamilyParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::wstring family;
|
|
Toshihiro Shimizu |
890ddd |
msg >> family >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFontManager::instance()->setFamily(family);
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok");
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// SetTypeface Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SetTypefaceParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::wstring typeface;
|
|
Toshihiro Shimizu |
890ddd |
msg >> typeface >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFontManager *fm = TFontManager::instance();
|
|
Toshihiro Shimizu |
890ddd |
fm->setTypeface(typeface);
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok")
|
|
Toshihiro Shimizu |
890ddd |
<< fm->getLineAscender()
|
|
Toshihiro Shimizu |
890ddd |
<< fm->getLineDescender();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// SetSize Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void SetSizeParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int size;
|
|
Toshihiro Shimizu |
890ddd |
msg >> size >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TFontManager *fm = TFontManager::instance();
|
|
Toshihiro Shimizu |
890ddd |
fm->setSize(size);
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok")
|
|
Toshihiro Shimizu |
890ddd |
<< fm->getLineAscender()
|
|
Toshihiro Shimizu |
890ddd |
<< fm->getLineDescender();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GetCurrentFamily Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GetCurrentFamilyParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::wstring family(TFontManager::instance()->getCurrentFamily());
|
|
Toshihiro Shimizu |
890ddd |
msg << clr << QString("ok") << family;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GetCurrentTypeface Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GetCurrentTypefaceParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
std::wstring typeface(TFontManager::instance()->getCurrentTypeface());
|
|
Toshihiro Shimizu |
890ddd |
msg << clr << QString("ok") << typeface;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// GetDistance Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void GetDistanceParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
wchar_t firstChar, secondChar;
|
|
Toshihiro Shimizu |
890ddd |
msg >> firstChar >> secondChar >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint dist = TFontManager::instance()->getDistance(firstChar, secondChar);
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok") << dist.x << dist.y;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// DrawCharVI Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DrawCharVIParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
wchar_t charCode, nextCode;
|
|
Toshihiro Shimizu |
890ddd |
msg >> charCode >> nextCode >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TVectorImageP vi(new TVectorImage);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint p = TFontManager::instance()->drawChar(vi, charCode, nextCode);
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok") << p.x << p.y;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Write the vector image
|
|
Toshihiro Shimizu |
890ddd |
std::vector<tthickpoint> cps;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
unsigned int i, strokesCount = vi->getStrokeCount();
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < strokesCount; ++i) {
|
|
Toshihiro Shimizu |
890ddd |
TStroke *stroke = vi->getStroke(i);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
cps.clear();
|
|
Toshihiro Shimizu |
890ddd |
stroke->getControlPoints(cps);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg << cps;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// DrawCharGR Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DrawCharGRParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int ink;
|
|
Toshihiro Shimizu |
890ddd |
QString shMemId;
|
|
Toshihiro Shimizu |
890ddd |
wchar_t charCode, nextCode;
|
|
Toshihiro Shimizu |
890ddd |
msg >> ink >> shMemId >> charCode >> nextCode >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Build the character
|
|
Toshihiro Shimizu |
890ddd |
TRasterGR8P charRas;
|
|
Toshihiro Shimizu |
890ddd |
TPoint unused;
|
|
Toshihiro Shimizu |
890ddd |
TPoint p = TFontManager::instance()->drawChar(charRas, unused, charCode, nextCode);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Retrieve the raster size
|
|
Toshihiro Shimizu |
890ddd |
int lx = charRas->getLx(), ly = charRas->getLy();
|
|
Toshihiro Shimizu |
890ddd |
int size = lx * ly * sizeof(TPixelGR8);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Request a shared memory segment of that size
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tipc::DefaultMessageParser<shmem_request> msgParser;</shmem_request>
|
|
Toshihiro Shimizu |
890ddd |
Message shMsg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
shMsg << shMemId << size << reset;
|
|
Toshihiro Shimizu |
890ddd |
msgParser(shMsg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString str;
|
|
Toshihiro Shimizu |
890ddd |
shMsg >> reset >> str;
|
|
Toshihiro Shimizu |
890ddd |
if (str != QString("ok")) {
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("err");
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Copy charRas to the shared segment
|
|
Toshihiro Shimizu |
890ddd |
QSharedMemory shmem(shMemId);
|
|
Toshihiro Shimizu |
890ddd |
shmem.attach();
|
|
Toshihiro Shimizu |
890ddd |
shmem.lock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
memcpy(shmem.data(), charRas->getRawData(), size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
shmem.unlock();
|
|
Toshihiro Shimizu |
890ddd |
shmem.detach();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok") << lx << ly << p.x << p.y;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// DrawCharCM Parser
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DrawCharCMParser::operator()(Message &msg)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int ink;
|
|
Toshihiro Shimizu |
890ddd |
QString shMemId;
|
|
Toshihiro Shimizu |
890ddd |
wchar_t charCode, nextCode;
|
|
Toshihiro Shimizu |
890ddd |
msg >> ink >> shMemId >> charCode >> nextCode >> clr;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Build the character
|
|
Toshihiro Shimizu |
890ddd |
TRasterCM32P charRas;
|
|
Toshihiro Shimizu |
890ddd |
TPoint unused;
|
|
Toshihiro Shimizu |
890ddd |
TPoint p = TFontManager::instance()->drawChar(charRas, unused, ink, charCode, nextCode);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Retrieve the raster size
|
|
Toshihiro Shimizu |
890ddd |
int lx = charRas->getLx(), ly = charRas->getLy();
|
|
Toshihiro Shimizu |
890ddd |
int size = lx * ly * sizeof(TPixelCM32);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Request a shared memory segment of that size
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tipc::DefaultMessageParser<shmem_request> msgParser;</shmem_request>
|
|
Toshihiro Shimizu |
890ddd |
Message shMsg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
shMsg << shMemId << size << reset;
|
|
Toshihiro Shimizu |
890ddd |
msgParser(shMsg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString str;
|
|
Toshihiro Shimizu |
890ddd |
shMsg >> reset >> str;
|
|
Toshihiro Shimizu |
890ddd |
if (str != QString("ok")) {
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("err");
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//Copy charRas to the shared segment
|
|
Toshihiro Shimizu |
890ddd |
QSharedMemory shmem(shMemId);
|
|
Toshihiro Shimizu |
890ddd |
shmem.attach();
|
|
Toshihiro Shimizu |
890ddd |
shmem.lock();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
memcpy(shmem.data(), charRas->getRawData(), size);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
shmem.unlock();
|
|
Toshihiro Shimizu |
890ddd |
shmem.detach();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
msg << QString("ok") << lx << ly << p.x << p.y;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} //namespace font_io
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // !__LP64
|
|
Toshihiro Shimizu |
890ddd |
#endif // MACOSX
|