]> code.delx.au - gnu-emacs/blobdiff - src/macfont.m
Fix shr.el/image build problem
[gnu-emacs] / src / macfont.m
index bab9f7cf9ffea6d606d468765ecd603a2d4ae1c3..c799100c8550823ac84311d5eae0f2f0c9474bec 100644 (file)
@@ -1,12 +1,12 @@
 /* Font driver on Mac OSX Core text.
-   Copyright (C) 2009-2015 Free Software Foundation, Inc.
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -771,7 +771,7 @@ mac_font_descriptor_get_adjusted_weight (CTFontDescriptorRef desc, CGFloat val)
 {
   long percent_val = lround (val * 100);
 
-  if (percent_val == -40 || percent_val == 56)
+  if (percent_val == -40)
     {
       CTFontRef font = NULL;
       CFStringRef name =
@@ -786,19 +786,10 @@ mac_font_descriptor_get_adjusted_weight (CTFontDescriptorRef desc, CGFloat val)
        {
          CFIndex weight = mac_font_get_weight (font);
 
-         if (percent_val == -40)
-           {
-             /* Workaround for crash when displaying Oriya characters
-                with Arial Unicode MS on OS X 10.11.  */
-             if (weight == 5)
-               val = 0;
-           }
-         else                  /* percent_val == 56 */
-           {
-             if (weight == 9)
-               /* Adjustment for HiraginoSans-W7 on OS X 10.11.  */
-               val = 0.4;
-           }
+         /* Workaround for crash when displaying Oriya characters
+            with Arial Unicode MS on OS X 10.11.  */
+         if (weight == 5)
+           val = 0;
          CFRelease (font);
        }
     }
@@ -2382,9 +2373,9 @@ macfont_list (struct frame *f, Lisp_Object spec)
                   != (spacing >= FONT_SPACING_MONO)))
             continue;
 
-          /* Don't use a color bitmap font unless its family is
-             explicitly specified.  */
-          if ((sym_traits & kCTFontTraitColorGlyphs) && NILP (family))
+          /* Don't use a color bitmap font until it is supported on
+            free platforms.  */
+          if (sym_traits & kCTFontTraitColorGlyphs)
             continue;
 
           if (j > 0
@@ -2765,7 +2756,6 @@ macfont_has_char (Lisp_Object font, int c)
 static unsigned
 macfont_encode_char (struct font *font, int c)
 {
-  struct macfont_info *macfont_info = (struct macfont_info *) font;
   CGGlyph glyph;
 
   block_input ();
@@ -2866,7 +2856,8 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
     {
       if (s->hl == DRAW_MOUSE_FACE)
         {
-          face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
+          face = FACE_FROM_ID_OR_NULL (s->f,
+                                      MOUSE_HL_INFO (s->f)->mouse_face_face_id);
           if (!face)
             face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
         }
@@ -3776,6 +3767,7 @@ mac_font_shape (CTFontRef font, CFStringRef string,
             {
               struct mac_glyph_layout *gl;
               CGPoint position;
+             CGFloat max_x;
 
               if (!RIGHT_TO_LEFT_P)
                 gl = glbuf + range.location;
@@ -3797,12 +3789,13 @@ mac_font_shape (CTFontRef font, CFStringRef string,
               CTRunGetGlyphs (ctrun, range, &gl->glyph_id);
 
               CTRunGetPositions (ctrun, range, &position);
+             max_x = position.x + CTRunGetTypographicBounds (ctrun, range,
+                                                             NULL, NULL, NULL);
+             max_x = max (max_x, total_advance);
               gl->advance_delta = position.x - total_advance;
               gl->baseline_delta = position.y;
-              gl->advance = (gl->advance_delta
-                             + CTRunGetTypographicBounds (ctrun, range,
-                                                          NULL, NULL, NULL));
-              total_advance += gl->advance;
+              gl->advance = max_x - total_advance;
+              total_advance = max_x;
             }
 
           if (RIGHT_TO_LEFT_P)
@@ -4052,8 +4045,6 @@ mac_register_font_driver (struct frame *f)
 void
 syms_of_macfont (void)
 {
-  static struct font_driver mac_font_driver;
-
   /* Core Text, for Mac OS X.  */
   DEFSYM (Qmac_ct, "mac-ct");
   macfont_driver.type = Qmac_ct;