mirror of
https://github.com/zulip/zulip.git
synced 2025-10-22 20:42:14 +00:00
emoji: Remove deprecated Google blobs emoji set.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
b742ab18f9
commit
85c94599c5
@@ -153,11 +153,7 @@ def get_square_size(emoji_data: Sequence[dict[str, Any]]) -> int:
|
||||
|
||||
|
||||
def generate_sprite_css_files(
|
||||
cache_path: str,
|
||||
emoji_data: list[dict[str, Any]],
|
||||
emojiset: str,
|
||||
alt_name: str,
|
||||
fallback_emoji_data: Sequence[dict[str, Any]],
|
||||
cache_path: str, emoji_data: list[dict[str, Any]], emojiset: str
|
||||
) -> None:
|
||||
"""
|
||||
Spritesheets are usually NxN squares.
|
||||
@@ -236,28 +232,11 @@ def generate_sprite_css_files(
|
||||
f.write(
|
||||
SPRITE_CSS_FILE_TEMPLATE.format(
|
||||
emojiset=emojiset,
|
||||
alt_name=alt_name,
|
||||
emoji_positions=emoji_positions,
|
||||
background_size=background_size,
|
||||
),
|
||||
)
|
||||
|
||||
# Google Classic stopped being supported in 2017. To be able to use other emoji, we
|
||||
# fallback to Google Modern for any emoji not covered by Google Classic.
|
||||
if emojiset == "google-blob":
|
||||
extra_emoji_positions = ""
|
||||
covered_emoji_codes = [
|
||||
get_emoji_code(emoji) for emoji in emoji_data if emoji["has_img_google"]
|
||||
]
|
||||
for emoji in fallback_emoji_data:
|
||||
code = get_emoji_code(emoji)
|
||||
if emoji["has_img_google"] and code not in covered_emoji_codes:
|
||||
extra_emoji_positions += EMOJI_OVERRIDE_TEMPLATE.format(
|
||||
codepoint=code,
|
||||
)
|
||||
with open(SPRITE_CSS_PATH, "a") as f:
|
||||
f.write(extra_emoji_positions)
|
||||
|
||||
# The Twitter emoji team was laid off in 2022, so new emoji aren't supported.
|
||||
# https://github.com/twitter/twemoji/issues/570#issuecomment-1303422143.
|
||||
# The "twitter" sprite sheet we’re using does have images in those locations,
|
||||
@@ -295,32 +274,20 @@ def setup_emoji_farms(cache_path: str, emoji_data: list[dict[str, Any]]) -> None
|
||||
dst_file = os.path.join(target_emoji_farm, img_file_name)
|
||||
shutil.copy2(src_file, dst_file)
|
||||
|
||||
def setup_emoji_farm(
|
||||
emojiset: str,
|
||||
emoji_data: list[dict[str, Any]],
|
||||
alt_name: str | None = None,
|
||||
fallback_emoji_data: Sequence[dict[str, Any]] = [],
|
||||
) -> None:
|
||||
# `alt_name` is an optional parameter that we use to avoid duplicating below
|
||||
# code. It is only used while setting up google-blob emoji set as it is just
|
||||
# a wrapper for an older version of emoji-datasource package due to which we
|
||||
# need to use 'google' at some places in this code. It has no meaning for other
|
||||
# emoji sets and is just equivalent to `emojiset`.
|
||||
alt_name = alt_name or emojiset
|
||||
|
||||
def setup_emoji_farm(emojiset: str, emoji_data: list[dict[str, Any]]) -> None:
|
||||
# Copy individual emoji images from npm packages.
|
||||
src_emoji_farm = os.path.join(
|
||||
NODE_MODULES_PATH, "emoji-datasource-" + emojiset, "img", alt_name, "64"
|
||||
NODE_MODULES_PATH, "emoji-datasource-" + emojiset, "img", emojiset, "64"
|
||||
)
|
||||
target_emoji_farm = os.path.join(cache_path, "static", "images-" + emojiset + "-64")
|
||||
os.makedirs(target_emoji_farm, exist_ok=True)
|
||||
print(f"Copying individual {emojiset} image files...")
|
||||
for emoji_dict in emoji_data:
|
||||
if emoji_dict["has_img_" + alt_name]:
|
||||
if emoji_dict["has_img_" + emojiset]:
|
||||
ensure_emoji_image(emoji_dict, src_emoji_farm, target_emoji_farm)
|
||||
skin_variations = emoji_dict.get("skin_variations", {})
|
||||
for img_info in skin_variations.values():
|
||||
if img_info["has_img_" + alt_name]:
|
||||
if img_info["has_img_" + emojiset]:
|
||||
ensure_emoji_image(img_info, src_emoji_farm, target_emoji_farm)
|
||||
|
||||
# Copy zulip.png to the emoji farm.
|
||||
@@ -334,7 +301,7 @@ def setup_emoji_farms(cache_path: str, emoji_data: list[dict[str, Any]]) -> None
|
||||
output_img_file = os.path.join(target_emoji_farm, "1f419.png")
|
||||
shutil.copyfile(input_img_file, output_img_file)
|
||||
|
||||
generate_sprite_css_files(cache_path, emoji_data, emojiset, alt_name, fallback_emoji_data)
|
||||
generate_sprite_css_files(cache_path, emoji_data, emojiset)
|
||||
|
||||
print(f"Converting {emojiset} sheet to webp...")
|
||||
TARGET_EMOJI_SHEETS = os.path.join(cache_path, "web", "emoji")
|
||||
@@ -344,7 +311,7 @@ def setup_emoji_farms(cache_path: str, emoji_data: list[dict[str, Any]]) -> None
|
||||
NODE_MODULES_PATH,
|
||||
f"emoji-datasource-{emojiset}",
|
||||
"img",
|
||||
alt_name,
|
||||
emojiset,
|
||||
"sheets-256",
|
||||
"64.png",
|
||||
)
|
||||
@@ -360,14 +327,6 @@ def setup_emoji_farms(cache_path: str, emoji_data: list[dict[str, Any]]) -> None
|
||||
for emojiset in ["google", "twitter"]:
|
||||
setup_emoji_farm(emojiset, emoji_data)
|
||||
|
||||
# Set up old Google "blobs" emoji set.
|
||||
GOOGLE_BLOB_EMOJI_DATA_PATH = os.path.join(
|
||||
NODE_MODULES_PATH, "emoji-datasource-google-blob", "emoji.json"
|
||||
)
|
||||
with open(GOOGLE_BLOB_EMOJI_DATA_PATH, "rb") as fp:
|
||||
blob_emoji_data = orjson.loads(fp.read())
|
||||
setup_emoji_farm("google-blob", blob_emoji_data, "google", emoji_data)
|
||||
|
||||
|
||||
def setup_old_emoji_farm(
|
||||
cache_path: str, emoji_map: dict[str, str], emoji_data: list[dict[str, Any]]
|
||||
|
Reference in New Issue
Block a user