diff modules/freetype.tp @ 328:c1fad3d93861

Add getKerning to freetype module and use it in sample
author Michael Pavone <pavone@retrodev.com>
date Wed, 25 Mar 2015 00:16:37 -0700
parents 50760ba52b11
children
line wrap: on
line diff
--- a/modules/freetype.tp	Tue Mar 24 23:13:13 2015 -0700
+++ b/modules/freetype.tp	Wed Mar 25 00:16:37 2015 -0700
@@ -232,6 +232,45 @@
 				u16ret
 			}
 			
+			llMessage: hasKerning? withVars: {
+				ret <- object ptr
+			} andCode: {
+				if: (FT_HAS_KERNING: face) {
+					true
+				} else {
+					false
+				}
+			}
+			
+			llMessage: getKerning:mode withVars: {
+				oleft <- object ptr
+				oright <- object ptr
+				omode <- object ptr
+				left <- obj_uint32 ptr
+				right <- obj_uint32 ptr
+				mode <- obj_uint32 ptr
+				x <- obj_int32 ptr
+				y <- obj_int32 ptr
+				ret <- object ptr
+				kernVec <- FT_Vector
+				err <- int
+			} andCode: :oleft oright :omode {
+				left <- (mcall: uint32 1 oleft) castTo: (obj_uint32 ptr)
+				right <- (mcall: uint32 1 oright) castTo: (obj_uint32 ptr)
+				mode <- (mcall: uint32 1 omode) castTo: (obj_uint32 ptr)
+				err <- FT_Get_Kerning: face (left num) (right num) (mode num) (addr_of: kernVec)
+				if: err != 0 {
+					mcall: none 1 option
+				} else: {
+					x <- make_object: (addr_of: obj_int32_meta) NULL 0
+					y <- make_object: (addr_of: obj_int32_meta) NULL 0
+					x num!: ((addr_of: kernVec) x)
+					y num!: ((addr_of: kernVec) y)
+					ret <- mcall: x:y 3 vec x y
+					mcall: value 2 option ret
+				}
+			}
+			
 			firstChar <- {
 				_helper getFirstChar: faceOpaque _makeChar
 			}
@@ -280,6 +319,12 @@
 		_constant: color FT_LOAD_COLOR
 	}
 	
+	_kerning <- #{
+		_constant: default FT_KERNING_DEFAULT
+		_constant: unfitted FT_KERNING_UNFITTED
+		_constant: unscaled FT_KERNING_UNSCALED
+	}
+	
 	#{
 		init <- {
 			
@@ -319,5 +364,6 @@
 		}
 		
 		loadFlags <- { _loadFlags }
+		kerning <- { _kerning }
 	}
 }
\ No newline at end of file