forked from pipeline-foundation/itext7-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into devsecops
- Loading branch information
Showing
40 changed files
with
713 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
itext.tests/itext.io.tests/itext/io/font/CjkResourceLoaderNoFontAsianTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2023 Apryse Group NV | ||
Authors: Apryse Software. | ||
This program is offered under a commercial and under the AGPL license. | ||
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. | ||
AGPL licensing: | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using System; | ||
using iText.IO.Font.Cmap; | ||
using iText.Test; | ||
|
||
namespace iText.IO.Font { | ||
[NUnit.Framework.Category("UnitTest")] | ||
public class CjkResourceLoaderNoFontAsianTest : ExtendedITextTest { | ||
// Android-Conversion-Skip-File (TODO DEVSIX-7376 investigate why CjkResourceLoaderNoFontAsianTest is skipped on Android) | ||
[NUnit.Framework.OneTimeSetUp] | ||
public static void BeforeClass() { | ||
// Here we mimic the absence of font asian | ||
CjkResourceLoader.SetCmapLocation(new CjkResourceLoaderNoFontAsianTest.DummyCMapLocationResource()); | ||
} | ||
|
||
[NUnit.Framework.OneTimeTearDown] | ||
public static void AfterClass() { | ||
CjkResourceLoader.SetCmapLocation(new CMapLocationResource()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCompatibleCidFontNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// any value passed into a method is expected to return null. | ||
NUnit.Framework.Assert.IsNull(CjkResourceLoader.GetCompatibleCidFont("78-RKSJ-V")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void IsPredefinedCidFontNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// any value passed into a method is expected to return false. | ||
NUnit.Framework.Assert.IsFalse(CjkResourceLoader.IsPredefinedCidFont("KozMinPro-Regular")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCompatibleCmapsNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// any value passed into a method is expected to return null. | ||
NUnit.Framework.Assert.IsNull(CjkResourceLoader.GetCompatibleCmaps("HeiseiKakuGo-W5")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetRegistryNamesNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// registry names collection is expected to be empty. | ||
NUnit.Framework.Assert.IsTrue(CjkResourceLoader.GetRegistryNames().IsEmpty()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCid2UniCMapNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// no CMap can be found. | ||
NUnit.Framework.Assert.Catch(typeof(iText.IO.Exceptions.IOException), () => CjkResourceLoader.GetCid2UniCmap | ||
("UniJIS-UTF16-H")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetUni2CidCMapNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// no CMap can be found. | ||
NUnit.Framework.Assert.Catch(typeof(iText.IO.Exceptions.IOException), () => CjkResourceLoader.GetUni2CidCmap | ||
("UniJIS-UTF16-H")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetByte2CidCMapNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// no CMap can be found. | ||
NUnit.Framework.Assert.Catch(typeof(iText.IO.Exceptions.IOException), () => CjkResourceLoader.GetByte2CidCmap | ||
("78ms-RKSJ-H")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCid2ByteCMapNoFontAsian() { | ||
// Without font-asian module in the class path | ||
// no CMap can be found. | ||
NUnit.Framework.Assert.Catch(typeof(iText.IO.Exceptions.IOException), () => CjkResourceLoader.GetCidToCodepointCmap | ||
("78ms-RKSJ-H")); | ||
} | ||
|
||
private class DummyCMapLocationResource : CMapLocationResource { | ||
public override String GetLocationPath() { | ||
return base.GetLocationPath() + "dummy/path/"; | ||
} | ||
} | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
itext.tests/itext.io.tests/itext/io/font/CjkResourceLoaderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2023 Apryse Group NV | ||
Authors: Apryse Software. | ||
This program is offered under a commercial and under the AGPL license. | ||
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. | ||
AGPL licensing: | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using System; | ||
using System.Collections.Generic; | ||
using iText.IO.Font.Cmap; | ||
using iText.Test; | ||
|
||
namespace iText.IO.Font { | ||
[NUnit.Framework.Category("IntegrationTest")] | ||
public class CjkResourceLoaderTest : ExtendedITextTest { | ||
[NUnit.Framework.Test] | ||
public virtual void GetCompatibleCidFont() { | ||
String expected = "HeiseiMin-W3"; | ||
String compatibleCidFont = CjkResourceLoader.GetCompatibleCidFont("78-RKSJ-V"); | ||
NUnit.Framework.Assert.AreEqual(expected, compatibleCidFont); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCompatibleCmaps() { | ||
ICollection<String> compatibleCmaps = CjkResourceLoader.GetCompatibleCmaps("HeiseiKakuGo-W5"); | ||
NUnit.Framework.Assert.AreEqual(66, compatibleCmaps.Count); | ||
NUnit.Framework.Assert.IsTrue(compatibleCmaps.Contains("78-RKSJ-V")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetRegistryNames() { | ||
IDictionary<String, ICollection<String>> registryNames = CjkResourceLoader.GetRegistryNames(); | ||
NUnit.Framework.Assert.AreEqual(9, registryNames.Count); | ||
NUnit.Framework.Assert.IsTrue(registryNames.ContainsKey("Adobe_Japan1")); | ||
NUnit.Framework.Assert.IsTrue(registryNames.Get("Adobe_Japan1").Contains("78-RKSJ-V")); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCid2UniCMap() { | ||
CMapCidUni cid2UniCmap = CjkResourceLoader.GetCid2UniCmap("UniJIS-UTF16-H"); | ||
NUnit.Framework.Assert.AreEqual(0x00b5, cid2UniCmap.Lookup(159)); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetUni2CidCMap() { | ||
CMapCodepointToCid uni2CidCmap = CjkResourceLoader.GetCodepointToCidCmap("UniJIS-UTF16-H"); | ||
NUnit.Framework.Assert.AreEqual(159, uni2CidCmap.Lookup(0x00b5)); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetByte2CidCMap() { | ||
CMapByteCid byte2CidCmap = CjkResourceLoader.GetByte2CidCmap("78ms-RKSJ-H"); | ||
int byteCode = 0x94e0; | ||
char cid = (char)7779; | ||
byte[] byteCodeBytes = new byte[] { (byte)((byteCode & 0xFF00) >> 8), (byte)(byteCode & 0xFF) }; | ||
String actual = byte2CidCmap.DecodeSequence(byteCodeBytes, 0, 2); | ||
String expected = new String(new char[] { cid }); | ||
NUnit.Framework.Assert.AreEqual(expected, actual); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void GetCid2ByteCMap() { | ||
CMapCidToCodepoint cid2Byte = CjkResourceLoader.GetCidToCodepointCmap("78ms-RKSJ-H"); | ||
int byteCode = 0x94e0; | ||
int cid = 7779; | ||
byte[] actual = cid2Byte.Lookup(cid); | ||
byte[] expected = new byte[] { (byte)((byteCode & 0xFF00) >> 8), (byte)(byteCode & 0xFF) }; | ||
NUnit.Framework.Assert.AreEqual(expected, actual); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
itext.tests/itext.io.tests/itext/io/font/FontProgramDescriptorFactoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2023 Apryse Group NV | ||
Authors: Apryse Software. | ||
This program is offered under a commercial and under the AGPL license. | ||
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. | ||
AGPL licensing: | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
using iText.Test; | ||
|
||
namespace iText.IO.Font { | ||
[NUnit.Framework.Category("UnitTest")] | ||
public class FontProgramDescriptorFactoryTest : ExtendedITextTest { | ||
[NUnit.Framework.Test] | ||
public virtual void KozminNamesTest() { | ||
FontProgramDescriptor descriptor = FontProgramDescriptorFactory.FetchDescriptor("KozMinPro-Regular"); | ||
NUnit.Framework.Assert.AreEqual("KozMinPro-Regular", descriptor.GetFontName()); | ||
NUnit.Framework.Assert.AreEqual("KozMinPro-Regular".ToLowerInvariant(), descriptor.GetFullNameLowerCase()); | ||
NUnit.Framework.Assert.AreEqual(400, descriptor.GetFontWeight()); | ||
} | ||
|
||
[NUnit.Framework.Test] | ||
public virtual void HelveticaNamesTest() { | ||
FontProgramDescriptor descriptor = FontProgramDescriptorFactory.FetchDescriptor("Helvetica"); | ||
NUnit.Framework.Assert.AreEqual("Helvetica", descriptor.GetFontName()); | ||
NUnit.Framework.Assert.AreEqual("helvetica", descriptor.GetFullNameLowerCase()); | ||
NUnit.Framework.Assert.AreEqual("helvetica", descriptor.GetFullNameLowerCase()); | ||
NUnit.Framework.Assert.AreEqual(500, descriptor.GetFontWeight()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.