diff options
author | Gilles Leblanc <gilles.leblanc@gmail.com> | 2015-01-07 21:07:23 -0500 |
---|---|---|
committer | Gilles Leblanc <gilles.leblanc@gmail.com> | 2015-01-15 20:01:40 -0500 |
commit | 9fe39951b07c2bcb0aebf7909719b150dcf5c973 (patch) | |
tree | 0b95c398a1614e5151a89aeb4b96ee90562cf7be /components/gfx/text | |
parent | 31627bdc9d698a31db1bcd47279d43de397298f1 (diff) | |
download | servo-9fe39951b07c2bcb0aebf7909719b150dcf5c973.tar.gz servo-9fe39951b07c2bcb0aebf7909719b150dcf5c973.zip |
Write a macro or syntax extension to generate OpenType tags
Fixes #4556
Diffstat (limited to 'components/gfx/text')
-rw-r--r-- | components/gfx/text/shaping/harfbuzz.rs | 12 | ||||
-rw-r--r-- | components/gfx/text/util.rs | 14 |
2 files changed, 8 insertions, 18 deletions
diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs index c86336b2ec6..cc328ca4f8c 100644 --- a/components/gfx/text/shaping/harfbuzz.rs +++ b/components/gfx/text/shaping/harfbuzz.rs @@ -47,13 +47,17 @@ use std::mem; use std::cmp; use std::ptr; +macro_rules! hb_tag { + ($t1:expr, $t2:expr, $t3:expr, $t4:expr) => ( + (($t1 as u32) << 24) | (($t2 as u32) << 16) | (($t3 as u32) << 8) | ($t4 as u32) + ); +} + static NO_GLYPH: i32 = -1; static CONTINUATION_BYTE: i32 = -2; -static KERN: u32 = ((b'k' as u32) << 24) | ((b'e' as u32) << 16) | ((b'r' as u32) << 8) | - (b'n' as u32); -static LIGA: u32 = ((b'l' as u32) << 24) | ((b'i' as u32) << 16) | ((b'g' as u32) << 8) | - (b'a' as u32); +static KERN: u32 = hb_tag!('k', 'e', 'r', 'n'); +static LIGA: u32 = hb_tag!('l', 'i', 'g', 'a'); pub struct ShapedGlyphData { count: int, diff --git a/components/gfx/text/util.rs b/components/gfx/text/util.rs index c8d082c405a..24c916a1ba1 100644 --- a/components/gfx/text/util.rs +++ b/components/gfx/text/util.rs @@ -128,20 +128,6 @@ pub fn fixed_to_rounded_int(before: int, f: i32) -> int { } } -/* Generate a 32-bit TrueType tag from its 4 characters */ -pub fn true_type_tag(a: char, b: char, c: char, d: char) -> u32 { - let a = a as u32; - let b = b as u32; - let c = c as u32; - let d = d as u32; - (a << 24 | b << 16 | c << 8 | d) as u32 -} - -#[test] -fn test_true_type_tag() { - assert_eq!(true_type_tag('c', 'm', 'a', 'p'), 0x_63_6D_61_70_u32); -} - #[test] fn test_transform_compress_none() { let test_strs = [ |