Skip to content

Latest commit

 

History

History
178 lines (147 loc) · 4.79 KB

README.md

File metadata and controls

178 lines (147 loc) · 4.79 KB

Collection of useful libraries for working with Emoji

Emoji

A full collection of all emojis available in iOS.

Emojis are retrieved from gemoji repository. It makes sense to use a more up-to-date source.

How to use?

import Emoji

let emoji = Emoji.violin // 🎻

TODO:

  1. Support ExpressibleByStringLiteral
  2. Add category, aliases and tags for all emojis.
  3. List of all emojis for each category.
  4. Find Emoji by tag or alias.
  5. Support MacOS.

EmojiImage

Library for creating UIImage from Emoji.

Why would this be useful?

  1. Designers like to use Emoji in the app interface, but the AppStore may reject the app if emojis are used as a prerendered images. [1]

From App Store Review Guidelines:

4.5.6 Apps may use Unicode characters that render as Apple emoji in their app and app metadata. Apple emoji may not be used on other platforms or embedded directly in your app binary.

To get around this limitation, you can generate Emoji in runtime using this library.

  1. You can use Emoji as text, but it's not always convenient. Sometimes you need to use emojis as an avatar placeholder or make emojis grayscale.

How to use?

500x500 pt image

import EmojiImage

let emoji = Emoji.grinningFaceWithSmilingEyes
    .size(500)
    .image
      

500x500 pt image with 50 pt insets and teal elipse background

import EmojiImage

let emoji: UIImage = Emoji.guitar
    .size(500)
    .inset(by: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50))
    .background(UIColor.systemTeal)
    .ellipse()
    .image
      

500x500 pt grayscale image

import EmojiImage

let emoji = Emoji.fox    
    .size(500)
    .grayscale(1)
    .image
      

500x500 pt semi-grayscale image with 50 pt insets and yellow background

import EmojiImage

let emoji = Emoji.owl
    .size(500)
    .inset(by: UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50))
    .grayscale(0.5)
    .background(UIColor.systemYellow)
    .image
      

500x500 pt image with custom processing

import CoreImage.CIFilterBuiltins
import EmojiImage

func blur(radius: Double) -> (UIImage) -> UIImage {
    return { image in
        guard let currentCGImage = image.cgImage else { return image }
        let currentCIImage = CIImage(cgImage: currentCGImage)
        let filter = CIFilter.gaussianBlur()
        filter.inputImage = currentCIImage
        filter.radius = radius
        guard let outputImage = filter.outputImage else { return image }
        let context = CIContext()
        if let cgimg = context.createCGImage(outputImage, from: outputImage.extent) {
            let processedImage = UIImage(cgImage: cgimg)
            return processedImage
        } else {
            return image
        }
    }
}

let emoji = Emoji.eye
     .size(500)
     .process(with: blur(radius: 30))
     .image
      

TODO:

  1. Create more built-in image processings
  2. Find a way to get a high-quality images

Example

To view the sample app open Emoji.workspace and run Example target. You also can use SwiftUI preview canvas in Example/ContentView.swift` file.

Other awesome repos

  1. https://github.com/onmyway133/Smile
  2. https://github.com/isaced/ISEmojiView

Contribution

I will be very grateful for any help and good ideas for new features.
Open issues, create pull requests, or write to me on Twitter (@inlinable).