From c853ffb5b2f75f5a889ed2e3ef89b818a736e87a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 13:50:49 +0200 Subject: Adding upstream version 1.3+ds. Signed-off-by: Daniel Baumann --- src/util/document-fonts.cpp | 80 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/util/document-fonts.cpp (limited to 'src/util/document-fonts.cpp') diff --git a/src/util/document-fonts.cpp b/src/util/document-fonts.cpp new file mode 100644 index 0000000..5711d31 --- /dev/null +++ b/src/util/document-fonts.cpp @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * This file contains document used fonts related logic. The functions to manage the + * document fonts are defined in this file. + * + * Authors: + * Vaibhav Malik + * + * The contents of this file may be used under the GNU General Public License Version 2 or later. + * + */ + +#include "document-fonts.h" + +#include + +using namespace Inkscape::IO::Resource; + +namespace Inkscape { + +// get instance method for the singleton design pattern. +DocumentFonts* DocumentFonts::get() +{ + static DocumentFonts* s_instance = new Inkscape::DocumentFonts(); + return s_instance; +} + +DocumentFonts::DocumentFonts() {} + +void DocumentFonts::clear() +{ + _document_fonts.clear(); +} + +/* +void DocumentFonts::print_document_fonts() +{ + std::cout << std::endl << "********************" << std::endl; + + for(auto const& font: _document_fonts) { + std::cout << font << std::endl; + } + + std::cout << std::endl << "********************" << std::endl; +} +*/ + +void DocumentFonts::update_document_fonts(const std::map>& font_data) +{ + // Clear the old fonts and then insert latest set. + clear(); + + // Iterate over all the fonts in this map, + // and insert these fonts into the document_fonts. + for(auto const& ele: font_data) { + _document_fonts.insert(ele.first); + } + + // Emit the update signal to keep everything consistent. + update_signal.emit(); +} + +// Returns the fonts used in the document. +const std::set DocumentFonts::get_fonts() +{ + return _document_fonts; +} + +} // Namespace + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3