mirror of https://github.com/qpdf/qpdf.git
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.
|
// See if the font is encoded with something we know about.
|
||||||
QPDFObjectHandle resources = AS.getDict().getKey("/Resources");
|
QPDFObjectHandle resources = AS.getDict().getKey("/Resources");
|
||||||
QPDFObjectHandle font = getFontFromResource(resources, font_name);
|
QPDFObjectHandle font = getFontFromResource(resources, font_name);
|
||||||
|
bool found_font_in_dr = false;
|
||||||
if (! font.isInitialized())
|
if (! font.isInitialized())
|
||||||
{
|
{
|
||||||
QPDFObjectHandle dr = getDefaultResources();
|
QPDFObjectHandle dr = getDefaultResources();
|
||||||
font = getFontFromResource(dr, font_name);
|
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() &&
|
if (font.isInitialized() &&
|
||||||
font.isDictionary() &&
|
font.isDictionary() &&
|
||||||
font.getKey("/Encoding").isName())
|
font.getKey("/Encoding").isName())
|
||||||
|
|
|
@ -583,3 +583,4 @@ qpdf pages keeping field from original 0
|
||||||
qpdf no more fields in pages 0
|
qpdf no more fields in pages 0
|
||||||
QPDFObjectHandle merge reuse 0
|
QPDFObjectHandle merge reuse 0
|
||||||
QPDFObjectHandle merge generate 0
|
QPDFObjectHandle merge generate 0
|
||||||
|
QPDFFormFieldObjectHelper get font from /DR 0
|
||||||
|
|
|
@ -385,7 +385,7 @@ $td->runtest("compare files",
|
||||||
show_ntests();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Appearance Streams ---");
|
$td->notify("--- Appearance Streams ---");
|
||||||
$n_tests += 8;
|
$n_tests += 10;
|
||||||
|
|
||||||
foreach my $f ('need-appearances',
|
foreach my $f ('need-appearances',
|
||||||
'need-appearances-more',
|
'need-appearances-more',
|
||||||
|
@ -444,6 +444,17 @@ foreach my $i (@choice_values)
|
||||||
{$td->FILE => "appearances-$i.pdf"});
|
{$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();
|
show_ntests();
|
||||||
# ----------
|
# ----------
|
||||||
$td->notify("--- Form XObject, underlay, overlay ---");
|
$td->notify("--- Form XObject, underlay, overlay ---");
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue