naiveproxy/components/services/font/public/interfaces/font_service.mojom

98 lines
3.6 KiB
Plaintext
Raw Normal View History

2018-12-10 05:59:24 +03:00
// Copyright 2014 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 font_service.mojom;
import "mojo/public/mojom/base/file.mojom";
enum TypefaceSlant {
ROMAN = 0,
ITALIC = 1,
OBLIQUE = 2,
};
struct TypefaceStyle {
uint16 weight;
uint8 width;
TypefaceSlant slant;
};
// A reference to specific font on the font service.
struct FontIdentity {
uint32 id;
int32 ttc_index;
// TODO(erg): So the string is supposed to be a path. However, the current
// chrome code goes out of its way to send this to the renderer process, and
// it is passed to blink, even though the openStream() IPC in chrome uses the
// id number instead. Do more investigation about what we need to do to plug
// this system path leak.
string str_representation;
};
enum RenderStyleSwitch {
OFF = 0,
ON = 1,
NO_PREFERENCE = 2,
};
struct FontRenderStyle {
RenderStyleSwitch use_bitmaps; // use embedded bitmap strike if possible
RenderStyleSwitch use_autohint; // use 'auto' hinting (FreeType specific)
RenderStyleSwitch use_hinting; // hint glyphs to the pixel grid
uint8 hint_style; // level of hinting, 0..3
RenderStyleSwitch use_antialias; // antialias glyph shapes
// use subpixel rendering (partially-filled pixels)
RenderStyleSwitch use_subpixel_rendering;
// use subpixel positioning (fractional X positions for glyphs)
RenderStyleSwitch use_subpixel_positioning;
};
// Loads and resolves fonts & returns additional information accessible from
// FontConfig only outside the sandbox.
//
// We still need to load fonts from within a sandboxed process. We set
// up a service to match fonts and load them. This service needs full
// filesystem access because fonts can be configured to live anywhere on the
// filesystem. The FontService takes a request for a font by family name
// and resolves it, hiding all filesystem details.
interface FontService {
// Returns the best match for |family_name| and |style|. On error, returns a
// null |identity|.
MatchFamilyName(string family_name, TypefaceStyle style) =>
(FontIdentity? identity, string family_name, TypefaceStyle style);
// Returns a handle to the raw font specified by |id_number|.
OpenStream(uint32 id_number) => (mojo_base.mojom.File? font_handle);
// Returns a fallback FontIdentity and Typeface style for the given character
// and locale. If no fallback font can be found, returns a null identity.
FallbackFontForCharacter(uint32 character, string locale) =>
(FontIdentity? identity,
string family_name,
bool is_bold,
bool is_italic);
// Fill out the given WebFontRenderStyle with the user's preferences for
// rendering the given font at the given size (in pixels), given weight
// (is_bold or not), and given slant (is_italic or not).
FontRenderStyleForStrike(string family,
uint32 size,
bool is_italic,
bool is_bold,
float device_scale_factor) =>
(FontRenderStyle? font_render_style);
// Matches a font uniquely by postscript name or full font name.
// Used in Blink for @font-face { src: local(arg) } matching.
// Provide full_postscript_name_or_full_font_name encoded as UTF-8.
MatchFontByPostscriptNameOrFullFontName(
string postscript_name_or_full_font_name) =>
(FontIdentity? identity);
// PPAPI Specific font call to match a font family and charset.
MatchFontWithFallback(string family, bool is_bold, bool is_italic,
uint32 charset, uint32 fallback_family_type) =>
(mojo_base.mojom.File? font_file_handle);
};