0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ScribusのPDFを書き出し直したあと、フォント埋め込みをどこで確認するか

0
Posted at

PDFの画面表示が正常でも、フォントがファイルに埋め込まれているかどうかは別の確認項目です。Scribus 1.6.7で小さなA4文書を作り、SLAを保存してアプリを終了しました。再度開いたあと、同じ条件でPDF 1.4に書き出し、終了前のPDFと比較しました。

フォント名からフォントデータへたどる

独立検証では、pypdfで各ページの /Resources を読み、/Font の参照先を調べました。複合フォントでは /DescendantFonts の先にあるフォント辞書を見ます。そこで /FontDescriptor を取得し、/FontFile、/FontFile2、/FontFile3 のどれかに実際のデータが含まれるかを確認します。たとえば /BaseFont に目的の名前があっても、その名前だけでは埋め込みの確認になりません。

同じPDFで実行した最小例です。この例では対象のScribus出力にフォント記述子があることを前提にしています。

from pypdf import PdfReader

for page in PdfReader("export-after-reopen.pdf").pages:
    for ref in page["/Resources"]["/Font"].values():
        font = ref.get_object()
        children = font.get("/DescendantFonts")
        target = children[0].get_object() if children else font
        descriptor = target["/FontDescriptor"].get_object()
        for key in ("/FontFile", "/FontFile2", "/FontFile3"):
            if key in descriptor:
                size = len(descriptor[key].get_object().get_data())
                print(font.get("/BaseFont"), size)
                break

再オープン後のPDFでは、各ページでBoldが17,756バイト、Regularが21,248バイトでした。

今回確認した項目

  • 再起動前後のPDFはどちらもA4の2ページでした。
  • Source Sans 3のRegularとBoldを使用し、検証したフォントストリームにはデータがありました。
  • テキスト抽出で café € 12345 が残っていました。テキスト抽出と画面描画はそれぞれ確認しました。
  • 画像と矩形の位置・寸法は、描画結果に加えてPDFのコンテンツストリームからも検証しました。

再現するときは、出力ごとにページ寸法、埋め込みデータ、テキスト、レンダリングを分けて記録すると、差が出た箇所を切り分けやすくなります。この検証はWindowsの小さなSLAを対象にしたもので、INDDやIDMLの移行、PDF/X、CMYKや特色印刷は検証していません。

2ページの出力例とScribus検証の条件(FOSS Desk、英語)を公開しています。筆者はFOSS Deskの運営者です。記事の構成と日本語化にはAIを使用し、記載した結果は実際の検証記録に基づきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?