summaryrefslogtreecommitdiff
path: root/emojis.hpp
blob: b3c2925d60d1f775a0d0c1a979c096dd12773543 (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
#pragma once
#include <string>
#include <cstdio>
#include <unordered_map>
#include <vector>
#include <gtkmm.h>

// shoutout to gtk for only supporting .svg's sometimes

class EmojiResource {
public:
    EmojiResource(std::string filepath);
    bool Load();
    Glib::RefPtr<Gdk::Pixbuf> GetPixBuf(const Glib::ustring &pattern);
    static Glib::ustring PatternToHex(const Glib::ustring &pattern);
    static Glib::ustring HexToPattern(Glib::ustring hex);
    const std::vector<Glib::ustring> &GetPatterns() const;

private:
    std::unordered_map<std::string, std::pair<int, int>> m_index; // pattern -> [pos, len]
    FILE *m_fp = nullptr;
    std::string m_filepath;
    std::vector<Glib::ustring> m_patterns;
};