]> code.delx.au - gnu-emacs/blobdiff - src/w32uniscribe.c
In display-buffer-record-window record selected window if necessary.
[gnu-emacs] / src / w32uniscribe.c
index 5d160b9d42f22dad437e8010a485c4d37370784c..73c0410c7b7fdfe3e8827c70f179631d9c43297d 100644 (file)
@@ -1,5 +1,5 @@
 /* Font backend for the Microsoft W32 Uniscribe API.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2015 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -47,14 +47,10 @@ struct uniscribe_font_info
 
 int uniscribe_available = 0;
 
-/* Defined in w32font.c, since it is required there as well.  */
-extern Lisp_Object Quniscribe;
-extern Lisp_Object Qopentype;
-
 /* EnumFontFamiliesEx callback.  */
-static int CALLBACK add_opentype_font_name_to_list (ENUMLOGFONTEX *,
-                                                    NEWTEXTMETRICEX *,
-                                                    DWORD, LPARAM);
+static int CALLBACK ALIGN_STACK add_opentype_font_name_to_list (ENUMLOGFONTEX *,
+                                                               NEWTEXTMETRICEX *,
+                                                               DWORD, LPARAM);
 /* Used by uniscribe_otf_capability.  */
 static Lisp_Object otf_features (HDC context, char *table);
 
@@ -69,28 +65,27 @@ memq_no_quit (Lisp_Object elt, Lisp_Object list)
 \f
 /* Font backend interface implementation.  */
 static Lisp_Object
-uniscribe_list (Lisp_Object frame, Lisp_Object font_spec)
+uniscribe_list (struct frame *f, Lisp_Object font_spec)
 {
-  Lisp_Object fonts = w32font_list_internal (frame, font_spec, 1);
+  Lisp_Object fonts = w32font_list_internal (f, font_spec, true);
   FONT_ADD_LOG ("uniscribe-list", font_spec, fonts);
   return fonts;
 }
 
 static Lisp_Object
-uniscribe_match (Lisp_Object frame, Lisp_Object font_spec)
+uniscribe_match (struct frame *f, Lisp_Object font_spec)
 {
-  Lisp_Object entity = w32font_match_internal (frame, font_spec, 1);
+  Lisp_Object entity = w32font_match_internal (f, font_spec, true);
   FONT_ADD_LOG ("uniscribe-match", font_spec, entity);
   return entity;
 }
 
 static Lisp_Object
-uniscribe_list_family (Lisp_Object frame)
+uniscribe_list_family (struct frame *f)
 {
   Lisp_Object list = Qnil;
   LOGFONT font_match_pattern;
   HDC dc;
-  FRAME_PTR f = XFRAME (frame);
 
   memset (&font_match_pattern, 0, sizeof (font_match_pattern));
   /* Limit enumerated fonts to outline fonts to save time.  */
@@ -107,7 +102,7 @@ uniscribe_list_family (Lisp_Object frame)
 }
 
 static Lisp_Object
