summaryrefslogtreecommitdiffstats
path: root/src/util/document-fonts.cpp
blob: 5711d3161961c99e1b1d75f78d0964071e97bf4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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 <vaibhavmalik2018@gmail.com>
 *
 * The contents of this file may be used under the GNU General Public License Version 2 or later.
 *
 */

#include "document-fonts.h"

#include <iostream>

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<Glib::ustring, std::set<Glib::ustring>>& 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 <Glib::ustring> 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 :