| |
| |
| #ifdef __LP64__ |
| |
| |
| #include "tvectorimage.h" |
| #include "tstroke.h" |
| #include "trop.h" |
| |
| |
| #include <QSharedMemory> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #include "tipc.h" |
| #include "t32bitsrv_wrap.h" |
| |
| #include "tfont.h" |
| |
| |
| |
| |
| |
| namespace |
| { |
| |
| QDataStream &operator>>(QDataStream &ds, TThickPoint &p) |
| { |
| return ds >> p.x >> p.y >> p.thick; |
| } |
| |
| void readVImage(TVectorImageP &vi, tipc::Message &msg) |
| { |
| std::vector<TThickPoint> strokeCPs; |
| |
| |
| while (!msg.ds().atEnd()) { |
| strokeCPs.clear(); |
| msg >> strokeCPs; |
| |
| vi->addStroke(new TStroke(strokeCPs)); |
| } |
| |
| vi->group(0, vi->getStrokeCount()); |
| } |
| |
| } |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| struct TFontManager::Impl { |
| int m_ascender; |
| int m_descender; |
| |
| Impl() {} |
| ~Impl() {} |
| }; |
| |
| |
| |
| |
| |
| TFontManager::TFontManager() |
| { |
| m_pimpl = new TFontManager::Impl(); |
| } |
| |
| |
| |
| TFontManager::~TFontManager() |
| { |
| delete m_pimpl; |
| } |
| |
| |
| |
| TFontManager *TFontManager::instance() |
| { |
| static TFontManager theInstance; |
| return &theInstance; |
| } |
| |
| |
| |
| |
| |
| TFont *TFontManager::getCurrentFont() |
| { |
| assert(false); |
| return 0; |
| } |
| |
| |
| |
| |
| void TFontManager::loadFontNames() |
| { |
| |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTloadFontNames")); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TFontLibraryLoadingError(); |
| } |
| |
| |
| |
| |
| |
| void TFontManager::setFamily(const std::wstring family) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTsetFamily") << family); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TFontCreationError(); |
| } |
| |
| |
| |
| |
| |
| void TFontManager::setTypeface(const std::wstring typeface) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTsetTypeface") << typeface); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TFontCreationError(); |
| |
| |
| msg >> m_pimpl->m_ascender >> m_pimpl->m_descender; |
| } |
| |
| |
| |
| std::wstring TFontManager::getCurrentFamily() const |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTgetCurrentFamily")); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Could not get font family"); |
| |
| std::wstring family; |
| msg >> family; |
| return family; |
| } |
| |
| |
| |
| std::wstring TFontManager::getCurrentTypeface() const |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTgetCurrentTypeface")); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Could not get font typeface"); |
| |
| std::wstring typeface; |
| msg >> typeface; |
| return typeface; |
| } |
| |
| |
| |
| void TFontManager::getAllFamilies(std::vector<std::wstring> &families) const |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTgetAllFamilies")); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Could not get font families"); |
| |
| msg >> families; |
| } |
| |
| |
| |
| void TFontManager::getAllTypefaces(std::vector<std::wstring> &typefaces) const |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTgetAllTypefaces")); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Could not get font typefaces"); |
| |
| msg >> typefaces; |
| } |
| |
| |
| |
| void TFontManager::setVertical(bool vertical) |
| { |
| } |
| |
| |
| |
| void TFontManager::setSize(int size) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTsetSize") << size); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| |
| |
| msg >> m_pimpl->m_ascender >> m_pimpl->m_descender; |
| } |
| |
| |
| |
| TPoint TFontManager::getDistance(wchar_t firstChar, wchar_t secondChar) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTgetDistance") << firstChar << secondChar); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| |
| TPoint d; |
| msg >> d.x >> d.y; |
| return d; |
| } |
| |
| |
| |
| int TFontManager::getMaxHeight() |
| { |
| return m_pimpl->m_ascender - m_pimpl->m_descender; |
| } |
| |
| |
| |
| int TFontManager::getMaxWidth() |
| { |
| assert(!"not implemented yet"); |
| return 100; |
| } |
| |
| |
| |
| bool TFontManager::hasVertical() |
| { |
| return false; |
| } |
| |
| |
| |
| bool TFontManager::hasKerning() |
| { |
| return true; |
| } |
| |
| |
| |
| int TFontManager::getLineAscender() |
| { |
| return m_pimpl->m_ascender; |
| } |
| |
| |
| |
| int TFontManager::getLineDescender() |
| { |
| return m_pimpl->m_descender; |
| } |
| |
| |
| |
| TPoint TFontManager::drawChar(TVectorImageP &outImage, wchar_t charcode, wchar_t nextCode) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| stream << (msg << QString("$FNTdrawCharVI") << charcode << nextCode); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| |
| TPoint ret; |
| msg >> ret.x >> ret.y; |
| ::readVImage(outImage, msg); |
| |
| return ret; |
| } |
| |
| |
| |
| TPoint TFontManager::drawChar(TRasterGR8P &outImage, TPoint &glyphOrigin, wchar_t charcode, wchar_t nextCode) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| QString shMemId(tipc::uniqueId()), res; |
| { |
| |
| stream << (msg << QString("$FNTdrawCharGR") |
| << shMemId << charcode << nextCode); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| } |
| |
| TDimension dim(0, 0); |
| msg >> dim.lx >> dim.ly; |
| TPoint ret; |
| msg >> ret.x >> ret.y; |
| |
| |
| outImage = TRasterGR8P(dim.lx, dim.ly); |
| |
| QSharedMemory shmem(shMemId); |
| shmem.attach(); |
| shmem.lock(); |
| |
| |
| TRasterGR8P ras(dim.lx, dim.ly, dim.lx, (TPixelGR8 *)shmem.data()); |
| TRop::copy(outImage, ras); |
| |
| shmem.unlock(); |
| shmem.detach(); |
| |
| |
| stream << (msg << tipc::clr << QString("$shmem_release") << shMemId); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| |
| return ret; |
| } |
| |
| |
| |
| TPoint TFontManager::drawChar(TRasterCM32P &outImage, TPoint &glyphOrigin, |
| int inkId, wchar_t charcode, wchar_t nextCode) |
| { |
| QLocalSocket socket; |
| tipc::startSlaveConnection(&socket, t32bitsrv::srvName(), -1, t32bitsrv::srvCmdline()); |
| |
| tipc::Stream stream(&socket); |
| tipc::Message msg; |
| |
| QString shMemId(tipc::uniqueId()), res; |
| { |
| |
| stream << (msg << QString("$FNTdrawCharCM") |
| << inkId << shMemId << charcode << nextCode); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| } |
| |
| TDimension dim(0, 0); |
| msg >> dim.lx >> dim.ly; |
| TPoint ret; |
| msg >> ret.x >> ret.y; |
| |
| |
| outImage = TRasterCM32P(dim.lx, dim.ly); |
| |
| QSharedMemory shmem(shMemId); |
| shmem.attach(); |
| shmem.lock(); |
| |
| |
| TRasterCM32P ras(dim.lx, dim.ly, dim.lx, (TPixelCM32 *)shmem.data()); |
| TRop::copy(outImage, ras); |
| |
| shmem.unlock(); |
| shmem.detach(); |
| |
| |
| stream << (msg << tipc::clr << QString("$shmem_release") << shMemId); |
| if (tipc::readMessage(stream, msg) != "ok") |
| throw TException("Unexpected error"); |
| |
| return ret; |
| } |
| |
| #endif |
| |