blob: 665557083cfcdaad2d86a7633c7875b4c7031405 (
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
|
/*
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/HashMap.h>
#include <AK/String.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Emoji.h>
namespace Gfx {
static HashMap<u32, RefPtr<Gfx::Bitmap>> s_emojis;
const Bitmap* Emoji::emoji_for_code_point(u32 code_point)
{
auto it = s_emojis.find(code_point);
if (it != s_emojis.end())
return (*it).value.ptr();
auto bitmap = Bitmap::load_from_file(String::formatted("/res/emoji/U+{:X}.png", code_point));
if (!bitmap) {
s_emojis.set(code_point, nullptr);
return nullptr;
}
s_emojis.set(code_point, bitmap);
return bitmap.ptr();
}
}
|