@@ -127,16 +127,16 @@ public void generateNormalAppearance()
127127 drawNewParagraph (annotation , contentStream );
128128 break ;
129129 case PDAnnotationText .NAME_STAR :
130- drawStar (annotation , contentStream );
130+ drawZapf (annotation , contentStream , 19 , 0 , "a35" ); // 0x2605
131131 break ;
132132 case PDAnnotationText .NAME_CHECK :
133- drawCheck (annotation , contentStream );
133+ drawZapf (annotation , contentStream , 19 , 50 , "a20" ); // 0x2714
134134 break ;
135135 case PDAnnotationText .NAME_RIGHT_ARROW :
136136 drawRightArrow (annotation , contentStream );
137137 break ;
138138 case PDAnnotationText .NAME_RIGHT_POINTER :
139- drawRightPointer (annotation , contentStream );
139+ drawZapf (annotation , contentStream , 17 , 50 , "a174" ); // 0x27A4
140140 break ;
141141 case PDAnnotationText .NAME_CROSS_HAIRS :
142142 drawCrossHairs (annotation , contentStream );
@@ -304,7 +304,6 @@ private void drawCross(PDAnnotationText annotation, final PDAppearanceContentStr
304304 contentStream .closeAndFillAndStroke ();
305305
306306 // alternatively, this could also be drawn with Zapf Dingbats "a21"
307- // see DrawStar()
308307 }
309308
310309 private void drawHelp (PDAnnotationText annotation , final PDAppearanceContentStream contentStream )
@@ -419,84 +418,6 @@ private void drawNewParagraph(PDAnnotationText annotation, final PDAppearanceCon
419418 contentStream .fill ();
420419 }
421420
422- private void drawStar (PDAnnotationText annotation , final PDAppearanceContentStream contentStream )
423- throws IOException
424- {
425- PDRectangle bbox = adjustRectAndBBox (annotation , 20 , 19 );
426-
427- float min = Math .min (bbox .getWidth (), bbox .getHeight ());
428-
429- contentStream .setMiterLimit (4 );
430- contentStream .setLineJoinStyle (1 );
431- contentStream .setLineCapStyle (0 );
432- contentStream .setLineWidth (0.59f ); // value from Adobe
433-
434- List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
435- float xScale = (float ) fontMatrix .get (0 );
436- float yScale = (float ) fontMatrix .get (3 );
437- contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
438-
439- // we get the shape of a Zapf Dingbats star (0x2605) and use that one.
440- // Adobe uses a different font (which one?), or created the shape from scratch.
441- GeneralPath path = Standard14Fonts .getGlyphPath (FontName .ZAPF_DINGBATS , "a35" );
442- addPath (contentStream , path );
443- contentStream .fillAndStroke ();
444- }
445-
446- //TODO this is mostly identical to drawStar, except for scale, translation and symbol
447- // maybe use a table with all values and draw from there
448- // this could also optionally use outer circle
449- private void drawCheck (PDAnnotationText annotation , final PDAppearanceContentStream contentStream )
450- throws IOException
451- {
452- PDRectangle bbox = adjustRectAndBBox (annotation , 20 , 19 );
453-
454- float min = Math .min (bbox .getWidth (), bbox .getHeight ());
455-
456- contentStream .setMiterLimit (4 );
457- contentStream .setLineJoinStyle (1 );
458- contentStream .setLineCapStyle (0 );
459- contentStream .setLineWidth (0.59f ); // value from Adobe
460-
461- List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
462- float xScale = (float ) fontMatrix .get (0 );
463- float yScale = (float ) fontMatrix .get (3 );
464- contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
465- contentStream .transform (Matrix .getTranslateInstance (0 , 50 ));
466-
467- // we get the shape of a Zapf Dingbats check (0x2714) and use that one.
468- // Adobe uses a different font (which one?), or created the shape from scratch.
469- GeneralPath path = Standard14Fonts .getGlyphPath (FontName .ZAPF_DINGBATS , "a20" );
470- addPath (contentStream , path );
471- contentStream .fillAndStroke ();
472- }
473-
474- //TODO this is mostly identical to drawStar, except for scale, translation and symbol
475- private void drawRightPointer (PDAnnotationText annotation , final PDAppearanceContentStream contentStream )
476- throws IOException
477- {
478- PDRectangle bbox = adjustRectAndBBox (annotation , 20 , 17 );
479-
480- float min = Math .min (bbox .getWidth (), bbox .getHeight ());
481-
482- contentStream .setMiterLimit (4 );
483- contentStream .setLineJoinStyle (1 );
484- contentStream .setLineCapStyle (0 );
485- contentStream .setLineWidth (0.59f ); // value from Adobe
486-
487- List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
488- float xScale = (float ) fontMatrix .get (0 );
489- float yScale = (float ) fontMatrix .get (3 );
490- contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
491- contentStream .transform (Matrix .getTranslateInstance (0 , 50 ));
492-
493- // we get the shape of a Zapf Dingbats right pointer (0x27A4) and use that one.
494- // Adobe uses a different font (which one?), or created the shape from scratch.
495- GeneralPath path = Standard14Fonts .getGlyphPath (FontName .ZAPF_DINGBATS , "a174" );
496- addPath (contentStream , path );
497- contentStream .fillAndStroke ();
498- }
499-
500421 private void drawCrossHairs (PDAnnotationText annotation , final PDAppearanceContentStream contentStream )
501422 throws IOException
502423 {
@@ -694,7 +615,32 @@ private void drawKey(PDAnnotationText annotation, final PDAppearanceContentStrea
694615 contentStream .curveTo (3441 , 4847 , 3253 , 4658 , 3253 , 4425 );
695616 contentStream .fillAndStroke ();
696617 }
697-
618+
619+ private void drawZapf (PDAnnotationText annotation , final PDAppearanceContentStream contentStream ,
620+ int by , int ty , String glyphName ) throws IOException
621+ {
622+ PDRectangle bbox = adjustRectAndBBox (annotation , 20 , by );
623+
624+ float min = Math .min (bbox .getWidth (), bbox .getHeight ());
625+
626+ contentStream .setMiterLimit (4 );
627+ contentStream .setLineJoinStyle (1 );
628+ contentStream .setLineCapStyle (0 );
629+ contentStream .setLineWidth (0.59f ); // value from Adobe
630+
631+ List <Number > fontMatrix = new PDType1Font (FontName .ZAPF_DINGBATS ).getFontBoxFont ().getFontMatrix ();
632+ float xScale = (float ) fontMatrix .get (0 );
633+ float yScale = (float ) fontMatrix .get (3 );
634+ contentStream .transform (Matrix .getScaleInstance (xScale * min / 0.8f , yScale * min / 0.8f ));
635+ contentStream .transform (Matrix .getTranslateInstance (0 , ty ));
636+
637+ // we get the shape of a Zapf Dingbats glyph and use that one.
638+ // Adobe uses a different font (which one?), or created the shape from scratch.
639+ GeneralPath path = Standard14Fonts .getGlyphPath (FontName .ZAPF_DINGBATS , glyphName );
640+ addPath (contentStream , path );
641+ contentStream .fillAndStroke ();
642+ }
643+
698644 private void addPath (final PDAppearanceContentStream contentStream , GeneralPath path ) throws IOException
699645 {
700646 double curX = 0 ;
0 commit comments