From 16ecff452d37622a110b81243eda6f51407acb79 Mon Sep 17 00:00:00 2001 From: Deadbeef Date: Sun, 14 Nov 2021 11:37:20 +0800 Subject: [PATCH] Add `with_glyph_index` function --- src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 27435f2..e2ad246 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,6 +110,14 @@ impl GlyphId { Self(c as u32 | C_BIT) } + /// Creates a `GlyphId` representing a glyph index. + /// + /// The index must not have the most significant bit set. + pub fn with_glyph_index(n: u32) -> Self { + assert!(n < C_BIT); + Self(n) + } + /// Creates a `GlyphId` representing a placeholder value. pub fn placeholder() -> Self { Self(0)