Struct truetype::glyph_data::ComponentFlags
source · pub struct ComponentFlags(pub u16);
Expand description
Component flags.
Tuple Fields§
§0: u16
Implementations§
source§impl ComponentFlags
impl ComponentFlags
sourcepub fn are_arguments_words(&self) -> bool
pub fn are_arguments_words(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 305)
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
fn read<T: Tape>(tape: &mut T, flags: ComponentFlags) -> Result<Self> {
match (flags.are_arguments_words(), flags.are_arguments_xy()) {
(true, true) => {
let x = tape.take::<i16>()?;
let y = tape.take::<i16>()?;
Ok(Arguments::Offsets(x, y))
}
(false, true) => {
let x = tape.take::<i8>()? as i16;
let y = tape.take::<i8>()? as i16;
Ok(Arguments::Offsets(x, y))
}
(true, false) => {
let i = tape.take::<u16>()?;
let j = tape.take::<u16>()?;
Ok(Arguments::Indices(i, j))
}
(false, false) => {
let i = tape.take::<u8>()? as u16;
let j = tape.take::<u8>()? as u16;
Ok(Arguments::Indices(i, j))
}
}
}
sourcepub fn are_arguments_xy(&self) -> bool
pub fn are_arguments_xy(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 305)
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
fn read<T: Tape>(tape: &mut T, flags: ComponentFlags) -> Result<Self> {
match (flags.are_arguments_words(), flags.are_arguments_xy()) {
(true, true) => {
let x = tape.take::<i16>()?;
let y = tape.take::<i16>()?;
Ok(Arguments::Offsets(x, y))
}
(false, true) => {
let x = tape.take::<i8>()? as i16;
let y = tape.take::<i8>()? as i16;
Ok(Arguments::Offsets(x, y))
}
(true, false) => {
let i = tape.take::<u16>()?;
let j = tape.take::<u16>()?;
Ok(Arguments::Indices(i, j))
}
(false, false) => {
let i = tape.take::<u8>()? as u16;
let j = tape.take::<u8>()? as u16;
Ok(Arguments::Indices(i, j))
}
}
}
pub fn should_round_xy_to_grid(&self) -> bool
sourcepub fn has_scalar_scale(&self) -> bool
pub fn has_scalar_scale(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 341)
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
fn read<T: Tape>(tape: &mut T, flags: ComponentFlags) -> Result<Self> {
if flags.has_scalar_scale() {
Ok(Options::Scalar(tape.take()?))
} else if flags.has_vector_scale() {
Ok(Options::Vector(tape.take()?, tape.take()?))
} else if flags.has_matrix_scale() {
Ok(Options::Matrix(
tape.take()?,
tape.take()?,
tape.take()?,
tape.take()?,
))
} else {
Ok(Options::None)
}
}
sourcepub fn has_more_components(&self) -> bool
pub fn has_more_components(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 210)
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
fn read<T: Tape>(tape: &mut T, contour_count: i16) -> Result<Self> {
if contour_count < -1 {
raise!("found a malformed glyph");
}
if contour_count >= 0 {
return Ok(Description::Simple(
tape.take_given(contour_count as usize)?,
));
}
let mut components = vec![];
let mut component_count = 0;
let mut has_more_components = true;
let mut has_instructions = false;
while has_more_components {
components.push(tape.take::<Component>()?);
has_instructions |= components[component_count].flags.has_instructions();
has_more_components = components[component_count].flags.has_more_components();
component_count += 1;
}
let instruction_size = if has_instructions {
tape.take::<u16>()?
} else {
0
};
let instructions = tape.take_bytes(instruction_size as usize)?;
Ok(Description::Composite(CompositeDescription {
components: components,
instruction_size: instruction_size,
instructions: instructions,
}))
}
sourcepub fn has_vector_scale(&self) -> bool
pub fn has_vector_scale(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 343)
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
fn read<T: Tape>(tape: &mut T, flags: ComponentFlags) -> Result<Self> {
if flags.has_scalar_scale() {
Ok(Options::Scalar(tape.take()?))
} else if flags.has_vector_scale() {
Ok(Options::Vector(tape.take()?, tape.take()?))
} else if flags.has_matrix_scale() {
Ok(Options::Matrix(
tape.take()?,
tape.take()?,
tape.take()?,
tape.take()?,
))
} else {
Ok(Options::None)
}
}
sourcepub fn has_matrix_scale(&self) -> bool
pub fn has_matrix_scale(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 345)
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
fn read<T: Tape>(tape: &mut T, flags: ComponentFlags) -> Result<Self> {
if flags.has_scalar_scale() {
Ok(Options::Scalar(tape.take()?))
} else if flags.has_vector_scale() {
Ok(Options::Vector(tape.take()?, tape.take()?))
} else if flags.has_matrix_scale() {
Ok(Options::Matrix(
tape.take()?,
tape.take()?,
tape.take()?,
tape.take()?,
))
} else {
Ok(Options::None)
}
}
sourcepub fn has_instructions(&self) -> bool
pub fn has_instructions(&self) -> bool
Examples found in repository?
src/glyph_data.rs (line 209)
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
fn read<T: Tape>(tape: &mut T, contour_count: i16) -> Result<Self> {
if contour_count < -1 {
raise!("found a malformed glyph");
}
if contour_count >= 0 {
return Ok(Description::Simple(
tape.take_given(contour_count as usize)?,
));
}
let mut components = vec![];
let mut component_count = 0;
let mut has_more_components = true;
let mut has_instructions = false;
while has_more_components {
components.push(tape.take::<Component>()?);
has_instructions |= components[component_count].flags.has_instructions();
has_more_components = components[component_count].flags.has_more_components();
component_count += 1;
}
let instruction_size = if has_instructions {
tape.take::<u16>()?
} else {
0
};
let instructions = tape.take_bytes(instruction_size as usize)?;
Ok(Description::Composite(CompositeDescription {
components: components,
instruction_size: instruction_size,
instructions: instructions,
}))
}
pub fn should_use_metrics(&self) -> bool
pub fn has_overlap(&self) -> bool
pub fn is_offset_scaled(&self) -> bool
pub fn is_offset_unscaled(&self) -> bool
pub fn is_invalid(&self) -> bool
Trait Implementations§
source§impl Clone for ComponentFlags
impl Clone for ComponentFlags
source§fn clone(&self) -> ComponentFlags
fn clone(&self) -> ComponentFlags
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ComponentFlags
impl Debug for ComponentFlags
source§impl Default for ComponentFlags
impl Default for ComponentFlags
source§fn default() -> ComponentFlags
fn default() -> ComponentFlags
Returns the “default value” for a type. Read more
source§impl Display for ComponentFlags
impl Display for ComponentFlags
source§impl From<ComponentFlags> for u16
impl From<ComponentFlags> for u16
source§fn from(flags: ComponentFlags) -> u16
fn from(flags: ComponentFlags) -> u16
Converts to this type from the input type.
source§impl PartialEq<ComponentFlags> for ComponentFlags
impl PartialEq<ComponentFlags> for ComponentFlags
source§fn eq(&self, other: &ComponentFlags) -> bool
fn eq(&self, other: &ComponentFlags) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.