1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:17:36 +00:00
serenity/Userland/Libraries
Rodrigo Tobar 1b90ea7d3a LibPDF: Augment Type11FontProgram with Type2 capabilities
The Type1FontProgram logic was based on the Adobe Type 1 Font Format; in
particular, it implemented the CharStrings Dictionary section
(charstring decoding, and most commands). In the case of Type1, these
charstrings are read from a PS1 diciontary, with one entry per character
in the font's charset. This has served us well for Type1 font rendering.

When implementing Type1C font rendering, this wasn't enough. Type1C PDF
fonts are specified in embedded CFF (Compact Font File) streams, which
also contain a charstring dictionary with an entry for each character in
the font's charset. These entries can be slightly different from those
in a PS1 Font Program though: depending on a flag in the CFF, the
entries will be encoded either in the original charstring format from
the Adobe Type 1 Font Format, or in the "Type 2 Charstring Format"
(Adobe's Technical Note #1577). This new format is for the most part a
super-set of the original, with small differences, all in the name of
making the representation as compact as possible:

 * The glyph's width is not specified via a separate command; instead
   it's an optional additional argument to the first command of the
   charstring stream (and even then, it's only the *difference* to a
   nominal character width specified in the CFF).
 * The interpretation of a 4-byte number is different from Type 1: in
   Type 1 this is a 4-byte unsigned integer, whereas in Type 1 it's a
   fixed decimal with 16 bits of fractional part.
 * Many commands accept a variable set of arguments, so they can draw
   more than one line/curve on a single go. These are all
   retro-compatible with Type 1's commands.

All these changes are implemented in this patch in a
backwards-compatible way. To ensure Type 1/2 behavior is accessed, a new
parameter indicates which behavior is desired when decoding the
charstring stream.

I also took the chance to centralise some logic that was previously
duplicated across the parse_glyph function. Common lambdas capture the
logic for moving to, or drawing a line/curve to a given point and
updating the glyph state. Similarly, some command logic, including
reading parameters, are shared by several commands. Finally, I've
re-organised the cases in the main switch to group together related
commands.
2023-01-25 15:40:11 +01:00
..
LibArchive LibCore: Return EBADF on unsupported stream operations 2023-01-19 11:41:56 +01:00
LibAudio AK: Remove InputBitStream and OutputBitStream 2023-01-21 00:45:33 +00:00
LibC LibC: Remove #ifdef KERNEL guard from stddef.h 2023-01-21 10:43:59 -07:00
LibCards LibCards: Use AK::shuffle() for shuffling new decks 2023-01-22 21:31:36 +00:00
LibChess Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
LibCodeComprehension Everywhere: Rename to_{string => deprecated_string}() where applicable 2022-12-06 08:54:33 +01:00
LibCompress Userland: Add missing Math.h and IntegralMath.h header includes 2023-01-19 11:29:48 +00:00
LibConfig LibConfig+LibCore+ConfigServer: Support u32 configuration entries 2022-12-23 23:26:21 +01:00
LibCore LibCore: Add nice get/set_process_name() wrappers in Core::Process 2023-01-25 14:27:45 +01:00
LibCoredump LibDebug: Propagate errors throughout DWARF parsing 2023-01-22 19:12:26 +01:00
LibCpp AK+Everywhere: Rename FlyString to DeprecatedFlyString 2023-01-09 23:00:24 +00:00
LibCrypt AK: Stop using DeprecatedString in Base64 encoding 2022-12-20 10:34:19 +01:00
LibCrypto Everywhere: Convert known short-strings to the infallible String factory 2023-01-20 14:24:12 -05:00
LibDebug LibDebug: Pass read_from_stream calls through read_value instead 2023-01-24 12:47:39 +00:00
LibDesktop AK+Everywhere: Rename JsonObject::get() to ::get_deprecated() 2023-01-17 19:52:52 -05:00
LibDeviceTree AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
LibDiff LibDiff: Make Diff::generate_only_additions take text as StringView 2022-12-20 10:58:54 +01:00
LibDNS LibDNS: Pass write_to_stream calls through write_value instead 2023-01-24 12:47:39 +00:00
LibDSP Everywhere: Use C++ concepts instead of requires clauses 2022-12-09 11:25:30 +00:00
LibEDID Everywhere: Remove string.h include from AK/Traits.h and resolve fallout 2023-01-21 10:43:59 -07:00
LibELF Kernel+Libraries: Don't include limits.h from LibELF/Validation.h 2023-01-21 10:43:59 -07:00
LibFileSystemAccessClient LibFileSystemAccessClient: Add functions returning FSAC::File 2023-01-07 10:53:43 +00:00
LibGemini LibGemini: Disallow cases forbidden in the spec 2023-01-14 12:28:02 +01:00
LibGfx LibGfx: Port GIFLoader to Core::Stream 2023-01-25 14:28:20 +01:00
LibGL Everywhere: Convert known short-strings to the infallible String factory 2023-01-20 14:24:12 -05:00
LibGLSL Everywhere: Convert known short-strings to the infallible String factory 2023-01-20 14:24:12 -05:00
LibGPU Userland: Add missing Math.h and IntegralMath.h header includes 2023-01-19 11:29:48 +00:00
LibGUI LibGUI: Mimic a user click when calling Button::click() 2023-01-21 14:49:46 +01:00
LibHTTP AK: Remove FileStream 2023-01-21 14:43:56 +01:00
LibIDL LibIDL: Use Core::Stream to read imports 2022-12-14 15:19:35 +00:00
LibImageDecoderClient LibGfx: Re-work the abstractions of sending image for decoding over IPC 2023-01-20 15:13:31 +00:00
LibIMAP Everywhere: Remove unused includes of AK/Format.h 2023-01-02 20:27:20 -05:00
LibIPC LibIPC: Decode messages using Core::Stream internally 2023-01-15 23:06:31 -05:00
LibJS LibJS+LibLocale: Port Intl.NumberFormat to String 2023-01-24 16:23:50 -05:00
LibKeyboard AK+Everywhere: Rename JsonObject::get() to ::get_deprecated() 2023-01-17 19:52:52 -05:00
LibLine LibLine: Do a whole bunch of internal error propagation 2023-01-16 21:04:48 +00:00
LibLocale LibJS+LibLocale: Port Intl.NumberFormat to String 2023-01-24 16:23:50 -05:00
LibMain Everywhere: Explicitly link all binaries against the LibC target 2022-11-01 14:49:09 +00:00
LibManual Help+LibManual: Open sibling page for subsections 2023-01-02 06:15:13 -07:00
LibMarkdown Everywhere: Remove unused includes of AK/Format.h 2023-01-02 20:27:20 -05:00
LibPartition Everywhere: Mark dependencies of most targets as PRIVATE 2022-11-01 14:49:09 +00:00
LibPCIDB AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
LibPDF LibPDF: Augment Type11FontProgram with Type2 capabilities 2023-01-25 15:40:11 +01:00
LibProtocol AK: Remove FileStream 2023-01-21 14:43:56 +01:00
LibRegex AK+Everywhere: Rename FlyString to DeprecatedFlyString 2023-01-09 23:00:24 +00:00
LibSanitizer LibC: Properly implement stack protectors 2022-11-01 14:49:09 +00:00
LibSoftGPU LibSoftGPU: Remove workaround for i686 depth comparison 2023-01-09 12:55:41 +01:00
LibSQL LibSQL: Don't do fchmod on OpenBSD 2023-01-14 16:32:14 +01:00
LibSymbolication LibDebug: Propagate errors throughout DWARF parsing 2023-01-22 19:12:26 +01:00
LibSyntax LibSyntax: Add common_language_extension() function 2022-12-19 14:13:50 -05:00
LibSystem Meta+Userland: Add ENABLE_USERSPACE_COVERAGE_COLLECTION CMake option 2022-05-02 01:46:18 +02:00
LibTest AK+Everywhere: Rename JsonObject::get() to ::get_deprecated() 2023-01-17 19:52:52 -05:00
LibTextCodec LibTextCodec: Add a MacRoman decoder 2023-01-24 14:37:20 +00:00
LibThreading Everywhere: Remove unused includes of AK/Format.h 2023-01-02 20:27:20 -05:00
LibTimeZone AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
LibTLS LibCrypto+Everywhere: Rename *BigInteger::to_base to to_base_deprecated 2023-01-15 01:00:20 +00:00
LibUnicode AK+LibUnicode: Provide Unicode-aware caseless String matching 2023-01-18 14:43:40 +00:00
LibUSBDB AK+Everywhere: Rename String to DeprecatedString 2022-12-06 08:54:33 +01:00
LibVideo LibVideo/VP9: Move TreeSelection class to TreeParser.cpp 2023-01-24 14:55:51 +00:00
LibVirtGPU Kernel+Userland: Move LibC/sys/ioctl_numbers to Kernel/API/Ioctl.h 2023-01-21 10:43:59 -07:00
LibVT Everywhere: Use ElapsedTimer::elapsed_time() for comparisons 2023-01-07 14:51:04 +01:00
LibWasm LibWasm: Use Core::Stream to read values in the bytecode interpreter 2023-01-25 17:10:05 +03:30
LibWeb LibWasm: Port the parser to Core::Stream 2023-01-25 17:10:05 +03:30
LibWebSocket AK: Stop using DeprecatedString in Base64 encoding 2022-12-20 10:34:19 +01:00
LibWebView AK+Everywhere: Rename JsonObject::get() to ::get_deprecated() 2023-01-17 19:52:52 -05:00
LibX86 LibX86: Remove i686 support 2022-12-28 11:53:41 +01:00
LibXML LibXML+LibWeb: Avoid implicit cast from StringView{}->DeprecatedString 2023-01-08 12:15:46 +01:00
CMakeLists.txt LibVirtGPU: Add a new GPU device that talks to our VirtIO-GPU driver 2022-12-26 09:39:20 +01:00