shithub: freetype+ttf2subf

Download patch

ref: 7f0994820bfbf9e790a10ddaf33fde7c06212adc
parent: 25a9bd9be066c7ff31bfb345cf9c76c5e408ca04
author: Werner Lemberg <[email protected]>
date: Sun May 24 05:50:24 EDT 2015

[truetype] Fix return values of GETINFO bytecode instruction.

* src/truetype/ttinterp.h (TT_ExecContextRec): New fields
`vertical_lcd' and `gray_cleartype'.

* src/truetype/ttgload.c (tt_loader_init): Initialize new fields.
Change `symmetrical smoothing' to TRUE, since FreeType produces
exactly this.

* src/truetype/ttinterp.c (Ins_GETINFO): Fix selector/return bit
values for symmetrical smoothing, namely 11/18.
Handle bits for vertical LCD subpixels (8/15) and Gray ClearType
(12/19).

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
 2015-05-23  Werner Lemberg  <[email protected]>
 
+	[truetype] Fix return values of GETINFO bytecode instruction.
+
+	* src/truetype/ttinterp.h (TT_ExecContextRec): New fields
+	`vertical_lcd' and `gray_cleartype'.
+
+	* src/truetype/ttgload.c (tt_loader_init): Initialize new fields.
+	Change `symmetrical smoothing' to TRUE, since FreeType produces
+	exactly this.
+
+	* src/truetype/ttinterp.c (Ins_GETINFO): Fix selector/return bit
+	values for symmetrical smoothing, namely 11/18.
+	Handle bits for vertical LCD subpixels (8/15) and Gray ClearType
+	(12/19).
+
+2015-05-23  Werner Lemberg  <[email protected]>
+
 	[truetype] Minor.
 
 	* src/truetype/ttinterp.h (TT_ExecContext):
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -2143,7 +2143,9 @@
       FT_Bool  compatible_widths;
       FT_Bool  symmetrical_smoothing;
       FT_Bool  bgr;
+      FT_Bool  vertical_lcd;
       FT_Bool  subpixel_positioned;
+      FT_Bool  gray_cleartype;
 #endif
 #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */
 
@@ -2194,9 +2196,11 @@
 
 #if 1
         exec->compatible_widths     = SPH_OPTION_SET_COMPATIBLE_WIDTHS;
-        exec->symmetrical_smoothing = FALSE;
+        exec->symmetrical_smoothing = TRUE;
         exec->bgr                   = FALSE;
+        exec->vertical_lcd          = FALSE;
         exec->subpixel_positioned   = TRUE;
+        exec->gray_cleartype        = FALSE;
 #else /* 0 */
         exec->compatible_widths =
           FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
@@ -2207,9 +2211,15 @@
         exec->bgr =
           FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
                    TT_LOAD_BGR );
+        exec->vertical_lcd =
+          FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+                   TT_LOAD_VERTICAL_LCD );
         exec->subpixel_positioned =
           FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
                    TT_LOAD_SUBPIXEL_POSITIONED );
+        exec->gray_cleartype =
+          FT_BOOL( FT_LOAD_TARGET_MODE( load_flags ) !=
+                   TT_LOAD_GRAY_CLEARTYPE );
 #endif /* 0 */
 
       }
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -7286,6 +7286,14 @@
   /* Opcode range: 0x88                                                    */
   /* Stack:        uint32 --> uint32                                       */
   /*                                                                       */
+  /* XXX: UNDOCUMENTED: Selector bits higher than 9 are currently (May     */
+  /*      2015) not documented in the OpenType specification.              */
+  /*                                                                       */
+  /*      Selector bit 11 is incorrectly described as bit 8, while the     */
+  /*      real meaning of bit 8 (vertical LCD subpixels) stays             */
+  /*      undocumented.  The same mistake can be found in Greg Hitchcock's */
+  /*      whitepaper.                                                      */
+  /*                                                                       */
   static void
   Ins_GETINFO( TT_ExecContext  exc,
                FT_Long*        args )
@@ -7371,12 +7379,12 @@
           K |= 1 << 14;
 
         /********************************/
-        /* SYMMETRICAL SMOOTHING        */
+        /* VERTICAL LCD SUBPIXELS?      */
         /* Selector Bit:  8             */
         /* Return Bit(s): 15            */
         /*                              */
         /* Functionality still needs to be added */
-        if ( ( args[0] & 256 ) != 0 && exc->symmetrical_smoothing )
+        if ( ( args[0] & 256 ) != 0 && exc->vertical_lcd )
           K |= 1 << 15;
 
         /********************************/
@@ -7398,6 +7406,24 @@
           /* Functionality still needs to be added */
           if ( ( args[0] & 1024 ) != 0 && exc->subpixel_positioned )
             K |= 1 << 17;
+
+          /********************************/
+          /* SYMMETRICAL SMOOTHING        */
+          /* Selector Bit:  11            */
+          /* Return Bit(s): 18            */
+          /*                              */
+          /* Functionality still needs to be added */
+          if ( ( args[0] & 2048 ) != 0 && exc->symmetrical_smoothing )
+            K |= 1 << 18;
+
+          /********************************/
+          /* GRAY CLEARTYPE               */
+          /* Selector Bit:  12            */
+          /* Return Bit(s): 19            */
+          /*                              */
+          /* Functionality still needs to be added */
+          if ( ( args[0] & 4096 ) != 0 && exc->gray_cleartype )
+            K |= 1 << 19;
         }
       }
     }
--- a/src/truetype/ttinterp.h
+++ b/src/truetype/ttinterp.h
@@ -257,13 +257,17 @@
                                           /* subpixel hinting.  On if gray */
                                           /* or subpixel hinting is on.    */
 
-    /* The following 4 aren't fully implemented but here for MS rasterizer */
+    /* The following 6 aren't fully implemented but here for MS rasterizer */
     /* compatibility.                                                      */
     FT_Bool            compatible_widths;     /* compatible widths?        */
     FT_Bool            symmetrical_smoothing; /* symmetrical_smoothing?    */
     FT_Bool            bgr;                   /* bgr instead of rgb?       */
+    FT_Bool            vertical_lcd;          /* long side of LCD subpixel */
+                                              /* rectangles is horizontal  */
     FT_Bool            subpixel_positioned;   /* subpixel positioned       */
                                               /* (DirectWrite ClearType)?  */
+    FT_Bool            gray_cleartype;        /* ClearType hinting but     */
+                                              /* grayscale rendering       */
 
     FT_Int             rasterizer_version;    /* MS rasterizer version     */