Skip to content

Commit

Permalink
s/rustybuzz/harfruzz/g
Browse files Browse the repository at this point in the history
  • Loading branch information
rsheeter committed Jul 25, 2024
1 parent 779ee85 commit 31d9639
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
52 changes: 26 additions & 26 deletions examples/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ struct Args {
font_file: Option<PathBuf>,
face_index: u32,
font_ptem: Option<f32>,
variations: Vec<rustybuzz::Variation>,
variations: Vec<harfruzz::Variation>,
text: Option<String>,
text_file: Option<PathBuf>,
unicodes: Option<String>,
direction: Option<rustybuzz::Direction>,
language: rustybuzz::Language,
script: Option<rustybuzz::Script>,
direction: Option<harfruzz::Direction>,
language: harfruzz::Language,
script: Option<harfruzz::Script>,
utf8_clusters: bool,
cluster_level: rustybuzz::BufferClusterLevel,
features: Vec<rustybuzz::Feature>,
cluster_level: harfruzz::BufferClusterLevel,
features: Vec<harfruzz::Feature>,
no_glyph_names: bool,
no_positions: bool,
no_advances: bool,
Expand Down Expand Up @@ -145,7 +145,7 @@ fn main() {
}

let font_data = std::fs::read(font_path).unwrap();
let mut face = rustybuzz::Face::from_slice(&font_data, args.face_index).unwrap();
let mut face = harfruzz::Face::from_slice(&font_data, args.face_index).unwrap();

face.set_points_per_em(args.font_ptem);

Expand Down Expand Up @@ -175,7 +175,7 @@ fn main() {
};

for text in lines {
let mut buffer = rustybuzz::UnicodeBuffer::new();
let mut buffer = harfruzz::UnicodeBuffer::new();
buffer.push_str(&text);

if let Some(d) = args.direction {
Expand All @@ -194,31 +194,31 @@ fn main() {
buffer.reset_clusters();
}

let glyph_buffer = rustybuzz::shape(&face, &args.features, buffer);
let glyph_buffer = harfruzz::shape(&face, &args.features, buffer);

let mut format_flags = rustybuzz::SerializeFlags::default();
let mut format_flags = harfruzz::SerializeFlags::default();
if args.no_glyph_names {
format_flags |= rustybuzz::SerializeFlags::NO_GLYPH_NAMES;
format_flags |= harfruzz::SerializeFlags::NO_GLYPH_NAMES;
}

if args.no_clusters || args.ned {
format_flags |= rustybuzz::SerializeFlags::NO_CLUSTERS;
format_flags |= harfruzz::SerializeFlags::NO_CLUSTERS;
}

if args.no_positions {
format_flags |= rustybuzz::SerializeFlags::NO_POSITIONS;
format_flags |= harfruzz::SerializeFlags::NO_POSITIONS;
}

if args.no_advances || args.ned {
format_flags |= rustybuzz::SerializeFlags::NO_ADVANCES;
format_flags |= harfruzz::SerializeFlags::NO_ADVANCES;
}

if args.show_extents {
format_flags |= rustybuzz::SerializeFlags::GLYPH_EXTENTS;
format_flags |= harfruzz::SerializeFlags::GLYPH_EXTENTS;
}

if args.show_flags {
format_flags |= rustybuzz::SerializeFlags::GLYPH_FLAGS;
format_flags |= harfruzz::SerializeFlags::GLYPH_FLAGS;
}

println!("{}", glyph_buffer.serialize(&face, format_flags));
Expand All @@ -239,39 +239,39 @@ fn parse_unicodes(s: &str) -> Result<String, String> {
Ok(text)
}

fn parse_features(s: &str) -> Result<Vec<rustybuzz::Feature>, String> {
fn parse_features(s: &str) -> Result<Vec<harfruzz::Feature>, String> {
let mut features = Vec::new();
for f in s.split(',') {
features.push(rustybuzz::Feature::from_str(&f)?);
features.push(harfruzz::Feature::from_str(&f)?);
}

Ok(features)
}

fn parse_variations(s: &str) -> Result<Vec<rustybuzz::Variation>, String> {
fn parse_variations(s: &str) -> Result<Vec<harfruzz::Variation>, String> {
let mut variations = Vec::new();
for v in s.split(',') {
variations.push(rustybuzz::Variation::from_str(&v)?);
variations.push(harfruzz::Variation::from_str(&v)?);
}

Ok(variations)
}

fn parse_cluster(s: &str) -> Result<rustybuzz::BufferClusterLevel, String> {
fn parse_cluster(s: &str) -> Result<harfruzz::BufferClusterLevel, String> {
match s {
"0" => Ok(rustybuzz::BufferClusterLevel::MonotoneGraphemes),
"1" => Ok(rustybuzz::BufferClusterLevel::MonotoneCharacters),
"2" => Ok(rustybuzz::BufferClusterLevel::Characters),
"0" => Ok(harfruzz::BufferClusterLevel::MonotoneGraphemes),
"1" => Ok(harfruzz::BufferClusterLevel::MonotoneCharacters),
"2" => Ok(harfruzz::BufferClusterLevel::Characters),
_ => Err(format!("invalid cluster level")),
}
}

fn system_language() -> rustybuzz::Language {
fn system_language() -> harfruzz::Language {
unsafe {
libc::setlocale(libc::LC_ALL, b"\0" as *const _ as *const i8);
let s = libc::setlocale(libc::LC_CTYPE, std::ptr::null());
let s = std::ffi::CStr::from_ptr(s);
let s = s.to_str().expect("locale must be ASCII");
rustybuzz::Language::from_str(s).unwrap()
harfruzz::Language::from_str(s).unwrap()
}
}
2 changes: 1 addition & 1 deletion src/hb/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl<'a> hb_font_t<'a> {
bbox = glyf.bbox(glyph);
}

// See https://github.com/RazrFalcon/rustybuzz/pull/98#issuecomment-1948430785
// See https://github.com/RazrFalcon/harfruzz/pull/98#issuecomment-1948430785
if self.ttfp_face.tables().glyf.is_some() && bbox.is_none() {
// Empty glyph; zero extents.
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/hb/shape_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn font_get_glyph(caller: Caller<'_, ShapingData>, _font: u32, codepoint: u32, u
// fn font_get_scale(font: u32, x_scale: *mut i32, y_scale: *mut i32);
// Returns the scale of the current font.
fn font_get_scale(mut caller: Caller<'_, ShapingData>, _font: u32, x_scale: u32, y_scale: u32) {
// Return upem as rustybuzz has no scale.
// Return upem as harfruzz has no scale.
let memory = caller.get_export("memory").unwrap().into_memory().unwrap();
let upem = caller.data().font.units_per_em();

Expand Down Expand Up @@ -550,8 +550,8 @@ fn shape_with(
.unwrap_or_default()
.to_string_lossy();

if !(shaper.eq_ignore_ascii_case("ot") || shaper.eq_ignore_ascii_case("rustybuzz")) {
log::warn!("Only ot shaper is available in rustybuzz.");
if !(shaper.eq_ignore_ascii_case("ot") || shaper.eq_ignore_ascii_case("harfruzz")) {
log::warn!("Only ot shaper is available in harfruzz.");
return 0;
}

Expand Down
42 changes: 21 additions & 21 deletions tests/shaping/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ mod wasm;

use std::str::FromStr;

use rustybuzz::BufferFlags;
use harfruzz::BufferFlags;

struct Args {
face_index: u32,
font_ptem: Option<f32>,
variations: Vec<String>,
direction: Option<rustybuzz::Direction>,
language: Option<rustybuzz::Language>,
script: Option<rustybuzz::Script>,
direction: Option<harfruzz::Direction>,
language: Option<harfruzz::Language>,
script: Option<harfruzz::Script>,
#[allow(dead_code)]
remove_default_ignorables: bool,
unsafe_to_concat: bool,
cluster_level: rustybuzz::BufferClusterLevel,
cluster_level: harfruzz::BufferClusterLevel,
features: Vec<String>,
pre_context: Option<String>,
post_context: Option<String>,
Expand Down Expand Up @@ -78,11 +78,11 @@ fn parse_string_list(s: &str) -> Result<Vec<String>, String> {
Ok(s.split(',').map(|s| s.to_string()).collect())
}

fn parse_cluster(s: &str) -> Result<rustybuzz::BufferClusterLevel, String> {
fn parse_cluster(s: &str) -> Result<harfruzz::BufferClusterLevel, String> {
match s {
"0" => Ok(rustybuzz::BufferClusterLevel::MonotoneGraphemes),
"1" => Ok(rustybuzz::BufferClusterLevel::MonotoneCharacters),
"2" => Ok(rustybuzz::BufferClusterLevel::Characters),
"0" => Ok(harfruzz::BufferClusterLevel::MonotoneGraphemes),
"1" => Ok(harfruzz::BufferClusterLevel::MonotoneCharacters),
"2" => Ok(harfruzz::BufferClusterLevel::Characters),
_ => Err(format!("invalid cluster level")),
}
}
Expand All @@ -107,20 +107,20 @@ pub fn shape(font_path: &str, text: &str, options: &str) -> String {

let font_data =
std::fs::read(font_path).unwrap_or_else(|e| panic!("Could not read {}: {}", font_path, e));
let mut face = rustybuzz::Face::from_slice(&font_data, args.face_index).unwrap();
let mut face = harfruzz::Face::from_slice(&font_data, args.face_index).unwrap();

face.set_points_per_em(args.font_ptem);

if !args.variations.is_empty() {
let variations: Vec<_> = args
.variations
.iter()
.map(|s| rustybuzz::Variation::from_str(s).unwrap())
.map(|s| harfruzz::Variation::from_str(s).unwrap())
.collect();
face.set_variations(&variations);
}

let mut buffer = rustybuzz::UnicodeBuffer::new();
let mut buffer = harfruzz::UnicodeBuffer::new();
if let Some(pre_context) = args.pre_context {
buffer.set_pre_context(&pre_context);
}
Expand Down Expand Up @@ -156,35 +156,35 @@ pub fn shape(font_path: &str, text: &str, options: &str) -> String {

let mut features = Vec::new();
for feature_str in args.features {
let feature = rustybuzz::Feature::from_str(&feature_str).unwrap();
let feature = harfruzz::Feature::from_str(&feature_str).unwrap();
features.push(feature);
}

let glyph_buffer = rustybuzz::shape(&face, &features, buffer);
let glyph_buffer = harfruzz::shape(&face, &features, buffer);

let mut format_flags = rustybuzz::SerializeFlags::default();
let mut format_flags = harfruzz::SerializeFlags::default();
if args.no_glyph_names {
format_flags |= rustybuzz::SerializeFlags::NO_GLYPH_NAMES;
format_flags |= harfruzz::SerializeFlags::NO_GLYPH_NAMES;
}

if args.no_clusters || args.ned {
format_flags |= rustybuzz::SerializeFlags::NO_CLUSTERS;
format_flags |= harfruzz::SerializeFlags::NO_CLUSTERS;
}

if args.no_positions {
format_flags |= rustybuzz::SerializeFlags::NO_POSITIONS;
format_flags |= harfruzz::SerializeFlags::NO_POSITIONS;
}

if args.no_advances || args.ned {
format_flags |= rustybuzz::SerializeFlags::NO_ADVANCES;
format_flags |= harfruzz::SerializeFlags::NO_ADVANCES;
}

if args.show_extents {
format_flags |= rustybuzz::SerializeFlags::GLYPH_EXTENTS;
format_flags |= harfruzz::SerializeFlags::GLYPH_EXTENTS;
}

if args.show_flags {
format_flags |= rustybuzz::SerializeFlags::GLYPH_FLAGS;
format_flags |= harfruzz::SerializeFlags::GLYPH_FLAGS;
}

glyph_buffer.serialize(&face, format_flags)
Expand Down

0 comments on commit 31d9639

Please sign in to comment.