Get detailed font information for a character

286 views
Skip to first unread message

Nikita Rybak

unread,
Sep 18, 2023, 3:22:18 AM9/18/23
to pdfium
Hi there,
I'm aware that I can get basic font information for an individual character with FPDFText_GetFontSize / FPDFText_GetFontInfo / FPDFText_GetFontWeight. There is also API to get detailed information for a font, e.g. FPDFFont_GetAscent & FPDFFont_GetDescent.

My question is, how does one connect the two? FPDFFont_GetAscent takes a FPDF_FONT handle, but I don't see a way to get such a handle using only font name received from FPDFText_GetFontInfo.
I only see a way to get a font handle using object-level api (FPDFTextObj_GetFont), and through FPDFText_LoadFont/FPDFText_LoadStandardFont (if I understand correctly, those are for editing a pdf)


Nikita

Justin Pierce

unread,
Sep 24, 2023, 11:48:36 PM9/24/23
to pdfium
Looks like you've done a thorough investigation. There is no way to enumerate all fonts in a document.

I believe the only way to retrieve an existing font is via `FPDFTextObj_GetFont` which requires a handle to a page object (`FPDFPage_GetObject`)

If you're willing to modify Pdfium, you can alternatively write a custom Pdfium method to interate through all of the indirect objects within `CPDF_Document` and check for fonts this way.

Lei Zhang

unread,
Sep 26, 2023, 6:00:25 PM9/26/23
to Nikita Rybak, pdfium
Thanks for noticing this gap in the API. Please file a feature request
on the bug tracker to add the missing FPDFText_GetFont() API.
> --
> You received this message because you are subscribed to the Google Groups "pdfium" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/91c0396c-5e14-4a7b-b677-a027a09cf335n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages