chiark / gitweb /
Beginnings of support for Unicode variation selectors
authorBen Harris <bjh21@bjh21.me.uk>
Wed, 19 Nov 2025 23:21:22 +0000 (23:21 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 13 Jan 2026 21:55:10 +0000 (21:55 +0000)
These are treated as particularly odd Unicode code points and packed
into the "unicode" field.  Currently only the encoding side is
implemented, withe the slashed zero, <U+0030, U+FE00>, as a motivating
example.

Generating a format 14 'cmap' subtable and properly formatting the
glyph complement are still to come.

bedstead.c

index b856ecf753fe2dfd4b1cf70f689916cb9b092a1d..32623ca209d7a6df078127d53daf236e37dc3447 100644 (file)
@@ -226,8 +226,15 @@ static struct glyph {
                char const *alias_of;
                int subr_idx;
        };
-       uint_least32_t unicode;
-#define NU (0xFFFFFFFF)
+       uint_least32_t unicode; /* Code point and maybe variation selector. */
+#define U_UVMASK 0x001FFFFF /* Code point of base character. */
+#define U_HASVS  0x00200000 /* Is there a variation selector? */
+#define U_VSMASK 0x0F000000 /* Bottom 4 bits of VS code point. */
+#define U_VSSHIFT 24
+#define VS(uvs) ((((long)uvs << U_VSSHIFT) & U_VSMASK) | U_HASVS)
+#define GET_UV(u) (u & U_UVMASK)
+#define GET_UVS(u) ((u & U_VSMASK) >> U_VSSHIFT)
+#define NU 0xFFFFFFFF /* No Unicode code point. Must be > all valid values. */
        char const *name;
        uint_least16_t flags;
 #define SEP  0x01 /* Separated graphics */
@@ -544,7 +551,8 @@ static struct glyph {
  /* Basic Latin */
  ALIAS("quotesingle.curly", "quoteright"),
  {"\00\00\04\12\21\12\04\00\00", NU, "zero.onum" },
- {"\16\21\23\25\31\21\16\00\00", NU, "zero.zero" },
+ ALIAS("zero.zero", "zero_uniFE00"), /* slashed zero */
+ {"\16\21\23\25\31\21\16\00\00", 0x0030 + VS(0xfe00), "zero_uniFE00" },
  {"\00\00\04\14\04\04\16\00\00", NU, "one.onum" },
  {"\00\00\36\01\16\20\37\00\00", NU, "two.onum" },
  {"\00\00\37\01\02\06\01\21\16", NU, "three.onum" },