mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
When resolving font from /DR, copy it into resources
This commit is contained in:
parent
a2124f992c
commit
887f35efaa
@ -963,11 +963,28 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
|
||||
// See if the font is encoded with something we know about.
|
||||
QPDFObjectHandle resources = AS.getDict().getKey("/Resources");
|
||||
QPDFObjectHandle font = getFontFromResource(resources, font_name);
|
||||
bool found_font_in_dr = false;
|
||||
if (! font.isInitialized())
|
||||
{
|
||||
QPDFObjectHandle dr = getDefaultResources();
|
||||
font = getFontFromResource(dr, font_name);
|
||||
found_font_in_dr = (font.isInitialized() && font.isDictionary());
|
||||
}
|
||||
if (found_font_in_dr && resources.isDictionary())
|
||||
{
|
||||
QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR");
|
||||
if (resources.isIndirect())
|
||||
{
|
||||
resources = resources.getOwningQPDF()->makeIndirectObject(
|
||||
resources.shallowCopy());
|
||||
AS.getDict().replaceKey("/Resources", resources);
|
||||
}
|
||||
// Use mergeResources to force /Font to be local
|
||||
resources.mergeResources(
|
||||
QPDFObjectHandle::parse("<< /Font << >> >>"));
|
||||
resources.getKey("/Font").replaceKey(font_name, font);
|
||||
}
|
||||
|
||||
if (font.isInitialized() &&
|
||||
font.isDictionary() &&
|
||||
font.getKey("/Encoding").isName())
|
||||
|
@ -583,3 +583,4 @@ qpdf pages keeping field from original 0
|
||||
qpdf no more fields in pages 0
|
||||
QPDFObjectHandle merge reuse 0
|
||||
QPDFObjectHandle merge generate 0
|
||||
QPDFFormFieldObjectHelper get font from /DR 0
|
||||
|
@ -385,7 +385,7 @@ $td->runtest("compare files",
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Appearance Streams ---");
|
||||
$n_tests += 8;
|
||||
$n_tests += 10;
|
||||
|
||||
foreach my $f ('need-appearances',
|
||||
'need-appearances-more',
|
||||
@ -444,6 +444,17 @@ foreach my $i (@choice_values)
|
||||
{$td->FILE => "appearances-$i.pdf"});
|
||||
}
|
||||
|
||||
$td->runtest("Update resources from /DR",
|
||||
{$td->COMMAND =>
|
||||
"qpdf --qdf --no-original-object-ids --static-id" .
|
||||
" --generate-appearances" .
|
||||
" resource-from-dr.pdf a.pdf"},
|
||||
{$td->STRING => "", $td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
$td->runtest("compare files",
|
||||
{$td->FILE => "a.pdf"},
|
||||
{$td->FILE => "resource-from-dr-out.pdf"});
|
||||
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Form XObject, underlay, overlay ---");
|
||||
|
3859
qpdf/qtest/qpdf/resource-from-dr-out.pdf
Normal file
3859
qpdf/qtest/qpdf/resource-from-dr-out.pdf
Normal file
File diff suppressed because it is too large
Load Diff
3797
qpdf/qtest/qpdf/resource-from-dr.pdf
Normal file
3797
qpdf/qtest/qpdf/resource-from-dr.pdf
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user