|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
deffae |
#if defined(__LP64__) && !defined(LINUX)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Toonz includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tvectorimage.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tstroke.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qsharedmemory></qsharedmemory>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
なぜか tipc.h の
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
template<typename t=""></typename>
|
|
Toshihiro Shimizu |
890ddd |
QDataStream& operator>>(QDataStream& ds, std::vector<t>& vec)</t>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
が T=TThickPoint でインスタンス化されようとして曖昧ですエラーになる
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
// tipc includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tipc.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "t32bitsrv_wrap.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tfont.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// Local namespace stuff
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QDataStream &operator>>(QDataStream &ds, TThickPoint &p) {
|
|
Shinya Kitaoka |
120a6e |
return ds >> p.x >> p.y >> p.thick;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void readVImage(TVectorImageP &vi, tipc::Message &msg) {
|
|
Shinya Kitaoka |
120a6e |
std::vector<tthickpoint> strokeCPs;</tthickpoint>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Read in all strokes
|
|
Shinya Kitaoka |
120a6e |
while (!msg.ds().atEnd()) {
|
|
Shinya Kitaoka |
120a6e |
strokeCPs.clear();
|
|
Shinya Kitaoka |
120a6e |
msg >> strokeCPs;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
vi->addStroke(new TStroke(strokeCPs));
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
vi->group(0, vi->getStrokeCount());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TFontManager Private stuff
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
The proxied Impl private just caches some data of the actual
|
|
Toshihiro Shimizu |
890ddd |
background counterpart
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
struct TFontManager::Impl {
|
|
Shinya Kitaoka |
120a6e |
int m_ascender;
|
|
Shinya Kitaoka |
120a6e |
int m_descender;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Impl() {}
|
|
Shinya Kitaoka |
120a6e |
~Impl() {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// TFontManager Proxied implementation
|
|
Toshihiro Shimizu |
890ddd |
//**************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFontManager::TFontManager() { m_pimpl = new TFontManager::Impl(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFontManager::~TFontManager() { delete m_pimpl; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TFontManager *TFontManager::instance() {
|
|
Shinya Kitaoka |
120a6e |
static TFontManager theInstance;
|
|
Shinya Kitaoka |
120a6e |
return &theInstance;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
//! This function is retained from old 32-bit legacy code.
|
|
Shinya Kitaoka |
120a6e |
//! Its use is now forbidden - use the TFontManager directly instead.
|
|
Shinya Kitaoka |
120a6e |
TFont *TFontManager::getCurrentFont() {
|
|
Shinya Kitaoka |
120a6e |
assert(false);
|
|
Shinya Kitaoka |
120a6e |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!\note Throws TFontLibraryLoadingError if fonts could not be loaded
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::loadFontNames() {
|
|
Shinya Kitaoka |
120a6e |
// Connect to the 32-bit background server process
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTloadFontNames"));
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok") throw TFontLibraryLoadingError();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!\note Throws TFontCreationError if the font could not be created, and
|
|
Shinya Kitaoka |
120a6e |
//! leaves the old font as current.
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::setFamily(const std::wstring family) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTsetFamily") << family);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok") throw TFontCreationError();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//!\note Throws TFontCreationError if the font could not be created, and
|
|
Shinya Kitaoka |
120a6e |
//! leaves the old font as current.
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::setTypeface(const std::wstring typeface) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTsetTypeface") << typeface);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok") throw TFontCreationError();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Also, store the font's ascender and descender
|
|
Shinya Kitaoka |
120a6e |
msg >> m_pimpl->m_ascender >> m_pimpl->m_descender;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring TFontManager::getCurrentFamily() const {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTgetCurrentFamily"));
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Could not get font family");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring family;
|
|
Shinya Kitaoka |
120a6e |
msg >> family;
|
|
Shinya Kitaoka |
120a6e |
return family;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring TFontManager::getCurrentTypeface() const {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTgetCurrentTypeface"));
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Could not get font typeface");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::wstring typeface;
|
|
Shinya Kitaoka |
120a6e |
msg >> typeface;
|
|
Shinya Kitaoka |
120a6e |
return typeface;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::getAllFamilies(std::vector<std::wstring> &families) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTgetAllFamilies"));
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Could not get font families");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
msg >> families;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::getAllTypefaces(std::vector<std::wstring> &typefaces) const {</std::wstring>
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTgetAllTypefaces"));
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Could not get font typefaces");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
msg >> typefaces;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::setVertical(bool vertical) {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void TFontManager::setSize(int size) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTsetSize") << size);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// Also, update ascender and descender
|
|
Shinya Kitaoka |
120a6e |
msg >> m_pimpl->m_ascender >> m_pimpl->m_descender;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint TFontManager::getDistance(wchar_t firstChar, wchar_t secondChar) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTgetDistance") << firstChar << secondChar);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint d;
|
|
Shinya Kitaoka |
120a6e |
msg >> d.x >> d.y;
|
|
Shinya Kitaoka |
120a6e |
return d;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFontManager::getMaxHeight() {
|
|
Shinya Kitaoka |
120a6e |
return m_pimpl->m_ascender - m_pimpl->m_descender;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFontManager::getMaxWidth() {
|
|
Shinya Kitaoka |
120a6e |
assert(!"not implemented yet");
|
|
Shinya Kitaoka |
120a6e |
return 100;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TFontManager::hasVertical() { return false; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool TFontManager::hasKerning() { return true; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFontManager::getLineAscender() { return m_pimpl->m_ascender; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int TFontManager::getLineDescender() { return m_pimpl->m_descender; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint TFontManager::drawChar(TVectorImageP &outImage, wchar_t charcode,
|
|
Shinya Kitaoka |
120a6e |
wchar_t nextCode) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTdrawCharVI") << charcode << nextCode);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint ret;
|
|
Shinya Kitaoka |
120a6e |
msg >> ret.x >> ret.y;
|
|
Shinya Kitaoka |
120a6e |
::readVImage(outImage, msg);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPoint TFontManager::drawChar(TRasterGR8P &outImage, TPoint &glyphOrigin,
|
|
Shinya Kitaoka |
120a6e |
wchar_t charcode, wchar_t nextCode) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString shMemId(tipc::uniqueId()), res;
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
// Invoke the appropriate command
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTdrawCharGR") << shMemId << charcode
|
|
Shinya Kitaoka |
120a6e |
<< nextCode);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDimension dim(0, 0);
|
|
Shinya Kitaoka |
120a6e |
msg >> dim.lx >> dim.ly;
|
|
Shinya Kitaoka |
120a6e |
TPoint ret;
|
|
Shinya Kitaoka |
120a6e |
msg >> ret.x >> ret.y;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Create outImage
|
|
Shinya Kitaoka |
120a6e |
outImage = TRasterGR8P(dim.lx, dim.ly);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QSharedMemory shmem(shMemId);
|
|
Shinya Kitaoka |
120a6e |
shmem.attach();
|
|
Shinya Kitaoka |
120a6e |
shmem.lock();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Copy the returned image to outImage
|
|
Shinya Kitaoka |
120a6e |
TRasterGR8P ras(dim.lx, dim.ly, dim.lx, (TPixelGR8 *)shmem.data());
|
|
Shinya Kitaoka |
120a6e |
TRop::copy(outImage, ras);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
shmem.unlock();
|
|
Shinya Kitaoka |
120a6e |
shmem.detach();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Release the shared segment
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << tipc::clr << QString("$shmem_release") << shMemId);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TPoint TFontManager::drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin,
|
|
Shinya Kitaoka |
120a6e |
int inkId, wchar_t charcode, wchar_t nextCode) {
|
|
Shinya Kitaoka |
120a6e |
QLocalSocket socket;
|
|
Shinya Kitaoka |
120a6e |
tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1,
|
|
Shinya Kitaoka |
120a6e |
t32bitsrv::srvCmdline());
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
tipc::Stream stream(&socket);
|
|
Shinya Kitaoka |
120a6e |
tipc::Message msg;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString shMemId(tipc::uniqueId()), res;
|
|
Shinya Kitaoka |
120a6e |
{
|
|
Shinya Kitaoka |
120a6e |
// Invoke the appropriate command
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << QString("$FNTdrawCharCM") << inkId << shMemId << charcode
|
|
Shinya Kitaoka |
120a6e |
<< nextCode);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TDimension dim(0, 0);
|
|
Shinya Kitaoka |
120a6e |
msg >> dim.lx >> dim.ly;
|
|
Shinya Kitaoka |
120a6e |
TPoint ret;
|
|
Shinya Kitaoka |
120a6e |
msg >> ret.x >> ret.y;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Create outImage
|
|
Shinya Kitaoka |
120a6e |
outImage = TRasterCM32P(dim.lx, dim.ly);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QSharedMemory shmem(shMemId);
|
|
Shinya Kitaoka |
120a6e |
shmem.attach();
|
|
Shinya Kitaoka |
120a6e |
shmem.lock();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Copy the returned image to outImage
|
|
Shinya Kitaoka |
120a6e |
TRasterCM32P ras(dim.lx, dim.ly, dim.lx, (TPixelCM32 *)shmem.data());
|
|
Shinya Kitaoka |
120a6e |
TRop::copy(outImage, ras);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
shmem.unlock();
|
|
Shinya Kitaoka |
120a6e |
shmem.detach();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// Release the shared segment
|
|
Shinya Kitaoka |
120a6e |
stream << (msg << tipc::clr << QString("$shmem_release") << shMemId);
|
|
Shinya Kitaoka |
120a6e |
if (tipc::readMessage(stream, msg) != "ok")
|
|
Shinya Kitaoka |
120a6e |
throw TException("Unexpected error");
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
return ret;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|