Skip to content

Commit ece2297

Browse files
committed
PDFBOX-5660: optimize debugging; closes #265
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1928782 13f79535-47bb-0310-9956-ffa450edef68
1 parent 013d84e commit ece2297

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

pdfbox/src/main/java/org/apache/pdfbox/pdmodel/fixup/processor/AcroFormOrphanWidgetsProcessor.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,19 @@ private void addFontFromWidget(PDResources acroFormResources, PDAnnotation annot
172172
{
173173
acroFormResources.put(fontName, widgetResources.getFont(fontName));
174174
LOG.debug("added font resource to AcroForm from widget for font name {}",
175-
fontName.getName());
175+
() -> fontName.getName());
176176
}
177177
}
178178
catch (IOException ioe)
179179
{
180180
LOG.debug("unable to add font to AcroForm for font name {}",
181-
fontName.getName());
181+
() -> fontName.getName());
182182
}
183183
}
184184
else
185185
{
186186
LOG.debug("font resource for widget was a subsetted font - ignored: {}",
187-
fontName.getName());
187+
() -> fontName.getName());
188188
}
189189
});
190190
}
@@ -239,17 +239,20 @@ private void ensureFontResources(PDResources defaultResources, PDVariableText fi
239239
if (defaultResources.getFont(fontName) == null)
240240
{
241241
LOG.debug("trying to add missing font resource for field {}",
242-
field.getFullyQualifiedName());
242+
() -> field.getFullyQualifiedName());
243243
FontMapper mapper = FontMappers.instance();
244244
FontMapping<TrueTypeFont> fontMapping = mapper.getTrueTypeFont(fontName.getName() , null);
245245
if (fontMapping != null)
246246
{
247247
PDType0Font pdFont = PDType0Font.load(document, fontMapping.getFont(), false);
248-
LOG.debug("looked up font for {} - found {}", fontName.getName(),
249-
fontMapping.getFont().getName());
248+
if (LOG.isDebugEnabled())
249+
{
250+
LOG.debug("looked up font for {} - found {}", fontName.getName(),
251+
fontMapping.getFont().getName());
252+
}
250253
defaultResources.put(fontName, pdFont);
251254
}
252-
else
255+
else if (LOG.isDebugEnabled())
253256
{
254257
LOG.debug("no suitable font found for field {} for font name {}",
255258
field.getFullyQualifiedName(), fontName.getName());
@@ -258,8 +261,11 @@ private void ensureFontResources(PDResources defaultResources, PDVariableText fi
258261
}
259262
catch (IOException ioe)
260263
{
261-
LOG.debug("unable to handle font resources for field {}: {}",
262-
field.getFullyQualifiedName(), ioe.getMessage());
264+
if (LOG.isDebugEnabled())
265+
{
266+
LOG.debug("unable to handle font resources for field {}: {}",
267+
field.getFullyQualifiedName(), ioe.getMessage());
268+
}
263269
}
264270
}
265271
}

0 commit comments

Comments
 (0)