Skip to content

Instantly share code, notes, and snippets.

@floriancargoet
Created May 2, 2024 07:05
Show Gist options
  • Save floriancargoet/a424142a02c400043d4f4bbf4b13074d to your computer and use it in GitHub Desktop.
Save floriancargoet/a424142a02c400043d4f4bbf4b13074d to your computer and use it in GitHub Desktop.
Emojis extension for Inform 7
Emojis (for Glulx only) by Florian Cargoët begins here.
[
I'm a bit conflicted with that code:
I don't remember having a good enough understanding of these things to have written it myself. It's not that complicated so it's possible I learned enough to make it work and then forgot about it but it's also possible I cobbled together bits of code found elsewhere and it's not my code.
]
[ A simple emoji (1 code point). ]
To say emoji (code point - number):
say code point as unicode;
To say (N - a number) as unicode: (-
if (glk_gestalt(gestalt_CharOutput, {N}) == gestalt_CharOutput_ExactPrint) {
print (char) {N};
}
-)
[ A combined emoji (multiple code points). ]
To say emoji (a - number) + (b - number): (-
EmojiJoin({a}, {b});
-)
To say emoji (a - number) + (b - number) + (c - number): (-
EmojiJoin({a}, {b}, {c});
-)
To say emoji (a - number) + (b - number) + (c - number) + (d - number): (-
EmojiJoin({a}, {b}, {c}, {d});
-)
Include (-
[EmojiJoin a b c d;
! Check if all are supported.
if (
UnicodeSupported(a) &&
(b == 0 || UnicodeSupported(b)) &&
(c == 0 || UnicodeSupported(c)) &&
(d == 0 || UnicodeSupported(d))
) {
print (char) a, (PrefixZWJ) b, (PrefixZWJ) c, (PrefixZWJ) d;
}
];
[PrefixZWJ c;
if (c == 0) rfalse;
! Don't join with ZWJ if the is a skin-tone or if it's a ZWJ.
if (~~IsSkinTone(c) && c ~= 8205) {
print (char) 8205;
}
print (char) c;
];
[UnicodeSupported c;
return glk_gestalt(gestalt_CharOutput, c) == gestalt_CharOutput_ExactPrint;
];
[IsSkinTone c;
return 127995 <= c && c <= 127999;
];
-)
Emojis ends here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment