Skip to main content

FontStats

Struct FontStats 

Source
pub struct FontStats {
Show 14 fields pub font_size_counts: BTreeMap<String, usize>, pub font_family_counts: BTreeMap<String, usize>, pub bold_counts: BoldCounts, pub italic_counts: ItalicCounts, pub most_common_font_size: f32, pub most_common_font_family: String, pub all_font_sizes: Vec<f32>, pub top_k_dominant_sizes: Vec<f32>, pub distinct_size_frequency_profile: Vec<DistinctSizeFrequency>, pub size_gap_first_to_second: f32, pub bold_density_per_size: BTreeMap<String, f32>, pub mean_font_size: f32, pub median_font_size: f32, pub variance_font_size: f32,
}
Expand description

Document-level font statistics produced by the analytics pre-pass. All fields are descriptive primitives — they expose font-distribution shape for the corpus-analysis lab and for downstream rules. Classification decisions (heading vs body, structural significance) belong to consumer rules, not to this type.

Fields§

§font_size_counts: BTreeMap<String, usize>

Element-count histogram keyed by string-formatted font size (see size_key() helper). Deterministic key ordering via BTreeMap.

§font_family_counts: BTreeMap<String, usize>

Element-count histogram keyed by font family name. Deterministic key ordering via BTreeMap.

§bold_counts: BoldCounts

Element counts split by bold/non-bold.

§italic_counts: ItalicCounts

Element counts split by italic/non-italic.

§most_common_font_size: f32

Single canonical body-size signal: the font size with the largest element count. Deterministic tiebreaker: larger size wins on equal count. Defaults to 12.0 if no elements observed.

§most_common_font_family: String

Single canonical body-family signal: the font family with the largest element count. Deterministic tiebreaker: lexicographically smaller family name wins on equal count. Defaults to "unknown" if no elements observed.

§all_font_sizes: Vec<f32>

Sorted, deduplicated list of every distinct font size seen (ascending).

§top_k_dominant_sizes: Vec<f32>

Top K font sizes by element count. Descriptive primitive only. Dominant sizes are typically body text; rare/non-dominant sizes are NOT necessarily structurally meaningful (e.g., a rare large red callout is not a heading). Consumer rules combine this with isolation, position, and other signals before drawing structural conclusions.

§distinct_size_frequency_profile: Vec<DistinctSizeFrequency>

Font sizes that account for at least config.distinct_size_min_fraction of elements. Descriptive primitive — populates corpus analysis and downstream rules. The number of qualifying sizes is suggestive of effective font diversity but is NOT a heading-depth classifier (rare sizes are often inline emphasis, formula symbols, or non-structural callouts).

§size_gap_first_to_second: f32

Absolute size difference between the two most common sizes (by element count). A small gap suggests low size-based separability between dominant content streams; a large gap suggests one stream is markedly larger than the other. Not a structural classifier on its own.

§bold_density_per_size: BTreeMap<String, f32>

Per-size fraction of elements that are bold. Identifies sizes where bold occurs disproportionately, candidate for the “bold heading size” signal. Combined with isolation and position by consumer rules.

§mean_font_size: f32

Mean of font sizes weighted by element count.

§median_font_size: f32

Median of font sizes weighted by element count.

§variance_font_size: f32

Variance of font sizes weighted by element count.

Trait Implementations§

Source§

impl Clone for FontStats

Source§

fn clone(&self) -> FontStats

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FontStats

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for FontStats

Source§

fn default() -> FontStats

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FontStats

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<FontStats, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FontStats

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.