Skip to content

Commit 64165a4

Browse files
LodrKumquatpavel-alay
authored andcommitted
Introduce StandardFontFamilies class, remove TIMES constant from StandardFonts
DEVSIX-1789 Autoported commit. Original commit hash: [dc1d22808]
1 parent 7dfc735 commit 64165a4

File tree

5 files changed

+77
-14
lines changed

5 files changed

+77
-14
lines changed

itext/itext.io/itext/io/font/FontConstants.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ public class FontConstants {
126126
/// <summary>This is a possible value of a base 14 type 1 font</summary>
127127
[System.ObsoleteAttribute(@"use iText.IO.Font.Constants.StandardFonts.ZAPFDINGBATS instead.")]
128128
public const String ZAPFDINGBATS = "ZapfDingbats";
129-
130-
/// <summary>This is a possible value of a base 14 type 1 font</summary>
131-
[System.ObsoleteAttribute(@"use iText.IO.Font.Constants.StandardFonts.TIMES instead.")]
132-
public const String TIMES = "Times";
133129
//-Font styles------------------------------------------------------------------------------------------------------
134130
//-Default fonts----------------------------------------------------------------------------------------------------
135131
}

itext/itext.io/itext/io/font/FontRegisterProvider.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ internal virtual FontProgram GetFont(String fontName, int style, bool cached) {
9494
return null;
9595
}
9696
String lowerCaseFontName = fontName.ToLowerInvariant();
97-
IList<String> family = fontFamilies.Get(lowerCaseFontName);
97+
IList<String> family = !lowerCaseFontName.EqualsIgnoreCase(StandardFonts.TIMES_ROMAN) ? fontFamilies.Get(lowerCaseFontName
98+
) : fontFamilies.Get(StandardFontFamilies.TIMES.ToLowerInvariant());
9899
if (family != null) {
99100
lock (family) {
100101
// some bugs were fixed here by Daniel Marczisovszky
@@ -142,26 +143,25 @@ protected internal virtual void RegisterStandardFontFamilies() {
142143
family.Add(StandardFonts.COURIER_BOLD);
143144
family.Add(StandardFonts.COURIER_OBLIQUE);
144145
family.Add(StandardFonts.COURIER_BOLDOBLIQUE);
145-
fontFamilies.Put(StandardFonts.COURIER.ToLowerInvariant(), family);
146+
fontFamilies.Put(StandardFontFamilies.COURIER.ToLowerInvariant(), family);
146147
family = new List<String>();
147148
family.Add(StandardFonts.HELVETICA);
148149
family.Add(StandardFonts.HELVETICA_BOLD);
149150
family.Add(StandardFonts.HELVETICA_OBLIQUE);
150151
family.Add(StandardFonts.HELVETICA_BOLDOBLIQUE);
151-
fontFamilies.Put(StandardFonts.HELVETICA.ToLowerInvariant(), family);
152+
fontFamilies.Put(StandardFontFamilies.HELVETICA.ToLowerInvariant(), family);
152153
family = new List<String>();
153154
family.Add(StandardFonts.SYMBOL);
154-
fontFamilies.Put(StandardFonts.SYMBOL.ToLowerInvariant(), family);
155+
fontFamilies.Put(StandardFontFamilies.SYMBOL.ToLowerInvariant(), family);
155156
family = new List<String>();
156157
family.Add(StandardFonts.TIMES_ROMAN);
157158
family.Add(StandardFonts.TIMES_BOLD);
158159
family.Add(StandardFonts.TIMES_ITALIC);
159160
family.Add(StandardFonts.TIMES_BOLDITALIC);
160-
fontFamilies.Put(StandardFonts.TIMES.ToLowerInvariant(), family);
161-
fontFamilies.Put(StandardFonts.TIMES_ROMAN.ToLowerInvariant(), family);
161+
fontFamilies.Put(StandardFontFamilies.TIMES.ToLowerInvariant(), family);
162162
family = new List<String>();
163163
family.Add(StandardFonts.ZAPFDINGBATS);
164-
fontFamilies.Put(StandardFonts.ZAPFDINGBATS.ToLowerInvariant(), family);
164+
fontFamilies.Put(StandardFontFamilies.ZAPFDINGBATS.ToLowerInvariant(), family);
165165
}
166166

167167
/// <exception cref="System.IO.IOException"/>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System;
2+
3+
namespace iText.IO.Font.Constants {
4+
/// <summary>
5+
/// Class containing families for
6+
/// <see cref="StandardFonts"/>
7+
/// .
8+
/// This class was made for
9+
/// <see cref="iText.IO.Font.FontRegisterProvider"/>
10+
/// .
11+
/// </summary>
12+
public sealed class StandardFontFamilies {
13+
private StandardFontFamilies() {
14+
}
15+
16+
/// <summary>
17+
/// Font family for
18+
/// <see cref="StandardFonts.COURIER"/>
19+
/// ,
20+
/// <see cref="StandardFonts.COURIER_BOLD"/>
21+
/// ,
22+
/// <see cref="StandardFonts.COURIER_OBLIQUE"/>
23+
/// and
24+
/// <see cref="StandardFonts.COURIER_BOLDOBLIQUE"/>
25+
/// .
26+
/// </summary>
27+
public const String COURIER = "Courier";
28+
29+
/// <summary>
30+
/// Font family for
31+
/// <see cref="StandardFonts.HELVETICA"/>
32+
/// ,
33+
/// <see cref="StandardFonts.HELVETICA_BOLD"/>
34+
/// ,
35+
/// <see cref="StandardFonts.HELVETICA_OBLIQUE"/>
36+
/// and
37+
/// <see cref="StandardFonts.HELVETICA_BOLDOBLIQUE"/>
38+
/// .
39+
/// </summary>
40+
public const String HELVETICA = "Helvetica";
41+
42+
/// <summary>
43+
/// Font family for
44+
/// <see cref="StandardFonts.SYMBOL"/>
45+
/// .
46+
/// </summary>
47+
public const String SYMBOL = "Symbol";
48+
49+
/// <summary>
50+
/// Font family for
51+
/// <see cref="StandardFonts.ZAPFDINGBATS"/>
52+
/// .
53+
/// </summary>
54+
public const String ZAPFDINGBATS = "ZapfDingbats";
55+
56+
/// <summary>
57+
/// Font family for
58+
/// <see cref="StandardFonts.TIMES_ROMAN"/>
59+
/// ,
60+
/// <see cref="StandardFonts.TIMES_BOLD"/>
61+
/// ,
62+
/// <see cref="StandardFonts.TIMES_ITALIC"/>
63+
/// and
64+
/// <see cref="StandardFonts.TIMES_BOLDITALIC"/>
65+
/// .
66+
/// </summary>
67+
public const String TIMES = "Times";
68+
}
69+
}

itext/itext.io/itext/io/font/constants/StandardFonts.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,5 @@ public static bool IsStandardFont(String fontName) {
112112

113113
/// <summary>This is a possible value of a base 14 type 1 font</summary>
114114
public const String ZAPFDINGBATS = "ZapfDingbats";
115-
116-
public const String TIMES = "Times";
117115
}
118116
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9c63e0f84eb62cf50b768e3dc8be8d6cce5b5c09
1+
dc1d22808d8442fcc7fb2ebba38f757920ca541e

0 commit comments

Comments
 (0)