KernPair Property

Build 1501 on 14/Nov/2017  This topic last edited on: 23/Mar/2016, at 12:20

Description

Returns the kern pair, specified by the ordinal number, in the currently loaded font.

Syntax

object.KernPair (i)

object

Required. Object name. Returned by Ted.GetFont.

i

Required. Kern pair index in the range of 0 to NKernPairs -1

Example

This script displays all kerning pairs and values of the font, numbered as 10031::

Dim objFont = Ted.GetFont

objFont.Code = 10031

dim str as String = ""

dim i as Integer

For i = 0 To objFont.NKernPairs-1

 str = str & objFont.KernPair(i) & " " & objFont.KernValue(i) & chr(13) & chr(10)

Next

msgbox (str)

 

This script displays the kerning value for the characters around insertion point.

dim sPair as String = sysGetChrPair

msgbox (sysGetKernPairValue (sPair))

 

Function sysGetChrPair as String

' v1

' returns the pair of characters around cursor

' or an empty string if no pair

 sysGetChrPair = ""

 if text.testcursorendtext then exit function

 dim sRight as String = text.gettxt

 if text.cursorleft = 0 then

   dim sLeft as String = text.gettxt

   text.cursorright

   sysGetChrPair = sLeft & sRight

 end if

end function

 

Function sysGetKernPairValue (sKernPair) as Integer

' v1

' returns the font kerning value in 1/1000em,

' or -2 if failed, or -1 if not found in the font

 sysGetKernPairValue = -1

 dim i as Integer

 if sKernPair = "" then sysGetKernPairValue = -2: exit function

 dim objFont = Ted.GetFont

 objFont.Code = text.gettextstatus.fontcode

 For i = 0 To objFont.NKernPairs-1

   if objFont.KernPair(i) = sKernPair then

     sysGetKernPairValue = objFont.KernValue(i)

     exit function

   end if

 Next

end function

 

Context

Font object