canvas-emojicdn
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

CANVAS + EMOJICDN

This is a simple implementation of the emojicdn service for Canvas.

Installation

npm install canvas-emojicnd

Usage

import { createCanvas, measureText } from 'canvas'
import { fillText } from 'canvas-emojicnd'

(async () => {
  const text = 'Hello, world!👋🥳'
  const canvas = createCanvas(200, 200)
  const ctx = canvas.getContext('2d')
  ctx.fillStyle = '#000'
  ctx.strokeStyle = '#fff'
  ctx.font = '25px Arial'
  
  // Get the width of the text
  const { width } = await measureText(ctx, text, 'whatsapp')

  // Draw the text:
  await fillText(ctx, text, canvas.width / 2 - width / 2, 100, 'whatsapp')
  await strokeText(ctx, text, canvas.width / 2 - width / 2, 200, 'whatsapp')

})()

Supported emoji styles:

  • apple
  • google
  • microsoft
  • samsung
  • whatsapp
  • twitter
  • messenger
  • joypixels
  • openmoji
  • emojidex
  • lg
  • htc
  • mozilla

If the emoji is not supported by the selected style, the emoji will be ignored.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

/canvas-emojicdn/

    Package Sidebar

    Install

    npm i canvas-emojicdn

    Weekly Downloads

    1

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    10.1 kB

    Total Files

    14

    Last publish

    Collaborators

    • 4l3dx