Repository: fschutt/printpdf (language: rust)

Issue:
Fonts are broken in iOS pdf viewer
Text using embedded fonts is not displayed correctly in iOS, like that one:
[target_date.pdf](https://github.com/fschutt/printpdf/files/2720886/target_date.pdf)

which looks like this in iOS:

![grafik](https://user-images.githubusercontent.com/198941/50594844-76aa3a80-0e9e-11e9-9b3e-d5d7ec2d543a.png)

when it should look like this:

![grafik](https://user-images.githubusercontent.com/198941/50594913-be30c680-0e9e-11e9-8ecb-f5c53e0347f6.png)

I made it display correctly by a roundtrip through pdf2ps and ps2pdf, which also made the file 20 times smaller.


Discussion / hints:
Well, I'm terribly sorry about that, of course. I did not test it on the iOS PDF viewer - it does view correctly on other PDF viewers, though. Thanks for reporting, I'll look into it.
The same is for macOS viewer of course, because they share CorePDF. Here's the font and the PDF produced
[test_working.pdf](https://github.com/fschutt/printpdf/files/2759889/test_working.pdf)
[OCRAStd.ttf.zip](https://github.com/fschutt/printpdf/files/2759893/OCRAStd.ttf.zip)



Fix patch:
diff --git a/src/types/plugins/graphics/two_dimensional/font.rs b/src/types/plugins/graphics/two_dimensional/font.rs
index 451faea..fe79207 100644
--- a/src/types/plugins/graphics/two_dimensional/font.rs
+++ b/src/types/plugins/graphics/two_dimensional/font.rs
@@ -172,7 +172,6 @@ impl ExternalFont {
         let font_stream = LoStream::new(
             LoDictionary::from_iter(vec![
                 ("Length1", Integer(font_buf_ref.len() as i64)),
-                ("Subtype", Name("CidFontType2".into())),
                 ]),
             font_buf_ref.to_vec())
         .with_compression(false); /* important! font stream must not be compressed! */
@@ -332,7 +331,7 @@ impl ExternalFont {
         ]);
 
         let font_bbox = vec![ Integer(0), Integer(max_height as i64), Integer(total_width as i64), Integer(max_height as i64) ];
-        font_descriptor_vec.push(("FontFile3".into(), Reference(doc.add_object(font_stream))));
+        font_descriptor_vec.push(("FontFile2".into(), Reference(doc.add_object(font_stream))));
 
         // although the following entry is technically not needed, Adobe Reader needs it
         font_descriptor_vec.push(("FontBBox".into(), Array(font_bbox)));


Test patch: