Skip to content

Commit

Permalink
[style] Hide behind HB_EXPERIMENTAL_API compile flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ebraminio committed Jun 4, 2020
1 parent d54de56 commit 759df46
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 43 deletions.
6 changes: 0 additions & 6 deletions docs/harfbuzz-sections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,6 @@ hb_shape_plan_set_user_data
hb_shape_plan_t
</SECTION>

<SECTION>
<FILE>hb-style</FILE>
hb_style_tag_t
hb_style_get_value
</SECTION>

<SECTION>
<FILE>hb-unicode</FILE>
HB_UNICODE_MAX
Expand Down
1 change: 1 addition & 0 deletions src/gen-def.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
hb_draw_funcs_set_line_to_func
hb_draw_funcs_set_move_to_func
hb_draw_funcs_set_quadratic_to_func
hb_style_get_value
hb_font_get_var_coords_design
hb_ot_layout_closure_lookups
hb_ot_layout_closure_features""".splitlines ()
Expand Down
40 changes: 38 additions & 2 deletions src/hb-style.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "hb.hh"

#ifndef HB_NO_STYLE
#ifdef HB_EXPERIMENTAL_API

#include "hb-aat-fdsc-table.hh"
#include "hb-ot-var-avar-table.hh"
Expand All @@ -35,6 +36,39 @@
#include "hb-ot-post-table.hh"
#include "hb-ot-face.hh"

/**
* hb_style_tag_t:
* @HB_STYLE_TAG_ITALIC: Used to vary between non-italic and italic.
* A value of 0 can be interpreted as "Roman" (non-italic); a value of 1 can
* be interpreted as (fully) italic.
* @HB_STYLE_TAG_OPTICAL_SIZE: Used to vary design to suit different text sizes.
* Non-zero. Values can be interpreted as text size, in points.
* @HB_STYLE_TAG_SLANT: Used to vary between upright and slanted text. Values
* must be greater than -90 and less than +90. Values can be interpreted as
* the angle, in counter-clockwise degrees, of oblique slant from whatever the
* designer considers to be upright for that font design.
* @HB_STYLE_TAG_WIDTH: Used to vary width of text from narrower to wider.
* Non-zero. Values can be interpreted as a percentage of whatever the font
* designer considers “normal width” for that font design.
* @HB_STYLE_TAG_WEIGHT: Used to vary stroke thicknesses or other design details
* to give variation from lighter to blacker. Values can be interpreted in direct
* comparison to values for usWeightClass in the OS/2 table,
* or the CSS font-weight property.
*
* Defined by https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg
*
* Since: EXPERIMENTAL
**/
typedef enum {
HB_STYLE_TAG_ITALIC = HB_TAG ('i','t','a','l'),
HB_STYLE_TAG_OPTICAL_SIZE = HB_TAG ('o','p','s','z'),
HB_STYLE_TAG_SLANT = HB_TAG ('s','l','n','t'),
HB_STYLE_TAG_WIDTH = HB_TAG ('w','d','t','h'),
HB_STYLE_TAG_WEIGHT = HB_TAG ('w','g','h','t'),

_HB_STYLE_TAG_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
} hb_style_tag_t;

/**
* hb_style_get_value:
* @font: a #hb_font_t object.
Expand All @@ -46,11 +80,12 @@
*
* Returns: Corresponding axis or default value to a style tag.
*
* Since: REPLACEME
* Since: EXPERIMENTAL
**/
float
hb_style_get_value (hb_font_t *font, hb_style_tag_t style_tag)
hb_style_get_value (hb_font_t *font, hb_tag_t tag)
{
hb_style_tag_t style_tag = (hb_style_tag_t) tag;
hb_face_t *face = font->face;

#ifndef HB_NO_VAR
Expand Down Expand Up @@ -111,3 +146,4 @@ hb_style_get_value (hb_font_t *font, hb_style_tag_t style_tag)
}

#endif
#endif
38 changes: 3 additions & 35 deletions src/hb-style.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,42 +33,10 @@

HB_BEGIN_DECLS


/**
* hb_style_tag_t:
* @HB_STYLE_TAG_ITALIC: Used to vary between non-italic and italic.
* A value of 0 can be interpreted as "Roman" (non-italic); a value of 1 can
* be interpreted as (fully) italic.
* @HB_STYLE_TAG_OPTICAL_SIZE: Used to vary design to suit different text sizes.
* Non-zero. Values can be interpreted as text size, in points.
* @HB_STYLE_TAG_SLANT: Used to vary between upright and slanted text. Values
* must be greater than -90 and less than +90. Values can be interpreted as
* the angle, in counter-clockwise degrees, of oblique slant from whatever the
* designer considers to be upright for that font design.
* @HB_STYLE_TAG_WIDTH: Used to vary width of text from narrower to wider.
* Non-zero. Values can be interpreted as a percentage of whatever the font
* designer considers “normal width” for that font design.
* @HB_STYLE_TAG_WEIGHT: Used to vary stroke thicknesses or other design details
* to give variation from lighter to blacker. Values can be interpreted in direct
* comparison to values for usWeightClass in the OS/2 table,
* or the CSS font-weight property.
*
* Defined by https://docs.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg
*
* Since: REPLACEME
**/
typedef enum {
HB_STYLE_TAG_ITALIC = HB_TAG ('i','t','a','l'),
HB_STYLE_TAG_OPTICAL_SIZE = HB_TAG ('o','p','s','z'),
HB_STYLE_TAG_SLANT = HB_TAG ('s','l','n','t'),
HB_STYLE_TAG_WIDTH = HB_TAG ('w','d','t','h'),
HB_STYLE_TAG_WEIGHT = HB_TAG ('w','g','h','t'),

_HB_STYLE_TAG_MAX_VALUE = HB_TAG_MAX_SIGNED /*< skip >*/
} hb_style_tag_t;

#ifdef HB_EXPERIMENTAL_API
HB_EXTERN float
hb_style_get_value (hb_font_t *font, hb_style_tag_t style_tag);
hb_style_get_value (hb_font_t *font, hb_tag_t style_tag);
#endif

HB_END_DECLS

Expand Down
2 changes: 2 additions & 0 deletions test/api/test-ot-face.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ test_font (hb_font_t *font, hb_codepoint_t cp)
hb_ot_name_get_utf16 (face, cp, NULL, NULL, NULL);
hb_ot_name_get_utf32 (face, cp, NULL, NULL, NULL);

#if 0
hb_style_get_value (font, HB_STYLE_TAG_ITALIC);
hb_style_get_value (font, HB_STYLE_TAG_OPTICAL_SIZE);
hb_style_get_value (font, HB_STYLE_TAG_SLANT);
hb_style_get_value (font, HB_STYLE_TAG_WIDTH);
hb_style_get_value (font, HB_STYLE_TAG_WEIGHT);
#endif

hb_ot_var_get_axis_count (face);
hb_ot_var_get_axis_infos (face, 0, NULL, NULL);
Expand Down
10 changes: 10 additions & 0 deletions test/api/test-style.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/

#ifdef HB_EXPERIMENTAL_API
#include "hb-test.h"

#include <hb.h>
Expand All @@ -30,6 +31,12 @@

#define assert_cmpfloat(n1, n2) g_assert_cmpint ((int) (n1 * 100.f), ==, (int) (n2 * 100.f))

#define HB_STYLE_TAG_ITALIC HB_TAG ('i','t','a','l')
#define HB_STYLE_TAG_OPTICAL_SIZE HB_TAG ('o','p','s','z')
#define HB_STYLE_TAG_SLANT HB_TAG ('s','l','n','t')
#define HB_STYLE_TAG_WIDTH HB_TAG ('w','d','t','h')
#define HB_STYLE_TAG_WEIGHT HB_TAG ('w','g','h','t')

static void
test_empty_face (void)
{
Expand Down Expand Up @@ -178,3 +185,6 @@ main (int argc, char **argv)

return hb_test_run ();
}
#else
int main () {}
#endif

0 comments on commit 759df46

Please sign in to comment.