use super::*;
use crate::object::TextStrLike;
const CIE_D65: [f32; 3] = [0.9505, 1.0, 1.0888];
const CIE_D50: [f32; 3] = [0.9642, 1.0, 0.82489];
const CIE_E: [f32; 3] = [1.000, 1.000, 1.000];
const CIE_C: [f32; 3] = [0.9807, 1.0000, 1.1822];
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
#[allow(unused)]
enum ColorSpaceType {
CalGray,
CalRgb,
Lab,
IccBased,
DeviceRgb,
DeviceCmyk,
DeviceGray,
Indexed,
Pattern,
Separation,
DeviceN,
}
impl ColorSpaceType {
pub(crate) fn to_name(self) -> Name<'static> {
match self {
Self::CalRgb => Name(b"CalRGB"),
Self::CalGray => Name(b"CalGray"),
Self::Lab => Name(b"Lab"),
Self::IccBased => Name(b"ICCBased"),
Self::DeviceRgb => Name(b"DeviceRGB"),
Self::DeviceCmyk => Name(b"DeviceCMYK"),
Self::DeviceGray => Name(b"DeviceGray"),
Self::Separation => Name(b"Separation"),
Self::DeviceN => Name(b"DeviceN"),
Self::Indexed => Name(b"Indexed"),
Self::Pattern => Name(b"Pattern"),
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum DeviceColorSpace {
Rgb,
Cmyk,
Gray,
}
impl DeviceColorSpace {
pub(crate) fn to_name(self) -> Name<'static> {
match self {
Self::Rgb => Name(b"DeviceRGB"),
Self::Cmyk => Name(b"DeviceCMYK"),
Self::Gray => Name(b"DeviceGray"),
}
}
}
pub struct ColorSpace<'a> {
obj: Obj<'a>,
}
writer!(ColorSpace: |obj| Self { obj });
impl ColorSpace<'_> {
pub fn cal_rgb(
self,
white_point: [f32; 3],
black_point: Option<[f32; 3]>,
gamma: Option<[f32; 3]>,
matrix: Option<[f32; 9]>,
) {
let mut array = self.obj.array();
array.item(ColorSpaceType::CalRgb.to_name());
let mut dict = array.push().dict();
dict.insert(Name(b"WhitePoint")).array().items(white_point);
if let Some(black_point) = black_point {
dict.insert(Name(b"BlackPoint")).array().items(black_point);
}
if let Some(gamma) = gamma {
dict.insert(Name(b"Gamma")).array().items(gamma);
}
if let Some(matrix) = matrix {
dict.insert(Name(b"Matrix")).array().items(matrix);
}
}
pub fn cal_gray(
self,
white_point: [f32; 3],
black_point: Option<[f32; 3]>,
gamma: Option<f32>,
) {
let mut array = self.obj.array();
array.item(ColorSpaceType::CalGray.to_name());
let mut dict = array.push().dict();
dict.insert(Name(b"WhitePoint")).array().items(white_point);
if let Some(black_point) = black_point {
dict.insert(Name(b"BlackPoint")).array().items(black_point);
}
if let Some(gamma) = gamma {
dict.pair(Name(b"Gamma"), gamma);
}
}
pub fn lab(
self,
white_point: [f32; 3],
black_point: Option<[f32; 3]>,
range: Option<[f32; 4]>,
) {
let mut array = self.obj.array();
array.item(ColorSpaceType::Lab.to_name());
let mut dict = array.push().dict();
dict.insert(Name(b"WhitePoint")).array().items(white_point);
if let Some(black_point) = black_point {
dict.insert(Name(b"BlackPoint")).array().items(black_point);
}
if let Some(range) = range {
dict.insert(Name(b"Range")).array().items(range);
}
}
pub fn icc_based(self, stream: Ref) {
let mut array = self.obj.array();
array.item(ColorSpaceType::IccBased.to_name());
array.item(stream);
}
}
pub struct IccProfile<'a> {
stream: Stream<'a>,
}
impl<'a> IccProfile<'a> {
pub(crate) fn start(stream: Stream<'a>) -> Self {
Self { stream }
}
pub fn n(&mut self, n: i32) -> &mut Self {
assert!(n == 1 || n == 3 || n == 4, "n must be 1, 3, or 4, but is {n}");
self.pair(Name(b"N"), n);
self
}
pub fn alternate(&mut self) -> ColorSpace<'_> {
ColorSpace::start(self.insert(Name(b"Alternate")))
}
pub fn alternate_name(&mut self, name: Name<'_>) -> &mut Self {
self.pair(Name(b"Alternate"), name);
self
}
pub fn range(&mut self, range: impl IntoIterator<Item = f32>) -> &mut Self {
self.insert(Name(b"Range")).array().typed().items(range);
self
}
pub fn metadata(&mut self, metadata: Ref) -> &mut Self {
self.pair(Name(b"Metadata"), metadata);
self
}
}
deref!('a, IccProfile<'a> => Stream<'a>, stream);
impl ColorSpace<'_> {
pub fn srgb(self) {
self.cal_rgb(
CIE_D65,
None,
Some([2.2, 2.2, 2.2]),
Some([0.4124, 0.2126, 0.0193, 0.3576, 0.715, 0.1192, 0.1805, 0.0722, 0.9505]),
)
}
pub fn adobe_rgb(self) {
self.cal_rgb(
CIE_D65,
None,
Some([2.1992188, 2.1992188, 2.1992188]),
Some([
0.57667, 0.29734, 0.02703, 0.18556, 0.62736, 0.07069, 0.18823, 0.07529,
0.99134,
]),
)
}
pub fn display_p3(self) {
self.cal_rgb(
CIE_D65,
None,
Some([2.6, 2.6, 2.6]),
Some([
0.48657, 0.2297, 0.0, 0.26567, 0.69174, 0.04511, 0.19822, 0.07929,
1.04394,
]),
)
}
pub fn pro_photo(self) {
self.cal_rgb(
CIE_D50,
None,
Some([1.8, 1.8, 1.8]),
Some([
0.7976749, 0.2880402, 0.0, 0.1351917, 0.7118741, 0.0, 0.0313534,
0.0000857, 0.82521,
]),
)
}
pub fn eci_rgb(self) {
self.cal_rgb(
CIE_D50,
None,
Some([1.8, 1.8, 1.8]),
Some([
0.6502043, 0.3202499, 0.0, 0.1780774, 0.6020711, 0.0678390, 0.1359384,
0.0776791, 0.757371,
]),
)
}
pub fn ntsc(self) {
self.cal_rgb(
CIE_C,
None,
Some([2.2, 2.2, 2.2]),
Some([
0.6068909, 0.2989164, 0.0, 0.1735011, 0.586599, 0.0660957, 0.200348,
0.1144845, 1.1162243,
]),
)
}
pub fn pal(self) {
self.cal_rgb(
CIE_D65,
None,
Some([2.2, 2.2, 2.2]),
Some([
0.430619, 0.2220379, 0.0201853, 0.3415419, 0.7066384, 0.1295504,
0.1783091, 0.0713236, 0.9390944,
]),
)
}
pub fn d65_gray(self) {
self.cal_gray(CIE_D65, None, Some(2.2))
}
pub fn d50_gray(self, gamma: Option<f32>) {
self.cal_gray(CIE_D50, None, gamma)
}
pub fn c_gray(self) {
self.cal_gray(CIE_C, None, Some(2.2))
}
pub fn e_gray(self, gamma: Option<f32>) {
self.cal_gray(CIE_E, None, gamma)
}
}
impl ColorSpace<'_> {
pub fn device_rgb(self) {
self.obj.primitive(ColorSpaceType::DeviceRgb.to_name());
}
pub fn device_cmyk(self) {
self.obj.primitive(ColorSpaceType::DeviceCmyk.to_name());
}
pub fn device_gray(self) {
self.obj.primitive(ColorSpaceType::DeviceGray.to_name());
}
}
impl<'a> ColorSpace<'a> {
pub fn separation(self, color_name: Name) -> Separation<'a> {
let mut array = self.obj.array();
array.item(ColorSpaceType::Separation.to_name());
array.item(color_name);
Separation::start(array)
}
pub fn device_n<'n>(self, names: impl IntoIterator<Item = Name<'n>>) -> DeviceN<'a> {
let mut array = self.obj.array();
array.item(ColorSpaceType::DeviceN.to_name());
array.push().array().items(names);
DeviceN::start(array)
}
pub fn indexed(self, base: Name, hival: i32, lookup: &[u8]) {
let mut array = self.obj.array();
array.item(ColorSpaceType::Indexed.to_name());
array.item(base);
array.item(hival);
array.item(Str(lookup));
}
pub fn pattern(self, base: Name) {
let mut array = self.obj.array();
array.item(ColorSpaceType::Pattern.to_name());
array.item(base);
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
enum PatternType {
Tiling,
Shading,
}
impl PatternType {
pub(crate) fn to_int(self) -> i32 {
match self {
Self::Tiling => 1,
Self::Shading => 2,
}
}
}
pub struct Separation<'a> {
array: Array<'a>,
has_alternate: bool,
}
impl<'a> Separation<'a> {
pub(crate) fn start(array: Array<'a>) -> Self {
Self { array, has_alternate: false }
}
pub fn alternate_device(&mut self, device_space: DeviceColorSpace) -> &mut Self {
if self.has_alternate {
panic!("alternate space already specified");
}
self.array.item(device_space.to_name());
self.has_alternate = true;
self
}
pub fn alternate_color_space(&mut self) -> ColorSpace<'_> {
if self.has_alternate {
panic!("alternate space already specified");
}
self.has_alternate = true;
ColorSpace::start(self.array.push())
}
pub fn alternate_color_space_ref(&mut self, id: Ref) -> &mut Self {
if self.has_alternate {
panic!("alternate space already specified");
}
self.array.item(id);
self.has_alternate = true;
self
}
pub fn tint_exponential(&mut self) -> ExponentialFunction<'_> {
if !self.has_alternate {
panic!("alternate space must be specified before tint transform");
}
ExponentialFunction::start(self.array.push())
}
pub fn tint_stitching(&mut self) -> StitchingFunction<'_> {
if !self.has_alternate {
panic!("alternate space must be specified before tint transform");
}
StitchingFunction::start(self.array.push())
}
pub fn tint_ref(&mut self, id: Ref) -> &mut Self {
if !self.has_alternate {
panic!("alternate space must be specified before tint transform");
}
self.array.item(id);
self
}
}
pub struct DeviceN<'a> {
array: Array<'a>,
has_alternate: bool,
has_tint: bool,
}
impl<'a> DeviceN<'a> {
pub(crate) fn start(array: Array<'a>) -> Self {
Self { array, has_alternate: false, has_tint: false }
}
pub fn alternate_device(&mut self, device_space: DeviceColorSpace) -> &mut Self {
if self.has_alternate {
panic!("alternate space already specified");
}
self.array.item(device_space.to_name());
self.has_alternate = true;
self
}
pub fn alternate_color_space(&mut self) -> ColorSpace<'_> {
if self.has_alternate {
panic!("alternate space already specified");
}
self.has_alternate = true;
ColorSpace::start(self.array.push())
}
pub fn alternate_color_space_ref(&mut self, id: Ref) -> &mut Self {
if self.has_alternate {
panic!("alternate space already specified");
}
self.array.item(id);
self.has_alternate = true;
self
}
pub fn tint_exponential(&mut self) -> ExponentialFunction<'_> {
if !self.has_alternate {
panic!("alternate space must be specified before tint transform");
} else if self.has_tint {
panic!("tint transform already specified");
}
self.has_tint = true;
ExponentialFunction::start(self.array.push())
}
pub fn tint_stitching(&mut self) -> StitchingFunction<'_> {
if !self.has_alternate {
panic!("alternate space must be specified before tint transform");
} else if self.has_tint {
panic!("tint transform already specified");
}
self.has_tint = true;
StitchingFunction::start(self.array.push())
}
pub fn tint_ref(&mut self, id: Ref) -> &mut Self {
if !self.has_alternate {
panic!("alternate space must be specified before tint transform");
} else if self.has_tint {
panic!("tint transform already specified");
}
self.array.item(id);
self.has_tint = true;
self
}
pub fn attrs(&mut self) -> DeviceNAttrs<'_> {
if !self.has_alternate {
panic!(
"alternate space and tint transform must be specified before attributes"
);
} else if !self.has_tint {
panic!("tint transform must be specified before attributes");
}
DeviceNAttrs::start(self.array.push())
}
}
pub struct DeviceNAttrs<'a> {
dict: Dict<'a>,
}
writer!(DeviceNAttrs: |obj| Self { dict: obj.dict() });
impl DeviceNAttrs<'_> {
pub fn subtype(&mut self, subtype: DeviceNSubtype) -> &mut Self {
self.dict.pair(Name(b"Subtype"), subtype.to_name());
self
}
pub fn colorants(&mut self) -> TypedDict<'_, Dict<'_>> {
self.dict.insert(Name(b"Colorants")).dict().typed()
}
pub fn process(&mut self) -> DeviceNProcess<'_> {
DeviceNProcess::start(self.dict.insert(Name(b"Process")))
}
pub fn mixing_hints(&mut self) -> DeviceNMixingHints<'_> {
DeviceNMixingHints::start(self.dict.insert(Name(b"MixingHints")))
}
}
pub struct DeviceNProcess<'a> {
dict: Dict<'a>,
}
writer!(DeviceNProcess: |obj| Self { dict: obj.dict() });
impl DeviceNProcess<'_> {
pub fn color_space(&mut self, color_space: Name) -> &mut Self {
self.dict.pair(Name(b"ColorSpace"), color_space);
self
}
pub fn color_space_array(&mut self) -> ColorSpace<'_> {
ColorSpace::start(self.dict.insert(Name(b"ColorSpace")))
}
pub fn components<'n>(
&mut self,
components: impl IntoIterator<Item = Name<'n>>,
) -> &mut Self {
self.dict
.insert(Name(b"Components"))
.array()
.typed()
.items(components);
self
}
}
pub enum DeviceNSubtype {
DeviceN,
NChannel,
}
impl DeviceNSubtype {
pub(crate) fn to_name(self) -> Name<'static> {
match self {
Self::DeviceN => Name(b"DeviceN"),
Self::NChannel => Name(b"NChannel"),
}
}
}
pub struct DeviceNMixingHints<'a> {
dict: Dict<'a>,
}
writer!(DeviceNMixingHints: |obj| Self { dict: obj.dict() });
impl DeviceNMixingHints<'_> {
pub fn solidities(&mut self) -> TypedDict<'_, f32> {
self.dict.insert(Name(b"Solidities")).dict().typed()
}
pub fn printing_order<'n>(
&mut self,
order: impl IntoIterator<Item = Name<'n>>,
) -> &mut Self {
self.dict.insert(Name(b"PrintingOrder")).array().typed().items(order);
self
}
pub fn dot_gain(&mut self) -> TypedDict<'_, f32> {
self.dict.insert(Name(b"DotGain")).dict().typed()
}
}
pub struct TilingPattern<'a> {
stream: Stream<'a>,
}
impl<'a> TilingPattern<'a> {
pub(crate) fn start_with_stream(mut stream: Stream<'a>) -> Self {
stream.pair(Name(b"Type"), Name(b"Pattern"));
stream.pair(Name(b"PatternType"), PatternType::Tiling.to_int());
Self { stream }
}
pub fn paint_type(&mut self, paint_type: PaintType) -> &mut Self {
self.stream.pair(Name(b"PaintType"), paint_type.to_int());
self
}
pub fn tiling_type(&mut self, tiling_type: TilingType) -> &mut Self {
self.stream.pair(Name(b"TilingType"), tiling_type.to_int());
self
}
pub fn bbox(&mut self, bbox: Rect) -> &mut Self {
self.stream.pair(Name(b"BBox"), bbox);
self
}
pub fn x_step(&mut self, x_step: f32) -> &mut Self {
assert!(x_step != 0.0, "x step must not be zero");
self.stream.pair(Name(b"XStep"), x_step);
self
}
pub fn y_step(&mut self, y_step: f32) -> &mut Self {
assert!(y_step != 0.0, "y step must not be zero");
self.stream.pair(Name(b"YStep"), y_step);
self
}
pub fn resources(&mut self) -> Resources<'_> {
self.insert(Name(b"Resources")).start()
}
pub fn matrix(&mut self, matrix: [f32; 6]) -> &mut Self {
self.stream.insert(Name(b"Matrix")).array().items(matrix);
self
}
}
deref!('a, TilingPattern<'a> => Stream<'a>, stream);
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum PaintType {
Colored,
Uncolored,
}
impl PaintType {
pub(crate) fn to_int(self) -> i32 {
match self {
Self::Colored => 1,
Self::Uncolored => 2,
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum TilingType {
ConstantSpacing,
NoDistortion,
FastConstantSpacing,
}
impl TilingType {
pub(crate) fn to_int(self) -> i32 {
match self {
Self::ConstantSpacing => 1,
Self::NoDistortion => 2,
Self::FastConstantSpacing => 3,
}
}
}
pub struct ShadingPattern<'a> {
dict: Dict<'a>,
}
writer!(ShadingPattern: |obj| {
let mut dict = obj.dict();
dict.pair(Name(b"Type"), Name(b"Pattern"));
dict.pair(Name(b"PatternType"), PatternType::Shading.to_int());
Self { dict }
});
impl ShadingPattern<'_> {
pub fn function_shading(&mut self) -> FunctionShading<'_> {
self.dict.insert(Name(b"Shading")).start()
}
pub fn shading_ref(&mut self, id: Ref) -> &mut Self {
self.dict.pair(Name(b"Shading"), id);
self
}
pub fn matrix(&mut self, matrix: [f32; 6]) -> &mut Self {
self.dict.insert(Name(b"Matrix")).array().items(matrix);
self
}
pub fn ext_graphics(&mut self) -> ExtGraphicsState<'_> {
self.dict.insert(Name(b"ExtGState")).start()
}
}
deref!('a, ShadingPattern<'a> => Dict< 'a>, dict);
pub struct FunctionShading<'a> {
dict: Dict<'a>,
}
writer!(FunctionShading: |obj| Self { dict: obj.dict() });
impl FunctionShading<'_> {
pub fn shading_type(&mut self, kind: FunctionShadingType) -> &mut Self {
self.dict.pair(Name(b"ShadingType"), kind.to_int());
self
}
pub fn color_space(&mut self) -> ColorSpace<'_> {
self.dict.insert(Name(b"ColorSpace")).start()
}
pub fn background(&mut self, background: impl IntoIterator<Item = f32>) -> &mut Self {
self.dict.insert(Name(b"Background")).array().items(background);
self
}
pub fn bbox(&mut self, bbox: Rect) -> &mut Self {
self.dict.pair(Name(b"BBox"), bbox);
self
}
pub fn anti_alias(&mut self, anti_alias: bool) -> &mut Self {
self.dict.pair(Name(b"AntiAlias"), anti_alias);
self
}
pub fn domain(&mut self, domain: [f32; 4]) -> &mut Self {
self.dict.insert(Name(b"Domain")).array().items(domain);
self
}
pub fn matrix(&mut self, matrix: [f32; 6]) -> &mut Self {
self.dict.insert(Name(b"Matrix")).array().items(matrix);
self
}
pub fn function(&mut self, function: Ref) -> &mut Self {
self.dict.pair(Name(b"Function"), function);
self
}
pub fn coords(&mut self, coords: impl IntoIterator<Item = f32>) -> &mut Self {
self.dict.insert(Name(b"Coords")).array().items(coords);
self
}
pub fn extend(&mut self, extend: [bool; 2]) -> &mut Self {
self.dict.insert(Name(b"Extend")).array().items(extend);
self
}
}
deref!('a, FunctionShading<'a> => Dict<'a>, dict);
pub struct StreamShading<'a> {
stream: Stream<'a>,
}
impl<'a> StreamShading<'a> {
pub(crate) fn start(stream: Stream<'a>) -> Self {
Self { stream }
}
pub fn shading_type(&mut self, kind: StreamShadingType) -> &mut Self {
self.stream.pair(Name(b"ShadingType"), kind.to_int());
self
}
pub fn color_space(&mut self) -> ColorSpace<'_> {
self.stream.insert(Name(b"ColorSpace")).start()
}
pub fn background(&mut self, background: impl IntoIterator<Item = f32>) -> &mut Self {
self.stream.insert(Name(b"Background")).array().items(background);
self
}
pub fn bbox(&mut self, bbox: Rect) -> &mut Self {
self.stream.pair(Name(b"BBox"), bbox);
self
}
pub fn anti_alias(&mut self, anti_alias: bool) -> &mut Self {
self.stream.pair(Name(b"AntiAlias"), anti_alias);
self
}
pub fn function(&mut self, function: Ref) -> &mut Self {
self.stream.pair(Name(b"Function"), function);
self
}
pub fn bits_per_coordinate(&mut self, bits: i32) -> &mut Self {
self.stream.pair(Name(b"BitsPerCoordinate"), bits);
self
}
pub fn bits_per_component(&mut self, bits: i32) -> &mut Self {
self.stream.pair(Name(b"BitsPerComponent"), bits);
self
}
pub fn bits_per_flag(&mut self, bits: i32) -> &mut Self {
self.stream.pair(Name(b"BitsPerFlag"), bits);
self
}
pub fn decode(&mut self, decode: impl IntoIterator<Item = f32>) -> &mut Self {
self.stream.insert(Name(b"Decode")).array().items(decode);
self
}
pub fn vertices_per_row(&mut self, vertices: i32) -> &mut Self {
self.stream.pair(Name(b"VerticesPerRow"), vertices);
self
}
}
deref!('a, StreamShading<'a> => Stream<'a>, stream);
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum FunctionShadingType {
Function,
Axial,
Radial,
}
impl FunctionShadingType {
pub(crate) fn to_int(self) -> i32 {
match self {
Self::Function => 1,
Self::Axial => 2,
Self::Radial => 3,
}
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum StreamShadingType {
FreeformGouraud,
LatticeGouraud,
CoonsPatch,
TensorProductPatch,
}
impl StreamShadingType {
pub(crate) fn to_int(self) -> i32 {
match self {
Self::FreeformGouraud => 4,
Self::LatticeGouraud => 5,
Self::CoonsPatch => 6,
Self::TensorProductPatch => 7,
}
}
}
pub struct SeparationInfo<'a> {
dict: Dict<'a>,
}
writer!(SeparationInfo: |obj| Self { dict: obj.dict() });
impl SeparationInfo<'_> {
pub fn pages(&mut self, pages: impl IntoIterator<Item = Ref>) -> &mut Self {
self.dict.insert(Name(b"Pages")).array().typed().items(pages);
self
}
pub fn device_colorant(&mut self, colorant: Name) -> &mut Self {
self.dict.pair(Name(b"DeviceColorant"), colorant);
self
}
pub fn device_colorant_str(&mut self, colorant: &str) -> &mut Self {
self.dict.pair(Name(b"DeviceColorant"), TextStr(colorant));
self
}
pub fn color_space(&mut self) -> ColorSpace<'_> {
self.dict.insert(Name(b"ColorSpace")).start()
}
}
pub struct OutputIntent<'a> {
dict: Dict<'a>,
}
writer!(OutputIntent: |obj| {
let mut dict = obj.dict();
dict.pair(Name(b"Type"), Name(b"OutputIntent"));
Self { dict }
});
impl OutputIntent<'_> {
pub fn subtype(&mut self, subtype: OutputIntentSubtype) -> &mut Self {
self.dict.pair(Name(b"S"), subtype.to_name());
self
}
pub fn output_condition(&mut self, condition: impl TextStrLike) -> &mut Self {
self.dict.pair(Name(b"OutputCondition"), condition);
self
}
pub fn output_condition_identifier(
&mut self,
identifier: impl TextStrLike,
) -> &mut Self {
self.dict.pair(Name(b"OutputConditionIdentifier"), identifier);
self
}
pub fn registry_name(&mut self, name: TextStr) -> &mut Self {
self.dict.pair(Name(b"RegistryName"), name);
self
}
pub fn info(&mut self, info: impl TextStrLike) -> &mut Self {
self.dict.pair(Name(b"Info"), info);
self
}
pub fn dest_output_profile(&mut self, profile: Ref) -> &mut Self {
self.dict.pair(Name(b"DestOutputProfile"), profile);
self
}
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum OutputIntentSubtype<'a> {
PDFX,
PDFA,
PDFE,
Custom(Name<'a>),
}
impl<'a> OutputIntentSubtype<'a> {
pub(crate) fn to_name(self) -> Name<'a> {
match self {
Self::PDFX => Name(b"GTS_PDFX"),
Self::PDFA => Name(b"GTS_PDFA1"),
Self::PDFE => Name(b"ISO_PDFE1"),
Self::Custom(name) => name,
}
}
}