summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/encoding.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/encoding.c b/src/encoding.c
index ae8767d..8f9671f 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -78,8 +78,15 @@ void encoding_write_glyph(int index, struct glyph *glyph,
glyph->name);
}
} else if (glyph->code != (unsigned int) -1) {
- fprintf(fp, "%4.4X;uni%04X;COMMENT\n", index,
- glyph->code);
+ if (glyph->code < 0x10000) {
+ /* Use uniXXXX for BMP codepoints */
+ fprintf(fp, "%4.4X;uni%04X;COMMENT\n", index,
+ glyph->code);
+ } else {
+ /* Use uXXXXX - uXXXXXXXX otherwise */
+ fprintf(fp, "%4.4X;u%X;COMMENT\n", index,
+ glyph->code);
+ }
} else {
fprintf(fp, "# Skipping %4.4X\n", index);
}
@@ -87,11 +94,26 @@ void encoding_write_glyph(int index, struct glyph *glyph,
if (glyph->name != 0) {
fprintf(fp, "/%s\n", glyph->name);
} else if (glyph->code != (unsigned int) -1) {
- fprintf(fp, "/uni%4.4X\n", glyph->code);
+ if (glyph->code < 0x10000) {
+ /* Use /uniXXXX for BMP codepoints */
+ fprintf(fp, "/uni%4.4X\n", glyph->code);
+ } else {
+ /* Use /uXXXXX - /uXXXXXXXX otherwise.
+ * These are supported since FM 3.53.
+ * FM 3.43 - 3.52 (inclusive) understood
+ * /uniXXXXYYYY, where XXXX and YYYY were
+ * a UTF-16 surrogate pair. We have never
+ * emitted such things and support for
+ * them was removed in FM 3.53 with the
+ * introduction of support for the /u form.
+ * Thus, take the easy option and rely on
+ * noone running a UCS FM earlier than 3.53
+ * expecting astral codepoints to work.
+ */
+ fprintf(fp, "/u%X\n", glyph->code);
+ }
} else {
fprintf(fp, "/.notdef\n");
}
}
}
-
-