diff --git a/src/Makefile.sources b/src/Makefile.sources index 33b5ef808..eccb35678 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -170,6 +170,7 @@ HB_BASE_sources = \ OT/Layout/GSUB/SubstLookup.hh \ OT/Layout/GSUB/SubstLookupSubTable.hh \ OT/name/name.hh \ + OT/Var/VARC/VARC.hh \ hb-ot-layout-gsubgpos.hh \ hb-ot-layout-jstf-table.hh \ hb-ot-layout.cc \ @@ -230,6 +231,7 @@ HB_BASE_sources = \ hb-ot-var-gvar-table.hh \ hb-ot-var-hvar-table.hh \ hb-ot-var-mvar-table.hh \ + hb-ot-var-varc-table.hh \ hb-ot-var.cc \ hb-ot-vorg-table.hh \ hb-pool.hh \ diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh new file mode 100644 index 000000000..64153c14c --- /dev/null +++ b/src/OT/Var/VARC/VARC.hh @@ -0,0 +1,66 @@ +#ifndef OT_VAR_VARC_VARC_HH +#define OT_VAR_VARC_VARC_HH + +#include "../../../hb-ot-layout-common.hh" + +namespace OT { + +//namespace Var { + +/* + * VARC -- Variable Composites + * https://github.com/harfbuzz/boring-expansion-spec/blob/main/VARC.md + */ + +struct VARC +{ + static constexpr hb_tag_t tableTag = HB_TAG ('V', 'A', 'R', 'C'); + + bool + get_path (hb_font_t *font, hb_codepoint_t gid, hb_draw_session_t &draw_session) const + { + unsigned idx = (this+coverage).get_coverage (gid); + if (idx == NOT_COVERED) + return false; + + // TODO + + return true; + } + + bool paint_glyph (hb_font_t *font, hb_codepoint_t gid, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const + { + funcs->push_clip_glyph (data, gid, font); + funcs->color (data, true, foreground); + funcs->pop_clip (data); + + return true; + } + + bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (version.sanitize (c) && + hb_barrier () && + version.major == 1 && + coverage.sanitize (c, this) && + varStore.sanitize (c, this) && + axisIndicesList.sanitize (c, this) && + glyphRecords.sanitize (c, this)); + } + + protected: + FixedVersion<> version; /* Version identifier */ + Offset32To coverage; + Offset32To varStore; + Offset32To*/> axisIndicesList; + Offset32To*/> glyphRecords; + public: + DEFINE_SIZE_STATIC (20); +}; + +//} + +} + +#endif /* OT_VAR_VARC_VARC_HH */ diff --git a/src/hb-ot-face-table-list.hh b/src/hb-ot-face-table-list.hh index b552dfdd9..4e8268c38 100644 --- a/src/hb-ot-face-table-list.hh +++ b/src/hb-ot-face-table-list.hh @@ -96,6 +96,7 @@ HB_OT_CORE_TABLE (OT, avar) HB_OT_CORE_TABLE (OT, cvar) HB_OT_ACCELERATOR (OT, gvar) HB_OT_CORE_TABLE (OT, MVAR) +HB_OT_CORE_TABLE (OT, VARC) #endif /* Legacy kern. */ diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 1da869d69..90cc15a45 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -43,6 +43,7 @@ #include "hb-ot-hmtx-table.hh" #include "hb-ot-post-table.hh" #include "hb-ot-stat-table.hh" // Just so we compile it; unused otherwise. +#include "hb-ot-var-varc-table.hh" #include "hb-ot-vorg-table.hh" #include "OT/Color/CBDT/CBDT.hh" #include "OT/Color/COLR/COLR.hh" @@ -523,6 +524,9 @@ hb_ot_draw_glyph (hb_font_t *font, { // Need draw_session to be destructed before emboldening. hb_draw_session_t draw_session (embolden ? hb_outline_recording_pen_get_funcs () : draw_funcs, embolden ? &outline : draw_data, font->slant_xy); +#ifndef HB_NO_VAR + if (!font->face->table.VARC->get_path (font, glyph, draw_session)) +#endif if (!font->face->table.glyf->get_path (font, glyph, draw_session)) #ifndef HB_NO_CFF if (!font->face->table.cff2->get_path (font, glyph, draw_session)) @@ -562,6 +566,9 @@ hb_ot_paint_glyph (hb_font_t *font, if (font->face->table.CBDT->paint_glyph (font, glyph, paint_funcs, paint_data)) return; if (font->face->table.sbix->paint_glyph (font, glyph, paint_funcs, paint_data)) return; #endif +#endif +#ifndef HB_NO_VAR + if (font->face->table.VARC->paint_glyph (font, glyph, paint_funcs, paint_data, foreground)) return; #endif if (font->face->table.glyf->paint_glyph (font, glyph, paint_funcs, paint_data, foreground)) return; #ifndef HB_NO_CFF diff --git a/src/hb-ot-var-varc-table.hh b/src/hb-ot-var-varc-table.hh new file mode 100644 index 000000000..603aeb258 --- /dev/null +++ b/src/hb-ot-var-varc-table.hh @@ -0,0 +1,32 @@ +/* + * Copyright © 2024 Google, Inc. + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_OT_VAR_VARC_TABLE_HH +#define HB_OT_VAR_VARC_TABLE_HH + +#include "OT/Var/VARC/VARC.hh" + +#endif /* HB_OT_VAR_VARC_TABLE_HH */ diff --git a/src/meson.build b/src/meson.build index daa919805..d398143d6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -173,6 +173,7 @@ hb_base_sources = files( 'OT/Layout/GSUB/SubstLookup.hh', 'OT/Layout/GSUB/SubstLookupSubTable.hh', 'OT/name/name.hh', + 'OT/Var/VARC/VARC.hh', 'hb-ot-layout-gsubgpos.hh', 'hb-ot-layout-jstf-table.hh', 'hb-ot-layout.cc', @@ -233,6 +234,7 @@ hb_base_sources = files( 'hb-ot-var-gvar-table.hh', 'hb-ot-var-hvar-table.hh', 'hb-ot-var-mvar-table.hh', + 'hb-ot-var-varc-table.hh', 'hb-ot-var.cc', 'hb-ot-vorg-table.hh', 'hb-pool.hh',