zpl 0.3.2

A high accuracy ZPL renderer
Documentation
//! Initial rendering options for specification behavior and identified printers.
use super::{compatibility::Compatibility, Options};

/// Specification-based rendering with every printer compatibility override disabled.
///
/// Command behavior follows the references in [`Compatibility`]; this is not a
/// claim of complete ZPL support. The 812 × 1218-dot canvas and 203 DPI are
/// application defaults, not dimensions mandated by the specification.
/// `^PW`/`^LL` and caller edits can override these initial settings.
pub const SPECIFICATION: Options = Options {
    width: 812,
    height: 1218,
    dpi: 203,
    compatibility: Compatibility {
        inline_graphic_implicit_separator: false,
        qr_malformed_header_uses_defaults: false,
        code39_normalize_input: false,
        barcode_module_width_through_12: false,
        box_zero_thickness_as_one: false,

        preview_width_quantum: None,
        preview_max_width: None,
        preview_width_latched_at_first_draw: false,
        preview_ignores_label_length: false,
        qr_printer_mask_selection: false,
        qr_printer_segmentation: false,
        qr_updates_barcode_module_width: false,
        pdf417_integer_grid_layout: false,
        pdf417_punctuation_latches: false,
        font0_fo_floor_baseline: false,
        font0_minimum_dimensions: false,
        block_preserves_extra_spaces: false,
        block_hard_break_resets_indent: false,
        preset_font_fo_last_dot: false,
        font_s_block_metrics: false,
        block_utf8_formatting_visible: false,
        remap_space: false,
        text_nul_processing: false,
        text_control_processing: false,
        text_tab_stops: false,
        text_esc_del_processing: false,
        unavailable_fonts_use_default: false,
        concatenation_printer_syntax: false,
        concatenation_retains_delimiter: false,
        concatenation_backward_reads_forward: false,
        numbered_fields_forward_only: false,
        advanced_text_omitted_flags_persist: false,
        bidi_isolates_as_missing_glyphs: false,
        bidi_skips_paired_bracket_resolution: false,
        serial_overlong_keeps_value: false,
        serial_ci13_zero_uses_source: false,
        retail_non_digits_as_zero: false,
        retail_ignore_supplied_check_digit: false,
        retail_printer_overlong_data: false,
        block_negative_pitch_clamps_to_zero: false,
        block_indent_printer_layout: false,
        block_center_overflow_clamps_to_origin: false,
        block_soft_hyphen_printer_layout: false,
        utf8_uses_legacy_backslash: false,
        block_backslash_without_ci13: false,
        block_fo_right_justification_printer_layout: false,
        text_clamps_negative_origins: false,
        block_center_rounds_down: false,
        block_narrow_printer_layout: false,
        graphic_clamps_negative_origin: false,
        graphic_ft_last_row_baseline: false,
        graphic_symbol_ignores_justification: false,
        graphic_symbol_last_row_baseline: false,
        bitmap_cf_font_only_resets_size: false,
        bitmap_font_maximum_dimensions: false,
        bitmap_font_ft_dot_origin: false,
        supplied_bitmap_font_metrics: false,
        supplied_truetype_printer_metrics: false,
        linear_barcode_rotated_edge_loses_dot: false,
        linear_barcode_clamps_negative_ink: false,
        code93_extended_checksum_preview: false,
        code93_control_interpretation: false,
        retail_caption_clamps_negative_inline_origin: false,
        code11_printer_element_widths: false,
        code11_interpretation_symbols: false,
        code93_interpretation_symbols: false,
        codabar_interpretation_delimiters: false,
        postal_interpretation_full_pitch: false,
        linear_interpretation_ignores_font: false,
        retail_interpretation_printer_layout: false,
        linear_barcode_ft_uses_last_bar_row: false,
        code39_floor_wide_elements: false,
        code39_interpretation_symbols: false,
        code39_interpretation_ignores_font: false,
        rounded_box_printer_geometry: false,
        rounded_box_printer_curve: false,
        circle_printer_curve: false,
        ellipse_printer_curve: false,
        databar_expanded_wide_bar_separator: false,
        databar_expanded_no_date_preview: false,
        tlc39_asterisk_separator: false,
        tlc39_extended_link_flag: false,
        tlc39_printer_layout: false,
        tlc39_additional_data_byte_capacity: false,
        maxicode_standard_minimum_six_bytes: false,
        maxicode_nul_terminates_data: false,
        maxicode_terminal_latch: false,
        maxicode_printer_run_boundaries: false,
        maxicode_printer_dot_geometry: false,
        maxicode_mode5_preview_omits_data: false,
        data_matrix_default_tilde_escape: false,
        data_matrix_edifact_printer_transitions: false,
        aztec_floor_default_error_correction: false,
        aztec_preserve_binary_runs: false,
        databar_retail_printer_dimensions: false,
        databar_upce_requires_upca_data: false,
        composite_height_in_modules: false,
        composite_linear_quiet_zone: false,
        validation_retail_long_is_short: false,
        validation_legacy_small_is_parameter: false,
        macro_pdf417_file_id: None,
        macro_micropdf417_reverse_origin_omits_side_raps: false,
        qr_model1_extended_versions: false,
        qr_fo_uses_by_height: false,
        qr_ft_includes_margin: false,
        diagonal_dot_runs: false,
        postal_fixed_pitch: false,
        intelligent_mail_outward_rounding: false,
        retail_guard_extension_dots: None,
        code93_normalize_input: false,
        codablock_a_row_height_in_dots: false,
        codablock_f_row_height_in_dots: false,
        codablock_f_fit_rows: false,
        right_justified_inverted_text_uses_ink_margin: false,
        barcode_interpretation_printer_layout: false,
        barcode_implicit_caption_uses_resident_font: false,
        barcode_fo_uses_bar_height: false,
        code128_fo_uses_bar_width: false,
        barcode_above_text_keeps_bar_origin: false,
        barcode_reverse_interpretation_shift: false,
        preview_ignores_label_top: false,
        preview_ignores_print_orientation: false,
        preview_ignores_print_mirror: false,
        field_vertical_ignores_gap: false,
        field_direction_printer_anchors: false,
        block_field_direction_printer_layout: false,
        bounded_text_printer_pitch: false,
        bounded_text_printer_anchors: false,
        bounded_text_font_cancels_block: false,
        block_spaces_ignore_character_gap: false,
        block_hyphenation_printer_layout: false,
        block_hyphenation_ci27_uses_eth: false,
        block_justification_rounds_up: false,
        block_center_includes_trailing_space: false,
        codablock_a_wrapping_checks: false,
        code128_above_text_keeps_bar_origin: false,
    },
};

