summaryrefslogtreecommitdiff
path: root/src/minifont.hh
blob: a26784251c98ea2571a317711089198b93dcb595 (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
/*
 * Copyright (C) 2003,2008 Red Hat, Inc.
 * Copyright © 2019, 2020 Christian Persch
 *
 * This library 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.
 *
 * This library 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 library.  If not, see <https://www.gnu.org/licenses/>.
 */

#pragma once

#include <cstdint>

#include "fwd.hh"
#include "vtetypes.hh"
#include "vteunistr.h"

namespace vte {
namespace view {

class Minifont {
public:

        /* Check if a unicode character is actually a graphic character we draw
         * ourselves to handle cases where fonts don't have glyphs for them.
         */
        static inline constexpr bool
        unistr_is_local_graphic(vteunistr const c) noexcept
        {
                /* Box Drawing & Block Elements */
                return ((c >=  0x23b8 && c <=  0x23bd) ||
                        (c >=  0x2500 && c <=  0x259f) ||
                        (c >=  0x25e2 && c <=  0x25e5) ||
                        (c >= 0x1fb00 && c <= 0x1fbebf) ||
                        (c >= 0x1cc00 && c <= 0x1ceaf));
        }

        /* Draw the graphic representation of a line-drawing or special graphics
         * character.
         */
        void draw_graphic(DrawingContext const& context,
                          vteunistr c,
                          uint32_t const attr,
                          vte::color::rgb const* fg,
                          int x,
                          int y,
                          int font_width,
                          int columns,
                          int font_height);

}; // class Minifont

} // namespace view
} // namespace vte