1use super::*;
2use std::marker::PhantomData;
3
4pub struct Type1Font<'a> {
8 dict: Dict<'a>,
9}
10
11writer!(Type1Font: |obj| {
12 let mut dict = obj.dict();
13 dict.pair(Name(b"Type"), Name(b"Font"));
14 dict.pair(Name(b"Subtype"), Name(b"Type1"));
15 Self { dict }
16});
17
18impl Type1Font<'_> {
19 pub fn name(&mut self, name: Name) -> &mut Self {
23 self.pair(Name(b"Name"), name);
24 self
25 }
26
27 pub fn base_font(&mut self, name: Name) -> &mut Self {
33 self.pair(Name(b"BaseFont"), name);
34 self
35 }
36
37 pub fn first_char(&mut self, first: u8) -> &mut Self {
41 self.pair(Name(b"FirstChar"), i32::from(first));
42 self
43 }
44
45 pub fn last_char(&mut self, last: u8) -> &mut Self {
49 self.pair(Name(b"LastChar"), i32::from(last));
50 self
51 }
52
53 pub fn widths(&mut self, widths: impl IntoIterator<Item = f32>) -> &mut Self {
56 self.insert(Name(b"Widths")).array().items(widths);
57 self
58 }
59
60 pub fn font_descriptor(&mut self, id: Ref) -> &mut Self {
63 self.pair(Name(b"FontDescriptor"), id);
64 self
65 }
66
67 pub fn encoding_predefined(&mut self, encoding: Name) -> &mut Self {
70 self.pair(Name(b"Encoding"), encoding);
71 self
72 }
73
74 pub fn encoding_custom(&mut self) -> Encoding<'_> {
77 self.insert(Name(b"Encoding")).start()
78 }
79
80 pub fn to_unicode(&mut self, id: Ref) -> &mut Self {
84 self.pair(Name(b"ToUnicode"), id);
85 self
86 }
87}
88
89deref!('a, Type1Font<'a> => Dict<'a>, dict);
90
91pub struct Type3Font<'a> {
95 dict: Dict<'a>,
96}
97
98writer!(Type3Font: |obj| {
99 let mut dict = obj.dict();
100 dict.pair(Name(b"Type"), Name(b"Font"));
101 dict.pair(Name(b"Subtype"), Name(b"Type3"));
102 Self { dict }
103});
104
105impl Type3Font<'_> {
106 pub fn name(&mut self, name: Name) -> &mut Self {
110 self.pair(Name(b"Name"), name);
111 self
112 }
113
114 pub fn bbox(&mut self, bbox: Rect) -> &mut Self {
116 self.pair(Name(b"FontBBox"), bbox);
117 self
118 }
119
120 pub fn matrix(&mut self, matrix: [f32; 6]) -> &mut Self {
123 self.insert(Name(b"FontMatrix")).array().items(matrix);
124 self
125 }
126
127 pub fn char_procs(&mut self) -> TypedDict<'_, Ref> {
134 self.insert(Name(b"CharProcs")).dict().typed()
135 }
136
137 pub fn encoding_predefined(&mut self, encoding: Name) -> &mut Self {
140 self.pair(Name(b"Encoding"), encoding);
141 self
142 }
143
144 pub fn encoding_custom(&mut self) -> Encoding<'_> {
147 self.insert(Name(b"Encoding")).start()
148 }
149
150 pub fn first_char(&mut self, first: u8) -> &mut Self {
153 self.pair(Name(b"FirstChar"), i32::from(first));
154 self
155 }
156
157 pub fn last_char(&mut self, last: u8) -> &mut Self {
160 self.pair(Name(b"LastChar"), i32::from(last));
161 self
162 }
163
164 pub fn widths(&mut self, widths: impl IntoIterator<Item = f32>) -> &mut Self {
167 self.insert(Name(b"Widths")).array().items(widths);
168 self
169 }
170
171 pub fn font_descriptor(&mut self, id: Ref) -> &mut Self {
173 self.pair(Name(b"FontDescriptor"), id);
174 self
175 }
176
177 pub fn resources(&mut self) -> Resources<'_> {
179 self.insert(Name(b"Resources")).start()
180 }
181
182 pub fn to_unicode(&mut self, id: Ref) -> &mut Self {
190 self.pair(Name(b"ToUnicode"), id);
191 self
192 }
193}
194
195deref!('a, Type3Font<'a> => Dict<'a>, dict);
196
197pub struct Encoding<'a> {
202 dict: Dict<'a>,
203}
204
205writer!(Encoding: |obj| {
206 let mut dict = obj.dict();
207 dict.pair(Name(b"Type"), Name(b"Encoding"));
208 Self { dict }
209});
210
211impl Encoding<'_> {
212 pub fn base_encoding(&mut self, name: Name) -> &mut Self {
215 self.pair(Name(b"BaseEncoding"), name);
216 self
217 }
218
219 pub fn differences(&mut self) -> Differences<'_> {
221 self.insert(Name(b"Differences")).start()
222 }
223}
224
225deref!('a, Encoding<'a> => Dict<'a>, dict);
226
227pub struct Differences<'a> {
231 array: Array<'a>,
232}
233
234writer!(Differences: |obj| Self { array: obj.array() });
235
236impl Differences<'_> {
237 pub fn consecutive<'n>(
240 &mut self,
241 start: u8,
242 names: impl IntoIterator<Item = Name<'n>>,
243 ) -> &mut Self {
244 self.item(i32::from(start));
245 for name in names {
246 self.item(name);
247 }
248 self
249 }
250}
251
252deref!('a, Differences<'a> => Array<'a>, array);
253
254pub struct Type0Font<'a> {
258 dict: Dict<'a>,
259}
260
261writer!(Type0Font: |obj| {
262 let mut dict = obj.dict();
263 dict.pair(Name(b"Type"), Name(b"Font"));
264 dict.pair(Name(b"Subtype"), Name(b"Type0"));
265 Self { dict }
266});
267
268impl Type0Font<'_> {
269 pub fn base_font(&mut self, name: Name) -> &mut Self {
272 self.pair(Name(b"BaseFont"), name);
273 self
274 }
275
276 pub fn encoding_predefined(&mut self, encoding: Name) -> &mut Self {
279 self.pair(Name(b"Encoding"), encoding);
280 self
281 }
282
283 pub fn encoding_cmap(&mut self, cmap: Ref) -> &mut Self {
287 self.pair(Name(b"Encoding"), cmap);
288 self
289 }
290
291 pub fn descendant_font(&mut self, cid_font: Ref) -> &mut Self {
294 self.insert(Name(b"DescendantFonts")).array().item(cid_font);
295 self
296 }
297
298 pub fn to_unicode(&mut self, cmap: Ref) -> &mut Self {
302 self.pair(Name(b"ToUnicode"), cmap);
303 self
304 }
305}
306
307deref!('a, Type0Font<'a> => Dict<'a>, dict);
308
309pub struct CidFont<'a> {
313 dict: Dict<'a>,
314}
315
316writer!(CidFont: |obj| {
317 let mut dict = obj.dict();
318 dict.pair(Name(b"Type"), Name(b"Font"));
319 Self { dict }
320});
321
322impl CidFont<'_> {
323 pub fn subtype(&mut self, subtype: CidFontType) -> &mut Self {
325 self.pair(Name(b"Subtype"), subtype.to_name());
326 self
327 }
328
329 pub fn base_font(&mut self, name: Name) -> &mut Self {
331 self.pair(Name(b"BaseFont"), name);
332 self
333 }
334
335 pub fn system_info(&mut self, info: SystemInfo) -> &mut Self {
337 info.write(self.insert(Name(b"CIDSystemInfo")));
338 self
339 }
340
341 pub fn font_descriptor(&mut self, id: Ref) -> &mut Self {
343 self.pair(Name(b"FontDescriptor"), id);
344 self
345 }
346
347 pub fn default_width(&mut self, width: f32) -> &mut Self {
349 self.pair(Name(b"DW"), width);
350 self
351 }
352
353 pub fn widths(&mut self) -> Widths<'_> {
355 self.insert(Name(b"W")).start()
356 }
357
358 pub fn cid_to_gid_map_predefined(&mut self, name: Name) -> &mut Self {
364 self.pair(Name(b"CIDToGIDMap"), name);
365 self
366 }
367
368 pub fn cid_to_gid_map_stream(&mut self, stream: Ref) -> &mut Self {
373 self.pair(Name(b"CIDToGIDMap"), stream);
374 self
375 }
376}
377
378deref!('a, CidFont<'a> => Dict<'a>, dict);
379
380#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
382pub enum CidFontType {
383 Type0,
385 Type2,
387}
388
389impl CidFontType {
390 pub(crate) fn to_name(self) -> Name<'static> {
391 match self {
392 Self::Type0 => Name(b"CIDFontType0"),
393 Self::Type2 => Name(b"CIDFontType2"),
394 }
395 }
396}
397
398pub struct Widths<'a> {
402 array: Array<'a>,
403}
404
405writer!(Widths: |obj| Self { array: obj.array() });
406
407impl Widths<'_> {
408 pub fn consecutive(
411 &mut self,
412 start: u16,
413 widths: impl IntoIterator<Item = f32>,
414 ) -> &mut Self {
415 self.item(i32::from(start));
416 self.push().array().items(widths);
417 self
418 }
419
420 pub fn same(&mut self, first: u16, last: u16, width: f32) -> &mut Self {
422 self.item(i32::from(first));
423 self.item(i32::from(last));
424 self.item(width);
425 self
426 }
427}
428
429deref!('a, Widths<'a> => Array<'a>, array);
430
431pub struct FontDescriptor<'a> {
435 dict: Dict<'a>,
436}
437
438writer!(FontDescriptor: |obj| {
439 let mut dict = obj.dict();
440 dict.pair(Name(b"Type"), Name(b"FontDescriptor"));
441 Self { dict }
442});
443
444impl FontDescriptor<'_> {
445 pub fn name(&mut self, name: Name) -> &mut Self {
447 self.pair(Name(b"FontName"), name);
448 self
449 }
450
451 pub fn family(&mut self, family: Str) -> &mut Self {
454 self.pair(Name(b"FontFamily"), family);
455 self
456 }
457
458 pub fn stretch(&mut self, stretch: FontStretch) -> &mut Self {
461 self.pair(Name(b"FontStretch"), stretch.to_name());
462 self
463 }
464
465 pub fn weight(&mut self, weight: u16) -> &mut Self {
469 self.pair(Name(b"FontWeight"), i32::from(weight));
470 self
471 }
472
473 pub fn flags(&mut self, flags: FontFlags) -> &mut Self {
475 self.pair(Name(b"Flags"), flags.bits() as i32);
476 self
477 }
478
479 pub fn bbox(&mut self, bbox: Rect) -> &mut Self {
481 self.pair(Name(b"FontBBox"), bbox);
482 self
483 }
484
485 pub fn italic_angle(&mut self, angle: f32) -> &mut Self {
487 self.pair(Name(b"ItalicAngle"), angle);
488 self
489 }
490
491 pub fn ascent(&mut self, ascent: f32) -> &mut Self {
493 self.pair(Name(b"Ascent"), ascent);
494 self
495 }
496
497 pub fn descent(&mut self, descent: f32) -> &mut Self {
499 self.pair(Name(b"Descent"), descent);
500 self
501 }
502
503 pub fn leading(&mut self, leading: f32) -> &mut Self {
505 self.pair(Name(b"Leading"), leading);
506 self
507 }
508
509 pub fn cap_height(&mut self, cap_height: f32) -> &mut Self {
512 self.pair(Name(b"CapHeight"), cap_height);
513 self
514 }
515
516 pub fn x_height(&mut self, x_height: f32) -> &mut Self {
518 self.pair(Name(b"XHeight"), x_height);
519 self
520 }
521
522 pub fn stem_v(&mut self, stem_v: f32) -> &mut Self {
524 self.pair(Name(b"StemV"), stem_v);
525 self
526 }
527
528 pub fn stem_h(&mut self, stem_h: f32) -> &mut Self {
530 self.pair(Name(b"StemH"), stem_h);
531 self
532 }
533
534 pub fn avg_width(&mut self, avg_width: f32) -> &mut Self {
536 self.pair(Name(b"AvgWidth"), avg_width);
537 self
538 }
539
540 pub fn max_width(&mut self, max_width: f32) -> &mut Self {
542 self.pair(Name(b"MaxWidth"), max_width);
543 self
544 }
545
546 pub fn missing_width(&mut self, missing_width: f32) -> &mut Self {
548 self.pair(Name(b"MissingWidth"), missing_width);
549 self
550 }
551
552 pub fn font_file(&mut self, id: Ref) -> &mut Self {
554 self.pair(Name(b"FontFile"), id);
555 self
556 }
557
558 pub fn font_file2(&mut self, id: Ref) -> &mut Self {
561 self.pair(Name(b"FontFile2"), id);
562 self
563 }
564
565 pub fn font_file3(&mut self, id: Ref) -> &mut Self {
568 self.pair(Name(b"FontFile3"), id);
569 self
570 }
571
572 pub fn char_set(&mut self, names: Str) -> &mut Self {
578 self.pair(Name(b"CharSet"), names);
579 self
580 }
581}
582
583impl FontDescriptor<'_> {
585 pub fn style(&mut self, class: u8, subclass: u8, panose: [u8; 10]) -> &mut Self {
591 let mut bytes = [0; 12];
592 bytes[0] = class;
593 bytes[1] = subclass;
594 bytes[2..].copy_from_slice(&panose);
595 self.insert(Name(b"Style")).dict().pair(Name(b"Panose"), Str(&bytes));
596 self
597 }
598
599 pub fn descriptor_override(&mut self) -> FontDescriptorOverride<'_> {
603 self.insert(Name(b"FD")).start()
604 }
605
606 pub fn cid_set(&mut self, id: Ref) -> &mut Self {
611 self.pair(Name(b"CIDSet"), id);
612 self
613 }
614}
615
616deref!('a, FontDescriptor<'a> => Dict<'a>, dict);
617
618pub struct FontDescriptorOverride<'a> {
624 dict: Dict<'a>,
625}
626
627writer!(FontDescriptorOverride: |obj| {
628 Self { dict: obj.dict() }
629});
630
631impl FontDescriptorOverride<'_> {
632 pub fn custom_class(&mut self, class: Name) -> FontDescriptor<'_> {
635 self.insert(class).start()
636 }
637
638 pub fn custom_class_ref(&mut self, class: Name, id: Ref) -> &mut Self {
641 self.pair(class, id);
642 self
643 }
644
645 pub fn cjk_class(&mut self, class: CjkClass) -> FontDescriptor<'_> {
647 self.insert(class.to_name()).start()
648 }
649
650 pub fn cjk_class_ref(&mut self, class: CjkClass, id: Ref) -> &mut Self {
653 self.pair(class.to_name(), id);
654 self
655 }
656}
657
658deref!('a, FontDescriptorOverride<'a> => Dict<'a>, dict);
659
660#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
662#[allow(missing_docs)]
663pub enum CjkClass {
664 Alphabetic,
665 AlphaNum,
666 Dingbats,
667 DingbatsRot,
668 Generic,
669 GenericRot,
670 Hangul,
671 Hanja,
672 Hanzi,
673 HRoman,
674 HRomanRot,
675 HKana,
676 HKanaRot,
677 HojoKanji,
678 Kana,
679 Kanji,
680 Proportional,
681 ProportionalRot,
682 Ruby,
683}
684
685impl CjkClass {
686 pub(crate) fn to_name(self) -> Name<'static> {
687 match self {
688 Self::Alphabetic => Name(b"Alphabetic"),
689 Self::AlphaNum => Name(b"AlphaNum"),
690 Self::Dingbats => Name(b"Dingbats"),
691 Self::DingbatsRot => Name(b"DingbatsRot"),
692 Self::Generic => Name(b"Generic"),
693 Self::GenericRot => Name(b"GenericRot"),
694 Self::Hangul => Name(b"Hangul"),
695 Self::Hanja => Name(b"Hanja"),
696 Self::Hanzi => Name(b"Hanzi"),
697 Self::HRoman => Name(b"HRoman"),
698 Self::HRomanRot => Name(b"HRomanRot"),
699 Self::HKana => Name(b"HKana"),
700 Self::HKanaRot => Name(b"HKanaRot"),
701 Self::HojoKanji => Name(b"HojoKanji"),
702 Self::Kana => Name(b"Kana"),
703 Self::Kanji => Name(b"Kanji"),
704 Self::Proportional => Name(b"Proportional"),
705 Self::ProportionalRot => Name(b"ProportionalRot"),
706 Self::Ruby => Name(b"Ruby"),
707 }
708 }
709}
710
711#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
713#[allow(missing_docs)]
714pub enum FontStretch {
715 UltraCondensed,
716 ExtraCondensed,
717 Condensed,
718 SemiCondensed,
719 Normal,
720 SemiExpanded,
721 Expanded,
722 ExtraExpanded,
723 UltraExpanded,
724}
725
726impl FontStretch {
727 pub(crate) fn to_name(self) -> Name<'static> {
728 match self {
729 Self::UltraCondensed => Name(b"UltraCondensed"),
730 Self::ExtraCondensed => Name(b"ExtraCondensed"),
731 Self::Condensed => Name(b"Condensed"),
732 Self::SemiCondensed => Name(b"SemiCondensed"),
733 Self::Normal => Name(b"Normal"),
734 Self::SemiExpanded => Name(b"SemiExpanded"),
735 Self::Expanded => Name(b"Expanded"),
736 Self::ExtraExpanded => Name(b"ExtraExpanded"),
737 Self::UltraExpanded => Name(b"UltraExpanded"),
738 }
739 }
740}
741
742bitflags::bitflags! {
743 pub struct FontFlags: u32 {
745 const FIXED_PITCH = 1 << 0;
747 const SERIF = 1 << 1;
749 const SYMBOLIC = 1 << 2;
752 const SCRIPT = 1 << 3;
754 const NON_SYMBOLIC = 1 << 5;
756 const ITALIC = 1 << 6;
758 const ALL_CAP = 1 << 16;
760 const SMALL_CAP = 1 << 17;
763 const FORCE_BOLD = 1 << 18;
766 }
767}
768
769pub struct Cmap<'a> {
773 stream: Stream<'a>,
774}
775
776impl<'a> Cmap<'a> {
777 pub(crate) fn start(mut stream: Stream<'a>) -> Self {
779 stream.pair(Name(b"Type"), Name(b"CMap"));
780 Self { stream }
781 }
782
783 pub fn name(&mut self, name: Name) -> &mut Self {
785 self.pair(Name(b"CMapName"), name);
786 self
787 }
788
789 pub fn system_info(&mut self, info: SystemInfo) -> &mut Self {
791 info.write(self.insert(Name(b"CIDSystemInfo")));
792 self
793 }
794
795 pub fn writing_mode(&mut self, mode: WMode) -> &mut Self {
803 self.pair(Name(b"WMode"), mode.to_int());
804 self
805 }
806
807 pub fn use_cmap_stream(&mut self, cmap: Ref) -> &mut Self {
815 self.pair(Name(b"UseCMap"), cmap);
816 self
817 }
818
819 pub fn use_cmap_predefined(&mut self, name: Name) -> &mut Self {
825 self.pair(Name(b"UseCMap"), name);
826 self
827 }
828}
829
830deref!('a, Cmap<'a> => Stream<'a>, stream);
831
832#[derive(Debug, Copy, Clone, Default, Eq, PartialEq, Hash)]
834#[allow(missing_docs)]
835pub enum WMode {
836 #[default]
837 Horizontal,
838 Vertical,
839}
840
841impl WMode {
842 pub(crate) fn to_int(self) -> i32 {
843 match self {
844 Self::Horizontal => 0,
845 Self::Vertical => 1,
846 }
847 }
848}
849
850pub struct UnicodeCmap<G = u16> {
852 buf: Buf,
853 mappings: Buf,
854 count: i32,
855 glyph_id: PhantomData<G>,
856}
857
858impl<G> UnicodeCmap<G>
859where
860 G: GlyphId,
861{
862 pub fn new(name: Name, info: SystemInfo) -> Self {
865 Self::with_writing_mode(name, info, WMode::Horizontal)
866 }
867
868 pub fn with_writing_mode(name: Name, info: SystemInfo, mode: WMode) -> Self {
871 let mut buf = Buf::new();
874
875 buf.extend(b"%!PS-Adobe-3.0 Resource-CMap\n");
877 buf.extend(b"%%DocumentNeededResources: procset CIDInit\n");
878 buf.extend(b"%%IncludeResource: procset CIDInit\n");
879
880 buf.extend(b"%%BeginResource: CMap ");
882 buf.extend(name.0);
883 buf.push(b'\n');
884 buf.extend(b"%%Title: (");
885 buf.extend(name.0);
886 buf.push(b' ');
887 buf.extend(info.registry.0);
888 buf.push(b' ');
889 buf.extend(info.ordering.0);
890 buf.push(b' ');
891 buf.push_int(info.supplement);
892 buf.extend(b")\n");
893 buf.extend(b"%%Version: 1\n");
894 buf.extend(b"%%EndComments\n");
895
896 buf.extend(b"/CIDInit /ProcSet findresource begin\n");
898 buf.extend(b"12 dict begin\n");
899 buf.extend(b"begincmap\n");
900 buf.extend(b"/CIDSystemInfo 3 dict dup begin\n");
901 buf.extend(b" /Registry ");
902 buf.push_val(info.registry);
903 buf.extend(b" def\n");
904 buf.extend(b" /Ordering ");
905 buf.push_val(info.ordering);
906 buf.extend(b" def\n");
907 buf.extend(b" /Supplement ");
908 buf.push_val(info.supplement);
909 buf.extend(b" def\n");
910 buf.extend(b"end def\n");
911 buf.extend(b"/CMapName ");
912 buf.push_val(name);
913 buf.extend(b" def\n");
914 buf.extend(b"/CMapVersion 1 def\n");
915 buf.extend(b"/CMapType 0 def\n");
916 buf.extend(b"/WMode ");
917 buf.push_int(mode.to_int());
918 buf.extend(b" def\n");
919
920 buf.extend(b"1 begincodespacerange\n");
922 buf.push(b'<');
923 G::MIN.push(&mut buf);
924 buf.extend(b"> <");
925 G::MAX.push(&mut buf);
926 buf.extend(b">\n");
927 buf.extend(b"endcodespacerange\n");
928
929 Self {
930 buf,
931 mappings: Buf::new(),
932 count: 0,
933 glyph_id: PhantomData,
934 }
935 }
936
937 pub fn pair(&mut self, glyph: G, codepoint: char) {
939 self.pair_with_multiple(glyph, [codepoint]);
940 }
941
942 pub fn pair_with_multiple(
944 &mut self,
945 glyph: G,
946 codepoints: impl IntoIterator<Item = char>,
947 ) {
948 self.mappings.push(b'<');
949 glyph.push(&mut self.mappings);
950 self.mappings.extend(b"> <");
951
952 for c in codepoints {
953 for &mut part in c.encode_utf16(&mut [0; 2]) {
954 self.mappings.push_hex_u16(part);
955 }
956 }
957
958 self.mappings.extend(b">\n");
959 self.count += 1;
960
961 if self.count >= 100 {
963 self.flush_range();
964 }
965 }
966
967 pub fn finish(mut self) -> Buf {
969 self.flush_range();
971
972 self.buf.extend(b"endcmap\n");
974 self.buf.extend(b"CMapName currentdict /CMap defineresource pop\n");
975 self.buf.extend(b"end\n");
976 self.buf.extend(b"end\n");
977 self.buf.extend(b"%%EndResource\n");
978 self.buf.extend(b"%%EOF");
979
980 self.buf
981 }
982
983 fn flush_range(&mut self) {
984 if self.count > 0 {
985 self.buf.push_int(self.count);
986 self.buf.extend(b" beginbfchar\n");
987 self.buf.extend(self.mappings.as_slice());
988 self.buf.extend(b"endbfchar\n");
989 }
990
991 self.count = 0;
992 self.mappings.inner.clear();
993 }
994}
995
996pub trait GlyphId: private::Sealed {}
1001
1002impl GlyphId for u8 {}
1003
1004impl GlyphId for u16 {}
1005
1006mod private {
1008 use crate::buf::Buf;
1009
1010 pub trait Sealed {
1011 const MIN: Self;
1012 const MAX: Self;
1013 fn push(self, buf: &mut Buf);
1014 }
1015
1016 impl Sealed for u8 {
1017 const MIN: Self = u8::MIN;
1018 const MAX: Self = u8::MAX;
1019
1020 fn push(self, buf: &mut Buf) {
1021 buf.push_hex(self);
1022 }
1023 }
1024
1025 impl Sealed for u16 {
1026 const MIN: Self = u16::MIN;
1027 const MAX: Self = u16::MAX;
1028
1029 fn push(self, buf: &mut Buf) {
1030 buf.push_hex_u16(self);
1031 }
1032 }
1033}
1034
1035#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
1037pub struct SystemInfo<'a> {
1038 pub registry: Str<'a>,
1040 pub ordering: Str<'a>,
1042 pub supplement: i32,
1044}
1045
1046impl SystemInfo<'_> {
1047 fn write(&self, obj: Obj<'_>) {
1048 obj.dict()
1049 .pair(Name(b"Registry"), self.registry)
1050 .pair(Name(b"Ordering"), self.ordering)
1051 .pair(Name(b"Supplement"), self.supplement);
1052 }
1053}