blob: 05147cc25e3167f1b94ca14a93cb45ec2dfeda3a [file] [log] [blame]
Behdad Esfahbod55d42fd2017-01-19 19:35:48 -08001/*
2 * Copyright © 2017 Google, Inc.
3 *
4 * This is part of HarfBuzz, a text shaping library.
5 *
6 * Permission is hereby granted, without written agreement and without
7 * license or royalty fees, to use, copy, modify, and distribute this
8 * software and its documentation for any purpose, provided that the
9 * above copyright notice and the following two paragraphs appear in
10 * all copies of this software.
11 *
12 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16 * DAMAGE.
17 *
18 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
21 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23 *
24 * Red Hat Author(s): Behdad Esfahbod
25 */
26
Khaled Hosny7b9e23f2021-02-10 23:37:43 +020027#if !defined(HB_OT_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR)
Behdad Esfahbod55d42fd2017-01-19 19:35:48 -080028#error "Include <hb-ot.h> instead."
29#endif
30
31#ifndef HB_OT_VAR_H
32#define HB_OT_VAR_H
33
34#include "hb.h"
35
36HB_BEGIN_DECLS
37
Nathan Willis938add72019-04-11 19:45:12 +010038/**
Khaled Hosny3d7a3612020-12-30 23:58:37 +020039 * HB_OT_TAG_VAR_AXIS_ITALIC:
40 *
41 * Registered tag for the roman/italic axis.
Nathan Willis938add72019-04-11 19:45:12 +010042 */
Behdad Esfahbod7a860f62017-01-22 19:52:09 -080043#define HB_OT_TAG_VAR_AXIS_ITALIC HB_TAG('i','t','a','l')
Nathan Willis938add72019-04-11 19:45:12 +010044
45/**
Khaled Hosny3d7a3612020-12-30 23:58:37 +020046 * HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE:
Nathan Willis938add72019-04-11 19:45:12 +010047 *
Khaled Hosny3d7a3612020-12-30 23:58:37 +020048 * Registered tag for the optical-size axis.
Nathan Willis938add72019-04-11 19:45:12 +010049 * <note>Note: The optical-size axis supersedes the OpenType `size` feature.</note>
50 */
Behdad Esfahbod7a860f62017-01-22 19:52:09 -080051#define HB_OT_TAG_VAR_AXIS_OPTICAL_SIZE HB_TAG('o','p','s','z')
Nathan Willis938add72019-04-11 19:45:12 +010052
53/**
Khaled Hosny3d7a3612020-12-30 23:58:37 +020054 * HB_OT_TAG_VAR_AXIS_SLANT:
55 *
56 * Registered tag for the slant axis
Nathan Willis938add72019-04-11 19:45:12 +010057 */
Behdad Esfahbod7a860f62017-01-22 19:52:09 -080058#define HB_OT_TAG_VAR_AXIS_SLANT HB_TAG('s','l','n','t')
Nathan Willis938add72019-04-11 19:45:12 +010059
60/**
Khaled Hosny3d7a3612020-12-30 23:58:37 +020061 * HB_OT_TAG_VAR_AXIS_WIDTH:
62 *
63 * Registered tag for the width axis.
Nathan Willis938add72019-04-11 19:45:12 +010064 */
Behdad Esfahbod7a860f62017-01-22 19:52:09 -080065#define HB_OT_TAG_VAR_AXIS_WIDTH HB_TAG('w','d','t','h')
Nathan Willis938add72019-04-11 19:45:12 +010066
67/**
Khaled Hosny3d7a3612020-12-30 23:58:37 +020068 * HB_OT_TAG_VAR_AXIS_WEIGHT:
69 *
70 * Registered tag for the weight axis.
Nathan Willis938add72019-04-11 19:45:12 +010071 */
Behdad Esfahbod7a860f62017-01-22 19:52:09 -080072#define HB_OT_TAG_VAR_AXIS_WEIGHT HB_TAG('w','g','h','t')
73
Behdad Esfahbod55d42fd2017-01-19 19:35:48 -080074
75/*
76 * fvar / avar
77 */
78
Behdad Esfahbod55d42fd2017-01-19 19:35:48 -080079HB_EXTERN hb_bool_t
80hb_ot_var_has_data (hb_face_t *face);
81
Behdad Esfahbod587d49f2018-11-19 14:27:19 -050082
83/*
84 * Variation axes.
85 */
86
Behdad Esfahbod422c0c32017-01-20 19:14:54 -080087
Behdad Esfahbod785982b2017-01-20 19:57:27 -080088HB_EXTERN unsigned int
89hb_ot_var_get_axis_count (hb_face_t *face);
90
Behdad Esfahbodeab5d152018-11-20 11:33:33 -050091/**
Behdad Esfahbod1a2eb102018-11-19 12:36:56 -050092 * hb_ot_var_axis_flags_t:
93 * @HB_OT_VAR_AXIS_FLAG_HIDDEN: The axis should not be exposed directly in user interfaces.
94 *
Khaled Hosny3d7a3612020-12-30 23:58:37 +020095 * Flags for #hb_ot_var_axis_info_t.
96 *
Behdad Esfahboddc41ece2018-11-29 11:53:53 -050097 * Since: 2.2.0
Behdad Esfahbod1a2eb102018-11-19 12:36:56 -050098 */
99typedef enum { /*< flags >*/
Behdad Esfahbod736897d2018-11-20 11:40:43 -0500100 HB_OT_VAR_AXIS_FLAG_HIDDEN = 0x00000001u,
101
Khaled Hosnya3fe43a2020-12-30 21:58:43 +0200102 /*< private >*/
Ebrahim Byagowidd9a0ed2019-07-24 00:47:19 +0430103 _HB_OT_VAR_AXIS_FLAG_MAX_VALUE= HB_TAG_MAX_SIGNED /*< skip >*/
Behdad Esfahbod1a2eb102018-11-19 12:36:56 -0500104} hb_ot_var_axis_flags_t;
105
Behdad Esfahbodf48bb9a2018-11-20 20:40:55 -0500106/**
107 * hb_ot_var_axis_info_t:
Nathan Willis938add72019-04-11 19:45:12 +0100108 * @axis_index: Index of the axis in the variation-axis array
109 * @tag: The #hb_tag_t tag identifying the design variation of the axis
110 * @name_id: The `name` table Name ID that provides display names for the axis
111 * @flags: The #hb_ot_var_axis_flags_t flags for the axis
luz paze2e30502022-01-16 07:00:53 -0500112 * @min_value: The minimum value on the variation axis that the font covers
Nathan Willis938add72019-04-11 19:45:12 +0100113 * @default_value: The position on the variation axis corresponding to the font's defaults
114 * @max_value: The maximum value on the variation axis that the font covers
115 *
116 * Data type for holding variation-axis values.
117 *
118 * The minimum, default, and maximum values are in un-normalized, user scales.
119 *
120 * <note>Note: at present, the only flag defined for @flags is
121 * #HB_OT_VAR_AXIS_FLAG_HIDDEN.</note>
Behdad Esfahbodf48bb9a2018-11-20 20:40:55 -0500122 *
Behdad Esfahboddc41ece2018-11-29 11:53:53 -0500123 * Since: 2.2.0
Behdad Esfahbodf48bb9a2018-11-20 20:40:55 -0500124 */
Khaled Hosnyb8b13012020-12-23 00:22:56 +0200125typedef struct hb_ot_var_axis_info_t {
Behdad Esfahbodf48bb9a2018-11-20 20:40:55 -0500126 unsigned int axis_index;
127 hb_tag_t tag;
128 hb_ot_name_id_t name_id;
129 hb_ot_var_axis_flags_t flags;
130 float min_value;
131 float default_value;
132 float max_value;
133 /*< private >*/
134 unsigned int reserved;
135} hb_ot_var_axis_info_t;
136
137HB_EXTERN unsigned int
138hb_ot_var_get_axis_infos (hb_face_t *face,
139 unsigned int start_offset,
140 unsigned int *axes_count /* IN/OUT */,
141 hb_ot_var_axis_info_t *axes_array /* OUT */);
142
143HB_EXTERN hb_bool_t
144hb_ot_var_find_axis_info (hb_face_t *face,
145 hb_tag_t axis_tag,
146 hb_ot_var_axis_info_t *axis_info);
147
Behdad Esfahbod587d49f2018-11-19 14:27:19 -0500148
149/*
150 * Named instances.
151 */
152
153HB_EXTERN unsigned int
154hb_ot_var_get_named_instance_count (hb_face_t *face);
155
156HB_EXTERN hb_ot_name_id_t
157hb_ot_var_named_instance_get_subfamily_name_id (hb_face_t *face,
158 unsigned int instance_index);
159
160HB_EXTERN hb_ot_name_id_t
161hb_ot_var_named_instance_get_postscript_name_id (hb_face_t *face,
162 unsigned int instance_index);
163
164HB_EXTERN unsigned int
165hb_ot_var_named_instance_get_design_coords (hb_face_t *face,
166 unsigned int instance_index,
167 unsigned int *coords_length, /* IN/OUT */
Behdad Esfahbodbe1828d2018-11-20 11:16:23 -0500168 float *coords /* OUT */);
Behdad Esfahbod587d49f2018-11-19 14:27:19 -0500169
170
171/*
172 * Conversions.
173 */
174
Behdad Esfahbod5ec96d32017-01-22 18:52:00 -0800175HB_EXTERN void
176hb_ot_var_normalize_variations (hb_face_t *face,
177 const hb_variation_t *variations, /* IN */
178 unsigned int variations_length,
179 int *coords, /* OUT */
180 unsigned int coords_length);
181
182HB_EXTERN void
183hb_ot_var_normalize_coords (hb_face_t *face,
184 unsigned int coords_length,
185 const float *design_coords, /* IN */
186 int *normalized_coords /* OUT */);
Behdad Esfahbod785982b2017-01-20 19:57:27 -0800187
Behdad Esfahbod55d42fd2017-01-19 19:35:48 -0800188
189HB_END_DECLS
190
191#endif /* HB_OT_VAR_H */