use crate::model::style::UnderlineType;
use crate::paint::RenderProfile;
use crate::paint::{
LayerNode, LayerNodeKind, PaintOp, TextDecorationKind, TextDecorationPaintGeometry,
};
use crate::renderer::image_resolver::detect_image_mime_type;
use crate::renderer::render_tree::{
BoundingBox, ImageNode, RectangleNode, RenderNode, RenderNodeType,
};
use crate::renderer::{hwpunit_to_px, DEFAULT_DPI, HWPUNIT_PER_INCH};
fn source_device_coordinate(px: f64, pixel: f64) -> f64 {
let hu = (px * HWPUNIT_PER_INCH / DEFAULT_DPI).round() as i32;
if hwpunit_to_px(hu, DEFAULT_DPI).to_bits() == px.to_bits() {
f64::from(hu) / (pixel * HWPUNIT_PER_INCH / DEFAULT_DPI)
} else {
px / pixel
}
}
#[derive(Clone, Copy)]
pub(crate) struct PagePaintContext {
print: bool,
logical_size: (f64, f64),
output_size: (f64, f64),
axis_aligned_graphics: bool,
print_paper: Option<super::print_paper::PrintPaper>,
image_column_origin: Option<(f64, f64)>,
image_column_blocked: bool,
table_fill_origin: super::table_fill_origin::TableFillOrigin,
}
impl PagePaintContext {
pub(crate) fn new(profile: RenderProfile, width: f64, height: f64) -> Self {
let print = profile == RenderProfile::Print;
let physical_extent = |px: f64| (px * 0.75 + 1e-9).floor() / 0.75;
Self {
print,
logical_size: (width, height),
output_size: if print {
(physical_extent(width), physical_extent(height))
} else {
(width, height)
},
axis_aligned_graphics: true,
print_paper: None,
image_column_origin: None,
image_column_blocked: false,
table_fill_origin: Default::default(),
}
}
pub(crate) fn with_hangul2024_print(mut self, enabled: bool) -> Self {
if self.print && enabled {
self.print_paper =
super::print_paper::PrintPaper::from_css(self.logical_size.0, self.logical_size.1);
if let Some(paper) = self.print_paper {
self.output_size = paper.size;
}
}
self
}
pub(crate) fn output_size(self) -> (f64, f64) {
self.output_size
}
pub(crate) fn for_children(mut self, node: &RenderNode) -> Self {
self.table_fill_origin = self.table_fill_origin.for_children(node);
self.image_column_blocked |= node.layer.is_some()
|| matches!(
&node.node_type,
RenderNodeType::MasterPage
| RenderNodeType::Header
| RenderNodeType::Footer
| RenderNodeType::FootnoteArea
| RenderNodeType::TableCell(_)
| RenderNodeType::TextBox
)
|| matches!(&node.node_type,
RenderNodeType::Group(group) if group.paint_transform.is_some());
if self.image_column_blocked {
self.image_column_origin = None;
} else if matches!(&node.node_type, RenderNodeType::Column(_)) {
self.image_column_origin = Some((node.bbox.x, node.bbox.y));
}
self
}
pub(crate) fn publish_table_border_geometry(self, node: &mut LayerNode) {
if !self.print {
return;
}
let ratio = |extent: f64| {
(extent * 0.75 + 1e-9).floor() / (extent * 600.0 / 96.0).round() * (600.0 / 72.0)
};
let (sx, sy) = self.print_paper.map_or_else(
|| (ratio(self.logical_size.0), ratio(self.logical_size.1)),
|paper| {
(
paper.device_units.0 * (600.0 / 96.0),
paper.device_units.1 * (600.0 / 96.0),
)
},
);
if ![sx, sy]
.into_iter()
.all(|value| value.is_finite() && value > 0.0)
{
return;
}
fn publish(node: &mut LayerNode, table_owned: bool, sx: f64, sy: f64) {
match &mut node.kind {
LayerNodeKind::Group {
children,
group_kind,
..
} => {
let table = matches!(group_kind, crate::paint::layer_tree::GroupKind::Table(_));
for child in children {
publish(child, table, sx, sy);
}
}
LayerNodeKind::ClipRect { child, .. } | LayerNodeKind::ClipPath { child, .. } => {
publish(child, table_owned, sx, sy)
}
LayerNodeKind::Leaf { ops } if table_owned => {
for op in ops {
if let PaintOp::Line { bbox, line } = op {
line.x1 *= sx;
line.x2 *= sx;
line.y1 *= sy;
line.y2 *= sy;
*bbox = line.ink_bbox();
}
}
}
LayerNodeKind::Leaf { .. } => {}
}
}
publish(node, false, sx, sy);
}
pub(crate) fn publish_glyph_geometry(
self,
node: &mut LayerNode,
prior_solid_fill: bool,
hangul2024_print: bool,
) {
if !self.print {
return;
}
let ratio =
|px: f64| (px * 0.75 + 1e-9).floor() / (px * 600.0 / 96.0).round() * (600.0 / 72.0);
let (sx, sy) = self.print_paper.map_or_else(
|| (ratio(self.logical_size.0), ratio(self.logical_size.1)),
|paper| {
(
paper.device_units.0 * (600.0 / 96.0),
paper.device_units.1 * (600.0 / 96.0),
)
},
);
if ![sx, sy].iter().all(|v| v.is_finite() && *v > 0.0) {
return;
}
let transform = crate::paint::LayerAffineTransform {
a: sx,
b: 0.0,
c: 0.0,
d: sy,
e: 0.0,
f: 0.0,
};
let mut sources = std::collections::HashSet::new();
let mut equation_sources = std::collections::HashSet::new();
fn collect(
node: &LayerNode,
sources: &mut std::collections::HashSet<u32>,
equation_sources: &mut std::collections::HashSet<crate::renderer::render_tree::NodeId>,
rounded: &mut bool,
plane: crate::paint::PaintReplayPlane,
inherited_layer: Option<crate::renderer::render_tree::RenderLayerInfo>,
hangul2024_print: bool,
) {
let active_layer = node.layer.or(inherited_layer);
match &node.kind {
LayerNodeKind::Group { children, .. } => {
for child in children {
collect(
child,
sources,
equation_sources,
rounded,
plane,
active_layer,
hangul2024_print,
);
}
}
LayerNodeKind::ClipRect { child, .. } | LayerNodeKind::ClipPath { child, .. } => {
collect(
child,
sources,
equation_sources,
rounded,
plane,
active_layer,
hangul2024_print,
)
}
LayerNodeKind::Leaf { ops } => {
for op in ops {
if crate::paint::paint_op_replay_plane_with_layer(op, active_layer) != plane
{
continue;
}
*rounded |= PagePaintContext::op_has_print_solid_fill(op, hangul2024_print);
if !*rounded {
if let (Some(id), PaintOp::Equation { equation, .. }) =
(node.source_node_id, op)
{
if crate::renderer::equation::uses_original_hft_glyphs(
&equation.layout_box,
) {
equation_sources.insert(id);
}
}
}
if let PaintOp::TextRun {
run,
source: Some(source),
..
} = op
{
if run.style.hft_print_frame && !*rounded {
sources.insert(source.id.0);
}
}
}
}
}
}
fn publish(
node: &mut LayerNode,
sources: &std::collections::HashSet<u32>,
transform: crate::paint::LayerAffineTransform,
) {
match &mut node.kind {
LayerNodeKind::Group { children, .. } => {
for child in children {
publish(child, sources, transform);
}
}
LayerNodeKind::ClipRect { child, .. } | LayerNodeKind::ClipPath { child, .. } => {
publish(child, sources, transform)
}
LayerNodeKind::Leaf { ops } => {
for op in ops {
match op {
PaintOp::TextRun {
source: Some(source),
paint_transform,
..
}
| PaintOp::CharOverlap {
source: Some(source),
paint_transform,
..
} if sources.contains(&source.id.0) => {
*paint_transform = Some(transform)
}
PaintOp::GlyphRun {
run,
paint_transform,
..
} if sources.contains(&run.source.id.0) => {
*paint_transform = Some(transform)
}
PaintOp::GlyphOutline {
outline,
paint_transform,
..
} if sources.contains(&outline.source.id.0) => {
*paint_transform = Some(transform)
}
_ => {}
}
}
}
}
}
fn header_footer_fill(node: &LayerNode, owned: bool, hangul2024_print: bool) -> bool {
match &node.kind {
LayerNodeKind::Group {
children,
group_kind,
..
} => {
let owned = owned
|| matches!(
group_kind,
crate::paint::layer_tree::GroupKind::Header
| crate::paint::layer_tree::GroupKind::Footer
);
children
.iter()
.any(|child| header_footer_fill(child, owned, hangul2024_print))
}
LayerNodeKind::ClipRect { child, .. } | LayerNodeKind::ClipPath { child, .. } => {
header_footer_fill(child, owned, hangul2024_print)
}
LayerNodeKind::Leaf { ops } => {
owned
&& ops.iter().any(|op| {
PagePaintContext::op_has_print_solid_fill(op, hangul2024_print)
})
}
}
}
let mut rounded = prior_solid_fill || header_footer_fill(node, false, hangul2024_print);
for plane in crate::paint::PaintReplayPlane::ORDERED {
collect(
node,
&mut sources,
&mut equation_sources,
&mut rounded,
plane,
None,
hangul2024_print,
);
}
publish(node, &sources, transform);
if self.print_paper.is_some() {
super::equation_print_frame::publish(node, &equation_sources, transform);
}
}
fn shape_has_print_solid_fill(style: &crate::renderer::ShapeStyle) -> bool {
style.opacity > 0.0 && style.fill_color.is_some()
}
fn rectangle_has_print_polygon_fill(
rect: &crate::renderer::render_tree::RectangleNode,
hangul2024_print: bool,
) -> bool {
((hangul2024_print || rect.control_index.is_some())
&& Self::shape_has_print_solid_fill(&rect.style))
|| (rect.picture_border
&& rect.style.opacity > 0.0
&& rect.style.stroke_color.is_some()
&& rect.style.stroke_width > 0.0)
}
fn op_has_print_solid_fill(op: &PaintOp, hangul2024_print: bool) -> bool {
match op {
PaintOp::Rectangle { bbox, rect } => {
bbox.width > 0.0
&& bbox.height > 0.0
&& Self::rectangle_has_print_polygon_fill(rect, hangul2024_print)
}
PaintOp::Ellipse { bbox, ellipse } => {
bbox.width > 0.0
&& bbox.height > 0.0
&& Self::shape_has_print_solid_fill(&ellipse.style)
}
PaintOp::Path { path, .. } => Self::shape_has_print_solid_fill(&path.style),
PaintOp::TextRun { run, .. } | PaintOp::CharOverlap { run, .. } => {
!run.text.is_empty()
&& crate::model::color::char_shade(run.style.shade_color).is_some()
}
_ => false,
}
}
pub(crate) fn node_has_print_solid_fill(node: &RenderNode, hangul2024_print: bool) -> bool {
use crate::renderer::render_tree::RenderNodeType;
if !node.visible || node.editor_only {
return false;
}
let filled = match &node.node_type {
RenderNodeType::Rectangle(rect) => {
node.bbox.width > 0.0
&& node.bbox.height > 0.0
&& Self::rectangle_has_print_polygon_fill(rect, hangul2024_print)
}
RenderNodeType::Ellipse(ellipse) => {
node.bbox.width > 0.0
&& node.bbox.height > 0.0
&& Self::shape_has_print_solid_fill(&ellipse.style)
}
RenderNodeType::Path(path) => Self::shape_has_print_solid_fill(&path.style),
RenderNodeType::TextRun(run) => {
!run.text.is_empty()
&& crate::model::color::char_shade(run.style.shade_color).is_some()
}
_ => false,
};
filled
|| node
.children
.iter()
.any(|child| Self::node_has_print_solid_fill(child, hangul2024_print))
}
pub(crate) fn publish_decoration_geometry(self, node: &mut LayerNode) {
if !self.print {
return;
}
let ratio = |px: f64| {
let device_extent = (px * 600.0 / 96.0).round();
let point_extent = (px * 0.75 + 1e-9).floor();
point_extent / device_extent * (600.0 / 72.0)
};
let (sx, sy) = self.print_paper.map_or_else(
|| (ratio(self.logical_size.0), ratio(self.logical_size.1)),
|paper| {
(
paper.device_units.0 * (600.0 / 96.0),
paper.device_units.1 * (600.0 / 96.0),
)
},
);
if ![sx, sy].iter().all(|x| x.is_finite() && *x > 0.0) {
return;
}
Self::publish_decoration_geometry_at(node, sx, sy);
}
fn publish_decoration_geometry_at(node: &mut LayerNode, sx: f64, sy: f64) {
match &mut node.kind {
LayerNodeKind::Group { children, .. } => {
for child in children {
Self::publish_decoration_geometry_at(child, sx, sy);
}
}
LayerNodeKind::ClipRect { child, .. } | LayerNodeKind::ClipPath { child, .. } => {
Self::publish_decoration_geometry_at(child, sx, sy)
}
LayerNodeKind::Leaf { ops } => {
for op in ops {
if let PaintOp::TextDecoration {
bbox,
run,
kind: TextDecorationKind::Underline,
paint_geometry,
..
} = op
{
if run.style.underline != UnderlineType::Bottom
|| run.style.underline_shape != 0
|| run.rotation != 0.0
|| run.is_vertical
|| run.style.superscript
|| run.style.subscript
{
continue;
}
let (font_size, baseline) = run
.style
.script_draw_metrics(run.style.font_size, run.baseline);
let underline_y = bbox.y
+ baseline
+ font_size
* crate::renderer::text_decoration::UNDERLINE_BASELINE_RATIO;
*paint_geometry = Some(TextDecorationPaintGeometry {
bbox: BoundingBox::new(
bbox.x * sx,
bbox.y + underline_y * (sy - 1.0),
bbox.width * sx,
bbox.height,
),
inline_scale: sx,
});
}
}
}
}
}
pub(crate) fn image_codec_width_points(
self,
image: &ImageNode,
frame: BoundingBox,
) -> Option<f64> {
if !self.print || !self.axis_aligned_graphics || image.transform.has_transform() {
return None;
}
let width = image.paint_bbox(&frame).width * 0.75;
(width.is_finite() && width > 0.0).then_some(width)
}
pub(crate) fn without_rectangle_mapping(mut self) -> Self {
self.axis_aligned_graphics = false;
self
}
fn fill_device_coordinate(
self,
value: f64,
pixel: f64,
axis: usize,
table_background: bool,
) -> f64 {
if let Some(origin) = self
.table_fill_origin
.axis(axis)
.filter(|_| table_background && self.print_paper.is_some())
{
super::print_coordinate::relative_device(origin, 0.0, pixel).round()
+ super::print_coordinate::relative_device(value, origin, pixel).round()
} else {
source_device_coordinate(value, pixel).round()
}
}
pub(crate) fn rectangle_fill_frame(
self,
frame: BoundingBox,
rect: &RectangleNode,
device_pixel: Option<f64>,
) -> Option<BoundingBox> {
if !self.print || !self.axis_aligned_graphics {
return None;
}
super::rectangle_fill::frame(frame, rect, device_pixel?)
}
pub(crate) fn solid_fill_frame(
self,
bounds: BoundingBox,
rect: &RectangleNode,
device_pixel: Option<f64>,
node: &RenderNode,
) -> BoundingBox {
let Some(pixel) = device_pixel.filter(|p| p.is_finite() && *p > 0.0) else {
return bounds;
};
if !self.print
|| !self.axis_aligned_graphics
|| rect.transform.has_transform()
|| !super::device_fill::eligible(rect)
|| ![bounds.x, bounds.y, bounds.width, bounds.height]
.into_iter()
.all(f64::is_finite)
|| bounds.width <= 0.0
|| bounds.height <= 0.0
{
return bounds;
}
let devices = (
(self.logical_size.0 / pixel).round(),
(self.logical_size.1 / pixel).round(),
);
if ![devices.0, devices.1, self.output_size.0, self.output_size.1]
.into_iter()
.all(|extent| extent.is_finite() && extent > 0.0)
{
return bounds;
}
let (x_unit, y_unit) = self.print_paper.map_or(
(
self.output_size.0 / devices.0,
self.output_size.1 / devices.1,
),
|paper| paper.device_units,
);
let background = node.table_background_paint;
let (x, width) = if node.layer.is_some_and(|layer| layer.master_page) {
(bounds.x, bounds.width)
} else {
let left = self.fill_device_coordinate(bounds.x, pixel, 0, background);
let right = self.fill_device_coordinate(bounds.x + bounds.width, pixel, 0, background);
(left * x_unit, (right - left) * x_unit)
};
let top = self.fill_device_coordinate(bounds.y, pixel, 1, background);
let bottom = self.fill_device_coordinate(bounds.y + bounds.height, pixel, 1, background);
BoundingBox::new(x, top * y_unit, width, (bottom - top) * y_unit)
}
pub(crate) fn picture_border_pen(self, rect: &mut RectangleNode, pixel: Option<f64>) {
let (Some(width_hu), Some(pixel)) = (
rect.picture_border_width_hu,
pixel.filter(|p| p.is_finite() && *p > 0.0),
) else {
return;
};
if !self.print
|| !self.axis_aligned_graphics
|| rect.transform.has_transform()
|| rect.image_frame_owner.is_none()
|| rect.style.stroke_dash != crate::renderer::StrokeDash::Solid
|| width_hu < 0
|| !rect.style.stroke_width.is_finite()
{
return;
}
let declared = if width_hu == 0 {
0.0
} else {
rect.style.stroke_width / pixel
};
let band = declared.round().max(1.0);
rect.print_picture_pen = Some([band * pixel, pixel]);
rect.style.stroke_width = (band + 1.0) * pixel;
rect.style.stroke_dash = crate::renderer::StrokeDash::Explicit([0.0; 6]);
}
pub(crate) fn picture_border_frame(
self,
bounds: BoundingBox,
rect: &RectangleNode,
) -> Option<BoundingBox> {
let paper = self.print_paper?;
if !self.print
|| !self.axis_aligned_graphics
|| rect.print_picture_pen.is_none()
|| rect.transform.has_transform()
|| ![bounds.x, bounds.y, bounds.width, bounds.height]
.into_iter()
.all(f64::is_finite)
|| bounds.width <= 0.0
|| bounds.height <= 0.0
{
return None;
}
let device = 600.0 / 96.0;
let left = (bounds.x * device).round();
let top = (bounds.y * device).round();
let right = ((bounds.x + bounds.width) * device).round();
let bottom = ((bounds.y + bounds.height) * device).round();
Some(BoundingBox::new(
left * paper.device_units.0,
top * paper.device_units.1,
(right - left) * paper.device_units.0,
(bottom - top) * paper.device_units.1,
))
}
pub(crate) fn rectangle_frame(
self,
node: &RenderNode,
rect: &mut RectangleNode,
device_pixel: Option<f64>,
) -> BoundingBox {
let Some(pixel) = device_pixel.filter(|p| p.is_finite() && *p > 0.0) else {
return node.bbox;
};
if !self.print
|| !self.axis_aligned_graphics
|| !node.layer.as_ref().is_some_and(|layer| layer.master_page)
|| rect.transform.has_transform()
{
return node.bbox;
}
let bounds = node.bbox;
let (width, _) = self.logical_size;
let (output_width, _) = self.output_size;
if ![bounds.x, bounds.width, width, output_width]
.into_iter()
.all(f64::is_finite)
|| bounds.width < 0.0
|| width <= 0.0
|| output_width <= 0.0
{
return bounds;
}
let device_width = (width / pixel).round();
if device_width <= 0.0 {
return bounds;
}
let left = (bounds.x / pixel).round();
let right = ((bounds.x + bounds.width) / pixel).round().max(left + 1.0);
let unit = self
.print_paper
.map_or(output_width / device_width, |paper| paper.device_units.0);
if rect.style.stroke_width.is_finite() && rect.style.stroke_width > 0.0 {
rect.style.stroke_width = (rect.style.stroke_width / pixel).round().max(1.0) * pixel;
}
BoundingBox::new(left * unit, bounds.y, (right - left) * unit, bounds.height)
}
pub(crate) fn image_frame(
self,
node: &RenderNode,
image: &ImageNode,
_device_pixel: Option<f64>,
) -> BoundingBox {
let bbox = node.bbox;
let is_master = node.layer.as_ref().is_some_and(|layer| layer.master_page);
let raster = image.data.as_deref().is_some_and(|bytes| {
matches!(
detect_image_mime_type(bytes),
"image/jpeg"
| "image/png"
| "image/bmp"
| "image/tiff"
| "image/gif"
| "image/webp"
| "image/x-pcx"
)
});
if !self.print || !raster {
return bbox;
}
let (width, height) = self.logical_size;
if ![width, height, bbox.width, bbox.height]
.iter()
.all(|extent| extent.is_finite() && *extent > 0.0)
|| ![bbox.x, bbox.y].into_iter().all(f64::is_finite)
{
return bbox;
}
if image.transform.rotation != 0.0 {
return if is_master {
let (output_width, output_height) = self.output_size;
BoundingBox::new(
bbox.x * output_width / width,
bbox.y * output_height / height,
bbox.width * output_width / width,
bbox.height * output_height / height,
)
} else {
bbox
};
}
let device_per_css = 600.0 / 96.0;
let point_to_css = 96.0 / 72.0;
let ctm = |extent: f64| (extent * 0.75 + 1e-9).floor() / (extent * device_per_css).round();
let (sx, sy) = self.print_paper.map_or_else(
|| (ctm(width) * point_to_css, ctm(height) * point_to_css),
|paper| paper.device_units,
);
if ![sx, sy]
.into_iter()
.all(|value| value.is_finite() && value > 0.0)
{
return bbox;
}
let (left, top) = image.crop.map_or((0, 0), |(left, top, _, _)| (left, top));
let column = self.image_column_origin.filter(|(x, y)| {
self.print_paper.is_some()
&& !self.image_column_blocked
&& self.axis_aligned_graphics
&& x.is_finite()
&& y.is_finite()
&& node.layer.is_none()
&& image.fill_mode.is_none()
&& !image.transform.has_transform()
&& image.content_inset.is_none()
&& image.cell_context.is_none()
&& image.header_footer_ref.is_none()
&& left == 0
&& top == 0
});
let inline_cell = self.print_paper.is_some()
&& self.axis_aligned_graphics
&& node.source_inline_picture
&& node.layer.is_none()
&& image.cell_context.is_some()
&& image.header_footer_ref.is_none()
&& image.fill_mode.is_none()
&& image.content_inset.is_none()
&& !image.transform.has_transform();
let axis = |index| {
column
.map(|(x, y)| if index == 0 { x } else { y })
.or_else(|| {
inline_cell
.then(|| self.table_fill_origin.inline_picture_axis(index))
.flatten()
})
};
let origin = |value: f64, clipped_start: bool, column_origin: Option<f64>| {
if clipped_start {
(value * device_per_css + 1e-9).floor()
} else if let Some(anchor) = column_origin {
(anchor * device_per_css).round() + ((value - anchor) * device_per_css).round()
} else {
(value * device_per_css - 1e-9).ceil()
}
};
BoundingBox::new(
origin(bbox.x, left > 0, axis(0)) * sx,
origin(bbox.y, top > 0, axis(1)) * sy,
(bbox.width * device_per_css).round() * sx,
(bbox.height * device_per_css).round() * sy,
)
}
pub(super) fn bitmap_fill_frame(
self,
node: &RenderNode,
image: &ImageNode,
device_pixel: Option<f64>,
) -> Option<super::bitmap_fill_frame::BitmapFillFrame> {
use crate::model::style::ImageFillMode;
use crate::renderer::image_header::{
canvaskit_encoded_image_header, CanvasKitEncodedImageFormat,
};
let pixel = device_pixel.filter(|p| p.is_finite() && *p > 0.0)?;
if !self.print
|| !self.axis_aligned_graphics
|| image.transform.has_transform()
|| image.crop.is_some()
|| image.content_inset.is_some()
{
return None;
}
let header = canvaskit_encoded_image_header(image.data.as_deref()?)?;
if !header.is_within_decode_limits()
|| !matches!(
header.format,
CanvasKitEncodedImageFormat::Bmp
| CanvasKitEncodedImageFormat::Png
| CanvasKitEncodedImageFormat::Jpeg
)
{
return None;
}
let bounds = node.bbox;
let fills_area = matches!(
image.fill_mode,
Some(ImageFillMode::FitToSize | ImageFillMode::Total)
) || (image.fill_mode == Some(ImageFillMode::Center)
&& image.original_size.is_none()
&& bounds.width < f64::from(header.width)
&& bounds.height < f64::from(header.height));
if !fills_area {
return None;
}
let background = node.table_background_paint;
let left = self.fill_device_coordinate(bounds.x, pixel, 0, background);
let top = self.fill_device_coordinate(bounds.y, pixel, 1, background);
let width =
if background && self.print_paper.is_some() && self.table_fill_origin.axis(0).is_some()
{
self.fill_device_coordinate(bounds.x + bounds.width, pixel, 0, background) - left
} else {
source_device_coordinate(bounds.width, pixel).round()
};
let height =
if background && self.print_paper.is_some() && self.table_fill_origin.axis(1).is_some()
{
self.fill_device_coordinate(bounds.y + bounds.height, pixel, 1, background) - top
} else {
source_device_coordinate(bounds.height, pixel).round()
};
super::bitmap_fill_frame::map(
BoundingBox::new(left, top, width, height),
(header.width, header.height),
(
(self.logical_size.0 / pixel).round(),
(self.logical_size.1 / pixel).round(),
),
self.output_size,
self.print_paper.map(|paper| paper.device_units),
)
}
}