Skip to content

Open-source Android PDF and document toolkit with PDF tools, Office viewing, XLSX editing, scanning, and image editing. Built with Kotlin and Jetpack Compose.

Engine: rustfmt the bold-in-own-face change

chethan616c3af60456e26
diff --git a/engine/crates/edit/src/text.rs b/engine/crates/edit/src/text.rs
index 7c2caee..9d07ac0 100644
--- a/engine/crates/edit/src/text.rs
+++ b/engine/crates/edit/src/text.rs
@@ -2544,7 +2544,8 @@ fn slanted(tm: &[f64; 6]) -> bool {
/// A face's family without its subset tag, weight and slant words: "ABCDEF+Calibri-BoldItalic"
/// and "Calibri" are one family, so a bold run can be drawn in the page's own bold of it.
pub(crate) fn family_key(base_font: &str) -> String {
- let mut key: String = base_font.rsplit('+').next().unwrap_or(base_font).chars().filter(char::is_ascii_alphanumeric).flat_map(char::to_lowercase).collect();
+ let mut key: String =
+ base_font.rsplit('+').next().unwrap_or(base_font).chars().filter(char::is_ascii_alphanumeric).flat_map(char::to_lowercase).collect();
for word in ["bolditalic", "boldoblique", "semibold", "demibold", "bold", "italic", "oblique", "regular", "roman", "book", "medium", "normal"] {
key = key.replace(word, "");
}
diff --git a/engine/crates/edit/src/text_regions.rs b/engine/crates/edit/src/text_regions.rs
index 1c019b4..4217c6e 100644
--- a/engine/crates/edit/src/text_regions.rs
+++ b/engine/crates/edit/src/text_regions.rs
@@ -487,7 +487,9 @@ pub(super) fn rewrite_styled_block(
fonts
.iter()
.take(256)
- .filter_map(|(name, object)| doc.resolve(object).as_dict().map(|d| (String::from_utf8_lossy(name).into_owned(), Metrics::from_dict(doc, d))))
+ .filter_map(|(name, object)| {
+ doc.resolve(object).as_dict().map(|d| (String::from_utf8_lossy(name).into_owned(), Metrics::from_dict(doc, d)))
+ })
.collect()
};
// Styled runs drawn in another of the page's faces (their widths are that face's own) and
@@ -564,7 +566,8 @@ pub(super) fn rewrite_styled_block(
let [r, g, b] = line.color;
line.origin.state.render_mode = 2;
line.origin.state.stroke = vec![Op::new("RG", vec![Object::Real(r), Object::Real(g), Object::Real(b)])];
- line.origin.state.line_width = Some((line.size * 0.03).max(0.05) / line.origin.ctm[0].hypot(line.origin.ctm[1]).max(1e-6));
+ line.origin.state.line_width =
+ Some((line.size * 0.03).max(0.05) / line.origin.ctm[0].hypot(line.origin.ctm[1]).max(1e-6));
line.bold = true;
} else if !want_bold && line.bold && synthetic_bold {
line.origin.state.render_mode = 0;
@@ -854,8 +857,9 @@ pub(super) fn rewrite_styled_block(
source.origin.state.word_spacing,
) * source.origin.state.scale
* across(source);
- let changed_face =
- style.resource.is_some() || own_variant.contains(&index) || overrides.get(&index).is_some_and(|r| r.family.is_some() || r.resource.is_some());
+ let changed_face = style.resource.is_some()
+ || own_variant.contains(&index)
+ || overrides.get(&index).is_some_and(|r| r.family.is_some() || r.resource.is_some());
let factor = if nominal > 0.0 && !changed_face { ((source.rect[2] - source.rect[0]) / nominal).clamp(0.5, 2.0) } else { 1.0 };
calibration.insert(index, factor);
}