THotPDF.RegisterAcroFormFont

THotPDF AcroForm /DR multi-font registration (v2.119.42)

 

AddXFAPacket  AcroForm Support  SetFormUnicodeFontDict

AcroForm Default Resources(/DR) 사전에 포함할 Unicode(Type 0 / CID-keyed) 폰트를 하나 더 등록합니다. 하나의 PDF 문서에서 여러 Unicode 폰트를 AcroForm 위젯에 동시에 노출할 수 있으며, 예를 들어 한 폼에서 Latin 폰트, CJK 폰트, Arabic 폰트가 함께 필요한 다국어 폼에 주로 쓰입니다.

 

Delphi syntax:

procedure RegisterAcroFormFont(const FontResourceName: AnsiString;

  FontIndirectRef: THPDFObject);

 

Description

AcroForm 위젯은 AcroForm 사전의 Default Resources(/DR) 사전을 통해 폰트를 참조하며, 이 사전이 모든 폼 필드 appearance 스트림이 공유하는 리소스 풀 역할을 합니다. v2.119.42 이전에는 AcroForm /DR에 Unicode 폰트가 정확히 하나(보통 SetFormUnicodeFontDict로 등록한 헬퍼 설정 Type 0 폰트)만 노출되었고, 모든 위젯이 같은 폰트 프로그램으로 렌더링되어야 했기 때문에 다국어 폼 워크플로에 제약이 있었습니다.

 

v2.119.42부터는 호출자가 임의의 리소스 이름으로 Unicode 폰트를 추가 등록할 수 있습니다. 등록된 폰트는 각각 /DR /Font /<name> <indirect ref> 항목이 되어 AcroForm /DR 사전에 들어가며, 이 작업은 EndDoc 시점에 이루어집니다. 그러면 위젯 appearance 스트림은 자체 appearance 콘텐츠 스트림 안의 /Tf <name> <size> 연산자로 등록된 어떤 이름이든 참조할 수 있습니다.

 

Parameters

FontResourceName - appearance 스트림의 /Tf 연산자가 참조하는 PDF Name입니다. 관례상 앞에 슬래시가 없는 짧고 안정적인 식별자를 씁니다(예: 'NotoSansArab', 'NotoSansCJK'). 직렬화할 때 앞의 슬래시는 HotPDF가 씁니다.

FontIndirectRef - 이미 존재하는 indirect Type 0(CID-keyed) 폰트 사전으로, 보통 CreateIndirectFontDict를, RegisterUnicodeTTF로 등록한 폰트에 적용한 결과입니다.

 

Typical workflow (multilingual form)

 

PDF.RegisterUnicodeTTF('NotoSansArab', 'NotoSansArabic-Regular.ttf');

PDF.RegisterUnicodeTTF('NotoSansJP'  , 'NotoSansJP-Regular.otf');

ArabRef := PDF.CreateIndirectFontDict('NotoSansArab');

JPRef   := PDF.CreateIndirectFontDict('NotoSansJP');

PDF.RegisterAcroFormFont('NotoSansArab', ArabRef);

PDF.RegisterAcroFormFont('NotoSansJP'  , JPRef);

 

Now Arabic-content widgets can author their appearance streams with /NotoSansArab 12 Tf while Japanese-content widgets use /NotoSansJP 12 Tf, sharing one document-wide AcroForm /DR resource pool.

 

Coexistence with SetFormUnicodeFontDict

기존의 단일 폰트 헬퍼(SetFormUnicodeFontDict)는 AcroForm /DR에 Unicode 폰트가 하나만 필요한 프로젝트에서 계속 동작합니다. RegisterAcroFormFont는 추가 방식입니다. SetFormUnicodeFontDict와 함께 쓰거나, Unicode 폰트가 둘 이상 필요하면 SetFormUnicodeFontDict를 아예 대체해서 쓸 수 있습니다.

 

See also: THotPDF.SetFormUnicodeFontDict, THotPDF.CreateIndirectFontDict, AcroForm Support, THPDFPage.AddTextField