Skip to content

Commit

Permalink
Update README.md for Font Access API.
Browse files Browse the repository at this point in the history
Change-Id: Ic1be80a3e7144327fe0ddc040fa2eb2bbe95d074
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3564616
Reviewed-by: Victor Costan <pwnall@chromium.org>
Commit-Queue: Daseul Lee <dslee@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988128}
  • Loading branch information
dslee414 authored and Chromium LUCI CQ committed Apr 1, 2022
1 parent e814519 commit 2e16b34
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 16 deletions.
38 changes: 38 additions & 0 deletions content/browser/font_access/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Font Access API

This directory contains the browser-side implementation of
[Font Access API](https://github.com/WICG/local-font-access/blob/main/README.md).

## Related directories

[`//third_party/blink/renderer/modules/font_access/`](../../../third_party/blink/renderer/modules/font_access/)
contains the renderer-side implementation, and
[`//third_party/blink/public/mojom/font_access`](../../../third_party/blink/public/mojom/font_access)
contains the mojom interface for this API.

## Code map

It consists of the following parts:

* `FontAccessManager`: `content::FontAccessManager` implements
`blink::mojom::FontAccessManager`, providing a way to enumerate local fonts.
It checks for the requirements to access local fonts such as user permission,
page visibility and transient user activation. Once all the requirements are
met, it returns the fonts data from `FontEnumerationCache`. In terms of code
ownership, there is one `FontAccessManager` per `StoragePartitionImpl`;
`Frame`s are bound to `FontAccessManager` via a `BindingContext`.

* `FontEnumerationCache`: `content::FontEnumerationCache` is a cache-like
object that memoizes the data about locally installed fonts as well as the
operation status, given the user locale. The data is read via
`content::FontEnumerationDataSource.GetFonts()` and is stored and served in
`ReadOnlySharedMemoryRegion`. This class is not thread-safe. Each instance
must be accessed from a single sequence, which must allow blocking.

* `FontEnumerationDataSource`: `content::FontEnumerationDataSource`, inherited
by OS-specific subclasses, reads locally installed fonts from the underlying
OS. While the subclasses of this class contains the implementation for
reading font data, this class itself does not, as it is instantiated for
non-supported OS. It is not thread-safe; all methods except for the
constructor must be used on the same sequence, and the sequence must allow
blocking I/O operations.
33 changes: 17 additions & 16 deletions third_party/blink/renderer/modules/font_access/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# Font Access API

This directory contains the implementation of the Font Access API.
This directory contains the renderer-side implementation of
[Font Access API](https://github.com/WICG/local-font-access/blob/main/README.md).

## Related directories

[`//third_party/blink/renderer/platform/fonts`](../../modules/font_access)
contains the platform implementation.
[`//content/browser/font_access/`](../../../../../content/browser/font_access/)
contains the browser-side implementation, and
[`blink/public/mojom/font_access`](../../../public/mojom/font_access) contains the
mojom interface for this API.

## APIs In this directory

This directory contains the implementation of the new and still under
development [Font Access API](https://github.com/inexorabletash/font-enumeration/blob/master/README.md).

It consists of the following parts:

* `FontMetadata`: Metadata about a font installed on the system. Provides
information that uniquely identifies a font, as well as text to present to
users in their system-configured locale.

* `FontIterator`, `FontIteratorEntry`: Mechanism providing the ability to
enumerate system-installed fonts using an asynchronous iterator.
* `NavigatorFonts`: implements `navigator.fonts`.

* `FontManager`: An object that exposes operations to access fonts. In the
future, this may be extended to add more capabilities.
* `FontManager`: An object that exposes an operation to access local fonts via
`query()` with an optional param `QueryOptions`. `FontManager` maintains a
mojo connection with browser-side, and is responsible for handling errors,
and optionally applying query filters provided by `QueryOptions`.

* `NavigatorFonts`: An entry point, available in documents and workers on
`navigator`, that lets a website enumerate locally installed system fonts.
* `FontData`: Implemented as `FontMetadata.cc`, `FontData` represents data
about a single font installed on the system. Currently, it provides basic
information such as postscript name, full name, family and style;
addiitonally, it exposes a method `blob()` for accessing additional font
blob data via Blink's `FontCache`.
(See more details [here](../../../blink/renderer/platform/fonts))

0 comments on commit 2e16b34

Please sign in to comment.