Revert "[cff] Use float instead of double"

This reverts commit c8f67ac28e.

Tests failing.
pull/4343/head
Behdad Esfahbod 1 year ago
parent c8f67ac28e
commit cb320d2222
  1. 14
      src/hb-cff-interp-common.hh
  2. 4
      src/hb-cff-interp-dict-common.hh
  3. 8
      src/hb-cff2-interp-cs.hh
  4. 6
      src/hb-subset-cff2.cc

@ -222,14 +222,14 @@ struct number_t
void set_int (int v) { value = v; } void set_int (int v) { value = v; }
int to_int () const { return value; } int to_int () const { return value; }
void set_fixed (int32_t v) { value = v / 65536.0f; } void set_fixed (int32_t v) { value = v / 65536.0; }
int32_t to_fixed () const { return value * 65536.0f; } int32_t to_fixed () const { return value * 65536.0; }
void set_real (float v) { value = v; } void set_real (double v) { value = v; }
float to_real () const { return value; } double to_real () const { return value; }
bool in_int_range () const bool in_int_range () const
{ return ((float) (int16_t) to_int () == value); } { return ((double) (int16_t) to_int () == value); }
bool operator > (const number_t &n) const { return value > n.to_real (); } bool operator > (const number_t &n) const { return value > n.to_real (); }
bool operator < (const number_t &n) const { return n > *this; } bool operator < (const number_t &n) const { return n > *this; }
@ -244,7 +244,7 @@ struct number_t
} }
protected: protected:
float value = 0.; double value = 0.;
}; };
/* byte string */ /* byte string */
@ -439,7 +439,7 @@ struct arg_stack_t : cff_stack_t<ARG, 513>
n.set_fixed (v); n.set_fixed (v);
} }
void push_real (float v) void push_real (double v)
{ {
ARG &n = S::push (); ARG &n = S::push ();
n.set_real (v); n.set_real (v);

@ -78,7 +78,7 @@ struct dict_opset_t : opset_t<number_t>
} }
/* Turns CFF's BCD format into strtod understandable string */ /* Turns CFF's BCD format into strtod understandable string */
static float parse_bcd (byte_str_ref_t& str_ref) static double parse_bcd (byte_str_ref_t& str_ref)
{ {
if (unlikely (str_ref.in_error ())) return .0; if (unlikely (str_ref.in_error ())) return .0;
@ -107,7 +107,7 @@ struct dict_opset_t : opset_t<number_t>
double pv; double pv;
if (unlikely (!hb_parse_double (&p, p + count, &pv, true/* whole buffer */))) if (unlikely (!hb_parse_double (&p, p + count, &pv, true/* whole buffer */)))
break; break;
return (float) pv; return pv;
} }
else else
{ {

@ -37,7 +37,7 @@ struct blend_arg_t : number_t
{ {
void set_int (int v) { reset_blends (); number_t::set_int (v); } void set_int (int v) { reset_blends (); number_t::set_int (v); }
void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); } void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
void set_real (float v) { reset_blends (); number_t::set_real (v); } void set_real (double v) { reset_blends (); number_t::set_real (v); }
void set_blends (unsigned int numValues_, unsigned int valueIndex_, void set_blends (unsigned int numValues_, unsigned int valueIndex_,
hb_array_t<const blend_arg_t> blends_) hb_array_t<const blend_arg_t> blends_)
@ -148,16 +148,16 @@ struct cff2_cs_interp_env_t : cs_interp_env_t<ELEM, CFF2Subrs>
void set_ivs (unsigned int ivs_) { ivs = ivs_; } void set_ivs (unsigned int ivs_) { ivs = ivs_; }
bool seen_vsindex () const { return seen_vsindex_; } bool seen_vsindex () const { return seen_vsindex_; }
float blend_deltas (hb_array_t<const ELEM> deltas) const double blend_deltas (hb_array_t<const ELEM> deltas) const
{ {
float v = 0; double v = 0;
if (do_blend) if (do_blend)
{ {
if (likely (scalars.length == deltas.length)) if (likely (scalars.length == deltas.length))
{ {
unsigned count = scalars.length; unsigned count = scalars.length;
for (unsigned i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
v += (float) scalars.arrayZ[i] * deltas.arrayZ[i].to_real (); v += (double) scalars.arrayZ[i] * deltas.arrayZ[i].to_real ();
} }
} }
return v; return v;

@ -266,14 +266,14 @@ struct cff2_private_blend_encoder_param_t
} }
} }
float blend_deltas (hb_array_t<const number_t> deltas) const double blend_deltas (hb_array_t<const number_t> deltas) const
{ {
float v = 0; double v = 0;
if (likely (scalars.length == deltas.length)) if (likely (scalars.length == deltas.length))
{ {
unsigned count = scalars.length; unsigned count = scalars.length;
for (unsigned i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
v += (float) scalars.arrayZ[i] * deltas.arrayZ[i].to_real (); v += (double) scalars.arrayZ[i] * deltas.arrayZ[i].to_real ();
} }
return v; return v;
} }

Loading…
Cancel
Save