@@ -201,7 +201,7 @@ public void applyKerning(GlyphLine text) {
201
201
for (int i = 1 ; i < text .size (); i ++) {
202
202
int kern = font .getKerning (text .glyphs .get (i - 1 ), text .glyphs .get (i ));
203
203
if (kern != 0 ) {
204
- text .glyphs .set (i , new Glyph (text .glyphs .get (i ), 0 , 0 , kern , 0 , 0 ));
204
+ text .glyphs .set (i - 1 , new Glyph (text .glyphs .get (i - 1 ), 0 , 0 , kern , 0 , 0 ));
205
205
}
206
206
}
207
207
}
@@ -612,17 +612,16 @@ public PdfCanvas showText(GlyphLine text) {
612
612
float w = 0 ;
613
613
for (int i = 0 ; i < text .size (); i ++) {
614
614
Glyph glyph = text .glyphs .get (i );
615
+ w += (glyph .getWidth () * fs + c ) * h ;
615
616
if (glyph .hasOffsets ()) {
616
- if (i - sub > 0 ) {
617
- font .writeText (text , sub , i - 1 , contentStream .getOutputStream ());
618
- contentStream .getOutputStream ().writeBytes (Tj );
619
- contentStream .getOutputStream ()
620
- .writeFloat (w )
621
- .writeSpace ()
622
- .writeFloat (0 )
623
- .writeSpace ()
624
- .writeBytes (Td );
625
- }
617
+ font .writeText (text , sub , i , contentStream .getOutputStream ());
618
+ contentStream .getOutputStream ().writeBytes (Tj );
619
+ contentStream .getOutputStream ()
620
+ .writeFloat (w )
621
+ .writeSpace ()
622
+ .writeFloat (0 )
623
+ .writeSpace ()
624
+ .writeBytes (Td );
626
625
627
626
if (glyph .hasPlacement ()) {
628
627
//TODO
@@ -631,14 +630,14 @@ public PdfCanvas showText(GlyphLine text) {
631
630
contentStream .getOutputStream ()
632
631
.writeFloat ((glyph .getXAdvance ()) * fs * h )
633
632
.writeSpace ()
634
- .writeFloat (glyph .getYAdvance () * fs )
633
+ .writeFloat (0 ) // glyph.getYAdvance() * fs)// TODO we shall return previous y position
635
634
.writeSpace ()
636
635
.writeBytes (Td );
637
636
}
638
- sub = i ;
637
+ sub = i + 1 ;
639
638
w = 0 ;
640
639
}
641
- w += ( glyph . getWidth () * fs + c ) * h ;
640
+
642
641
}
643
642
if (text .size () - sub > 0 ) {
644
643
font .writeText (text , sub , text .size () - 1 , contentStream .getOutputStream ());
0 commit comments