JSPM

@canvacord/emoji-parser

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 113
  • Score
    100M100P100Q79620F
  • License MIT

Emoji parser for canvacord.

Package Exports

  • @canvacord/emoji-parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@canvacord/emoji-parser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Emoji Parser

Emoji parser for Canvacord.

Emojis

  • twemoji
  • discord emojis

Installing

$ npm i @canvacord/emoji-parser

Example

const Canvas = require("canvas");
const { fillTextWithTwemoji } = require("@canvacord/emoji-parser");
const fs = require("fs");

const canvas = Canvas.createCanvas(500, 270);
const ctx = canvas.getContext("2d");

ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, canvas.width, canvas.height);

ctx.fillStyle = "#FF0000";
ctx.font = "32px Arial";

fillTextWithTwemoji(ctx, "Hello World 😊 <:kek:750253062689652768>", 120, 150)
    .then(() => {
        fs.writeFileSync("./img.png", canvas.toBuffer())
    })
    .catch(console.error);

With Typescript

import { fillTextWithTwemoji } from "@canvacord/emoji-parser";

Preview

Preview

Available Methods

fillTextWithEmoji(context: CanvasRenderingContext2D, text: string, x: number, y: number, options?: DrawTextWithEmojiParams): Promise

Renders emojis with fillType: "fill".

strokeTextWithEmoji(context: CanvasRenderingContext2D, text: string, x: number, y: number, options?: DrawTextWithEmojiParams): Promise

Renders emojis with fillType: "stroke".

drawTextWithEmoji(context: CanvasRenderingContext2D, fillType: "fill" | "stroke", text: string, x: number, y: number, options?: DrawTextWithEmojiParams): Promise

Main method used by both fillTextWithEmoji and strokeTextWithEmoji.