Skip to content

Commit

Permalink
Write a macro or syntax extension to generate OpenType tags
Browse files Browse the repository at this point in the history
Fixes #4556
  • Loading branch information
gilles-leblanc committed Jan 16, 2015
1 parent 31627bd commit 9fe3995
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
12 changes: 8 additions & 4 deletions components/gfx/text/shaping/harfbuzz.rs
Expand Up @@ -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,
Expand Down
14 changes: 0 additions & 14 deletions components/gfx/text/util.rs
Expand Up @@ -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 = [
Expand Down

5 comments on commit 9fe3995

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from Manishearth
at gilles-leblanc@9fe3995

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging gilles-leblanc/servo/issue-4556 = 9fe3995 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gilles-leblanc/servo/issue-4556 = 9fe3995 merged ok, testing candidate = 9fd675c

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9fd675c

Please sign in to comment.