]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix macfont backend color handling
authorAlan Third <alan@idiocy.org>
Sat, 21 Aug 2021 18:39:39 +0000 (19:39 +0100)
committerAlan Third <alan@idiocy.org>
Wed, 22 Dec 2021 20:48:19 +0000 (20:48 +0000)
* src/macfont.m (get_cgcolor): Replace use of ns_lookup_indexed_color.
(CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND):
(CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND):
(CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND): Fix call to get_cgcolor
and fix all callers.

src/macfont.m

index ce7a5ec8cda1a9d1a29e1e6bb3a40ef6f836589a..3f87c1be76d2a8b430b963559640cf55cbeec3be 100644 (file)
@@ -598,9 +598,9 @@ mac_screen_font_shape (ScreenFontRef font, CFStringRef string,
 }
 
 static CGColorRef
-get_cgcolor(unsigned long idx, struct frame *f)
+get_cgcolor(unsigned long color)
 {
-  NSColor *nsColor = ns_lookup_indexed_color (idx, f);
+  NSColor *nsColor = [NSColor colorWithUnsignedLong:color];
   [nsColor set];
   CGColorSpaceRef colorSpace = [[nsColor colorSpace] CGColorSpace];
   NSInteger noc = [nsColor numberOfComponents];
@@ -628,21 +628,21 @@ get_cgcolor_from_nscolor (NSColor *nsColor, struct frame *f)
   return cgColor;
 }
 
-#define CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND(context, face, f)        \
+#define CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND(context, face)           \
   do {                                                                  \
-    CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face), f);    \
+    CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face));       \
     CGContextSetFillColorWithColor (context, refcol_) ;                 \
     CGColorRelease (refcol_);                                           \
   } while (0)
-#define CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND(context, face, f)        \
+#define CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND(context, face)           \
   do {                                                                  \
-    CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (face), f);    \
+    CGColorRef refcol_ = get_cgcolor (NS_FACE_BACKGROUND (face));       \
     CGContextSetFillColorWithColor (context, refcol_);                  \
     CGColorRelease (refcol_);                                           \
   } while (0)
-#define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face, f)      \
+#define CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND(context, face)         \
   do {                                                                  \
-    CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face), f);    \
+    CGColorRef refcol_ = get_cgcolor (NS_FACE_FOREGROUND (face));       \
     CGContextSetStrokeColorWithColor (context, refcol_);                \
     CGColorRelease (refcol_);                                           \
   } while (0)
@@ -2933,7 +2933,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
          CGColorRelease (colorref);
         }
       else
-       CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face, f);
+        CG_SET_FILL_COLOR_WITH_FACE_BACKGROUND (context, face);
       CGContextFillRects (context, &background_rect, 1);
     }
 
@@ -2949,7 +2949,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
          CGColorRelease (colorref);
         }
       else
-       CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face, s->f);
+        CG_SET_FILL_COLOR_WITH_FACE_FOREGROUND (context, face);
       if (macfont_info->synthetic_italic_p)
         atfm = synthetic_italic_atfm;
       else
@@ -2978,7 +2978,7 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
             CGContextSetLineWidth (context, synthetic_bold_factor * font_size);
 #endif
-          CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND (context, face, f);
+          CG_SET_STROKE_COLOR_WITH_FACE_FOREGROUND (context, face);
         }
       if (no_antialias_p)
         CGContextSetShouldAntialias (context, false);