pspp 0.6.1

Statistical analysis software
Documentation
// PSPP - a program for statistical analysis.
// Copyright (C) 2025 Free Software Foundation, Inc.
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later
// version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
// details.
//
// You should have received a copy of the GNU General Public License along with
// this program.  If not, see <http://www.gnu.org/licenses/>.

use pango::SCALE;

use crate::output::pivot::look::HorzAlign;

mod driver;
pub mod fsm;
pub mod pager;

pub use driver::{CairoConfig, CairoDriver};

/// Conversion from 1/96" units ("pixels") to Cairo/Pango units.
fn px_to_xr(x: isize) -> isize {
    x * 3 * (SCALE as isize * 72 / 96) / 3
}

fn xr_to_pt(x: isize) -> f64 {
    x as f64 / SCALE as f64
}

impl From<HorzAlign> for pango::Alignment {
    fn from(horz_align: HorzAlign) -> Self {
        match horz_align {
            HorzAlign::Right | HorzAlign::Decimal { .. } => pango::Alignment::Right,
            HorzAlign::Left => pango::Alignment::Left,
            HorzAlign::Center => pango::Alignment::Center,
        }
    }
}

#[cfg(test)]
mod tests {
    use crate::output::drivers::cairo::{CairoConfig, CairoDriver};

    #[test]
    fn create() {
        CairoDriver::new(&CairoConfig::new("test.pdf")).unwrap();
    }
}