/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
#ifndef mozilla_gfx_FontationsGlueGenerated_h
#define mozilla_gfx_FontationsGlueGenerated_h
#include <cstdarg>
#include <cstdint>
#include <cstdlib>
#include <ostream>
#include <new>
#include "nsStringFwd.h"
#include "nsTArrayForwardDeclare.h"
namespace mozilla {
namespace gfx {
/// Type used to represent a Skrifa FontRef in C++ as an opaque struct.
struct SkrifaFontRef;
struct SkrifaGlyphMetrics;
struct SkrifaLocation;
/// Type to represent a reference to a table in a Skrifa font.
/// The data is immutable and remains owned by the Skrifa font ref.
struct SkrifaFontTable {
uintptr_t length;
const uint8_t *data;
};
struct SkrifaMetrics {
float scale_factor;
float max_advance;
float ave_char_width;
float max_ascent;
float max_descent;
float external_leading;
float underline_offset;
float underline_size;
float strikeout_offset;
float strikeout_size;
float x_height;
float cap_height;
float x_min;
float y_min;
float x_max;
float y_max;
};
using BoundingBox = Rect;
extern "C" {
/// Create a SkrifaFontRef object for the given font data; returns null on failure.
SkrifaFontRef *skrifa_font_new(const uint8_t *data, uintptr_t length);
/// Create a SkrifaFontRef object for the face with the given index in a collection; returns null on failure.
SkrifaFontRef *skrifa_font_new_from_index(const uint8_t *data,
uintptr_t length,
uint32_t index);
/// Delete a SkrifaFontRef object.
void skrifa_font_delete(SkrifaFontRef *font);
/// Map the given unicode codepoint to a glyph ID; returns 0 for unsupported codepoints.
uint32_t skrifa_font_map_char_to_glyph(const SkrifaFontRef *font, uint32_t unicode);
/// Get a name (identified by OpenType name ID) from a Skrifa font as a Gecko string.
/// Returns false if unable to find a name for the given name_id.
bool skrifa_font_get_preferred_name(const SkrifaFontRef *font,
uint16_t name_id,
nsCString *ret_val);
/// Get a (read-only) reference to the table with the given tag.
/// Returns an empty (0-length) table if the tag is not present.
SkrifaFontTable skrifa_font_get_table(const SkrifaFontRef *font, uint32_t tag);
/// Check whether a given table is present.
/// Note that a table that appears in the directory, but has zero length,
/// is considered to be missing.
bool skrifa_font_has_table(const SkrifaFontRef *font, uint32_t tag);
SkrifaLocation *skrifa_font_resolve_variations_to_location(const SkrifaFontRef *font,
const nsTArray<gfxFontVariation> *settings);
void skrifa_location_delete(SkrifaLocation *location);
uintptr_t skrifa_font_axes_count(const SkrifaFontRef *font);
uintptr_t skrifa_font_copy_axes(const SkrifaFontRef *font,
nsTArray<gfxFontVariationAxis> *axes,
bool include_hidden);
uintptr_t skrifa_font_instances_count(const SkrifaFontRef *font);
uintptr_t skrifa_font_instance_settings_count(const SkrifaFontRef *font, uintptr_t index);
bool skrifa_font_copy_instance(const SkrifaFontRef *font,
uintptr_t index,
nsCString *name,
nsTArray<gfxFontVariation> *settings);
void skrifa_font_get_metrics(const SkrifaFontRef *font,
float size,
const SkrifaLocation *location,
SkrifaMetrics *result);
SkrifaGlyphMetrics *skrifa_font_create_glyph_metrics(const SkrifaFontRef *font,
float size,
const SkrifaLocation *location);
void skrifa_glyph_metrics_delete(SkrifaGlyphMetrics *metrics);
float skrifa_metrics_get_glyph_advance(const SkrifaGlyphMetrics *glyph_metrics, uint32_t gid);
bool skrifa_metrics_get_glyph_bounds(const SkrifaGlyphMetrics *glyph_metrics,
uint32_t gid,
BoundingBox *bbox);
} // extern "C"
} // namespace gfx
} // namespace mozilla
#endif // mozilla_gfx_FontationsGlueGenerated_h