blob: 0c5fc3b8f5ac6fb80fe4c378382ae6635aee2bd3 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "mojo/public/mojom/base/file_path.mojom";
import "mojo/public/mojom/base/read_only_file.mojom";
import "mojo/public/mojom/base/shared_memory.mojom";
import "mojo/public/mojom/base/string16.mojom";
struct DWriteStringPair {
mojo_base.mojom.String16 first;
mojo_base.mojom.String16 second;
};
struct DWriteFontStyle {
uint16 font_weight;
uint8 font_slant;
uint8 font_stretch;
};
struct FallbackFamilyAndStyle {
string fallback_family_name;
uint16 weight;
uint8 width;
uint8 slant;
};
struct MapCharactersResult {
uint32 family_index;
mojo_base.mojom.String16 family_name;
uint32 mapped_length;
float scale;
DWriteFontStyle font_style;
};
enum UniqueFontLookupMode {
kRetrieveTable,
kSingleLookups
};
interface DWriteFontProxy {
// Locates the index of the specified font family within the system
// collection.
[Sync]
FindFamily(mojo_base.mojom.String16 family_name) => (uint32 out_index);
// Returns the number of font families in the system collection.
[Sync]
GetFamilyCount() => (uint32 out_count);
// Returns the list of locale and family name pairs for the font family at the
// specified index.
[Sync]
GetFamilyNames(uint32 family_index)
=> (array<DWriteStringPair> out_family_names);
// Returns the list of font file paths in the system font directory that
// contain font data for the font family at the specified index.
[Sync]
GetFontFiles(uint32 family_index)
=> (array<mojo_base.mojom.FilePath> file_paths,
array<mojo_base.mojom.ReadOnlyFile> file_handles);
// Returns which font unique name matching lookup mode is to be used on the
// current machine. On DirectWrite 10 and above, single lookups can be
// performed directly against DirectWrite API. On older DirectWrite (Windows
// 7-8.1), unique font lookups need to be performed against a shared memory
// region which contains the lookup table. Compare GetUniqueFontLookupTable()
// for lookup mode kRetrieveTable and MatchUniqueFont for
// lookup mode kSingleLookups.
[Sync]
GetUniqueFontLookupMode() => (UniqueFontLookupMode lookup_mode);
// On supported Windows versions, matches a unique PostScript or full font
// name against the installed fonts using DirectWrite API. Returns a file path
// and ttc_index from which the unique font can be instantiated. Check which
// mode is supported using GetFontUniqueNameLookupMode(). Returns empty path
// and 0 ttc index if no font is found. Must not be called if
// GetUniqueFontLookupMode() returned kRetrieveTable.
[Sync]
MatchUniqueFont(mojo_base.mojom.String16 font_unique_name)
=> (mojo_base.mojom.FilePath file_path, uint32 ttc_index);
// Synchronously returns a protobuf structured lookup list of
// (full_font_name|postscript_name) => (font_file + ttc_index) to the
// renderer process as a ReadOnlySharedMemoryRegion if it is available
// immediately without any blocking operations. Use FontTableMatcher to
// perform searches in it. If it is not available without blocking operations,
// sync_available is false and no shared memory region is provided.
[Sync]
GetUniqueNameLookupTableIfAvailable()
=> (bool sync_available,
mojo_base.mojom.ReadOnlySharedMemoryRegion? font_lookup_table);
// Asynchronously returns a protobuf structured lookup list of
// (full_font_name|postscript_name) => (font_file + ttc_index) to the
// renderer process as a ReadOnlySharedMemoryRegion. The lookup list is built
// on the first renderer call to retrieving this list. Use FontTableMatcher
// to perform searches in it. Retrieval may take up to several seconds if the
// table needs rebuilding on browser side.
GetUniqueNameLookupTable() =>
(mojo_base.mojom.ReadOnlySharedMemoryRegion? font_lookup_table);
// Locates a font family that is able to render the specified text using the
// specified style. If successful, the family_index and family_name will
// indicate which family in the system font collection can render the
// requested text and the mapped_length will indicate how many characters can
// be rendered. If no font exists that can render the text, family_index will
// be UINT32_MAX and mapped_length will indicate how many characters cannot be
// rendered by any installed font.
[Sync]
MapCharacters(mojo_base.mojom.String16 text,
DWriteFontStyle font_style,
mojo_base.mojom.String16 locale_name,
uint32 reading_direction,
mojo_base.mojom.String16 base_family_name)
=> (MapCharactersResult out);
// For a given base family name, bcp47 language tag, and codepoint to look up,
// return a font family name that is available on the system to display the
// given codepoint. This internally calls Skia's
// SkFontMgr_DirectWrite::matchFamilyStyleCharacter which executes
// IDWriteTextLayout based fallback code, which cannot be run in the renderer
// due triggering loading the DWrite system font collection.
// Use only on Windows 8.0 and earlier - otherwise better fallback API is
// available through using a proxies IDWriteFontFallback.
[Sync]
FallbackFamilyAndStyleForCodepoint(string base_family_name,
string bcp47_language_tag,
uint32 codepoint)
=> (FallbackFamilyAndStyle fallback_result);
};