Ticket #58552: CGFloat@Leopard-2.patch

File CGFloat@Leopard-2.patch, 3.1 KB (added by ballapete (Peter "Pete" Dyballa), 5 years ago)

Leopard's patch for CGFloat

  • src/hb-coretext.

    Fix on Leopard "error: implicit conversion increases floating-point precision"
    when building for 32-bit.
    https://github.com/harfbuzz/harfbuzz/issues/1740
    
    old new  
    4040HB_BEGIN_DECLS
    4141
    4242
     43/* The macOS macro `ABS` should be equivalent, but I can't figure out
     44   which header to include to get that macro. */
     45#if CGFLOAT_IS_DOUBLE
     46#define hb_CGFloat_abs(x) fabs(x)
     47#else
     48#define hb_CGFloat_abs(x) fabsf(x)
     49#endif
     50
    4351#define HB_CORETEXT_TAG_MORT HB_TAG('m','o','r','t')
    4452#define HB_CORETEXT_TAG_MORX HB_TAG('m','o','r','x')
    4553#define HB_CORETEXT_TAG_KERX HB_TAG('k','e','r','x')
  • src/hb-coretext.

    old new  
    5454   *
    5555   * https://developer.apple.com/library/content/documentation/GraphicsAnimation/Conceptual/HighResolutionOSX/Explained/Explained.html
    5656   */
    57   ptem *= 96.f / 72.f;
     57  ptem *= ((CGFloat) 96.f) / ((CGFloat) 72.f);
    5858  return (CGFloat) (ptem <= 0.f ? HB_CORETEXT_DEFAULT_FONT_SIZE : ptem);
    5959}
    6060static float
    6161coretext_font_size_to_ptem (CGFloat size)
    6262{
    63   size *= 72. / 96.;
     63  size *= ((CGFloat) 72.) / ((CGFloat) 96.);
    6464  return size <= 0 ? 0 : size;
    6565}
    6666
     
    341341  const hb_coretext_font_data_t *data = font->data.coretext;
    342342  if (unlikely (!data)) return nullptr;
    343343
    344   if (fabs (CTFontGetSize((CTFontRef) data) - coretext_font_size_from_ptem (font->ptem)) > .5)
     344  if (hb_CGFloat_abs (CTFontGetSize((CTFontRef) data) - coretext_font_size_from_ptem (font->ptem)) > (CGFloat) .5)
    345345  {
    346346    /* XXX-MT-bug
    347347     * Note that evaluating condition above can be dangerous if another thread
     
    10181018        hb_glyph_info_t *info = run_info;
    10191019        if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction))
    10201020        {
    1021           hb_position_t x_offset = (positions[0].x - advances_so_far) * x_mult;
     1021          hb_position_t x_offset = (positions[0].x - ((CGFloat) advances_so_far)) * x_mult;
    10221022          for (unsigned int j = 0; j < num_glyphs; j++)
    10231023          {
    1024             double advance;
     1024            CGFloat advance;
    10251025            if (likely (j + 1 < num_glyphs))
    10261026              advance = positions[j + 1].x - positions[j].x;
    10271027            else /* last glyph */
    1028               advance = run_advance - (positions[j].x - positions[0].x);
     1028              advance = ((CGFloat) run_advance) - (positions[j].x - positions[0].x);
    10291029            info->mask = advance * x_mult;
    10301030            info->var1.i32 = x_offset;
    10311031            info->var2.i32 = positions[j].y * y_mult;
     
    10341034        }
    10351035        else
    10361036        {
    1037           hb_position_t y_offset = (positions[0].y - advances_so_far) * y_mult;
     1037          hb_position_t y_offset = (positions[0].y - ((CGFloat) advances_so_far)) * y_mult;
    10381038          for (unsigned int j = 0; j < num_glyphs; j++)
    10391039          {
    1040             double advance;
     1040            CGFloat advance;
    10411041            if (likely (j + 1 < num_glyphs))
    10421042              advance = positions[j + 1].y - positions[j].y;
    10431043            else /* last glyph */
    1044               advance = run_advance - (positions[j].y - positions[0].y);
     1044              advance = ((CGFloat) run_advance) - (positions[j].y - positions[0].y);
    10451045            info->mask = advance * y_mult;
    10461046            info->var1.i32 = positions[j].x * x_mult;
    10471047            info->var2.i32 = y_offset;