/// Zebra ZD621, 203 DPI, firmware V93.21.33Z HTTP Preview Label behavior.
///
/// Calibrated against the captures described in `docs/printer-accuracy.md`.
/// Dimensions are initial defaults; `^PW`/`^LL` still override them. This does
/// not emulate preview width adjustment, select QR masks automatically, or
/// promise pixel parity for unimplemented behavior. Other firmware is untested.
///
/// ```
/// use zpl::{Options, render::profiles::ZD621_203_DPI};
/// let mut options = Options { height: 300, ..ZD621_203_DPI };
/// options.compatibility.qr_fo_uses_by_height = false;
/// ```
pub const ZD621_203_DPI: Options = Options {
    width: 832,
    height: 1218,
    dpi: 203,
    compatibility: Compatibility {
        inline_graphic_implicit_separator: true,
        qr_malformed_header_uses_defaults: true,
        code39_normalize_input: true,
        barcode_module_width_through_12: true,
        box_zero_thickness_as_one: true,

        preview_width_quantum: None,
        preview_max_width: None,
        preview_width_latched_at_first_draw: false,
        preview_ignores_label_length: false,
        qr_printer_mask_selection: true,
        qr_printer_segmentation: true,
        qr_updates_barcode_module_width: true,
        pdf417_integer_grid_layout: true,
        pdf417_punctuation_latches: true,
        font0_fo_floor_baseline: true,
        font0_minimum_dimensions: true,
        block_preserves_extra_spaces: true,
        block_hard_break_resets_indent: true,
        preset_font_fo_last_dot: true,
        font_s_block_metrics: true,
        block_utf8_formatting_visible: true,
        remap_space: true,
        text_nul_processing: true,
        text_control_processing: true,
        text_tab_stops: true,
        text_esc_del_processing: true,
        unavailable_fonts_use_default: true,
        concatenation_printer_syntax: true,
        concatenation_retains_delimiter: true,
        concatenation_backward_reads_forward: true,
        numbered_fields_forward_only: true,
        advanced_text_omitted_flags_persist: true,
        bidi_isolates_as_missing_glyphs: true,
        bidi_skips_paired_bracket_resolution: true,
        serial_overlong_keeps_value: true,
        serial_ci13_zero_uses_source: true,
        retail_non_digits_as_zero: true,
        retail_ignore_supplied_check_digit: true,
        retail_printer_overlong_data: true,
        block_negative_pitch_clamps_to_zero: true,
        block_indent_printer_layout: true,
        block_center_overflow_clamps_to_origin: true,
        block_soft_hyphen_printer_layout: true,
        utf8_uses_legacy_backslash: true,
        block_backslash_without_ci13: true,
        block_fo_right_justification_printer_layout: true,
        text_clamps_negative_origins: true,
        block_center_rounds_down: true,
        block_narrow_printer_layout: true,
        graphic_clamps_negative_origin: true,
        graphic_ft_last_row_baseline: true,
        graphic_symbol_ignores_justification: true,
        graphic_symbol_last_row_baseline: true,
        bitmap_cf_font_only_resets_size: true,
        bitmap_font_maximum_dimensions: true,
        bitmap_font_ft_dot_origin: true,
        supplied_bitmap_font_metrics: true,
        supplied_truetype_printer_metrics: true,
        linear_barcode_rotated_edge_loses_dot: true,
        linear_barcode_clamps_negative_ink: true,
        code93_extended_checksum_preview: true,
        code93_control_interpretation: true,
        retail_caption_clamps_negative_inline_origin: true,
        code11_printer_element_widths: true,
        code11_interpretation_symbols: true,
        code93_interpretation_symbols: true,
        codabar_interpretation_delimiters: true,
        postal_interpretation_full_pitch: true,
        linear_interpretation_ignores_font: true,
        retail_interpretation_printer_layout: true,
        linear_barcode_ft_uses_last_bar_row: true,
        code39_floor_wide_elements: true,
        code39_interpretation_symbols: true,
        code39_interpretation_ignores_font: true,
        rounded_box_printer_geometry: true,
        rounded_box_printer_curve: true,
        circle_printer_curve: true,
        ellipse_printer_curve: true,
        databar_expanded_wide_bar_separator: true,
        databar_expanded_no_date_preview: true,
        tlc39_asterisk_separator: true,
        tlc39_extended_link_flag: true,
        tlc39_printer_layout: true,
        tlc39_additional_data_byte_capacity: true,
        maxicode_standard_minimum_six_bytes: true,
        maxicode_nul_terminates_data: true,
        maxicode_terminal_latch: true,
        maxicode_printer_run_boundaries: true,
        maxicode_printer_dot_geometry: true,
        maxicode_mode5_preview_omits_data: true,
        data_matrix_default_tilde_escape: true,
        data_matrix_edifact_printer_transitions: true,
        aztec_floor_default_error_correction: true,
        aztec_preserve_binary_runs: true,
        databar_retail_printer_dimensions: true,
        databar_upce_requires_upca_data: true,
        composite_height_in_modules: true,
        composite_linear_quiet_zone: true,
        validation_retail_long_is_short: true,
        validation_legacy_small_is_parameter: true,
        macro_pdf417_file_id: Some([0, 0, 36]),
        macro_micropdf417_reverse_origin_omits_side_raps: true,
        qr_model1_extended_versions: true,
        qr_fo_uses_by_height: true,
        qr_ft_includes_margin: true,
        diagonal_dot_runs: true,
        postal_fixed_pitch: true,
        intelligent_mail_outward_rounding: true,
        retail_guard_extension_dots: Some(13),
        code93_normalize_input: true,
        codablock_a_row_height_in_dots: true,
        codablock_f_row_height_in_dots: true,
        codablock_f_fit_rows: true,
        right_justified_inverted_text_uses_ink_margin: true,
        barcode_interpretation_printer_layout: true,
        barcode_implicit_caption_uses_resident_font: true,
        barcode_fo_uses_bar_height: true,
        code128_fo_uses_bar_width: true,
        barcode_above_text_keeps_bar_origin: true,
        barcode_reverse_interpretation_shift: true,
        preview_ignores_label_top: true,
        preview_ignores_print_orientation: true,
        preview_ignores_print_mirror: true,
        field_vertical_ignores_gap: true,
        field_direction_printer_anchors: true,
        block_field_direction_printer_layout: true,
        bounded_text_printer_pitch: true,
        bounded_text_printer_anchors: true,
        bounded_text_font_cancels_block: true,
        block_spaces_ignore_character_gap: true,
        block_hyphenation_printer_layout: true,
        block_hyphenation_ci27_uses_eth: true,
        block_justification_rounds_up: true,
        block_center_includes_trailing_space: true,
        codablock_a_wrapping_checks: true,
        code128_above_text_keeps_bar_origin: true,
    },
};

