From 69ac5c6bfd386a75df15af81738395cfd3b4e337 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 19 Nov 2025 23:21:22 +0000 Subject: [PATCH] Beginnings of support for Unicode variation selectors 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, , as a motivating example. Generating a format 14 'cmap' subtable and properly formatting the glyph complement are still to come. --- bedstead.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/bedstead.c b/bedstead.c index b856ecf..32623ca 100644 --- a/bedstead.c +++ b/bedstead.c @@ -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" }, -- 2.30.2