// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. module font_data_service.mojom; import "mojo/public/mojom/base/file.mojom"; import "mojo/public/mojom/base/shared_memory.mojom"; enum TypefaceSlant { kRoman = 0, kItalic = 1, kOblique = 2, }; struct TypefaceStyle { uint16 weight; uint8 width; TypefaceSlant slant; }; struct Coordinate { uint32 axis; float value; }; struct VariationPosition { array coordinates; uint16 coordinateCount; }; struct TypefaceFile { mojo_base.mojom.ReadOnlyFile file_handle; // Represents a unique identifier for a font_file that the receiver of this // result can use to avoid remapping the same file multiple times. uint64 id; }; // Represents the different type of data that can recreate the typeface. union TypefaceData { // Font data mapped to a shared memory region. mojo_base.mojom.ReadOnlySharedMemoryRegion region; // A file handle to the font. TypefaceFile font_file; }; struct MatchFamilyNameResult { // The data used to recreate the typeface. TypefaceData typeface_data; // The index of the matching typeface, or zero if typeface is not a // collection. int32 ttc_index; // Variable font properties. VariationPosition? variation_position; // Flags to indicate that bold/oblique are being internally simulated. bool synthetic_bold; bool synthetic_oblique; }; // Loads and resolves fonts from the renderer to the browser (embedder). Takes // requests by font family name and style and resolves it with the matching // typeface. // // Created on renderer process startup when constructing the font manager. interface FontDataService { // Returns the best match for |family_name| and |style|. // On error, returns null. [Sync] MatchFamilyName(string family_name, TypefaceStyle style) => (MatchFamilyNameResult? result); // Returns the best match for |family_name| and |style| for a given // |character| in the languages described by |bcp47s|. // On error, returns null. [Sync] MatchFamilyNameCharacter( string family_name, TypefaceStyle style, array bcp47s, int32 character) => (MatchFamilyNameResult? result); // Returns all the available font families on the system. Usage of this // function is strongly discouraged as it iterates over all installed fonts. [Sync] GetAllFamilyNames() => (array result); // Returns a typeface matching |family_name| and |style|, or the default // typeface if |family_name| is null. Use of this function is discouraged, // prefer |MatchFamilyName*|. [Sync] LegacyMakeTypeface(string? family_name, TypefaceStyle style) => (MatchFamilyNameResult? result); // Returns a match for a font identified by its PostScript name or full font // name (as used by @font-face src: local()). Returns null if not found or // if local font matching is not supported on the current platform. [Sync] MatchLocalFont(string font_unique_name) => (MatchFamilyNameResult? result); };