You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/11/15 20:10:51 UTC
svn commit: r1895071 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
Author: tilman
Date: Mon Nov 15 20:10:51 2021
New Revision: 1895071
URL: http://svn.apache.org/viewvc?rev=1895071&view=rev
Log:
PDFBOX-4892: use jdk8 syntax
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java?rev=1895071&r1=1895070&r2=1895071&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/FontMapperImpl.java Mon Nov 15 20:10:51 2021
@@ -104,13 +104,13 @@ final class FontMapperImpl implements Fo
// these include names such as "Arial" and "TimesNewRoman"
for (String baseName : Standard14Fonts.getNames())
{
- if (!substitutes.containsKey(baseName))
+ substitutes.computeIfAbsent(baseName, key ->
{
- FontName mappedName = Standard14Fonts.getMappedFontName(baseName);
- substitutes.put(baseName, copySubstitutes(mappedName));
- }
+ FontName mappedName = Standard14Fonts.getMappedFontName(key);
+ return new ArrayList<>(substitutes.get(mappedName.getName()));
+ });
}
-
+
// -------------------------
try
@@ -197,14 +197,6 @@ final class FontMapperImpl implements Fo
}
/**
- * Copies a list of font substitutes, adding the original font at the start of the list.
- */
- private List<String> copySubstitutes(FontName postScriptName)
- {
- return new ArrayList<>(substitutes.get(postScriptName.getName()));
- }
-
- /**
* Adds a top-priority substitute for the given font.
*
* @param match PostScript name of the font to match
@@ -212,11 +204,7 @@ final class FontMapperImpl implements Fo
*/
public void addSubstitute(String match, String replace)
{
- if (!substitutes.containsKey(match))
- {
- substitutes.put(match, new ArrayList<>());
- }
- substitutes.get(match).add(replace);
+ substitutes.computeIfAbsent(match, key -> new ArrayList<>()).add(replace);
}
/**