Skip to content

Lightpanda: the headless browser designed for AI and automation

Embed DejaVuSansMono-Bold.ttf for bold headings

Karl Seguinde422a72f51a
diff --git a/src/rust/html5ever/lib.rs b/src/rust/html5ever/lib.rs
index fea23d236..ef6209495 100644
--- a/src/rust/html5ever/lib.rs
+++ b/src/rust/html5ever/lib.rs
@@ -788,7 +788,10 @@ pub extern "C" fn xml5ever_parse_document(
let bytes = strip_doctype_internal_subset(bytes);
let tb = xml5ever::tree_builder::XmlTreeBuilder::new(sink, Default::default());
let tokenizer = xml5ever::tokenizer::XmlTokenizer::new(
- UnclosedTagSink { tb, depth: Cell::new(0) },
+ UnclosedTagSink {
+ tb,
+ depth: Cell::new(0),
+ },
Default::default(),
);
html5ever::tendril::stream::Utf8LossyDecoder::new(XmlDocumentParser {
@@ -818,7 +821,7 @@ fn strip_doctype_internal_subset(bytes: &[u8]) -> std::borrow::Cow<'_, [u8]> {
if c == q {
quote = None
}
- },
+ }
None => match c {
b'"' | b'\'' => quote = Some(c),
b'>' if open.is_none() => return std::borrow::Cow::Borrowed(bytes),
@@ -828,8 +831,8 @@ fn strip_doctype_internal_subset(bytes: &[u8]) -> std::borrow::Cow<'_, [u8]> {
out.extend_from_slice(&bytes[..open.unwrap()]);
out.extend_from_slice(&bytes[i + 1..]);
return std::borrow::Cow::Owned(out);
- },
- _ => {},
+ }
+ _ => {}
},
}
i += 1;
@@ -860,16 +863,18 @@ impl<'arena> xml5ever::tokenizer::TokenSink for UnclosedTagSink<'arena> {
TagKind::StartTag => self.depth.set(self.depth.get() + 1),
TagKind::EndTag | TagKind::ShortTag => {
self.depth.set(self.depth.get().saturating_sub(1))
- },
- TagKind::EmptyTag => {},
+ }
+ TagKind::EmptyTag => {}
},
Token::EndOfFile => {
if self.depth.get() > 0 {
use xml5ever::tree_builder::TreeSink;
- self.tb.sink.parse_error(std::borrow::Cow::Borrowed("Unclosed element at EOF"));
+ self.tb
+ .sink
+ .parse_error(std::borrow::Cow::Borrowed("Unclosed element at EOF"));
}
- },
- _ => {},
+ }
+ _ => {}
}
self.tb.process_token(token)
}
diff --git a/src/rust/render/fonts/DejaVuSansMono-Bold.ttf b/src/rust/render/fonts/DejaVuSansMono-Bold.ttf
new file mode 100644
index 000000000..0c9d808d2
Binary files /dev/null and b/src/rust/render/fonts/DejaVuSansMono-Bold.ttf differ
diff --git a/src/rust/render/lib.rs b/src/rust/render/lib.rs
index dbb398fda..f496c3bc1 100644
--- a/src/rust/render/lib.rs
+++ b/src/rust/render/lib.rs
@@ -37,7 +37,7 @@ use parley::{
use skrifa::instance::{LocationRef, Size};
use skrifa::outline::{DrawSettings, OutlinePen};
use skrifa::{GlyphId, MetadataProvider};
-use tiny_skia::{Color, FillRule, IntRect, Paint, PathBuilder, Pixmap, Rect, Stroke, Transform};
+use tiny_skia::{Color, FillRule, IntRect, Paint, PathBuilder, Pixmap, Rect, Transform};
// ---------------------------------------------------------------------------
// C ABI — mirrored by src/browser/screenshot.zig.
@@ -308,6 +308,10 @@ impl Renderer {
let sans = Self::register(&mut collection, include_bytes!("fonts/DejaVuSans.ttf"));
Self::register(&mut collection, include_bytes!("fonts/DejaVuSans-Bold.ttf"));
let mono = Self::register(&mut collection, include_bytes!("fonts/DejaVuSansMono.ttf"));
+ Self::register(
+ &mut collection,
+ include_bytes!("fonts/DejaVuSansMono-Bold.ttf"),
+ );
for generic in [
GenericFamily::SansSerif,
GenericFamily::Serif,
@@ -610,14 +614,8 @@ impl Renderer {
let mut x = ox + gr.offset();
let skew = synth
.skew()
- .map(|deg| (-deg.to_radians()).tan())
+ .map(|deg| deg.to_radians().tan())
.unwrap_or(0.0);
- // Stroking happens in path space, which is now font units, so the
- // width is upem/24 to still land at font_size/24 device px.
- let stroke = synth.embolden().then(|| Stroke {
- width: upem / 24.0,
- ..Default::default()
- });
for glyph in gr.glyphs() {
let gx = x + glyph.x;
let gy = baseline - glyph.y;
@@ -640,9 +638,6 @@ impl Renderer {
// onto the pixmap.
let t = Transform::from_row(scale, 0.0, skew * scale, -scale, gx, gy);
pixmap.fill_path(path, &paint, FillRule::Winding, t, None);
- if let Some(stroke) = &stroke {
- pixmap.stroke_path(path, &paint, stroke, t, None);
- }
}
}