Merge pull request #4028 from harfbuzz/mvar-instancing
[instancer] Add MVAR values to OS/2
This commit is contained in:
commit
c60c5995bb
|
@ -93,15 +93,15 @@ struct Glyph
|
|||
float topSideY = all_points[len - 2].y;
|
||||
float bottomSideY = all_points[len - 1].y;
|
||||
|
||||
unsigned hori_aw = roundf (rightSideX - leftSideX);
|
||||
signed hori_aw = roundf (rightSideX - leftSideX);
|
||||
if (hori_aw < 0) hori_aw = 0;
|
||||
int lsb = roundf (xMin - leftSideX);
|
||||
plan->hmtx_map.set (new_gid, hb_pair (hori_aw, lsb));
|
||||
plan->hmtx_map.set (new_gid, hb_pair ((unsigned) hori_aw, lsb));
|
||||
|
||||
unsigned vert_aw = roundf (topSideY - bottomSideY);
|
||||
signed vert_aw = roundf (topSideY - bottomSideY);
|
||||
if (vert_aw < 0) vert_aw = 0;
|
||||
int tsb = roundf (topSideY - yMax);
|
||||
plan->vmtx_map.set (new_gid, hb_pair (vert_aw, tsb));
|
||||
plan->vmtx_map.set (new_gid, hb_pair ((unsigned) vert_aw, tsb));
|
||||
}
|
||||
|
||||
bool compile_header_bytes (const hb_subset_plan_t *plan,
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "hb-ot-maxp-table.hh"
|
||||
#include "hb-ot-hhea-table.hh"
|
||||
#include "hb-ot-var-hvar-table.hh"
|
||||
#include "hb-ot-var-mvar-table.hh"
|
||||
#include "hb-ot-metrics.hh"
|
||||
|
||||
/*
|
||||
|
@ -76,10 +77,10 @@ struct hmtxvmtx
|
|||
const hb_hashmap_t<hb_codepoint_t, hb_pair_t<unsigned, int>>* get_mtx_map (const hb_subset_plan_t *plan) const
|
||||
{ return T::is_horizontal ? &plan->hmtx_map : &plan->vmtx_map; }
|
||||
|
||||
bool subset_update_header (hb_subset_plan_t *plan,
|
||||
bool subset_update_header (hb_subset_context_t *c,
|
||||
unsigned int num_hmetrics) const
|
||||
{
|
||||
hb_blob_t *src_blob = hb_sanitize_context_t ().reference_table<H> (plan->source, H::tableTag);
|
||||
hb_blob_t *src_blob = hb_sanitize_context_t ().reference_table<H> (c->plan->source, H::tableTag);
|
||||
hb_blob_t *dest_blob = hb_blob_copy_writable_or_fail (src_blob);
|
||||
hb_blob_destroy (src_blob);
|
||||
|
||||
|
@ -91,7 +92,26 @@ struct hmtxvmtx
|
|||
H *table = (H *) hb_blob_get_data (dest_blob, &length);
|
||||
table->numberOfLongMetrics = num_hmetrics;
|
||||
|
||||
bool result = plan->add_table (H::tableTag, dest_blob);
|
||||
#ifndef HB_NO_VAR
|
||||
if (c->plan->normalized_coords)
|
||||
{
|
||||
auto &MVAR = *c->plan->source->table.MVAR;
|
||||
if (T::is_horizontal)
|
||||
{
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CARET_RISE, caretSlopeRise);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CARET_RUN, caretSlopeRun);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CARET_OFFSET, caretOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_VERTICAL_CARET_RISE, caretSlopeRise);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_VERTICAL_CARET_RUN, caretSlopeRun);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_VERTICAL_CARET_OFFSET, caretOffset);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool result = c->plan->add_table (H::tableTag, dest_blob);
|
||||
hb_blob_destroy (dest_blob);
|
||||
|
||||
return result;
|
||||
|
@ -169,7 +189,7 @@ struct hmtxvmtx
|
|||
return_trace (false);
|
||||
|
||||
// Amend header num hmetrics
|
||||
if (unlikely (!subset_update_header (c->plan, num_long_metrics)))
|
||||
if (unlikely (!subset_update_header (c, num_long_metrics)))
|
||||
return_trace (false);
|
||||
|
||||
return_trace (true);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "hb-open-type.hh"
|
||||
#include "hb-ot-os2-unicode-ranges.hh"
|
||||
#include "hb-ot-var-mvar-table.hh"
|
||||
|
||||
#include "hb-set.hh"
|
||||
|
||||
|
@ -62,6 +63,7 @@ struct OS2V2Tail
|
|||
bool has_data () const { return sxHeight || sCapHeight; }
|
||||
|
||||
const OS2V2Tail * operator -> () const { return this; }
|
||||
OS2V2Tail * operator -> () { return this; }
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c) const
|
||||
{
|
||||
|
@ -213,6 +215,37 @@ struct OS2
|
|||
OS2 *os2_prime = c->serializer->embed (this);
|
||||
if (unlikely (!os2_prime)) return_trace (false);
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
if (c->plan->normalized_coords)
|
||||
{
|
||||
auto &MVAR = *c->plan->source->table.MVAR;
|
||||
auto *table = os2_prime;
|
||||
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_ASCENDER, sTypoAscender);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_DESCENDER, sTypoDescender);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_LINE_GAP, sTypoLineGap);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_ASCENT, usWinAscent);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_DESCENT, usWinDescent);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_SIZE, ySubscriptXSize);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_SIZE, ySubscriptYSize);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_X_OFFSET, ySubscriptXOffset);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUBSCRIPT_EM_Y_OFFSET, ySubscriptYOffset);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_SIZE, ySuperscriptXSize);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_SIZE, ySuperscriptYSize);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_X_OFFSET, ySuperscriptXOffset);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_SUPERSCRIPT_EM_Y_OFFSET, ySuperscriptYOffset);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_STRIKEOUT_SIZE, yStrikeoutSize);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_STRIKEOUT_OFFSET, yStrikeoutPosition);
|
||||
|
||||
if (os2_prime->version >= 2)
|
||||
{
|
||||
auto *table = & const_cast<OS2V2Tail &> (os2_prime->v2 ());
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_X_HEIGHT, sxHeight);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_CAP_HEIGHT, sCapHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (c->plan->user_axes_location.has (HB_TAG ('w','g','h','t')) &&
|
||||
!c->plan->pinned_at_default)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define HB_OT_POST_TABLE_HH
|
||||
|
||||
#include "hb-open-type.hh"
|
||||
#include "hb-ot-var-mvar-table.hh"
|
||||
|
||||
#define HB_STRING_ARRAY_NAME format1_names
|
||||
#define HB_STRING_ARRAY_LIST "hb-ot-post-macroman.hh"
|
||||
|
@ -98,6 +99,17 @@ struct post
|
|||
post *post_prime = c->serializer->start_embed<post> ();
|
||||
if (unlikely (!post_prime)) return_trace (false);
|
||||
|
||||
#ifndef HB_NO_VAR
|
||||
if (c->plan->normalized_coords)
|
||||
{
|
||||
auto &MVAR = *c->plan->source->table.MVAR;
|
||||
auto *table = post_prime;
|
||||
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_UNDERLINE_SIZE, underlineThickness);
|
||||
HB_ADD_MVAR_VAR (HB_OT_METRICS_TAG_UNDERLINE_OFFSET, underlinePosition);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool glyph_names = c->plan->flags & HB_SUBSET_FLAGS_GLYPH_NAMES;
|
||||
if (!serialize (c->serializer, glyph_names))
|
||||
return_trace (false);
|
||||
|
|
|
@ -116,4 +116,13 @@ protected:
|
|||
} /* namespace OT */
|
||||
|
||||
|
||||
#define HB_ADD_MVAR_VAR(tag, field) \
|
||||
c->serializer->check_assign (table->field, \
|
||||
roundf (table->field + \
|
||||
MVAR.get_var (tag, \
|
||||
c->plan->normalized_coords.arrayZ, \
|
||||
c->plan->normalized_coords.length)), \
|
||||
HB_SERIALIZE_ERROR_INT_OVERFLOW)
|
||||
|
||||
|
||||
#endif /* HB_OT_VAR_MVAR_TABLE_HH */
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1 @@
|
|||
--drop-tables+=GSUB,GPOS,GDEF
|
|
@ -0,0 +1,12 @@
|
|||
FONTS:
|
||||
NotoSans-VF.abc.ttf
|
||||
|
||||
PROFILES:
|
||||
no-layout.txt
|
||||
|
||||
SUBSETS:
|
||||
*
|
||||
|
||||
INSTANCES:
|
||||
wght=150,wdth=80,CTGR=0
|
||||
wght=300,wdth=90,CTGR=0
|
Loading…
Reference in New Issue