Add Microsoft Fluent Emoji to Siyuan Note

  1. The following content uses ==Google Translate==
  2. This solution is to add Microsoft emojis by adding ==custom emojis== . The whole set has about 10,000 emojis. You can use it as appropriate.
  3. As usual, the tutorial is given first and then the example, so the pictures are below the steps ====.
  4. This tutorial is mainly to cooperate with the folder grouping function of Siyuan plug-in: emoji enhancement (siyuan-plugin-emoji-enhance) to automatically group the source files.

First of all, the disadvantages are explained:

  1. No suitable fluent emoji font has been found for the time being, so this solution cannot replace the built-in emoji of Siyuan.
  2. There are many and large files, with a total of 10,000+ (four styles in total) and a size of 100MB. Choose and use as appropriate.

Steps

Prerequisites

  1. Download the compressed file of fluent emoji: GitHub - microsoft/fluentui-emoji: A collection of familiar, friendly, and modern emoji from Microsoft
  2. Green button: Code ---> Download ZIP
  3. Install emoji enhancement (siyuan plugin emoji enhance) in Siyuan
  4. Install python https://www.python.org/

Specific steps

  1. Unzip the downloaded ZIP file
  2. Find the unzipped folder
  3. Create a python file organize_emoji.py under Folder path --> assets
  4. Copy the code to the python file and run it in this folder
  5. Run the command: python3 organize_emoji.py
  6. Code:
import os
import json
import shutil

# 设定当前目录为工作目录
root_dir = '.'

# 功能:递归遍历文件夹,寻找最底层的目录
def move_files_and_remove_dir(path, group):
    # 判断是否是最底层目录
    if all(os.path.isdir(os.path.join(path, x)) for x in os.listdir(path)):
        for dir_name in os.listdir(path):
            # 递归调用处理下一层目录
            move_files_and_remove_dir(os.path.join(path, dir_name), group)
    else:
        # 移动文件到目标目录
        target_folder = os.path.join(root_dir, f"{group}_{os.path.basename(path)}")
        os.makedirs(target_folder, exist_ok=True)
        for file in os.listdir(path):
            src_file = os.path.join(path, file)
            dst_file = os.path.join(target_folder, file)
            shutil.move(src_file, dst_file)
        # 检查是否可以删除原目录
        if not os.listdir(path):
            os.rmdir(path)

# 遍历所有顶级文件夹
for emoji_folder in os.listdir(root_dir):
    emoji_path = os.path.join(root_dir, emoji_folder)
    if os.path.isdir(emoji_path) and 'metadata.json' in os.listdir(emoji_path):
        metadata_path = os.path.join(emoji_path, 'metadata.json')

        # 读取metadata.json获取group信息
        with open(metadata_path, 'r', encoding='utf-8') as f:
            data = json.load(f)
            group = data.get('group')

        # 处理此emoji文件夹下的所有文件
        for item in os.listdir(emoji_path):
            item_path = os.path.join(emoji_path, item)
            if os.path.isdir(item_path):
                move_files_and_remove_dir(item_path, group)

        # 删除原emoji目录
        shutil.rmtree(emoji_path, ignore_errors=True)

# 打印完成信息
print("文件已按照分组信息和风格分类。原文件夹已删除。")

  1. To be safe, close SourceScript, and then copy all folders in assets to the bottom of SourceScript's emojis folder
  2. Open SourceScript
  3. By the way, here is a CSS snippet to fix the emoji enhanced grouping column

.emojis>.fn__flex {
    overflow-x: scroll;
}

Introduction

Microsoft fluent is divided into four styles:

  1. 3D: PNG format, good effect
  2. Colorful Color: SVG format, three-dimensional icons with effects that are somewhat different from 3D
  3. Flat Flat: SVG format, flat icons
  4. High Contrast (black and white): SVG format, black and white icons

image.png

image.png

image.png

Style of plug-ins combined in SourceScript

You can see that the bottom is grouped by default type and style.

image.png

image.png

    1 Operate
    ACai updated this article at 2024-08-02 12:53:32

    Welcome to here!

    Here we can learn from each other how to use SiYuan, give feedback and suggestions, and build SiYuan together.

    Signup About
    Please input reply content ...