mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 20:42:21 +00:00
LibUnicode+LibGfx: Remove superfluous emoji metadata
For SerenityOS, we parse emoji metadata from the UCD to learn emoji groups, subgroups, names, etc. We used this information only in the emoji picker dialog. It is entirely unused within Ladybird. This removes our dependence on the UCD emoji file, as we no longer need any of its information. All we need to know is the file path to our custom emoji, which we get from Meta/emoji-file-list.txt.
This commit is contained in:
parent
aa3a30870b
commit
069bed5d47
Notes:
sideshowbarker
2024-07-18 22:57:59 +09:00
Author: https://github.com/trflynn89
Commit: 069bed5d47
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/239
7 changed files with 70 additions and 660 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace Unicode {
|
||||
|
||||
Optional<Emoji> __attribute__((weak)) find_emoji_for_code_points(ReadonlySpan<u32>) { return {}; }
|
||||
Optional<StringView> __attribute__((weak)) emoji_image_for_code_points(ReadonlySpan<u32>) { return {}; }
|
||||
|
||||
// https://unicode.org/reports/tr51/#def_emoji_core_sequence
|
||||
static bool could_be_start_of_emoji_core_sequence(u32 code_point, Optional<u32> const& next_code_point, SequenceType type)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2022-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022-2024, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -13,39 +13,7 @@
|
|||
|
||||
namespace Unicode {
|
||||
|
||||
enum class EmojiGroup : u8 {
|
||||
Unknown,
|
||||
|
||||
SmileysAndEmotion,
|
||||
PeopleAndBody,
|
||||
Component,
|
||||
AnimalsAndNature,
|
||||
FoodAndDrink,
|
||||
TravelAndPlaces,
|
||||
Activities,
|
||||
Objects,
|
||||
Symbols,
|
||||
Flags,
|
||||
|
||||
// Non-standard emoji added for SerenityOS:
|
||||
SerenityOS,
|
||||
};
|
||||
|
||||
struct Emoji {
|
||||
StringView name;
|
||||
Optional<StringView> image_path;
|
||||
EmojiGroup group { EmojiGroup::Unknown };
|
||||
u32 display_order { 0 };
|
||||
ReadonlySpan<u32> code_points;
|
||||
};
|
||||
|
||||
Optional<Emoji> find_emoji_for_code_points(ReadonlySpan<u32> code_points);
|
||||
|
||||
template<size_t Size>
|
||||
Optional<Emoji> find_emoji_for_code_points(u32 const (&code_points)[Size])
|
||||
{
|
||||
return find_emoji_for_code_points(ReadonlySpan<u32> { code_points });
|
||||
}
|
||||
Optional<StringView> emoji_image_for_code_points(ReadonlySpan<u32> code_points);
|
||||
|
||||
enum class SequenceType {
|
||||
Any,
|
||||
|
@ -55,66 +23,4 @@ enum class SequenceType {
|
|||
bool could_be_start_of_emoji_sequence(Utf8CodePointIterator const&, SequenceType = SequenceType::Any);
|
||||
bool could_be_start_of_emoji_sequence(Utf32CodePointIterator const&, SequenceType = SequenceType::Any);
|
||||
|
||||
constexpr StringView emoji_group_to_string(EmojiGroup group)
|
||||
{
|
||||
switch (group) {
|
||||
case EmojiGroup::Unknown:
|
||||
return "Unknown"sv;
|
||||
case EmojiGroup::SmileysAndEmotion:
|
||||
return "Smileys & Emotion"sv;
|
||||
case EmojiGroup::PeopleAndBody:
|
||||
return "People & Body"sv;
|
||||
case EmojiGroup::Component:
|
||||
return "Component"sv;
|
||||
case EmojiGroup::AnimalsAndNature:
|
||||
return "Animals & Nature"sv;
|
||||
case EmojiGroup::FoodAndDrink:
|
||||
return "Food & Drink"sv;
|
||||
case EmojiGroup::TravelAndPlaces:
|
||||
return "Travel & Places"sv;
|
||||
case EmojiGroup::Activities:
|
||||
return "Activities"sv;
|
||||
case EmojiGroup::Objects:
|
||||
return "Objects"sv;
|
||||
case EmojiGroup::Symbols:
|
||||
return "Symbols"sv;
|
||||
case EmojiGroup::Flags:
|
||||
return "Flags"sv;
|
||||
case EmojiGroup::SerenityOS:
|
||||
return "SerenityOS"sv;
|
||||
}
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
constexpr EmojiGroup emoji_group_from_string(StringView group)
|
||||
{
|
||||
if (group == "Unknown"sv)
|
||||
return EmojiGroup::Unknown;
|
||||
if (group == "Smileys & Emotion"sv)
|
||||
return EmojiGroup::SmileysAndEmotion;
|
||||
if (group == "People & Body"sv)
|
||||
return EmojiGroup::PeopleAndBody;
|
||||
if (group == "Component"sv)
|
||||
return EmojiGroup::Component;
|
||||
if (group == "Animals & Nature"sv)
|
||||
return EmojiGroup::AnimalsAndNature;
|
||||
if (group == "Food & Drink"sv)
|
||||
return EmojiGroup::FoodAndDrink;
|
||||
if (group == "Travel & Places"sv)
|
||||
return EmojiGroup::TravelAndPlaces;
|
||||
if (group == "Activities"sv)
|
||||
return EmojiGroup::Activities;
|
||||
if (group == "Objects"sv)
|
||||
return EmojiGroup::Objects;
|
||||
if (group == "Symbols"sv)
|
||||
return EmojiGroup::Symbols;
|
||||
if (group == "Flags"sv)
|
||||
return EmojiGroup::Flags;
|
||||
if (group == "SerenityOS"sv)
|
||||
return EmojiGroup::SerenityOS;
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
namespace Unicode {
|
||||
|
||||
enum class BidiClass;
|
||||
enum class EmojiGroup : u8;
|
||||
|
||||
struct CurrencyCode;
|
||||
struct Emoji;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue