Skip to content

Commit

Permalink
Fix emoji generator for Unicode 14.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jul 19, 2022
1 parent 762500d commit 8815d7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions codegen/emoji/data.cpp
Expand Up @@ -193,7 +193,6 @@ void append(Id &id, uint32 code) {
if (same.size() == 2) {
// original: 1
// same: original + color
// different: some1 + color1 + sep + some2 + sep + some3 + color2
if (same[1] != ColorMask) {
logDataError() << "color code should appear at index 1.";
return {};
Expand All @@ -206,10 +205,25 @@ void append(Id &id, uint32 code) {
} else {
append(variatedId, same[0]);
}
// add an alias to 'same' in the form ..
// .. of 'some1 + color + sep + some2 + sep + some3 + color'
if (std::count(different.begin(), different.end(), kJoiner) != 2) {
logDataError() << "complex double colored bad different.";
if (different.size() == 5) {
// different: some1 + color1 + sep + some2 + color2
if (std::count(different.begin(), different.end(), kJoiner) != 1
|| different[2] != kJoiner) {
logDataError() << "complex short double colored bad different.";
return {};
}
// add an alias to 'same' in the form ..
// .. of 'some1 + color + sep + some2 + color'
} else if (different.size() >= 7) {
// different: some1 + color1 + sep + some2 + sep + some3 + color2
if (std::count(different.begin(), different.end(), kJoiner) != 2) {
logDataError() << "complex double colored bad different.";
return {};
}
// add an alias to 'same' in the form ..
// .. of 'some1 + color + sep + some2 + sep + some3 + color'
} else {
logDataError() << "complex double colored unknown different.";
return {};
}
for (const auto color : Colors) {
Expand All @@ -226,7 +240,7 @@ void append(Id &id, uint32 code) {
AddAlias(sameWithColor, differentWithColor);
}
} else {
// same: som1 + color + sep + some2 + sep + some3 + color
// same: some1 + color + sep + some2 + sep + some3 + color
// different: some1 + color1 + sep + some2 + sep + some3 + color2
auto copy = different;
if (copy.size() < 7 || copy[1] != Colors[0] || copy[copy.size() - 1] != Colors[1]) {
Expand Down
2 changes: 1 addition & 1 deletion codegen/emoji/data_read.cpp
Expand Up @@ -223,7 +223,7 @@ InputData ReadData(const QString &path) {
const auto differentId = InputIdFromString(different);
if (originalId.empty() || sameId.empty() || differentId.empty()) {
return InputData();
} else if (originalId.size() < 1 || sameId.size() < 2 || differentId.size() < 7) {
} else if (originalId.size() < 1 || sameId.size() < 2 || differentId.size() < 5) {
logDataError()
<< "Bad double colored emoji: "
<< original.toStdString()
Expand Down

0 comments on commit 8815d7a

Please sign in to comment.