blob: 8a3ff2b0f0aca72b6dd4624588af1c70e9d41985 [file] [log] [blame]
/* Copyright (c) 2013 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.
*/
/**
* This file defines the <code>PPB_TrueTypeFont_Dev</code> interface. This
* interface exposes font table data for 'sfnt' fonts on the host system. These
* include TrueType and OpenType fonts.
*/
[generate_thunk,thunk_include="ppapi/thunk/ppb_truetype_font_singleton_api.h"]
label Chrome {
M26 = 0.1
};
/**
* The PP_TrueTypeFontFamily_Dev defines generic font families. These can be
* used to create generic fonts consistent with the user's browser settings.
*/
[assert_size(4)]
enum PP_TrueTypeFontFamily_Dev {
/**
* For a description of these default families, see the
* <a href="http://www.w3.org/TR/css3-fonts/#generic-font-families">
* 3.1.1 Generic font families</a> documentation.
*/
PP_TRUETYPEFONTFAMILY_SERIF = 0,
PP_TRUETYPEFONTFAMILY_SANSSERIF = 1,
PP_TRUETYPEFONTFAMILY_CURSIVE = 2,
PP_TRUETYPEFONTFAMILY_FANTASY = 3,
PP_TRUETYPEFONTFAMILY_MONOSPACE = 4
};
/**
* The PP_TrueTypeFontStyle_Dev enum defines font styles.
*/
[assert_size(4)]
enum PP_TrueTypeFontStyle_Dev {
PP_TRUETYPEFONTSTYLE_NORMAL = 0,
PP_TRUETYPEFONTSTYLE_ITALIC = 1
};
/**
* The PP_TrueTypeFontWeight_Dev enum defines font weights.
*/
[assert_size(4)]
enum PP_TrueTypeFontWeight_Dev {
PP_TRUETYPEFONTWEIGHT_THIN = 100,
PP_TRUETYPEFONTWEIGHT_ULTRALIGHT = 200,
PP_TRUETYPEFONTWEIGHT_LIGHT = 300,
PP_TRUETYPEFONTWEIGHT_NORMAL = 400,
PP_TRUETYPEFONTWEIGHT_MEDIUM = 500,
PP_TRUETYPEFONTWEIGHT_SEMIBOLD = 600,
PP_TRUETYPEFONTWEIGHT_BOLD = 700,
PP_TRUETYPEFONTWEIGHT_ULTRABOLD = 800,
PP_TRUETYPEFONTWEIGHT_HEAVY = 900
};
/**
* The PP_TrueTypeFontWidth_Dev enum defines font widths.
*/
[assert_size(4)]
enum PP_TrueTypeFontWidth_Dev {
PP_TRUETYPEFONTWIDTH_ULTRACONDENSED = 0,
PP_TRUETYPEFONTWIDTH_EXTRACONDENSED = 1,
PP_TRUETYPEFONTWIDTH_CONDENSED = 2,
PP_TRUETYPEFONTWIDTH_SEMICONDENSED = 3,
PP_TRUETYPEFONTWIDTH_NORMAL = 4,
PP_TRUETYPEFONTWIDTH_SEMIEXPANDED = 5,
PP_TRUETYPEFONTWIDTH_EXPANDED = 6,
PP_TRUETYPEFONTWIDTH_EXTRAEXPANDED = 7,
PP_TRUETYPEFONTWIDTH_ULTRAEXPANDED = 8
};
/**
* The PP_TrueTypeFontCharset enum defines font character sets.
*/
[assert_size(4)]
enum PP_TrueTypeFontCharset_Dev {
PP_TRUETYPEFONTCHARSET_ANSI = 0,
PP_TRUETYPEFONTCHARSET_DEFAULT = 1,
PP_TRUETYPEFONTCHARSET_SYMBOL = 2,
PP_TRUETYPEFONTCHARSET_MAC = 77,
PP_TRUETYPEFONTCHARSET_SHIFTJIS = 128,
PP_TRUETYPEFONTCHARSET_HANGUL = 129,
PP_TRUETYPEFONTCHARSET_JOHAB = 130,
PP_TRUETYPEFONTCHARSET_GB2312 =134,
PP_TRUETYPEFONTCHARSET_CHINESEBIG5 = 136,
PP_TRUETYPEFONTCHARSET_GREEK = 161,
PP_TRUETYPEFONTCHARSET_TURKISH = 162,
PP_TRUETYPEFONTCHARSET_VIETNAMESE = 163,
PP_TRUETYPEFONTCHARSET_HEBREW = 177,
PP_TRUETYPEFONTCHARSET_ARABIC = 178,
PP_TRUETYPEFONTCHARSET_BALTIC = 186,
PP_TRUETYPEFONTCHARSET_RUSSIAN = 204,
PP_TRUETYPEFONTCHARSET_THAI = 222,
PP_TRUETYPEFONTCHARSET_EASTEUROPE = 238,
PP_TRUETYPEFONTCHARSET_OEM = 255
};
/**
* The <code>PP_TrueTypeFontDesc</code> struct describes a TrueType font. It is
* passed to Create(), and returned by Describe().
*/
[assert_size(40)]
struct PP_TrueTypeFontDesc_Dev {
/**
* Font family name as a string. This can also be an undefined var, in which
* case the generic family will be obeyed. If the face is not available on
* the system, the browser will attempt to do font fallback or pick a default
* font.
*/
PP_Var family;
/** This value specifies a generic font family. If a family name string is
* provided when creating a font, this is ignored. */
PP_TrueTypeFontFamily_Dev generic_family;
/** This value specifies the font style. */
PP_TrueTypeFontStyle_Dev style;
/** This value specifies the font weight. */
PP_TrueTypeFontWeight_Dev weight;
/** This value specifies the font width, for condensed or expanded fonts */
PP_TrueTypeFontWidth_Dev width;
/** This value specifies a character set. */
PP_TrueTypeFontCharset_Dev charset;
/**
* Ensure that this struct is 40-bytes wide by padding the end. In some
* compilers, PP_Var is 8-byte aligned, so those compilers align this struct
* on 8-byte boundaries as well and pad it to 16 bytes even without this
* padding attribute. This padding makes its size consistent across
* compilers.
*/
int32_t padding;
};
interface PPB_TrueTypeFont_Dev {
/**
* Gets an array of TrueType font family names available on the host.
* These names can be used to create a font from a specific family.
*
* @param[in] instance A <code>PP_Instance</code> requesting the family names.
* @param[in] output A <code>PP_ArrayOutput</code> to hold the names.
* The output is an array of PP_Vars, each holding a family name.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion of GetFontFamilies.
*
* @return If >= 0, the number of family names returned, otherwise an error
* code from <code>pp_errors.h</code>.
*/
[singleton,api=PPB_TrueTypeFont_Singleton_API]
int32_t GetFontFamilies([in] PP_Instance instance,
[in] PP_ArrayOutput output,
[in] PP_CompletionCallback callback);
/**
* Gets an array of TrueType font descriptors for a given font family. These
* descriptors can be used to create a font in that family and matching the
* descriptor attributes.
*
* @param[in] instance A <code>PP_Instance</code> requesting the font
* descriptors.
* @param[in] family A <code>PP_Var</code> holding a string specifying the
* font family.
* @param[in] output A <code>PP_ArrayOutput</code> to hold the descriptors.
* The output is an array of <code>PP_TrueTypeFontDesc</code> structs. Each
* desc contains a PP_Var for the family name which must be released.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion of GetFontsInFamily.
*
* @return If >= 0, the number of font descriptors returned, otherwise an
* error code from <code>pp_errors.h</code>.
*/
[singleton,api=PPB_TrueTypeFont_Singleton_API]
int32_t GetFontsInFamily([in] PP_Instance instance,
[in] PP_Var family,
[in] PP_ArrayOutput output,
[in] PP_CompletionCallback callback);
/**
* Creates a font resource matching the given font characteristics. The
* resource id will be non-zero on success, or zero on failure.
*
* @param[in] instance A <code>PP_Instance</code> to own the font.
* @param[in] desc A pointer to a <code>PP_TrueTypeFontDesc</code> describing
* the font.
*/
PP_Resource Create([in] PP_Instance instance,
[in] PP_TrueTypeFontDesc_Dev desc);
/**
* Determines if the given resource is a TrueType font.
*
* @param[in] resource A <code>PP_Resource</code> corresponding to a resource.
*
* @return <code>PP_TRUE</code> if the resource is a
* <code>PPB_TrueTypeFont_Dev</code>, <code>PP_FALSE</code> otherwise.
*/
PP_Bool IsTrueTypeFont([in] PP_Resource resource);
/**
* Returns a description of the given font resource. This description may
* differ from the description passed to Create, reflecting the host's font
* matching and fallback algorithm.
*
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
* @param[out] desc A pointer to a <code>PP_TrueTypeFontDesc</code> to hold
* the description. The internal 'family' PP_Var should be set to undefined,
* since this function overwrites the <code>PP_TrueTypeFontDesc</code>. After
* successful completion, the family will be set to a PP_Var with a single
* reference, which the caller must release after use.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion of Describe.
*
* @return A return code from <code>pp_errors.h</code>. If an error code is
* returned, the <code>PP_TrueTypeFontDesc</code> will be unchanged.
*/
int32_t Describe([in] PP_Resource font,
[out] PP_TrueTypeFontDesc_Dev desc,
[in] PP_CompletionCallback callback);
/**
* Gets an array of identifying tags for each table in the font. These tags
* can be used to request specific tables using GetTable.
*
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
* @param[in] output A <code>PP_ArrayOutput</code> to hold the tags.
* The output is an array of 4 byte integers, each representing a table tag.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion of GetTableTags.
*
* @return If >= 0, the number of table tags returned, otherwise an error
* code from <code>pp_errors.h</code>.
*/
int32_t GetTableTags([in] PP_Resource font,
[in] PP_ArrayOutput output,
[in] PP_CompletionCallback callback);
/**
* Copies the given font table into client memory.
*
* @param[in] font A <code>PP_Resource</code> corresponding to a font.
* @param[in] table A 4 byte value indicating which table to copy.
* For example, 'glyf' will cause the outline table to be copied into the
* output array. A zero tag value will cause the entire font to be copied.
* @param[in] offset The offset into the font table. Passing an offset
* greater than or equal to the table size will succeed with 0 bytes copied.
* @param[in] max_data_length The maximum number of bytes to transfer from
* <code>offset</code>.
* @param[in] output A <code>PP_ArrayOutput</code> to hold the font data.
* The output is an array of bytes.
* @param[in] callback A <code>PP_CompletionCallback</code> to be called upon
* completion of GetTable.
*
* @return If >= 0, the table size in bytes, otherwise an error code from
* <code>pp_errors.h</code>.
*/
int32_t GetTable([in] PP_Resource font,
[in] uint32_t table,
[in] int32_t offset,
[in] int32_t max_data_length,
[in] PP_ArrayOutput output,
[in] PP_CompletionCallback callback);
};