pub struct JustificationControl {
pub mode: JustifyMode,
pub word_space: GlueSpec,
pub sentence_space: GlueSpec,
pub char_space: GlueSpec,
pub penalties: SpacePenalty,
pub french_spacing: bool,
pub max_consecutive_hyphens: u8,
pub emergency_stretch_factor: u32,
}Expand description
Unified justification configuration.
Combines alignment mode, glue specs per space category, and penalty modifiers into a single configuration object that can be passed to the line-break optimizer.
Fields§
§mode: JustifyModeText alignment mode.
word_space: GlueSpecGlue spec for inter-word spaces.
sentence_space: GlueSpecGlue spec for inter-sentence spaces.
char_space: GlueSpecGlue spec for inter-character adjustments (tracking).
penalties: SpacePenaltyPenalty modifiers for adjustment quality.
french_spacing: boolWhether to use French spacing (same space after sentences as words).
max_consecutive_hyphens: u8Maximum consecutive hyphens before incurring extra penalty.
emergency_stretch_factor: u32Emergency stretch multiplier (1/256ths): applied when no feasible break exists. 256 = 1x (no extra), 512 = 2x emergency stretch.
Implementations§
Source§impl JustificationControl
impl JustificationControl
Sourcepub const TYPOGRAPHIC: Self
pub const TYPOGRAPHIC: Self
Typographic: full justification with fine-grained controls.
Sourcepub const fn glue_for(&self, category: SpaceCategory) -> GlueSpec
pub const fn glue_for(&self, category: SpaceCategory) -> GlueSpec
Look up the glue spec for a given space category.
Sourcepub fn total_natural(&self, spaces: &[SpaceCategory]) -> u32
pub fn total_natural(&self, spaces: &[SpaceCategory]) -> u32
Compute total natural width for a sequence of space categories.
Sourcepub fn total_stretch(&self, spaces: &[SpaceCategory]) -> u32
pub fn total_stretch(&self, spaces: &[SpaceCategory]) -> u32
Compute total stretchability for a sequence of space categories.
Sourcepub fn total_shrink(&self, spaces: &[SpaceCategory]) -> u32
pub fn total_shrink(&self, spaces: &[SpaceCategory]) -> u32
Compute total shrinkability for a sequence of space categories.
Sourcepub fn adjustment_ratio(
&self,
slack_subcell: i32,
total_stretch: u32,
total_shrink: u32,
) -> Option<i32>
pub fn adjustment_ratio( &self, slack_subcell: i32, total_stretch: u32, total_shrink: u32, ) -> Option<i32>
Compute the adjustment ratio for a line.
slack_subcell = desired_width - content_width - natural_space_width
(positive means line is too short, needs stretching).
Returns ratio in 1/256ths, or None if adjustment is impossible
(shrink required exceeds total shrinkability).
Sourcepub fn badness(ratio_fixed: i32) -> u64
pub fn badness(ratio_fixed: i32) -> u64
Compute badness for a given adjustment ratio.
Uses the standard TeX cubic formula: |r/256|³ × 10000.
Returns u64::MAX for infeasible adjustments.
Sourcepub fn line_demerits(
&self,
ratio_fixed: i32,
spaces: &[SpaceCategory],
break_penalty: i64,
) -> u64
pub fn line_demerits( &self, ratio_fixed: i32, spaces: &[SpaceCategory], break_penalty: i64, ) -> u64
Compute total demerits for a line, combining badness and penalties.
ratio_fixed: adjustment ratio in 1/256ths.
spaces: the space categories on this line.
break_penalty: penalty from the break point itself.
Trait Implementations§
Source§impl Clone for JustificationControl
impl Clone for JustificationControl
Source§fn clone(&self) -> JustificationControl
fn clone(&self) -> JustificationControl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for JustificationControl
impl Debug for JustificationControl
Source§impl Default for JustificationControl
impl Default for JustificationControl
Source§impl Display for JustificationControl
impl Display for JustificationControl
Source§impl Hash for JustificationControl
impl Hash for JustificationControl
Source§impl PartialEq for JustificationControl
impl PartialEq for JustificationControl
impl Copy for JustificationControl
impl Eq for JustificationControl
impl StructuralPartialEq for JustificationControl
Auto Trait Implementations§
impl Freeze for JustificationControl
impl RefUnwindSafe for JustificationControl
impl Send for JustificationControl
impl Sync for JustificationControl
impl Unpin for JustificationControl
impl UnwindSafe for JustificationControl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.