Commit 93ec9384 authored by Alex Butler's avatar Alex Butler
Browse files

Merge branch 'rustfmt' into 'master'

cargo fmt + remove commented code

See merge request !22
parents 9768b2a8 43f6dc46
Pipeline #1122 passed with stages
in 2 minutes and 59 seconds
......@@ -419,7 +419,11 @@ fn scale_for_pixel_height_gudea(b: &mut test::Bencher) {
fn get_v_metrics_deja_vu_mono(b: &mut test::Bencher) {
let font = FontInfo::new(&*DEJA_VU_MONO, 0).unwrap();
let mut v_metrics = VMetrics { ascent: 1, descent: 2, line_gap: 3 };
let mut v_metrics = VMetrics {
ascent: 1,
descent: 2,
line_gap: 3,
};
b.iter(|| {
// repeat so its a similar number of calls to the other benchmarks
for _ in 0..test::black_box(ALPHABET_SIZE) {
......@@ -427,7 +431,11 @@ fn get_v_metrics_deja_vu_mono(b: &mut test::Bencher) {
}
});
let VMetrics { ascent, descent, line_gap } = v_metrics;
let VMetrics {
ascent,
descent,
line_gap,
} = v_metrics;
assert_eq!(ascent, 1901);
assert_eq!(descent, -483);
assert_eq!(line_gap, 0);
......@@ -437,7 +445,11 @@ fn get_v_metrics_deja_vu_mono(b: &mut test::Bencher) {
fn get_v_metrics_gudea(b: &mut test::Bencher) {
let font = FontInfo::new(&*GUDEA, 0).unwrap();
let mut v_metrics = VMetrics { ascent: 1, descent: 2, line_gap: 3 };
let mut v_metrics = VMetrics {
ascent: 1,
descent: 2,
line_gap: 3,
};
b.iter(|| {
// repeat so its a similar number of calls to the other benchmarks
for _ in 0..test::black_box(ALPHABET_SIZE) {
......@@ -445,7 +457,11 @@ fn get_v_metrics_gudea(b: &mut test::Bencher) {
}
});
let VMetrics { ascent, descent, line_gap } = v_metrics;
let VMetrics {
ascent,
descent,
line_gap,
} = v_metrics;
assert_eq!(ascent, 972);
assert_eq!(descent, -264);
assert_eq!(line_gap, 0);
......
......@@ -9,17 +9,36 @@ fn main() {
for info in font.get_font_name_strings() {
let (name, pl_en_la, na) = info;
let name = (match pl_en_la {
Some(stb_truetype::PlatformEncodingLanguageId::Mac(Some(Ok(stb_truetype::MacEid::Roman)), _)) => ::std::str::from_utf8(name).ok().map(Cow::Borrowed),
Some(stb_truetype::PlatformEncodingLanguageId::Microsoft(Some(Ok(stb_truetype::MicrosoftEid::UnicodeBMP)), _)) => {
let name16be = unsafe { ::std::slice::from_raw_parts(name.as_ptr() as *const u16, name.len() / 2) };
let name16 = name16be.iter().map(|&v| u16::from_be(v)).collect::<Vec<_>>();
Some(stb_truetype::PlatformEncodingLanguageId::Mac(
Some(Ok(stb_truetype::MacEid::Roman)),
_,
)) => ::std::str::from_utf8(name).ok().map(Cow::Borrowed),
Some(stb_truetype::PlatformEncodingLanguageId::Microsoft(
Some(Ok(stb_truetype::MicrosoftEid::UnicodeBMP)),
_,
)) => {
let name16be = unsafe {
::std::slice::from_raw_parts(name.as_ptr() as *const u16, name.len() / 2)
};
let name16 = name16be
.iter()
.map(|&v| u16::from_be(v))
.collect::<Vec<_>>();
String::from_utf16(&name16).ok().map(Cow::Owned)
},
Some(stb_truetype::PlatformEncodingLanguageId::Microsoft(Some(Ok(stb_truetype::MicrosoftEid::UnicodeFull)), _)) => {
let name16be = unsafe { ::std::slice::from_raw_parts(name.as_ptr() as *const u16, name.len() / 2) };
let name16 = name16be.iter().map(|&v| u16::from_be(v)).collect::<Vec<_>>();
}
Some(stb_truetype::PlatformEncodingLanguageId::Microsoft(
Some(Ok(stb_truetype::MicrosoftEid::UnicodeFull)),
_,
)) => {
let name16be = unsafe {
::std::slice::from_raw_parts(name.as_ptr() as *const u16, name.len() / 2)
};
let name16 = name16be
.iter()
.map(|&v| u16::from_be(v))
.collect::<Vec<_>>();
String::from_utf16(&name16).ok().map(Cow::Owned)
},
}
Some(_) => Some(Cow::Borrowed("(Unknown encoding)")),
None => Some(Cow::Borrowed("(Unknown Platform ID)")),
}).unwrap_or(Cow::Borrowed("(Encoding error)"));
......
# rustfmt 0.3.x-nightly
wrap_comments = true
error_on_line_overflow = false
use_field_init_shorthand = true
condense_wildcard_suffixes = true
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment