Go to file
Ben Wagner 225c8861b7 [pdf] Differentiate text from byte strings.
In PDF there are two different physical encodings of strings (as a
sequence of bytes). There is the literal string encoding which is
delimited by '(' and ') which stores the bytes as-is except for '(',
')', and the escape character '\' (which can introduce octal encoded
bytes). There is also the hex string encoding delimited by '<' and '>'
and the bytes are encoded in hex pairs (with an implicit '0' at the end
for odd length encodings).

The interpretation of these bytes depends on the logical string type of
the dictionary key. There is a base abstract (well, almost abstract
except for legacy purposes) string type. The subtypes of the string type
are `text string`, `ASCII string`, and `byte string`. The `text string`
is logically further subtyped into `PDFDocEncoded string` and `UTF-16BE
with BOM`. In theory any of these logical string types may have its
encoded bytes written out in either of the two physical string
encodings.

In practice for Skia this means there are two types of string to keep
track of, since `ASCII string` and `byte string` can be treated the
same (in this change they are both treated as `byte string`). If the
type is `text string` then the bytes Skia has are interpreted as UTF-8
and may be converted to `UTF-16BE with BOM` or used directly as
`PDFDocEncoded string` if that is valid. If the type is `byte string`
then the bytes Skia has may not be converted and must be written as-is.

This means that when Skia sets a dictionary key to a string value it
must, at the very least, remember if the key's type was `text string`.
This change replaces all `String` methods with `ByteString` and
`TextString` methods and updates all the callers to the correct one
based on the key being written.

With the string handling corrected, the `/ActualText` string is now
emitted with this new common code as well for better output and to
reduce code duplication. A few no longer used public APIs involving
these strings are removed. The documentation for the URI annotation is
updated to reflect reality.

This change outputs `UTF-16BE with BOM` with the hex string encoding
only and does not attempt to fix the literal string encoding which
always escapes bytes > 0x7F. These changes may be attempted in a
separate change.

