emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/w32font.c,v


From: Jason Rumney
Subject: [Emacs-diffs] Changes to emacs/src/w32font.c,v
Date: Fri, 25 Jul 2008 11:25:44 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Jason Rumney <jasonr>   08/07/25 11:25:43

Index: w32font.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32font.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- w32font.c   25 Jul 2008 00:36:45 -0000      1.49
+++ w32font.c   25 Jul 2008 11:25:42 -0000      1.50
@@ -327,8 +327,13 @@
 
   if (c > 0xFFFF)
     {
-      /* TODO: Encode as surrogate pair and lookup the glyph.  */
-      return FONT_INVALID_CODE;
+      DWORD surrogate = c - 0x10000;
+
+      /* High surrogate: U+D800 - U+DBFF.  */
+      in[0] = 0xD800 + ((surrogate >> 10) & 0x03FF);
+      /* Low surrogate: U+DC00 - U+DFFF.  */
+      in[1] = 0xDC00 + (surrogate & 0x03FF);
+      len = 2;
     }
   else
     {
@@ -394,7 +399,7 @@
   HDC dc = NULL;
   struct frame * f;
   int total_width = 0;
-  WORD *wcode = NULL;
+  WORD *wcode;
   SIZE size;
 
   struct w32font_info *w32_font = (struct w32font_info *) font;
@@ -484,19 +489,27 @@
   /* For non-truetype fonts, GetGlyphOutlineW is not supported, so
      fallback on other methods that will at least give some of the metric
      information.  */
-  if (!wcode) {
-    wcode = alloca (nglyphs * sizeof (WORD));
+  
+  /* Make array big enough to hold surrogates.  */
+  wcode = alloca (nglyphs * sizeof (WORD) * 2);
     for (i = 0; i < nglyphs; i++)
       {
        if (code[i] < 0x10000)
          wcode[i] = code[i];
        else
          {
-           /* TODO: Convert to surrogate, reallocating array if needed */
-           wcode[i] = 0xffff;
-         }
+          DWORD surrogate = code[i] - 0x10000;
+
+          /* High surrogate: U+D800 - U+DBFF.  */
+          wcode[i++] = 0xD800 + ((surrogate >> 10) & 0x03FF);
+          /* Low surrogate: U+DC00 - U+DFFF.  */
+          wcode[i] = 0xDC00 + (surrogate & 0x03FF);
+          /* An extra glyph. wcode is already double the size of code to
+             cope with this.  */
+          nglyphs++;
       }
   }
+
   if (dc == NULL)
     {
       /* TODO: Frames can come and go, and their fonts outlive




reply via email to

[Prev in Thread] Current Thread [Next in Thread]