~alcinnz/harfbuzz-pure

fd6388d7b4014ec8b5ab7f937a1619bad843bdae — Adrian Cochrane 2 years ago d7c2115
Fix tag encoding & decoding (remembered hex digits are nybbles not bytes)
1 files changed, 8 insertions(+), 8 deletions(-)

M Data/Text/Glyphize/Buffer.hs
M Data/Text/Glyphize/Buffer.hs => Data/Text/Glyphize/Buffer.hs +8 -8
@@ 267,19 267,19 @@ script_from_string str = tag_from_string $ case titlecase str of
tag_from_string :: String -> Word32
tag_from_string str = case str ++ Prelude.repeat ' ' of
    c1:c2:c3:c4:_ -> Prelude.foldl (.|.) 0 [
        shiftL (c2w c1 .&. 0x7) 24,
        shiftL (c2w c2 .&. 0x7) 16,
        shiftL (c2w c3 .&. 0x7) 8,
        shiftL (c2w c4 .&. 0x7) 0
        shiftL (c2w c1 .&. 0x7f) 24,
        shiftL (c2w c2 .&. 0x7f) 16,
        shiftL (c2w c3 .&. 0x7f) 8,
        shiftL (c2w c4 .&. 0x7f) 0
      ]
    _ -> 0
-- | Converts a "tag" `Word32` into a 4 `Char` `String`.
tag_to_string :: Word32 -> String
tag_to_string tag = [
    w2c (shiftR tag 24 .&. 0x7),
    w2c (shiftR tag 16 .&. 0x7),
    w2c (shiftR tag 8 .&. 0x7),
    w2c (shiftR tag 0 .&. 0x7)
    w2c (shiftR tag 24 .&. 0x7f),
    w2c (shiftR tag 16 .&. 0x7f),
    w2c (shiftR tag 8 .&. 0x7f),
    w2c (shiftR tag 0 .&. 0x7f)
  ]

------