Bug: chromium:1323159
Change-Id: I00bdd5c90ad1ff2edfb74a9de41424c4eeac5ccb
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/543084
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
Reviewed-by: Herb Derby <herb@google.com>
2022-05-24 18:46:42 +00:00
bazel Manual dawn roll 2022-05-23 16:22:20 +00:00
bench [pdf] Differentiate text from byte strings. 2022-05-24 18:46:42 +00:00
bin Update SKPs documentation link 2022-05-18 15:21:44 +00:00
build/fuchsia [fuchsia] Fix fidlc command. 2020-06-10 03:29:24 +00:00
build_overrides Set dawn_vulkan_tools_dir in Dawn's GN overrides 2022-04-14 17:05:33 +00:00
client_utils/android Revert "Move SkCamera.h to client_utils/android" 2022-04-25 12:33:01 +00:00
demos.skia.org [canvaskit] Add in fillText to spreadsheet demo for comparison 2022-02-15 15:35:43 +00:00
dm [graphite] Add SkCombinationBuilder.h 2022-05-23 20:26:17 +00:00
docker [infra] Avoid timeouts in CreateDockerImage_Skia_WASM_Release 2022-04-08 12:26:54 +00:00
docs/examples Reland "Add kR8_unorm_SkColorType" 2022-02-10 18:00:19 +00:00
example [bazel] Put licenses() after legacy_exports 2022-05-02 15:04:33 +00:00
experimental Reland "[infra] Remove old python scripts and urllib2 references" 2022-05-16 20:15:49 +00:00
fuzz Run SkSL unit tests with optimizations disabled. 2022-05-11 14:38:07 +00:00
gm Remove SkNx entirely 2022-05-24 15:57:57 +00:00
gn Remove SkNx entirely 2022-05-24 15:57:57 +00:00
include [pdf] Differentiate text from byte strings. 2022-05-24 18:46:42 +00:00
infra [bazel] Temporarily remove IWYU CI job 2022-05-24 14:58:10 +00:00
modules [canvaskit] Fix uniform handling for makeShader and MallocObj 2022-05-24 16:33:17 +00:00
platform_tools Fix bug where SkQP test that are always to be excluded are not. 2022-04-29 20:26:54 +00:00
resources [particles] add support for multiframe asset bindings 2022-05-19 19:39:12 +00:00
samplecode Remove SkNx entirely 2022-05-24 15:57:57 +00:00
site Doc typos and formatting 2022-05-16 16:33:43 +00:00
specs [infra] Port serve.py from Python2 to 3 2021-08-31 15:28:19 +00:00
src [pdf] Differentiate text from byte strings. 2022-05-24 18:46:42 +00:00
tests [pdf] Differentiate text from byte strings. 2022-05-24 18:46:42 +00:00
third_party Roll skcms from dcb0286a1e17 to 9c30a95f0f16 (1 revision) 2022-05-20 20:43:00 +00:00
toolchain set up tools for building Skia on Mac semi hermetically 2022-05-04 16:56:46 +00:00
tools Move GrTextBlobRedrawCoordinator to sktext:gpu namespace. 2022-05-24 15:36:34 +00:00
.bazelrc [infra] Add BazelBuild task to build CanvasKit on the CI with Bazel 2022-05-06 17:54:08 +00:00
.bazelversion [canvaskit] Add skottie to Bazel build 2022-02-04 19:18:27 +00:00
.clang-format no more bin packing in .clang-format 2021-03-04 17:22:50 +00:00
.clang-tidy Disable ClangTidy namespace comments for short blocks. 2020-08-24 14:01:22 +00:00
.gitignore [infra] Add BazelBuild task to build CanvasKit on the CI with Bazel 2022-05-06 17:54:08 +00:00
.gn Add support for ANGLE's Metal backend 2022-04-28 19:53:18 +00:00
.vpython [python3] Reland recipes -> python3 changes 2021-12-01 13:04:03 +00:00
AUTHORS Add mike@reedtribe.org to AUTHORS 2022-05-19 12:49:11 +00:00
BUILD.bazel [bazel] Put licenses() after legacy_exports 2022-05-02 15:04:33 +00:00
BUILD.gn Fix up Ganesh and Graphite defines. 2022-05-23 20:51:28 +00:00
codereview.settings Make uploading to Gerrit the default for Skia 2016-11-09 19:07:56 +00:00
CONTRIBUTING Fix references to https://sites.google.com/site/skiadocs/. 2015-02-03 13:12:54 -02:00
CQ_COMMITTERS Moved committer list to chrome-infra-auth and deleted it from the repo 2015-09-02 13:37:54 -07:00
DEPS Roll Dawn from 318f6acd56c0 to c45f11ddb539 (7 revisions) 2022-05-24 04:40:56 +00:00
DIR_METADATA Move metadata in OWNERS files to DIR_METADATA files 2021-02-02 23:41:54 +00:00
go_repositories.bzl [infra] Update dep of infra repo 2022-04-28 13:20:10 +00:00
go.mod [infra] Update dep of infra repo 2022-04-28 13:20:10 +00:00
go.sum [infra] Fix go.sum 2022-04-28 18:01:34 +00:00
LICENSE LICENSE file: clean up 2019-11-22 21:59:03 +00:00
OWNERS [infra] Add wildcard OWNERS 2021-08-30 19:19:34 +00:00
OWNERS.android Update OWNERS.android with more details 2022-03-16 18:13:33 +00:00
package-lock.json [bazel] Make custom karma_test rule 2022-02-23 14:53:01 +00:00
package.json [bazel] Make custom karma_test rule 2022-02-23 14:53:01 +00:00
PRESUBMIT.py [bazel] Add Presubmit to remind devs about adding/deleting files. 2022-05-17 18:01:58 +00:00
public.bzl Remove SkNx entirely 2022-05-24 15:57:57 +00:00
README Fix references to https://sites.google.com/site/skiadocs/. 2015-02-03 13:12:54 -02:00
README.chromium Update README.chromium. 2015-06-11 13:19:24 -07:00
RELEASE_NOTES.txt Make float color versions of SkBitmap::clear 2022-05-19 23:25:06 +00:00
requirements.txt Added expected hash for MarkupSafe for the MacOS platform with the M1 chip 2022-05-19 17:54:32 +00:00
whitespace.txt Push shaders.skia.org. 2022-01-19 21:46:16 +00:00
WORKSPACE.bazel [bazel] Move third party BUILD.bazel files to bazel/external 2022-05-17 12:13:49 +00:00

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.

See full details, and build instructions, at https://skia.org.