Skip to content

Commit

Permalink
flags support
Browse files Browse the repository at this point in the history
  • Loading branch information
mreq committed May 5, 2016
1 parent 1d3e094 commit e533e6e
Show file tree
Hide file tree
Showing 4 changed files with 959 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ By default, xelatex-emoji expects the images to be in `images/utf8code.png`. You
```tex
\newcommand{\xelatexemojipath}[1]{mycustompath/{#1}.pdf}
```

## Development

To generate the flag codes:

```
ruby bin/generate_flags.rb > xelatexemoji-flags.sty
```
71 changes: 71 additions & 0 deletions bin/generate_flags.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
letters = [
['A', '๐Ÿ‡ฆ', '1f1e6'],
['B', '๐Ÿ‡ง', '1f1e7'],
['C', '๐Ÿ‡จ', '1f1e8'],
['D', '๐Ÿ‡ฉ', '1f1e9'],
['E', '๐Ÿ‡ช', '1f1ea'],
['F', '๐Ÿ‡ซ', '1f1eb'],
['G', '๐Ÿ‡ฌ', '1f1ec'],
['H', '๐Ÿ‡ญ', '1f1ed'],
['I', '๐Ÿ‡ฎ', '1f1ee'],
['J', '๐Ÿ‡ฏ', '1f1ef'],
['K', '๐Ÿ‡ฐ', '1f1f0'],
['L', '๐Ÿ‡ฑ', '1f1f1'],
['M', '๐Ÿ‡ฒ', '1f1f2'],
['N', '๐Ÿ‡ณ', '1f1f3'],
['O', '๐Ÿ‡ด', '1f1f4'],
['P', '๐Ÿ‡ต', '1f1f5'],
['Q', '๐Ÿ‡ถ', '1f1f6'],
['R', '๐Ÿ‡ท', '1f1f7'],
['S', '๐Ÿ‡ธ', '1f1f8'],
['T', '๐Ÿ‡น', '1f1f9'],
# ['U', '๐Ÿ‡บ', ''],
['V', '๐Ÿ‡ป', '1f1fb'],
['W', '๐Ÿ‡ผ', '1f1fc'],
['X', '๐Ÿ‡ฝ', '1f1fd'],
['Y', '๐Ÿ‡พ', '1f1fe'],
# ['Z', '๐Ÿ‡ฟ', ''],
]

output = ["\\ExplSyntaxOn"]

letters.each do |letter_data|
output << "\\newunicodechar{#{letter_data[1]}}{ \\flags_print:n {#{letter_data[0]}} }"
end

output << %(
{
\\cs_new:Nn \\flags_print:n
{
\\flags_print_unicode:nn { #1 }
}
}
\\cs_new_protected:Nn \\flags_print_unicode:nn
{
\\use:c { flags_#1:n } { #2 }
}
)

letters.each do |letter_data|
partial_output = []
partial_output << %(
\\cs_new_protected:Nn \\flags_#{letter_data[0]}:n
{
\\str_case:nnF {#1}
{
)
letters.each do |sub_letter_data|
partial_output << "{#{sub_letter_data[1]}}{\\xelatexemoji{#{letter_data[2]}-#{sub_letter_data[2]}}}"
end
partial_output
partial_output << %(
}
{}
}
)
output << partial_output.join("\n")
end

output << "\\ExplSyntaxOff"

puts output.join("\n")
Loading

0 comments on commit e533e6e

Please sign in to comment.