ladybird/Userland/Libraries/LibGfx/Emoji.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

33 lines
714 B
C++

/*
* 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();
}
}