+/***********************************************************************
+ Faces
+ ***********************************************************************/
+
+
+/* Turn appearances of face FACE_ID on tty frame F on. */
+
+static WORD
+w32_face_attributes (f, face_id)
+ struct frame *f;
+ int face_id;
+{
+ WORD char_attr;
+ struct face *face = FACE_FROM_ID (f, face_id);
+
+ xassert (face != NULL);
+
+ char_attr = char_attr_normal;
+
+ if (face->foreground != FACE_TTY_DEFAULT_FG_COLOR
+ && face->foreground != FACE_TTY_DEFAULT_COLOR)
+ char_attr = (char_attr & 0xfff0) + (face->foreground % 16);
+
+ if (face->background != FACE_TTY_DEFAULT_BG_COLOR
+ && face->background != FACE_TTY_DEFAULT_COLOR)
+ char_attr = (char_attr & 0xff0f) + ((face->background % 16) << 4);
+
+
+ /* NTEMACS_TODO: Faces defined during startup get both foreground
+ and background of 0. Need a better way around this - for now detect
+ the problem and invert one of the faces to make the text readable. */
+ if (((char_attr & 0x00f0) >> 4) == (char_attr & 0x000f))
+ char_attr ^= 0x0007;
+
+ if (face->tty_reverse_p)
+ char_attr = (char_attr & 0xff00) + ((char_attr & 0x000f) << 4)
+ + ((char_attr & 0x00f0) >> 4);
+
+ return char_attr;
+}
+
+
+/* Emulation of some X window features from xfns.c and xfaces.c. */
+
+extern char unspecified_fg[], unspecified_bg[];
+
+
+/* Given a color index, return its standard name. */
+Lisp_Object
+vga_stdcolor_name (int idx)
+{
+ /* Standard VGA colors, in the order of their standard numbering
+ in the default VGA palette. */
+ static char *vga_colors[16] = {
+ "black", "blue", "green", "cyan", "red", "magenta", "brown",
+ "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
+ "lightred", "lightmagenta", "yellow", "white"
+ };
+
+ extern Lisp_Object Qunspecified;
+
+ if (idx >= 0 && idx < sizeof (vga_colors) / sizeof (vga_colors[0]))
+ return build_string (vga_colors[idx]);
+ else
+ return Qunspecified; /* meaning the default */
+}
+