/// Zebra ZQ610 Plus, 203 DPI, V100.21.21Z HTTP Preview Label baseline.
///
/// The captured device returned 384 × 2030 previews, retaining its configured
/// height despite ^LL. Set `height` to match a differently configured device.
/// Shared ZD621 behavior is verified by the focused paired barcode captures in
/// `tests/fixtures/zq610-plus-v1`, not by the full ZD621 corpus. Width rounds up
/// to 64-dot boundaries, centers by whole dots, and caps at 384 dots. Its width
/// is latched after the first draw. Other fonts, firmware and physical printing
/// are not established by this focused preview corpus.
pub const ZQ610_PLUS_203_DPI: Options = Options {
    width: 384,
    height: 2030,
    compatibility: Compatibility {
        // Public-document tolerances have only been observed on the ZD621.
        inline_graphic_implicit_separator: false,
        qr_malformed_header_uses_defaults: false,
        code39_normalize_input: false,
        barcode_module_width_through_12: false,
        box_zero_thickness_as_one: false,

        preview_width_quantum: Some(64),
        preview_max_width: Some(384),
        preview_width_latched_at_first_draw: true,
        preview_ignores_label_length: true,
        // Supplied TrueType scaling has only been validated on ZD621.
        supplied_truetype_printer_metrics: false,
        // Automatic QR segmentation evidence is ZD621-only.
        qr_printer_segmentation: false,
        // SurePost run-boundary evidence is ZD621-only.
        maxicode_printer_run_boundaries: false,
        // Integer-grid and punctuation-run controls were captured on ZD621.
        pdf417_integer_grid_layout: false,
        pdf417_punctuation_latches: false,
        ..ZD621_203_DPI.compatibility
    },
    ..ZD621_203_DPI
};