1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00
serenity/Userland/Libraries/LibPDF/Fonts
Nico Weber bd74447dba LibPDF: Initial support for drawing CFF-based Type0 fonts
Together with the already-merged #23122, #23128, #23135, #23136, #23162,
and #23167, #23179, #23190, #23194 this adds initial support for
rendering some CFF-based Type0 fonts :^)

There's a long list of things that still need improving after this:

* A small number of CFF programs contain the charstring command 0,
  which is invalid. Currently, this makes us reject the whole font.

* Type1FontProgram::rasterize_glyph() is name-based. For CID-based
  fonts, we want a version that takes CIDs (character IDs) instead.
  For now, I'm printing the CID to a string and using that, yuck.
  (I looked into doing this nicely. I do want to do that, but I
  need to read up on how the `seac` type1 charstring command uses
  character names to identify parts of an accented character.
  Also, it looks like `seac`'s accented character handling moved
  over to `endchar` in type2 charstring commands (i.e. in CFF data),
  and it looks like we don't implement that at all. So I need to do
  more reading first, and I didn't want to block this on that.)

* The name for the first string in name-based CFF fonts looks wrong;
  added a FIXME for that for now.

* This supports the named Identity-H cmap only for now. Identity-H
  maps UTF16-BE values to glyph IDs with the idenity function, and
  assumes it's horizontal text. Other named cmaps in my test files are
  UniJIS-UCS2-H, UniCNS-UCS2-H, Identity-V, UniGB-UCS2-H, UniKS-UCS2-H.
  (There are also 2 files using the stream-based cmaps instead of the
  name-based ones.)

  * In particular, we can't draw vertical text (`-V`) yet

* Passing in the encoding to CFF::create() is awkward (it's nullptr
  for CID-keyed fonts), and it's also not necessary since
  `Type1Font::draw_glyph()` already does the "take encoding from PDF,
  and only from font if the PDF doesn't store one" dance.

* This doesn't cache glyphs but re-rasterizes them each time. Easy
  to add, but maybe I want to look at rotation first. And things
  don't feel glacial as-is.

* Type0Font::draw_glyph() is pretty similar to second half of
  Type1Font::draw_glyph()
2024-02-16 12:41:10 -05:00
..
CFF.cpp LibPDF: Initial support for drawing CFF-based Type0 fonts 2024-02-16 12:41:10 -05:00
CFF.h LibPDF/CFF: Compute per-glyph glyph width in CID-keyed fonts 2024-02-16 12:41:10 -05:00
PDFFont.cpp LibPDF: Add some scaffolding for type 3 fonts 2023-11-17 19:47:53 +00:00
PDFFont.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
PS1FontProgram.cpp Everywhere: Use to_number<T> instead of to_{int,uint,float,double} 2023-12-23 20:41:07 +01:00
PS1FontProgram.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
SimpleFont.cpp LibPDF: Scale default glyph width by font size and x scale 2024-02-12 14:32:04 +00:00
SimpleFont.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
TrueTypeFont.cpp LibPDF: Tweak vertical position of truetype fonts again 2024-02-01 10:05:40 +01:00
TrueTypeFont.h LibPDF: Pass Renderer to SimpleFont::draw_glyph() 2023-11-17 19:47:53 +00:00
Type0Font.cpp LibPDF: Initial support for drawing CFF-based Type0 fonts 2024-02-16 12:41:10 -05:00
Type0Font.h Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Type1Font.cpp LibPDF/CFF: Store if a font program is CID-keyed 2024-02-15 12:32:31 +01:00
Type1Font.h LibPDF: Pass Renderer to SimpleFont::draw_glyph() 2023-11-17 19:47:53 +00:00
Type1FontProgram.cpp Everywhere: Rename {Deprecated => Byte}String 2023-12-17 18:25:10 +03:30
Type1FontProgram.h LibPDF/CFF: Store if a font program is CID-keyed 2024-02-15 12:32:31 +01:00
Type3Font.cpp LibPDF: Add an initial implementation of type 3 glyph rendering 2023-11-17 19:47:53 +00:00
Type3Font.h LibPDF: Pass Renderer to SimpleFont::draw_glyph() 2023-11-17 19:47:53 +00:00