@@ -175,5 +175,54 @@ public virtual void TestContentReplacingWithNullActualText() {
175
175
// Test that no exception has been thrown. Also check the content.
176
176
NUnit . Framework . Assert . AreEqual ( "Belarus" , lineToBeReplaced . ToString ( ) ) ;
177
177
}
178
+
179
+ [ NUnit . Framework . Test ]
180
+ public virtual void TestActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany01 ( ) {
181
+ String expectedActualTextForFirstGlyph = "0" ;
182
+ String expectedActualTextForSecondGlyph = "A" ;
183
+ byte [ ] ttf = StreamUtil . InputStreamToArray ( new FileStream ( iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
184
+ . CurrentContext . TestDirectory ) + "/resources/itext/io/font/otf/FreeSans.ttf" , FileMode . Open , FileAccess . Read
185
+ ) ) ;
186
+ TrueTypeFont font = new TrueTypeFont ( ttf ) ;
187
+ // no actual text for the second glyph is set - it should be created during substitution
188
+ GlyphLine line = new GlyphLine ( ConstructGlyphListFromString ( "AA" , font ) ) ;
189
+ line . SetActualText ( 0 , 1 , expectedActualTextForFirstGlyph ) ;
190
+ line . idx = 1 ;
191
+ line . SubstituteOneToMany ( font . GetGsubTable ( ) , new int [ ] { 39 , 40 } ) ;
192
+ NUnit . Framework . Assert . IsNotNull ( line . actualText ) ;
193
+ NUnit . Framework . Assert . AreEqual ( 3 , line . actualText . Count ) ;
194
+ NUnit . Framework . Assert . AreSame ( line . actualText [ 1 ] , line . actualText [ 2 ] ) ;
195
+ NUnit . Framework . Assert . AreEqual ( expectedActualTextForSecondGlyph , line . actualText [ 1 ] . value ) ;
196
+ // check that it hasn't been corrupted
197
+ NUnit . Framework . Assert . AreEqual ( expectedActualTextForFirstGlyph , line . actualText [ 0 ] . value ) ;
198
+ }
199
+
200
+ [ NUnit . Framework . Test ]
201
+ public virtual void TestActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany02 ( ) {
202
+ String expectedActualTextForFirstGlyph = "A" ;
203
+ byte [ ] ttf = StreamUtil . InputStreamToArray ( new FileStream ( iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
204
+ . CurrentContext . TestDirectory ) + "/resources/itext/io/font/otf/FreeSans.ttf" , FileMode . Open , FileAccess . Read
205
+ ) ) ;
206
+ TrueTypeFont font = new TrueTypeFont ( ttf ) ;
207
+ GlyphLine line = new GlyphLine ( ConstructGlyphListFromString ( "A" , font ) ) ;
208
+ line . SetActualText ( 0 , 1 , expectedActualTextForFirstGlyph ) ;
209
+ line . SubstituteOneToMany ( font . GetGsubTable ( ) , new int [ ] { 39 , 40 } ) ;
210
+ NUnit . Framework . Assert . IsNotNull ( line . actualText ) ;
211
+ NUnit . Framework . Assert . AreEqual ( 2 , line . actualText . Count ) ;
212
+ NUnit . Framework . Assert . AreSame ( line . actualText [ 0 ] , line . actualText [ 1 ] ) ;
213
+ NUnit . Framework . Assert . AreEqual ( expectedActualTextForFirstGlyph , line . actualText [ 0 ] . value ) ;
214
+ }
215
+
216
+ [ NUnit . Framework . Test ]
217
+ public virtual void TestActualTextForSubstitutedGlyphProcessingInSubstituteOneToMany03 ( ) {
218
+ byte [ ] ttf = StreamUtil . InputStreamToArray ( new FileStream ( iText . Test . TestUtil . GetParentProjectDirectory ( NUnit . Framework . TestContext
219
+ . CurrentContext . TestDirectory ) + "/resources/itext/io/font/otf/FreeSans.ttf" , FileMode . Open , FileAccess . Read
220
+ ) ) ;
221
+ TrueTypeFont font = new TrueTypeFont ( ttf ) ;
222
+ // no actual text is set
223
+ GlyphLine line = new GlyphLine ( ConstructGlyphListFromString ( "A" , font ) ) ;
224
+ line . SubstituteOneToMany ( font . GetGsubTable ( ) , new int [ ] { 39 , 40 } ) ;
225
+ NUnit . Framework . Assert . IsNull ( line . actualText ) ;
226
+ }
178
227
}
179
228
}
0 commit comments