11use std:: ptr;
2- use std:: { ffi:: CString , num:: NonZero } ;
2+ use std:: {
3+ ffi:: { c_uint, CString } ,
4+ num:: NonZero ,
5+ } ;
36
47use bitflags:: bitflags;
8+
59use mupdf_sys:: * ;
6- use num_enum:: TryFromPrimitive ;
710
811use crate :: {
9- context, ColorParams , Colorspace , DisplayList , Error , FFIWrapper , IRect , Image , Matrix , Path ,
10- Pixmap , Rect , Shade , StrokeState , Text , TextPage , TextPageFlags ,
12+ context, from_enum , ColorParams , Colorspace , DisplayList , Error , FFIWrapper , IRect , Image ,
13+ Matrix , Path , Pixmap , Rect , Shade , StrokeState , Text , TextPage , TextPageFlags ,
1114} ;
1215
1316mod native;
1417pub use native:: NativeDevice ;
1518
16- #[ derive( Debug , Clone , Copy , PartialEq , TryFromPrimitive ) ]
17- #[ repr( u32 ) ]
18- pub enum BlendMode {
19- /* PDF 1.4 -- standard separable */
20- Normal = FZ_BLEND_NORMAL as u32 ,
21- Multiply = FZ_BLEND_MULTIPLY as u32 ,
22- Screen = FZ_BLEND_SCREEN as u32 ,
23- Overlay = FZ_BLEND_OVERLAY as u32 ,
24- Darken = FZ_BLEND_DARKEN as u32 ,
25- Lighten = FZ_BLEND_LIGHTEN as u32 ,
26- ColorDodge = FZ_BLEND_COLOR_DODGE as u32 ,
27- ColorBurn = FZ_BLEND_COLOR_BURN as u32 ,
28- HardLight = FZ_BLEND_HARD_LIGHT as u32 ,
29- SoftLight = FZ_BLEND_SOFT_LIGHT as u32 ,
30- Difference = FZ_BLEND_DIFFERENCE as u32 ,
31- Exclusion = FZ_BLEND_EXCLUSION as u32 ,
32- /* PDF 1.4 -- standard non-separable */
33- Hue = FZ_BLEND_HUE as u32 ,
34- Saturation = FZ_BLEND_SATURATION as u32 ,
35- Color = FZ_BLEND_COLOR as u32 ,
36- Luminosity = FZ_BLEND_LUMINOSITY as u32 ,
19+ from_enum ! { c_uint,
20+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
21+ pub enum BlendMode {
22+ /* PDF 1.4 -- standard separable */
23+ Normal = FZ_BLEND_NORMAL ,
24+ Multiply = FZ_BLEND_MULTIPLY ,
25+ Screen = FZ_BLEND_SCREEN ,
26+ Overlay = FZ_BLEND_OVERLAY ,
27+ Darken = FZ_BLEND_DARKEN ,
28+ Lighten = FZ_BLEND_LIGHTEN ,
29+ ColorDodge = FZ_BLEND_COLOR_DODGE ,
30+ ColorBurn = FZ_BLEND_COLOR_BURN ,
31+ HardLight = FZ_BLEND_HARD_LIGHT ,
32+ SoftLight = FZ_BLEND_SOFT_LIGHT ,
33+ Difference = FZ_BLEND_DIFFERENCE ,
34+ Exclusion = FZ_BLEND_EXCLUSION ,
35+ /* PDF 1.4 -- standard non-separable */
36+ Hue = FZ_BLEND_HUE ,
37+ Saturation = FZ_BLEND_SATURATION ,
38+ Color = FZ_BLEND_COLOR ,
39+ Luminosity = FZ_BLEND_LUMINOSITY ,
40+ }
3741}
3842
3943bitflags ! {
@@ -56,99 +60,101 @@ bitflags! {
5660 }
5761}
5862
59- #[ derive( Debug , PartialEq , Eq , Clone , Copy , TryFromPrimitive ) ]
60- #[ repr( i32 ) ]
61- pub enum Structure {
62- Invalid = fz_structure_FZ_STRUCTURE_INVALID as _ ,
63-
64- /* Grouping elements (PDF 1.7 - Table 10.20) */
65- Document = fz_structure_FZ_STRUCTURE_DOCUMENT as _ ,
66- Part = fz_structure_FZ_STRUCTURE_PART as _ ,
67- Art = fz_structure_FZ_STRUCTURE_ART as _ ,
68- Sect = fz_structure_FZ_STRUCTURE_SECT as _ ,
69- Div = fz_structure_FZ_STRUCTURE_DIV as _ ,
70- BlockQuote = fz_structure_FZ_STRUCTURE_BLOCKQUOTE as _ ,
71- Caption = fz_structure_FZ_STRUCTURE_CAPTION as _ ,
72- TOC = fz_structure_FZ_STRUCTURE_TOC as _ ,
73- TOCI = fz_structure_FZ_STRUCTURE_TOCI as _ ,
74- Index = fz_structure_FZ_STRUCTURE_INDEX as _ ,
75- NonStruct = fz_structure_FZ_STRUCTURE_NONSTRUCT as _ ,
76- Private = fz_structure_FZ_STRUCTURE_PRIVATE as _ ,
77- /* Grouping elements (PDF 2.0 - Table 364) */
78- DocumentFragment = fz_structure_FZ_STRUCTURE_DOCUMENTFRAGMENT as _ ,
79- /* Grouping elements (PDF 2.0 - Table 365) */
80- Aside = fz_structure_FZ_STRUCTURE_ASIDE as _ ,
81- /* Grouping elements (PDF 2.0 - Table 366) */
82- Title = fz_structure_FZ_STRUCTURE_TITLE as _ ,
83- FENote = fz_structure_FZ_STRUCTURE_FENOTE as _ ,
84- /* Grouping elements (PDF 2.0 - Table 367) */
85- Sub = fz_structure_FZ_STRUCTURE_SUB as _ ,
86-
87- /* Paragraphlike elements (PDF 1.7 - Table 10.21) */
88- P = fz_structure_FZ_STRUCTURE_P as _ ,
89- H = fz_structure_FZ_STRUCTURE_H as _ ,
90- H1 = fz_structure_FZ_STRUCTURE_H1 as _ ,
91- H2 = fz_structure_FZ_STRUCTURE_H2 as _ ,
92- H3 = fz_structure_FZ_STRUCTURE_H3 as _ ,
93- H4 = fz_structure_FZ_STRUCTURE_H4 as _ ,
94- H5 = fz_structure_FZ_STRUCTURE_H5 as _ ,
95- H6 = fz_structure_FZ_STRUCTURE_H6 as _ ,
96-
97- /* List elements (PDF 1.7 - Table 10.23) */
98- List = fz_structure_FZ_STRUCTURE_LIST as _ ,
99- ListItem = fz_structure_FZ_STRUCTURE_LISTITEM as _ ,
100- Label = fz_structure_FZ_STRUCTURE_LABEL as _ ,
101- ListBody = fz_structure_FZ_STRUCTURE_LISTBODY as _ ,
102-
103- /* Table elements (PDF 1.7 - Table 10.24) */
104- Table = fz_structure_FZ_STRUCTURE_TABLE as _ ,
105- TR = fz_structure_FZ_STRUCTURE_TR as _ ,
106- TH = fz_structure_FZ_STRUCTURE_TH as _ ,
107- TD = fz_structure_FZ_STRUCTURE_TD as _ ,
108- THead = fz_structure_FZ_STRUCTURE_THEAD as _ ,
109- TBody = fz_structure_FZ_STRUCTURE_TBODY as _ ,
110- TFoot = fz_structure_FZ_STRUCTURE_TFOOT as _ ,
111-
112- /* Inline elements (PDF 1.7 - Table 10.25) */
113- Span = fz_structure_FZ_STRUCTURE_SPAN as _ ,
114- Quote = fz_structure_FZ_STRUCTURE_QUOTE as _ ,
115- Note = fz_structure_FZ_STRUCTURE_NOTE as _ ,
116- Reference = fz_structure_FZ_STRUCTURE_REFERENCE as _ ,
117- BibEntry = fz_structure_FZ_STRUCTURE_BIBENTRY as _ ,
118- Code = fz_structure_FZ_STRUCTURE_CODE as _ ,
119- Link = fz_structure_FZ_STRUCTURE_LINK as _ ,
120- Annot = fz_structure_FZ_STRUCTURE_ANNOT as _ ,
121- /* Inline elements (PDF 2.0 - Table 368) */
122- Em = fz_structure_FZ_STRUCTURE_EM as _ ,
123- Strong = fz_structure_FZ_STRUCTURE_STRONG as _ ,
124-
125- /* Ruby inline element (PDF 1.7 - Table 10.26) */
126- Ruby = fz_structure_FZ_STRUCTURE_RUBY as _ ,
127- RB = fz_structure_FZ_STRUCTURE_RB as _ ,
128- RT = fz_structure_FZ_STRUCTURE_RT as _ ,
129- RP = fz_structure_FZ_STRUCTURE_RP as _ ,
130-
131- /* Warichu inline element (PDF 1.7 - Table 10.26) */
132- Warichu = fz_structure_FZ_STRUCTURE_WARICHU as _ ,
133- WT = fz_structure_FZ_STRUCTURE_WT as _ ,
134- WP = fz_structure_FZ_STRUCTURE_WP as _ ,
135-
136- /* Illustration elements (PDF 1.7 - Table 10.27) */
137- Figure = fz_structure_FZ_STRUCTURE_FIGURE as _ ,
138- Formula = fz_structure_FZ_STRUCTURE_FORMULA as _ ,
139- Form = fz_structure_FZ_STRUCTURE_FORM as _ ,
140-
141- /* Artifact structure type (PDF 2.0 - Table 375) */
142- Artifact = fz_structure_FZ_STRUCTURE_ARTIFACT as _ ,
63+ from_enum ! { fz_structure,
64+ #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
65+ pub enum Structure {
66+ Invalid = fz_structure_FZ_STRUCTURE_INVALID,
67+
68+ /* Grouping elements (PDF 1.7 - Table 10.20) */
69+ Document = fz_structure_FZ_STRUCTURE_DOCUMENT,
70+ Part = fz_structure_FZ_STRUCTURE_PART,
71+ Art = fz_structure_FZ_STRUCTURE_ART,
72+ Sect = fz_structure_FZ_STRUCTURE_SECT,
73+ Div = fz_structure_FZ_STRUCTURE_DIV,
74+ BlockQuote = fz_structure_FZ_STRUCTURE_BLOCKQUOTE,
75+ Caption = fz_structure_FZ_STRUCTURE_CAPTION,
76+ TOC = fz_structure_FZ_STRUCTURE_TOC,
77+ TOCI = fz_structure_FZ_STRUCTURE_TOCI,
78+ Index = fz_structure_FZ_STRUCTURE_INDEX,
79+ NonStruct = fz_structure_FZ_STRUCTURE_NONSTRUCT,
80+ Private = fz_structure_FZ_STRUCTURE_PRIVATE,
81+ /* Grouping elements (PDF 2.0 - Table 364) */
82+ DocumentFragment = fz_structure_FZ_STRUCTURE_DOCUMENTFRAGMENT,
83+ /* Grouping elements (PDF 2.0 - Table 365) */
84+ Aside = fz_structure_FZ_STRUCTURE_ASIDE,
85+ /* Grouping elements (PDF 2.0 - Table 366) */
86+ Title = fz_structure_FZ_STRUCTURE_TITLE,
87+ FENote = fz_structure_FZ_STRUCTURE_FENOTE,
88+ /* Grouping elements (PDF 2.0 - Table 367) */
89+ Sub = fz_structure_FZ_STRUCTURE_SUB,
90+
91+ /* Paragraphlike elements (PDF 1.7 - Table 10.21) */
92+ P = fz_structure_FZ_STRUCTURE_P,
93+ H = fz_structure_FZ_STRUCTURE_H,
94+ H1 = fz_structure_FZ_STRUCTURE_H1,
95+ H2 = fz_structure_FZ_STRUCTURE_H2,
96+ H3 = fz_structure_FZ_STRUCTURE_H3,
97+ H4 = fz_structure_FZ_STRUCTURE_H4,
98+ H5 = fz_structure_FZ_STRUCTURE_H5,
99+ H6 = fz_structure_FZ_STRUCTURE_H6,
100+
101+ /* List elements (PDF 1.7 - Table 10.23) */
102+ List = fz_structure_FZ_STRUCTURE_LIST,
103+ ListItem = fz_structure_FZ_STRUCTURE_LISTITEM,
104+ Label = fz_structure_FZ_STRUCTURE_LABEL,
105+ ListBody = fz_structure_FZ_STRUCTURE_LISTBODY,
106+
107+ /* Table elements (PDF 1.7 - Table 10.24) */
108+ Table = fz_structure_FZ_STRUCTURE_TABLE,
109+ TR = fz_structure_FZ_STRUCTURE_TR,
110+ TH = fz_structure_FZ_STRUCTURE_TH,
111+ TD = fz_structure_FZ_STRUCTURE_TD,
112+ THead = fz_structure_FZ_STRUCTURE_THEAD,
113+ TBody = fz_structure_FZ_STRUCTURE_TBODY,
114+ TFoot = fz_structure_FZ_STRUCTURE_TFOOT,
115+
116+ /* Inline elements (PDF 1.7 - Table 10.25) */
117+ Span = fz_structure_FZ_STRUCTURE_SPAN,
118+ Quote = fz_structure_FZ_STRUCTURE_QUOTE,
119+ Note = fz_structure_FZ_STRUCTURE_NOTE,
120+ Reference = fz_structure_FZ_STRUCTURE_REFERENCE,
121+ BibEntry = fz_structure_FZ_STRUCTURE_BIBENTRY,
122+ Code = fz_structure_FZ_STRUCTURE_CODE,
123+ Link = fz_structure_FZ_STRUCTURE_LINK,
124+ Annot = fz_structure_FZ_STRUCTURE_ANNOT,
125+ /* Inline elements (PDF 2.0 - Table 368) */
126+ Em = fz_structure_FZ_STRUCTURE_EM,
127+ Strong = fz_structure_FZ_STRUCTURE_STRONG,
128+
129+ /* Ruby inline element (PDF 1.7 - Table 10.26) */
130+ Ruby = fz_structure_FZ_STRUCTURE_RUBY,
131+ RB = fz_structure_FZ_STRUCTURE_RB,
132+ RT = fz_structure_FZ_STRUCTURE_RT,
133+ RP = fz_structure_FZ_STRUCTURE_RP,
134+
135+ /* Warichu inline element (PDF 1.7 - Table 10.26) */
136+ Warichu = fz_structure_FZ_STRUCTURE_WARICHU,
137+ WT = fz_structure_FZ_STRUCTURE_WT,
138+ WP = fz_structure_FZ_STRUCTURE_WP,
139+
140+ /* Illustration elements (PDF 1.7 - Table 10.27) */
141+ Figure = fz_structure_FZ_STRUCTURE_FIGURE,
142+ Formula = fz_structure_FZ_STRUCTURE_FORMULA,
143+ Form = fz_structure_FZ_STRUCTURE_FORM,
144+
145+ /* Artifact structure type (PDF 2.0 - Table 375) */
146+ Artifact = fz_structure_FZ_STRUCTURE_ARTIFACT,
147+ }
143148}
144149
145- #[ derive( Debug , PartialEq , Eq , Clone , Copy , TryFromPrimitive ) ]
146- #[ repr( u32 ) ]
147- pub enum Metatext {
148- ActualText = fz_metatext_FZ_METATEXT_ACTUALTEXT as _ ,
149- Alt = fz_metatext_FZ_METATEXT_ALT as _ ,
150- Abbreviation = fz_metatext_FZ_METATEXT_ABBREVIATION as _ ,
151- Title = fz_metatext_FZ_METATEXT_TITLE as _ ,
150+ from_enum ! { fz_metatext,
151+ #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
152+ pub enum Metatext {
153+ ActualText = fz_metatext_FZ_METATEXT_ACTUALTEXT,
154+ Alt = fz_metatext_FZ_METATEXT_ALT,
155+ Abbreviation = fz_metatext_FZ_METATEXT_ABBREVIATION,
156+ Title = fz_metatext_FZ_METATEXT_TITLE,
157+ }
152158}
153159
154160pub struct DefaultColorspaces {
0 commit comments