Compare commits

..

4 Commits

Author SHA1 Message Date
Mislav Marohnić
6a39782a46 gemoji 2.0.1 2014-08-02 09:24:58 -07:00
Adam Roben
c6a9db29bd Fix tests 2014-08-02 09:24:09 -07:00
Adam Roben
3ec375d299 Remove incorrect unicode aliases
db/aliases.html now clears out any incorrect aliases it finds.
2014-08-02 09:24:09 -07:00
Adam Roben
34cd8356bb Use the same unicode aliases as Safari 7.0.5 on OS X 10.9.4
Category-Emoji.json contains many code point sequences ending in U+FE0F
VARIATION SELECTOR-16. OS X renders some of these code point sequences
as color emoji even if you strip off VARIATION SELECTOR-16. (And in fact
it even renders some of them as color emoji if you replace VARIATION
SELECTOR-16 with VARIATION SELECTOR-15, even though that is explicitly
requesting a "text" variant of the character).

We used to assume that VARIATION SELECTOR-16 was optional for all emoji.
But this doesn't match OS X's behavior. This could cause problems, e.g.,
if you were to use the unicode_aliases property to detect Unicode emoji
and replace them with images for browsers that don't support emoji
natively.

The Ruby code no longer does anything special with VARIATION SELECTOR-16
other than to remove it from the description of each emoji. The new
db/aliases.html file can be used to determine which the correct Unicode
aliases for each emoji are. That page takes each emoji, generates a set
of variants using VARIATION SELECTOR-16 and VARIATION SELECTOR-15,
and renders each variant into a <canvas> element twice: once with a red
font color, and once with a green font color. If the variant renders the
same way, the OS is rendering the variant as a color emoji, and we add
it to the "unicodes" array for that emoji.

So the new process for generating db/emoji.json is:

1. rake db:dump > tmp
2. mv tmp db/emoji.json
3. open -a Safari db/aliases.html
4. Copy the resulting JSON from Safari
5. pbpaste > db/emoji.json

This ensures that unicode_aliases only contains those code point
sequences which actually render as color emoji on OS X.
2014-08-02 09:24:09 -07:00
1000 changed files with 398 additions and 644 deletions

View File

@@ -1,7 +1,5 @@
script: script/test
rvm:
- 1.9.3
- 2.1.2
- 2.2
notifications:
email: false

View File

@@ -1,49 +0,0 @@
Our emoji set is based off Apple's emoji character palette, plus some custom
emoji such as :octocat: :shipit: :metal:.
Some useful tools in development are:
```
script/bootstrap
```
Sets up the development environment. The prerequisites are:
* Ruby 1.9+
* Bundler
```
rake db:generate
```
On OS X, this will rebuild the `db/Category-Emoji.json` file from the system
one, pulling in any new emoji that Apple may have added in the meantime.
```
script/test
```
Runs the test suite, including the integrity test where we assert that we have
covered each of Apple's emoji.
```
script/regenerate
```
Rebuilds the `db/emoji.json` file which is our main list of emoji: their
canonical representations, descriptions, aliases, and tags. This requires OS X
because Safari is used in the process to verify which character render as emoji
and which render as ordinary Unicode glyphs from the current font.
```
script/console
```
Opens `irb` console with gemoji library preloded for experimentation.
```
script/release
```
For maintainers only: after the gemspec has been edited, this commits the
change, tags a release, and pushes it to both GitHub and RubyGems.org.

View File

@@ -1,6 +1,5 @@
source "https://rubygems.org"
gem "ttfunk", "~> 1.4.0"
gem "rake"
gem "minitest"

View File

@@ -1,14 +1,13 @@
PATH
remote: .
specs:
gemoji (2.1.0)
gemoji (2.0.1)
GEM
remote: https://rubygems.org/
specs:
minitest (5.3.5)
rake (10.3.2)
ttfunk (1.4.0)
PLATFORMS
ruby
@@ -17,4 +16,3 @@ DEPENDENCIES
gemoji!
minitest
rake
ttfunk (~> 1.4.0)

27
MAINTAINING.md Normal file
View File

