// Copyright (C) 2000-2007, Luca Padovani . // // This file is part of GtkMathView, a flexible, high-quality rendering // engine for MathML documents. // // GtkMathView is free software; you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published // by the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // GtkMathView 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 // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see . #include #include #include "AbstractLogger.hh" #include "Configuration.hh" #include "PS_Backend.hh" #include "PS_AreaFactory.hh" #include "PS_MathGraphicDevice.hh" #if GMV_ENABLE_BOXML #include "PS_BoxGraphicDevice.hh" #else #include "BoxGraphicDevice.hh" #endif // GMV_ENABLE_BOXML #include "SpaceShaper.hh" #include "NullShaper.hh" #ifdef GMV_ENABLE_TFM #include "TFMManager.hh" #include "TFMFontManager.hh" #include "PS_TFMComputerModernMathGraphicDevice.hh" #include "PS_TFMComputerModernShaper.hh" #endif // GMV_ENABLE_TFM #include "ShaperManager.hh" PS_Backend::PS_Backend(const SmartPtr& l, const SmartPtr& conf) : Backend(l, conf) { SmartPtr factory = PS_AreaFactory::create(); #if GMV_ENABLE_TFM SmartPtr cmShaper; // the fact that the Type1 and TT versions of the computer modern // shapers for the PS backend share the same font manager is just a // twisted coincidence. Beware SmartPtr tfm = TFMManager::create(); SmartPtr fm = TFMFontManager::create(tfm); #endif // GMV_ENABLE_TFM std::multimap > shaperSet; if (conf->getBool(l, "ps-backend/null-shaper/enabled", false)) shaperSet.insert(std::pair >(conf->getInt(l, "ps-backend/null-shaper/priority", 0), NullShaper::create(l))); if (conf->getBool(l, "ps-backend/space-shaper/enabled", false)) shaperSet.insert(std::pair >(conf->getInt(l, "ps-backend/space-shaper/priority", 0), SpaceShaper::create())); #if GMV_ENABLE_TFM if (conf->getBool(l, "ps-backend/type1-computer-modern-shaper/enabled", false)) { cmShaper = PS_TFMComputerModernShaper::create(l, conf); cmShaper->setFontManager(fm); shaperSet.insert(std::pair >(conf->getInt(l, "ps-backend/type1-computer-modern-shaper/priority", 0), cmShaper)); } /* if (conf->getBool(l, "ps-backend/ttf-computer-modern-shaper/enabled", false)) { cmShaper = PS_TTF_TFMComputerModernShaper::create(l, conf); cmShaper->setFontManager(fm); shaperSet.insert(std::pair >(conf->getInt(l, "ps-backend/ttf-computer-modern-shaper/priority", 0), cmShaper)); } */ #endif // GMV_ENABLE_TFM #if GMV_ENABLE_TFM SmartPtr mgd; if (cmShaper) { SmartPtr tfmMGD = PS_TFMComputerModernMathGraphicDevice::create(l, conf); tfmMGD->setFamily(cmShaper->getFamily()); tfmMGD->setTFMManager(tfm); mgd = tfmMGD; } else mgd = PS_MathGraphicDevice::create(l, conf); #else SmartPtr mgd = PS_MathGraphicDevice::create(l, conf); #endif // GMV_ENABLE_TFM mgd->setFactory(factory); setMathGraphicDevice(mgd); #if GMV_ENABLE_BOXML SmartPtr bgd = PS_BoxGraphicDevice::create(l, conf); bgd->setFactory(factory); setBoxGraphicDevice(bgd); #endif // GMV_ENABLE_BOXML for (std::multimap >::const_iterator p = shaperSet.begin(); p != shaperSet.end(); p++) getShaperManager()->registerShaper(p->second); } PS_Backend::~PS_Backend() { } SmartPtr PS_Backend::create(const SmartPtr& l, const SmartPtr& conf) { return new PS_Backend(l, conf); }