Skip to content

Commit c10e92d

Browse files
SnipxiText-CI
authored andcommitted
Expose TypographyUtils#isPdfCalligraphAvailable()
This allows easily checking if layout is aware of pdfCalligraph being present in classpath DEVSIX-3085 Autoported commit. Original commit hash: [f69c36649]
1 parent 4544a37 commit c10e92d

File tree

4 files changed

+65
-8
lines changed

4 files changed

+65
-8
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
This file is part of the iText (R) project.
3+
Copyright (c) 1998-2019 iText Group NV
4+
Authors: iText Software.
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License version 3
8+
as published by the Free Software Foundation with the addition of the
9+
following permission added to Section 15 as permitted in Section 7(a):
10+
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY
11+
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
12+
OF THIRD PARTY RIGHTS
13+
14+
This program is distributed in the hope that it will be useful, but
15+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16+
or FITNESS FOR A PARTICULAR PURPOSE.
17+
See the GNU Affero General Public License for more details.
18+
You should have received a copy of the GNU Affero General Public License
19+
along with this program; if not, see http://www.gnu.org/licenses or write to
20+
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21+
Boston, MA, 02110-1301 USA, or download the license from the following URL:
22+
http://itextpdf.com/terms-of-use/
23+
24+
The interactive user interfaces in modified source and object code versions
25+
of this program must display Appropriate Legal Notices, as required under
26+
Section 5 of the GNU Affero General Public License.
27+
28+
In accordance with Section 7(b) of the GNU Affero General Public License,
29+
a covered work must retain the producer line in every PDF that is created
30+
or manipulated using iText.
31+
32+
You can be released from the requirements of the license by purchasing
33+
a commercial license. Buying such a license is mandatory as soon as you
34+
develop commercial activities involving the iText software without
35+
disclosing the source code of your own applications.
36+
These activities include: offering paid services to customers as an ASP,
37+
serving PDFs on the fly in a web application, shipping iText with a closed
38+
source product.
39+
40+
For more information, please contact iText Software Corp. at this
41+
42+
*/
43+
using iText.Test;
44+
45+
namespace iText.Layout.Renderer {
46+
public class TypographyUtilsTest : ExtendedITextTest {
47+
[NUnit.Framework.Test]
48+
public virtual void VerifyPdfCalligraphIsNotAvailable() {
49+
NUnit.Framework.Assert.IsFalse(TypographyUtils.IsPdfCalligraphAvailable());
50+
}
51+
}
52+
}

itext/itext.layout/itext/layout/renderer/TextRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public override LayoutResult Layout(LayoutContext layoutContext) {
535535
public virtual void ApplyOtf() {
536536
UpdateFontAndText();
537537
UnicodeScript? script = this.GetProperty<UnicodeScript?>(Property.FONT_SCRIPT);
538-
if (!otfFeaturesApplied && TypographyUtils.IsTypographyModuleInitialized() && text.start < text.end) {
538+
if (!otfFeaturesApplied && TypographyUtils.IsPdfCalligraphAvailable() && text.start < text.end) {
539539
if (HasOtfFont()) {
540540
Object typographyConfig = this.GetProperty<Object>(Property.TYPOGRAPHY_CONFIG);
541541
ICollection<UnicodeScript> supportedScripts = null;

itext/itext.layout/itext/layout/renderer/TypographyUtils.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ source product.
5454
using iText.Layout.Properties;
5555

5656
namespace iText.Layout.Renderer {
57-
internal sealed class TypographyUtils {
58-
private static readonly ILog logger = LogManager.GetLogger(typeof(TypographyUtils));
57+
public sealed class TypographyUtils {
58+
private static readonly ILog logger = LogManager.GetLogger(typeof(iText.Layout.Renderer.TypographyUtils));
5959

6060
private const String TYPOGRAPHY_PACKAGE = "iText.Typography.";
6161

@@ -128,6 +128,15 @@ static TypographyUtils() {
128128
SUPPORTED_SCRIPTS = supportedScripts;
129129
}
130130

131+
private TypographyUtils() {
132+
}
133+
134+
/// <summary>Checks if layout module can access pdfCalligraph</summary>
135+
/// <returns><code>true</code> if layout can access pdfCalligraph and <code>false</code> otherwise</returns>
136+
public static bool IsPdfCalligraphAvailable() {
137+
return TYPOGRAPHY_MODULE_INITIALIZED;
138+
}
139+
131140
internal static void ApplyOtfScript(FontProgram fontProgram, GlyphLine text, UnicodeScript? script, Object
132141
typographyConfig) {
133142
if (!TYPOGRAPHY_MODULE_INITIALIZED) {
@@ -263,10 +272,6 @@ internal static ICollection<UnicodeScript> GetSupportedScripts(Object typography
263272
}
264273
}
265274

266-
internal static bool IsTypographyModuleInitialized() {
267-
return TYPOGRAPHY_MODULE_INITIALIZED;
268-
}
269-
270275
private static Object CallMethod(String className, String methodName, Type[] parameterTypes, params Object
271276
[] args) {
272277
return CallMethod(className, methodName, (Object)null, parameterTypes, args);

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2ec5ebc58553d147be174a03bf5305f53acc9659
1+
f69c3664989e9df4e15b74ebfc10e181714a653a

0 commit comments

Comments
 (0)