@@ -0,0 +1,27 @@
# Maintainers
## Releasing a new gem
If you are just adding new emoji or making a small fix, only increment the patch level "1.0.x". If you need to rename a ton of emojis or making any other radical (but still mostly backwards compatible changes), bump the minor version "1.x.x".
### Make a release commit
To prepare the release commit, edit the [gemoji.gemspec](https://github.com/github/gemoji/blob/master/gemoji.gemspec) `version` value. Then make a single commit with the description as "Gemoji 1.x.x". Finally, tag the commit with `v1.x.x`.
Example commit https://github.com/github/gemoji/commit/v1.0.0
```
$ git ci -m "Gemoji 1.0.0"
$ git tag v1.0.0
$ git push
$ git push --tags
```
### Publish the gem
Build and push the new gem with
```
$ gem build gemoji.gemspec
$ gem push gemoji-1.0.0.gem
```

View File

@@ -56,7 +56,7 @@ See the [Emoji cheat sheet](http://www.emoji-cheat-sheet.com) for more examples.
module EmojiHelper
def emojify(content)
h(content).to_str.gsub(/:([\w+-]+):/) do |match|
if emoji = Emoji.find_by_alias($1)
if emoji = Emoji.find_by_alias($1) { nil }
%(<img alt="#$1" src="#{asset_path("emoji/#{emoji.image_filename}")}" style="vertical-align:middle" width="20" height="20" />)
else
match

View File

@@ -1,5 +1,4 @@
require 'rake/testtask'
require 'rake/extensiontask'
task :default => :test
@@ -28,25 +27,3 @@ end
file 'db/NamesList.txt' do |t|
system "curl -fsSL '#{nameslist_url}' -o '#{t.name}'"
end
namespace :images do
desc %(Extract PNG images from Apple's "Apple Color Emoji.ttf" font)
task :extract do
require 'emoji/extractor'
gem_dir = File.dirname(File.realpath(__FILE__))
Emoji::Extractor.new(64, "#{gem_dir}/images/emoji/unicode").extract!
end
end
namespace :c do
task :headers do
require 'emoji/tables'
gem_dir = File.dirname(File.realpath(__FILE__))
File.open(File.join(gem_dir, "ext/gemoji/emoji.h"), "w") do |file|
file.puts(Emoji::Tables.generate_length_tables)
end
end
end
Rake::ExtensionTask.new('gemoji')

View File

@@ -1,13 +0,0 @@
set jsCode to "document.getElementById('output').value"
set json to missing value
tell application "Safari"
repeat
set json to (do JavaScript jsCode in current tab of window 1)
if (json is not missing value) then exit repeat
delay 0.5
end repeat
close current tab of window 1
end tell
return json

View File

@@ -13,7 +13,6 @@
<script>
const VARIATION_SELECTOR_15 = String.fromCharCode(0xfe0e);
const VARIATION_SELECTOR_16 = String.fromCharCode(0xfe0f);
const EMOJI_SIZE = 32
function detectAliases(db) {
for (var i = 0; i < db.length; ++i) {
@@ -23,14 +22,23 @@
continue;
}
if (raw.indexOf(VARIATION_SELECTOR_16) > -1) {
var candidates = [raw.replace(VARIATION_SELECTOR_16, ""), raw];
} else {
var candidates = [raw, raw + VARIATION_SELECTOR_16];
var candidates = [];
if (raw.length === 1) {
candidates.push(raw + VARIATION_SELECTOR_15);
candidates.push(raw + VARIATION_SELECTOR_16);
} else if (raw[raw.length - 1] === VARIATION_SELECTOR_16) {
var base = raw.substr(0, raw.length - 1);
candidates.push(base);
candidates.push(base + VARIATION_SELECTOR_15);
}
var aliases = candidates.filter(isColorEmoji);
emoji.emoji = aliases[0];
if (aliases.length) {
emoji.unicodes = aliases;
} else {
delete emoji.unicodes;
}
}
dump(db);
@@ -44,16 +52,14 @@
}
var canvas = document.createElement("canvas");
canvas.width = canvas.height = EMOJI_SIZE;
function color(emoji, rgb) {
var context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
context.clearRect(0, 0, 32, 32);
context.fillStyle = rgb;
context.textBaseline = "top";
context.font = EMOJI_SIZE+"px Arial";
context.font = "32px Arial";
context.fillText(emoji, 0, 0);
var data = context.getImageData(0, 0, EMOJI_SIZE, EMOJI_SIZE).data;
var data = context.getImageData(0, 0, 32, 32).data;
for (var i = 0; i < data.length; i += 4) {
if (data[i] === 0 && data[i + 1] === 0 && data[i + 2] === 0) {
continue;

View File

@@ -52,14 +52,19 @@ end
trap(:PIPE) { abort }
items = []
variation_codepoint = Emoji::VARIATION_SELECTOR_16.codepoints[0]
variation = "\u{fe0f}".freeze
for emoji in Emoji.all
unicodes = emoji.unicode_aliases.dup
item = {}
unless emoji.custom?
variation_codepoint = variation.codepoints[0]
chars = emoji.raw.codepoints.map { |code| UnicodeCharacter.fetch(code) unless code == variation_codepoint }.compact
item[:emoji] = emoji.raw
item[:emoji] = unicodes.shift
item[:unicodes] = unicodes if unicodes.any?
item[:description] = chars.map(&:description).join(' + ')
end

View File

@@ -931,6 +931,10 @@
}
, {
"emoji": "✨"
, "unicodes": [
"✨︎"
, "✨️"
]
, "description": "sparkles"
, "aliases": [
"sparkles"
@@ -1122,6 +1126,10 @@
}
, {
"emoji": "✊"
, "unicodes": [
"✊︎"
, "✊️"
]
, "description": "raised fist"
, "aliases": [
"fist"
@@ -1153,6 +1161,10 @@
}
, {
"emoji": "✋"
, "unicodes": [
"✋︎"
, "✋️"
]
, "description": "raised hand"
, "aliases": [
"hand"
@@ -2904,7 +2916,10 @@
]
}
, {
"emoji": "⭐"
"emoji": "⭐"
, "unicodes": [
"⭐"
]
, "description": "white medium star"
, "aliases": [
"star"
@@ -2923,7 +2938,11 @@
]
}
, {
"emoji": "⛅"
"emoji": "⛅"
, "unicodes": [
"⛅"
, "⛅︎"
]
, "description": "sun behind cloud"
, "aliases": [
"partly_sunny"
@@ -2943,7 +2962,10 @@
]
}
, {
"emoji": "⚡"
"emoji": "⚡"
, "unicodes": [
"⚡"
]
, "description": "high voltage sign"
, "aliases": [
"zap"
@@ -2954,7 +2976,10 @@
]
}
, {
"emoji": "☔"
"emoji": "☔"
, "unicodes": [
"☔"
]
, "description": "umbrella with rain drops"
, "aliases": [
"umbrella"
@@ -2977,7 +3002,11 @@
]
}
, {
"emoji": "⛄"
"emoji": "⛄"
, "unicodes": [
"⛄"
, "⛄︎"
]
, "description": "snowman without snow"
, "aliases": [
"snowman"
@@ -3482,6 +3511,10 @@
}
, {
"emoji": "⏳"
, "unicodes": [
"⏳︎"
, "⏳️"
]
, "description": "hourglass with flowing sand"
, "aliases": [
"hourglass_flowing_sand"
@@ -3491,7 +3524,10 @@
]
}
, {
"emoji": "⌛"
"emoji": "⌛"
, "unicodes": [
"⌛"
]
, "description": "hourglass"
, "aliases": [
"hourglass"
@@ -3502,6 +3538,10 @@
}
, {
"emoji": "⏰"
, "unicodes": [
"⏰︎"
, "⏰️"
]
, "description": "alarm clock"
, "aliases": [
"alarm_clock"
@@ -3511,7 +3551,10 @@
]
}
, {
"emoji": "⌚"
"emoji": "⌚"
, "unicodes": [
"⌚"
]
, "description": "watch"
, "aliases": [
"watch"
@@ -4487,7 +4530,11 @@
]
}
, {
"emoji": "🀄"
"emoji": "🀄"
, "unicodes": [
"🀄"
, "🀄︎"
]
, "description": "mahjong tile red dragon"
, "aliases": [
"mahjong"
@@ -4537,7 +4584,10 @@
]
}
, {
"emoji": "⚽"
"emoji": "⚽"
, "unicodes": [
"⚽"
]
, "description": "soccer ball"
, "aliases": [
"soccer"
@@ -4596,7 +4646,11 @@
]
}
, {
"emoji": "⛳"
"emoji": "⛳"
, "unicodes": [
"⛳"
, "⛳︎"
]
, "description": "flag in hole"
, "aliases": [
"golf"
@@ -4700,7 +4754,10 @@
]
}
, {
"emoji": "☕"
"emoji": "☕"
, "unicodes": [
"☕"
]
, "description": "hot beverage"
, "aliases": [
"coffee"
@@ -5358,7 +5415,11 @@
]
}
, {
"emoji": "⛪"
"emoji": "⛪"
, "unicodes": [
"⛪"
, "⛪︎"
]
, "description": "church"
, "aliases": [
"church"
@@ -5421,7 +5482,11 @@
]
}
, {
"emoji": "⛺"
"emoji": "⛺"
, "unicodes": [
"⛺"
, "⛺︎"
]
, "description": "tent"
, "aliases": [
"tent"
@@ -5530,7 +5595,11 @@
]
}
, {
"emoji": "⛲"
"emoji": "⛲"
, "unicodes": [
"⛲"
, "⛲︎"
]
, "description": "fountain"
, "aliases": [
"fountain"
@@ -5557,7 +5626,11 @@
]
}
, {
"emoji": "⛵"
"emoji": "⛵"
, "unicodes": [
"⛵"
, "⛵︎"
]
, "description": "sailboat"
, "aliases": [
"boat"
@@ -5586,7 +5659,10 @@
]
}
, {
"emoji": "⚓"
"emoji": "⚓"
, "unicodes": [
"⚓"
]
, "description": "anchor"
, "aliases": [
"anchor"
@@ -6014,7 +6090,11 @@
]
}
, {
"emoji": "⛽"
"emoji": "⛽"
, "unicodes": [
"⛽"
, "⛽︎"
]
, "description": "fuel pump"
, "aliases": [
"fuelpump"
@@ -6528,6 +6608,10 @@
}
, {
"emoji": "⏪"
, "unicodes": [
"⏪︎"
, "⏪️"
]
, "description": "black left-pointing double triangle"
, "aliases": [
"rewind"
@@ -6537,6 +6621,10 @@
}
, {
"emoji": "⏩"
, "unicodes": [
"⏩︎"
, "⏩️"
]
, "description": "black right-pointing double triangle"
, "aliases": [
"fast_forward"
@@ -6546,6 +6634,10 @@
}
, {
"emoji": "⏫"
, "unicodes": [
"⏫︎"
, "⏫️"
]
, "description": "black up-pointing double triangle"
, "aliases": [
"arrow_double_up"
@@ -6555,6 +6647,10 @@
}
, {
"emoji": "⏬"
, "unicodes": [
"⏬︎"
, "⏬️"
]
, "description": "black down-pointing double triangle"
, "aliases": [
"arrow_double_down"
@@ -6696,7 +6792,11 @@
]
}
, {
"emoji": "🈯"
"emoji": "🈯"
, "unicodes": [
"🈯"
, "🈯︎"
]
, "description": "squared cjk unified ideograph-6307"
, "aliases": [
"u6307"
@@ -6777,7 +6877,11 @@
]
}
, {
"emoji": "🈚"
"emoji": "🈚"
, "unicodes": [
"🈚"
, "🈚︎"
]
, "description": "squared cjk unified ideograph-7121"
, "aliases": [
"u7121"
@@ -6861,7 +6965,10 @@
]
}
, {
"emoji": "♿"
"emoji": "♿"
, "unicodes": [
"♿"
]
, "description": "wheelchair symbol"
, "aliases": [
"wheelchair"
@@ -6880,7 +6987,7 @@
]
}
, {
"emoji": "🈷"
"emoji": "🈷"
, "description": "squared cjk unified ideograph-6708"
, "aliases": [
"u6708"
@@ -6898,7 +7005,7 @@
]
}
, {
"emoji": "🈂"
"emoji": "🈂"
, "description": "squared katakana sa"
, "aliases": [
"sa"
@@ -7083,7 +7190,11 @@
]
}
, {
"emoji": "⛔"
"emoji": "⛔"
, "unicodes": [
"⛔"
, "⛔︎"
]
, "description": "no entry"
, "aliases": [
"no_entry"
@@ -7112,6 +7223,10 @@
}
, {
"emoji": "❎"
, "unicodes": [
"❎︎"
, "❎️"
]
, "description": "negative squared cross mark"
, "aliases": [
"negative_squared_cross_mark"
@@ -7121,6 +7236,10 @@
}
, {
"emoji": "✅"
, "unicodes": [
"✅︎"
, "✅️"
]
, "description": "white heavy check mark"
, "aliases": [
"white_check_mark"
@@ -7176,7 +7295,7 @@
]
}
, {
"emoji": "🅰"
"emoji": "🅰"
, "description": "negative squared latin capital letter a"
, "aliases": [
"a"
@@ -7185,7 +7304,7 @@
]
}
, {
"emoji": "🅱"
"emoji": "🅱"
, "description": "negative squared latin capital letter b"
, "aliases": [
"b"
@@ -7203,7 +7322,7 @@
]
}
, {
"emoji": "🅾"
"emoji": "🅾"
, "description": "negative squared latin capital letter o"
, "aliases": [
"o2"
@@ -7222,6 +7341,9 @@
}
, {
"emoji": "➿"
, "unicodes": [
"➿️"
]
, "description": "double curly loop"
, "aliases": [
"loop"
@@ -7241,7 +7363,10 @@
]
}
, {
"emoji": "♈"
"emoji": "♈"
, "unicodes": [
"♈"
]
, "description": "aries"
, "aliases": [
"aries"
@@ -7250,7 +7375,10 @@
]
}
, {
"emoji": "♉"
"emoji": "♉"
, "unicodes": [
"♉"
]
, "description": "taurus"
, "aliases": [
"taurus"
@@ -7259,7 +7387,10 @@
]
}
, {
"emoji": "♊"
"emoji": "♊"
, "unicodes": [
"♊"
]
, "description": "gemini"
, "aliases": [
"gemini"
@@ -7268,7 +7399,10 @@
]
}
, {
"emoji": "♋"
"emoji": "♋"
, "unicodes": [
"♋"
]
, "description": "cancer"
, "aliases": [
"cancer"
@@ -7277,7 +7411,10 @@
]
}
, {
"emoji": "♌"
"emoji": "♌"
, "unicodes": [
"♌"
]
, "description": "leo"
, "aliases": [
"leo"
@@ -7286,7 +7423,10 @@
]
}
, {
"emoji": "♍"
"emoji": "♍"
, "unicodes": [
"♍"
]
, "description": "virgo"
, "aliases": [
"virgo"
@@ -7295,7 +7435,10 @@
]
}
, {
"emoji": "♎"
"emoji": "♎"
, "unicodes": [
"♎"
]
, "description": "libra"
, "aliases": [
"libra"
@@ -7304,7 +7447,10 @@
]
}
, {
"emoji": "♏"
"emoji": "♏"
, "unicodes": [
"♏"
]
, "description": "scorpius"
, "aliases": [
"scorpius"
@@ -7313,7 +7459,10 @@
]
}
, {
"emoji": "♐"
"emoji": "♐"
, "unicodes": [
"♐"
]
, "description": "sagittarius"
, "aliases": [
"sagittarius"
@@ -7322,7 +7471,10 @@
]
}
, {
"emoji": "♑"
"emoji": "♑"
, "unicodes": [
"♑"
]
, "description": "capricorn"
, "aliases": [
"capricorn"
@@ -7331,7 +7483,10 @@
]
}
, {
"emoji": "♒"
"emoji": "♒"
, "unicodes": [
"♒"
]
, "description": "aquarius"
, "aliases": [
"aquarius"
@@ -7340,7 +7495,10 @@
]
}
, {
"emoji": "♓"
"emoji": "♓"
, "unicodes": [
"♓"
]
, "description": "pisces"
, "aliases": [
"pisces"
@@ -7350,6 +7508,10 @@
}
, {
"emoji": "⛎"
, "unicodes": [
"⛎︎"
, "⛎️"
]
, "description": "ophiuchus"
, "aliases": [
"ophiuchus"
@@ -7403,7 +7565,10 @@
]
}
, {
"emoji": "
"emoji": "©"
, "unicodes": [
"©️"
]
, "description": "copyright sign"
, "aliases": [
"copyright"
@@ -7412,7 +7577,10 @@
]
}
, {
"emoji": "
"emoji": "®"
, "unicodes": [
"®️"
]
, "description": "registered sign"
, "aliases": [
"registered"
@@ -7421,7 +7589,10 @@
]
}
, {
"emoji": "™"
"emoji": "™"
, "unicodes": [
"™️"
]
, "description": "trade mark sign"
, "aliases": [
"tm"
@@ -7432,6 +7603,10 @@
}
, {
"emoji": "❌"
, "unicodes": [
"❌︎"
, "❌️"
]
, "description": "cross mark"
, "aliases": [
"x"
@@ -7458,7 +7633,11 @@
]
}
, {
"emoji": "❗"
"emoji": "❗"
, "unicodes": [
"❗"
, "❗︎"
]
, "description": "heavy exclamation mark symbol"
, "aliases": [
"exclamation"
@@ -7470,6 +7649,10 @@
}
, {
"emoji": "❓"
, "unicodes": [
"❓︎"
, "❓️"
]
, "description": "black question mark ornament"
, "aliases": [
"question"
@@ -7480,6 +7663,10 @@
}
, {
"emoji": "❕"
, "unicodes": [
"❕︎"
, "❕️"
]
, "description": "white exclamation mark ornament"
, "aliases": [
"grey_exclamation"
@@ -7489,6 +7676,10 @@
}
, {
"emoji": "❔"
, "unicodes": [
"❔︎"
, "❔️"
]
, "description": "white question mark ornament"
, "aliases": [
"grey_question"
@@ -7497,7 +7688,11 @@
]
}
, {
"emoji": "⭕"
"emoji": "⭕"
, "unicodes": [
"⭕"
, "⭕︎"
]
, "description": "heavy large circle"
, "aliases": [
"o"
@@ -7786,6 +7981,10 @@
}
, {
"emoji": ""
, "unicodes": [
""
, ""
]
, "description": "heavy plus sign"
, "aliases": [
"heavy_plus_sign"
@@ -7795,6 +7994,10 @@
}
, {
"emoji": ""
, "unicodes": [
""
, ""
]
, "description": "heavy minus sign"
, "aliases": [
"heavy_minus_sign"
@@ -7804,6 +8007,10 @@
}
, {
"emoji": "➗"
, "unicodes": [
"➗︎"
, "➗️"
]
, "description": "heavy division sign"
, "aliases": [
"heavy_division_sign"
@@ -7905,6 +8112,10 @@
}
, {
"emoji": "➰"
, "unicodes": [
"➰︎"
, "➰️"
]
, "description": "curly loop"
, "aliases": [
"curly_loop"
@@ -7913,7 +8124,10 @@
]
}
, {
"emoji": "〰"
"emoji": "〰"
, "unicodes": [
"〰️"
]
, "description": "wavy dash"
, "aliases": [
"wavy_dash"
@@ -7958,7 +8172,10 @@
]
}
, {
"emoji": "◾"
"emoji": "◾"
, "unicodes": [
"◾"
]
, "description": "black medium small square"
, "aliases": [
"black_medium_small_square"
@@ -7967,7 +8184,10 @@
]
}
, {
"emoji": "◽"
"emoji": "◽"
, "unicodes": [
"◽"
]
, "description": "white medium small square"
, "aliases": [
"white_medium_small_square"
@@ -8021,7 +8241,10 @@
]
}
, {
"emoji": "⚫"
"emoji": "⚫"
, "unicodes": [
"⚫"
]
, "description": "medium black circle"
, "aliases": [
"black_circle"
@@ -8030,7 +8253,10 @@
]
}
, {
"emoji": "⚪"
"emoji": "⚪"
, "unicodes": [
"⚪"
]
, "description": "medium white circle"
, "aliases": [
"white_circle"
@@ -8066,7 +8292,10 @@
]
}
, {
"emoji": "⬜"
"emoji": "⬜"
, "unicodes": [
"⬜"
]
, "description": "white large square"
, "aliases": [
"white_large_square"
@@ -8075,7 +8304,10 @@
]
}
, {
"emoji": "⬛"
"emoji": "⬛"
, "unicodes": [
"⬛"
]
, "description": "black large square"
, "aliases": [
"black_large_square"
@@ -8119,20 +8351,6 @@
, "tags": [
]
}
, {
"aliases": [
"basecamp"
]
, "tags": [
]
}
, {
"aliases": [
"basecampy"
]
, "tags": [
]
}
, {
"aliases": [
"bowtie"

View File

@@ -1,11 +0,0 @@
static const long emoji_byte_lengths[][5] = {
{0},
{11, 8, 7, 4, 0},
{6, 3, 0},
{7, 0},
{6, 0},
{5, 0},
};
static const int8_t emoji_magic_bytes[] =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

View File

@@ -1,6 +0,0 @@
require 'mkmf'
$CFLAGS << ' -ggdb3 -O0 '
dir_config('gemoji')
create_makefile('gemoji')

View File

@@ -1,125 +0,0 @@
#include <ruby.h>
#include <ruby/encoding.h>
#include "emoji.h"
#define unlikely(x) __builtin_expect((x),0)
static long
lookup_emoji(VALUE *rb_emoji, VALUE rb_bytes, VALUE rb_unicode_map, const long *possible_len)
{
const uint8_t *src = (uint8_t *)RSTRING_PTR(rb_bytes);
for (; *possible_len; ++possible_len) {
const long emoji_size = *possible_len;
if (emoji_size > RSTRING_LEN(rb_bytes))
continue;
if ((src[emoji_size - 1] & 0xC0) != 0x80)
continue;
rb_str_set_len(rb_bytes, emoji_size);
*rb_emoji = rb_hash_lookup(rb_unicode_map, rb_bytes);
if (!NIL_P(*rb_emoji))
return emoji_size;
}
return 0;
}
static VALUE
replace_emoji(const uint8_t *src, long size, VALUE rb_unicode_map)
{
VALUE rb_emoji, rb_bytes, rb_out = Qnil;
long i = 0, org, emoji_len;
int8_t emoji_byte;
while (i < size) {
org = i;
retry_search:
while (i < size && (emoji_byte = emoji_magic_bytes[(int)src[i]]) == 0)
i++;
if (i + 1 < size && (src[i + 1] & 0x80) != 0x80) {
i++;
goto retry_search;
}
if (unlikely(org == 0)) {
if (i == size)
return Qnil;
rb_out = rb_str_buf_new(size * 4 / 3);
rb_enc_associate(rb_out, rb_utf8_encoding());
rb_bytes = rb_str_buf_new(16);
rb_enc_associate(rb_bytes, rb_utf8_encoding());
}
if (i > org)
rb_str_buf_cat(rb_out, (const char *)src + org, i - org);
if (unlikely(i == size))
break;
emoji_len = size - i;
if (emoji_len > 12)
emoji_len = 12;
memcpy(RSTRING_PTR(rb_bytes), src + i, emoji_len);
rb_str_set_len(rb_bytes, emoji_len);
emoji_len = lookup_emoji(&rb_emoji, rb_bytes, rb_unicode_map, emoji_byte_lengths[(int)emoji_byte]);
if (emoji_len) {
VALUE rb_repl = rb_yield(rb_emoji);
if (NIL_P(rb_repl)) {
rb_str_buf_cat(rb_out, (const char *)src + i, emoji_len);
} else {
Check_Type(rb_repl, T_STRING);
rb_str_buf_append(rb_out, rb_repl);
}
i += emoji_len;
continue;
}
rb_str_buf_cat(rb_out, (const char *)src + i, 1);
i++;
}
return rb_out;
}
static VALUE
rb_gemoji_replace_unicode(VALUE klass, VALUE rb_source)
{
VALUE rb_output;
VALUE rb_unicode_map = rb_funcall(klass, rb_intern("unicodes_index"), 0);
Check_Type(rb_source, T_STRING);
Check_Type(rb_unicode_map, T_HASH);
rb_must_asciicompat(rb_source);
if (ENC_CODERANGE_ASCIIONLY(rb_source))
return rb_source;
if (rb_enc_get(rb_source) != rb_utf8_encoding())
rb_raise(rb_eEncCompatError, "expected UTF-8 encoding");
rb_output = replace_emoji((uint8_t *)RSTRING_PTR(rb_source), RSTRING_LEN(rb_source), rb_unicode_map);
if (NIL_P(rb_output))
return rb_source;
return rb_output;
}
void Init_gemoji(void)
{
VALUE rb_mEmoji = rb_define_module("Emoji");
rb_define_method(rb_mEmoji, "gsub_unicode", rb_gemoji_replace_unicode, 1);
}

View File

@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "gemoji"
s.version = "2.1.0"
s.version = "2.0.1"
s.summary = "Emoji conversion and image assets"
s.description = "Image assets and character information for emoji."

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 898 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1004 B

After

Width:  |  Height:  |  Size: 1016 B

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Some files were not shown because too many files have changed in this diff Show More