Imported Upstream version 2.3.1
[platform/upstream/harfbuzz.git] / src / hb-ot-math.cc
index 1667a7d..bd31bf5 100644 (file)
  * Igalia Author(s): Frédéric Wang
  */
 
-#include "hb-open-type-private.hh"
+#include "hb-open-type.hh"
 
-#include "hb-ot-layout-private.hh"
+#include "hb-ot-face.hh"
 #include "hb-ot-math-table.hh"
 
-static inline const OT::MATH&
-_get_math (hb_face_t *face)
-{
-  if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH);
-  hb_ot_layout_t * layout = hb_ot_layout_from_face (face);
-  return *(layout->math.get ());
-}
+
+/**
+ * SECTION:hb-ot-math
+ * @title: hb-ot-math
+ * @short_description: OpenType Math information
+ * @include: hb-ot.h
+ *
+ * Functions for fetching mathematics layout data from OpenType fonts.
+ **/
+
 
 /*
  * OT::MATH
@@ -55,7 +58,7 @@ _get_math (hb_face_t *face)
 hb_bool_t
 hb_ot_math_has_data (hb_face_t *face)
 {
-  return &_get_math (face) != &Null(OT::MATH);
+  return face->table.MATH->has_data ();
 }
 
 /**
@@ -77,8 +80,7 @@ hb_position_t
 hb_ot_math_get_constant (hb_font_t *font,
                         hb_ot_math_constant_t constant)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_constant(constant, font);
+  return font->face->table.MATH->get_constant(constant, font);
 }
 
 /**
@@ -94,8 +96,7 @@ hb_position_t
 hb_ot_math_get_glyph_italics_correction (hb_font_t *font,
                                         hb_codepoint_t glyph)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_math_glyph_info().get_italics_correction (glyph, font);
+  return font->face->table.MATH->get_glyph_info().get_italics_correction (glyph, font);
 }
 
 /**
@@ -111,8 +112,7 @@ hb_position_t
 hb_ot_math_get_glyph_top_accent_attachment (hb_font_t *font,
                                            hb_codepoint_t glyph)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_math_glyph_info().get_top_accent_attachment (glyph, font);
+  return font->face->table.MATH->get_glyph_info().get_top_accent_attachment (glyph, font);
 }
 
 /**
@@ -128,8 +128,7 @@ hb_bool_t
 hb_ot_math_is_glyph_extended_shape (hb_face_t *face,
                                    hb_codepoint_t glyph)
 {
-  const OT::MATH &math = _get_math (face);
-  return math.get_math_glyph_info().is_extended_shape (glyph);
+  return face->table.MATH->get_glyph_info().is_extended_shape (glyph);
 }
 
 /**
@@ -155,8 +154,10 @@ hb_ot_math_get_glyph_kerning (hb_font_t *font,
                              hb_ot_math_kern_t kern,
                              hb_position_t correction_height)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_math_glyph_info().get_kerning (glyph, kern, correction_height, font);
+  return font->face->table.MATH->get_glyph_info().get_kerning (glyph,
+                                                              kern,
+                                                              correction_height,
+                                                              font);
 }
 
 /**
@@ -186,11 +187,10 @@ hb_ot_math_get_glyph_variants (hb_font_t *font,
                               unsigned int *variants_count, /* IN/OUT */
                               hb_ot_math_glyph_variant_t *variants /* OUT */)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_math_variants().get_glyph_variants (glyph, direction, font,
-                                                     start_offset,
-                                                     variants_count,
-                                                     variants);
+  return font->face->table.MATH->get_variants().get_glyph_variants (glyph, direction, font,
+                                                                   start_offset,
+                                                                   variants_count,
+                                                                   variants);
 }
 
 /**
@@ -211,8 +211,7 @@ hb_position_t
 hb_ot_math_get_min_connector_overlap (hb_font_t *font,
                                      hb_direction_t direction)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_math_variants().get_min_connector_overlap (direction, font);
+  return font->face->table.MATH->get_variants().get_min_connector_overlap (direction, font);
 }
 
 /**
@@ -244,10 +243,11 @@ hb_ot_math_get_glyph_assembly (hb_font_t *font,
                               hb_ot_math_glyph_part_t *parts, /* OUT */
                               hb_position_t *italics_correction /* OUT */)
 {
-  const OT::MATH &math = _get_math (font->face);
-  return math.get_math_variants().get_glyph_parts (glyph, direction, font,
-                                                  start_offset,
-                                                  parts_count,
-                                                  parts,
-                                                  italics_correction);
+  return font->face->table.MATH->get_variants().get_glyph_parts (glyph,
+                                                                direction,
+                                                                font,
+                                                                start_offset,
+                                                                parts_count,
+                                                                parts,
+                                                                italics_correction);
 }