This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| # http://vcl.itn.liu.se/publications/2011/GS11/edtaa_preprint.pdf | |
| def tex(df, cos_th): | |
| cos_th = abs(cos_th) | |
| sin_th = math.sqrt(1 - cos_th ** 2) | |
| if cos_th < sin_th: | |
| cos_th, sin_th = sin_th, cos_th | |
| a1 = 0.5 * sin_th / cos_th # note: paper is missing the 0.5! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::borrow::Cow; | |
| pub trait StrSource { | |
| fn len(&self) -> usize; | |
| fn str_at(&self, ix: usize) -> &str; | |
| fn str_before(&self, ix: usize) -> &str; | |
| fn to_string(&self) -> String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extern crate dwrote; | |
| extern crate winapi; | |
| use std::borrow::Cow; | |
| use winapi::um::dwrite::{DWRITE_NUMBER_SUBSTITUTION_METHOD_NONE, DWRITE_READING_DIRECTION, | |
| DWRITE_READING_DIRECTION_LEFT_TO_RIGHT | |
| }; | |
| use dwrote::{FontCollection, FontFallback, FontStretch, FontStyle, FontWeight, NumberSubstitution, | |
| TextAnalysisSource, TextAnalysisSourceImpl, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use harfbuzz::Blob; | |
| fn create_blob() -> Blob { | |
| let vec = vec![1; 256]; | |
| Blob::new_read_only(&vec) | |
| // BAD: vec is dropped here, the blob still holds a reference | |
| } | |
| fn blob_sum(blob: &Blob) -> u32 { | |
| blob.iter().map(|byte| *byte as u32).sum() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Key(Arc<()>); | |
| impl Key { | |
| pub fn new() { | |
| Key(Arc::new(())) | |
| } | |
| } | |
| // Note: Key is not Clone, there can be only one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(test)] | |
| extern crate test; | |
| // Note: this dependency is nightly only | |
| extern crate packed_simd; | |
| #[macro_use] | |
| extern crate cfg_if; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright 2018 Google LLC | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // http://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright 2017 Google LLC | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // https://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Copyright 2017 Google LLC | |
| // | |
| // Licensed under the Apache License, Version 2.0 (the "License"); | |
| // you may not use this file except in compliance with the License. | |
| // You may obtain a copy of the License at | |
| // | |
| // https://www.apache.org/licenses/LICENSE-2.0 | |
| // | |
| // Unless required by applicable law or agreed to in writing, software | |
| // distributed under the License is distributed on an "AS IS" BASIS, |