-uniscribe_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
+uniscribe_open (struct frame *f, Lisp_Object font_entity, int pixel_size)
 {
   Lisp_Object font_object
     = font_make_object (VECSIZE (struct uniscribe_font_info),
@@ -128,15 +123,13 @@ uniscribe_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
   /* Uniscribe backend uses glyph indices.  */
   uniscribe_font->w32_font.glyph_idx = ETO_GLYPH_INDEX;
 
-  /* Mark the format as opentype  */
-  uniscribe_font->w32_font.font.props[FONT_FORMAT_INDEX] = Qopentype;
   uniscribe_font->w32_font.font.driver = &uniscribe_font_driver;
 
   return font_object;
 }
 
 static void
-uniscribe_close (FRAME_PTR f, struct font *font)
+uniscribe_close (struct font *font)
 {
   struct uniscribe_font_info *uniscribe_font
     = (struct uniscribe_font_info *) font;
@@ -144,7 +137,7 @@ uniscribe_close (FRAME_PTR f, struct font *font)
   if (uniscribe_font->cache)
     ScriptFreeCache (&(uniscribe_font->cache));
 
-  w32font_close (f, font);
+  w32font_close (font);
 }
 
 /* Return a list describing which scripts/languages FONT supports by
@@ -190,8 +183,9 @@ uniscribe_otf_capability (struct font *font)
 static Lisp_Object
 uniscribe_shape (Lisp_Object lgstring)
 {
-  struct font * font;
-  struct uniscribe_font_info * uniscribe_font;
+  struct font *font = CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring));
+  struct uniscribe_font_info *uniscribe_font
+    = (struct uniscribe_font_info *) font;
   EMACS_UINT nchars;
   int nitems, max_items, i, max_glyphs, done_glyphs;
   wchar_t *chars;
@@ -206,9 +200,6 @@ uniscribe_shape (Lisp_Object lgstring)
   HDC context = NULL;
   HFONT old_font = NULL;
 
-  CHECK_FONT_GET_OBJECT (LGSTRING_FONT (lgstring), font);
-  uniscribe_font = (struct uniscribe_font_info *) font;
-
   /* Get the chars from lgstring in a form we can use with uniscribe.  */
   max_glyphs = nchars = LGSTRING_GLYPH_LEN (lgstring);
   done_glyphs = 0;
@@ -333,7 +324,7 @@ uniscribe_shape (Lisp_Object lgstring)
 
                  if (NILP (lglyph))
                    {
-                     lglyph = Fmake_vector (make_number (LGLYPH_SIZE), Qnil);
+                     lglyph = LGLYPH_NEW ();
                      LGSTRING_SET_GLYPH (lgstring, lglyph_index, lglyph);
                    }
                  /* Copy to a 32-bit data type to shut up the
@@ -435,8 +426,8 @@ uniscribe_shape (Lisp_Object lgstring)
                         are zero.  */
                      || (!attributes[j].fClusterStart && items[i].a.fRTL))
                    {
-                     Lisp_Object vec;
-                     vec = Fmake_vector (make_number (3), Qnil);
+                     Lisp_Object vec = make_uninit_vector (3);
+
                      if (items[i].a.fRTL)
                        {
                          /* Empirically, it looks like Uniscribe
@@ -594,23 +585,21 @@ uniscribe_encode_char (struct font *font, int c)
    Lisp_Object uniscribe_get_cache (Lisp_Object frame);
    void uniscribe_free_entity (Lisp_Object font_entity);
    int uniscribe_has_char (Lisp_Object entity, int c);
-   int uniscribe_text_extents (struct font *font, unsigned *code,
-                               int nglyphs, struct font_metrics *metrics);
+   void uniscribe_text_extents (struct font *font, unsigned *code,
+                                int nglyphs, struct font_metrics *metrics);
    int uniscribe_draw (struct glyph_string *s, int from, int to,
                        int x, int y, int with_background);
 
    Unused:
-   int uniscribe_prepare_face (FRAME_PTR f, struct face *face);
-   void uniscribe_done_face (FRAME_PTR f, struct face *face);
+   int uniscribe_prepare_face (struct frame *f, struct face *face);
+   void uniscribe_done_face (struct frame *f, struct face *face);
    int uniscribe_get_bitmap (struct font *font, unsigned code,
                              struct font_bitmap *bitmap, int bits_per_pixel);
    void uniscribe_free_bitmap (struct font *font, struct font_bitmap *bitmap);
-   void * uniscribe_get_outline (struct font *font, unsigned code);
-   void uniscribe_free_outline (struct font *font, void *outline);
    int uniscribe_anchor_point (struct font *font, unsigned code,
                                int index, int *x, int *y);
-   int uniscribe_start_for_frame (FRAME_PTR f);
-   int uniscribe_end_for_frame (FRAME_PTR f);
+   int uniscribe_start_for_frame (struct frame *f);
+   int uniscribe_end_for_frame (struct frame *f);
 
 */
 
@@ -618,7 +607,7 @@ uniscribe_encode_char (struct font *font, int c)
 /* Callback function for EnumFontFamiliesEx.
    Adds the name of opentype fonts to a Lisp list (passed in as the
    lParam arg). */
-static int CALLBACK
+static int CALLBACK ALIGN_STACK
 add_opentype_font_name_to_list (ENUMLOGFONTEX *logical_font,
                                NEWTEXTMETRICEX *physical_font,
                                DWORD font_type, LPARAM list_object)
@@ -965,7 +954,7 @@ font_table_error:
 \f
 struct font_driver uniscribe_font_driver =
   {
-    0, /* Quniscribe */
+    LISP_INITIALLY_ZERO, /* Quniscribe */
     0, /* case insensitive */
     w32font_get_cache,
     uniscribe_list,
@@ -982,8 +971,6 @@ struct font_driver uniscribe_font_driver =
     w32font_draw,
     NULL, /* get_bitmap */
     NULL, /* free_bitmap */
-    NULL, /* get_outline */
-    NULL, /* free_outline */
     NULL, /* anchor_point */
     uniscribe_otf_capability, /* Defined so (font-get FONTOBJ :otf) works.  */
     NULL, /* otf_drive - use shape instead.  */