Coverage Report

Created: 2026-07-30 07:17

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/splash/SplashFontFile.h
Line
Count
Source
1
//========================================================================
2
//
3
// SplashFontFile.h
4
//
5
//========================================================================
6
7
//========================================================================
8
//
9
// Modified under the Poppler project - http://poppler.freedesktop.org
10
//
11
// All changes made under the Poppler project to this file are licensed
12
// under GPL version 2 or later
13
//
14
// Copyright (C) 2006 Takashi Iwai <tiwai@suse.de>
15
// Copyright (C) 2008, 2010, 2018, 2024-2026 Albert Astals Cid <aacid@kde.org>
16
// Copyright (C) 2022 Oliver Sander <oliver.sander@tu-dresden.de>
17
// Copyright (C) 2024, 2026 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
18
//
19
// To see a description of the changes please see the Changelog file that
20
// came with your tarball or type make ChangeLog if you are building from git
21
//
22
//========================================================================
23
24
#ifndef SPLASHFONTFILE_H
25
#define SPLASHFONTFILE_H
26
27
#include <string>
28
#include <variant>
29
#include <vector>
30
#include <memory>
31
32
#include "SplashTypes.h"
33
#include "poppler_private_export.h"
34
35
class SplashFontEngine;
36
class SplashFont;
37
class SplashFontFileID;
38
39
//------------------------------------------------------------------------
40
// SplashFontFile
41
//------------------------------------------------------------------------
42
43
class POPPLER_PRIVATE_EXPORT SplashFontSrc
44
{
45
public:
46
    explicit SplashFontSrc(const std::string &file);
47
    explicit SplashFontSrc(std::vector<unsigned char> &&data);
48
49
    SplashFontSrc(const SplashFontSrc &) = delete;
50
    SplashFontSrc &operator=(const SplashFontSrc &) = delete;
51
52
0
    const std::vector<unsigned char> &buf() const { return std::get<std::vector<unsigned char>>(m_data); }
53
54
0
    const std::string &fileName() const { return std::get<std::string>(m_data); }
55
0
    bool isFile() const { return std::holds_alternative<std::string>(m_data); }
56
    ~SplashFontSrc();
57
58
private:
59
    const std::variant<std::string, std::vector<unsigned char>> m_data;
60
};
61
62
class POPPLER_PRIVATE_EXPORT SplashFontFile
63
{
64
public:
65
    virtual ~SplashFontFile();
66
67
    SplashFontFile(const SplashFontFile &) = delete;
68
    SplashFontFile &operator=(const SplashFontFile &) = delete;
69
70
    // Create a new SplashFont, i.e., a scaled instance of this font
71
    // file.
72
    virtual SplashFont *makeFont(const std::array<double, 4> &mat, const std::array<double, 4> &textMat) = 0;
73
74
    // Get the font file ID.
75
0
    const SplashFontFileID &getID() const { return *id; }
76
77
    bool doAdjustMatrix;
78
79
protected:
80
    SplashFontFile(std::unique_ptr<SplashFontFileID> idA, std::unique_ptr<SplashFontSrc> srcA);
81
82
    std::unique_ptr<SplashFontFileID> id;
83
    const std::unique_ptr<SplashFontSrc> src;
84
85
    friend class SplashFontEngine;
86
};
87
88
#endif