撰寫 FontForge 的直譯程式來修改字型
翻譯:Edward G.J. Lee 李果正
FontForge 包含直譯器,所以,可以撰寫直譯程式來修改字型。
如果 fontforge 是由命令列直譯程式所啟動,將不會有視窗出現,在程式結束時,fontforge 也就跟著結束。
$ fontforge -script scriptfile.pe {字型檔名}
FontForge 也可以當成解譯器,此時 shell 會傳給 FontForge 來執行。如果將你的直譯程式設定為可執行
$ chmod +x scriptfile.pe
及和直譯程式開頭處有寫一行
#!/usr/local/bin/fontforge
(視 FontForge 安裝路徑)則可以直接執行這個直譯程式
$ scriptfile.pe {fontnames}
如果想在標準輸入讓 FontForge 讀入直譯程式,可以使用 "-" 當成「檔名」。(如果在編譯 FontForge 時沒有編入 X11,那麼啟動時,fontforge 會試圖從標準輸入來讀入)。
亦可在已啟動的 FontForge 功能選單 File->Execute Script,來讀入直譯程式檔,你可以利用 Preference 功能選單來定義一組常用的直譯程式檔,以便從功能選單上去啟動他。
此直譯語言提供功能選單中的多項存取功能。但目前不包括(可能永遠也不會包括)所有選單上的全部功能。(如果你發現有什麼需求,請讓我知道,我可能會為你而加入)。他不包含製作字框曲線的功能,但能讓你做較高階的修改字型。
如果你設定了 FONTFORGE_VERBOSE 環境變數(無需設定值,只需有這個變數存在即可),那麼 FontForge 會在標準輸出印出相對的直譯語言碼出來,正如同他執行這個程式碼一樣。
一般來說,我想像這些可能對某些情況有用,像拉丁語系字型將之擴充包含斯拉夫語系的字。因此,直譯程式可能:
-
將字型重編碼
-
置入相對應的斯拉夫語系 "A" 來取代拉丁語系 "A"
-
拷貝拉丁語系 "R" 為斯拉夫語系 "YA"
-
修整 "YA" 的水平位置
-
修正他的方位
-
以及等等……
這有點像 C 及 shell 混合的的語法。每個檔案相當於一個程序(procedure)。如同 shell 傳入引數一樣,$1, $2, ... $n 代表所接的各個引數。$0 本身則是程式名。$argc 是引數的個數。$argv[<expr>] 提供陣列來存取所傳入的引數。
項目可以是
-
變數的名稱(像 "$1" 或 "i" 或 "@fontvar" 或 "_global")
變數的作用範圍視第一個開頭字元而定。
-
'$' 代表他是內建變數。使用者不能指定一個以 '$' 開頭的變數名稱。但已有的此種內建變數可以另指定其他的值。
-
'_' 開頭的變數是全域變數,他在整個程式內都有效。你可以使用此種變數來做不同直譯程式間共用的變數(或從巢狀的直譯程式碼內做存取)。
-
'@' 開頭的變數是和字型關聯的。任兩個直譯程式對於同一字型會存取到這種相同的變數。
-
由其他正常英文字母開頭的變數是區域(local)變數。他是要在目前的直譯程式內有效。巢狀式的直譯程式區塊對於同一名稱的此種變數,會有不同的內涵。
-
整數可以使用 16、10、8 進位來表示。
-
一個 unicode 字碼位置(以 "0u" 或 "0U" 開頭,後附上 16 進位數字字串,這僅能用在 select 指令)。
-
實數(在 "C" locale 下 -- "." 代表小數點字元)
-
由英文雙引號或單引號括住的,代表是字串。他最大只能 256 bytes。"\n" 是換行字元。
-
程序的呼叫及檔案的引入。
-
括號括住的表示式。
支援三種註解的方式:
-
"#" 字元開頭,直至本行結束。
-
"//" 字元開頭,直至本行結束。
-
"/*" 及 "*/" 之間的部份。
表示式類似 C,但有些運算子已經略去。部份則是採自 shell scripts。運算子已稍加簡化。這些運算子(及他們的慣例)有:
-
單元運算子(unary operators)(+, -, !, ~, ++ (前置及後置), -- (前置及後置), () (程序呼叫), [] (陣列索引), :h, :t, :r, :e
這些大部份和 C 類同,最後四種則是借用自 shell script,而作用在字串上。
-
:h 取得絕對路徑頭(不含檔名)。
-
:t 取得絕對路徑尾(即檔名)。
-
:r 取得主檔名(不含延伸檔名)。
-
:e 取得延伸檔名。
-
*, /, % (乘除二元運算子)
-
+, - (加減算術二元運算子)
如果 + 之前的運算元是字串,則 + 會被視為連接前後字串,而非算術加法。此時,如果第二個運算元是數字,那將會被轉成字串型態,然後和前一字串相連接。
-
==, !=, >, <, >=, <= (比較運算子,可作用於兩整數或兩字串。)
-
&&, & (logical and, bitwise and. (logical and will do short circuit
evaluation))
-
||, |, ^ (logical or, bitwise or, bitwise exclusive or (logical or will do
short circuit evaluation))
-
=, +=, -=, *=, /=, %= (如 C 的指定運算子。如果 += 第一個運算元是字串,將會做連接的作用。)
請注意,並沒有逗點及 "?:" 運算子。邏輯 "and" 及 "or" 運算子已被簡化成和指定運算子有相等的優先性。
程序呼叫可使用 name token 或字串。如果 name token 或字串為 FontFogre 所認得的內建程序,那將來被直接執行,否則會被視為含 fontforge 直譯語言的檔案的檔名,並會被啟動(由於檔名可能含有不合法的字元,因此要使用一般字元來命名檔案名稱)。如果程序並不含路徑,那麼會視為檔案和被執行的直譯程式在同一目錄。程序最多只能接受 25 個引數。
陣列傳址(passed by reference),字串和數字則是傳值(passed by value)。
變數可指定值來定義(只能使用 "="),因此:
i=3
這不僅定義了 "i" 這個變數,而且指定了他的值。變數作用範圍不及於程序間的呼叫。
一個敘述可能是
-
一個表示式(運算式)。
-
if ( 表示式 )
敘述
{elseif ( 表示式 )
敘述}
[else
敘述]
endif
-
while ( 表示式 )
敘述
endloop
-
foreach
敘述
endloop
-
return [ 表示式 ]
-
shift
和 C 一樣,非 0 的運算式是被定義成真(true)。
敘述的傳回值,可以是(運算式)的值或一個程序,也可以不傳回任何東西(void)。
shift 的敘述是取材自 shell script,可讓引數移位(引數 0 代表 script 本身的檔名,這保留沒有改變)。
foreach 敘述只對目前字型作用。他對每個所選取的字(glyph)一一作用。但在敘述中每次只選取一個字。等執行完畢,會恢復原來的選取狀態(警告:不可使用 foreach 敘述來對整個字型做重編碼)。
敘述由於換行或分號而結束(可使用反斜線來把多行串成一行)。
實例:
i=0; #分號在此並不需要,但有也沒關係
while ( i<3 )
if ( i==1 /* pointless comment */ )
Print( "Got to one" ) // Another comment
endif
++i
endloop
FontForge 維持一個「目前字型」("current font")的概念,幾乎所有指令都是針對目前字型而作用(及必須是個字型)。如果從 File->Execute Script 來執行一個 script,所謂的目前字型就是正在編輯中的字型,否則將無開始的目前字型存在。Open(), New() 及 Close() 指令通通都會改變目前字型。FontForge 亦有 list 的概念,代表所有開啟的字型。這個 list 並沒有特定的順序,他開始於 $firstfont。
在 cid keyed fonts 也是相同的情形。FontForge 作用於 "current sub font",大部份指令也是作用於這個 sub font。CIDChangeSubFont() 指令可以改變他。
所有內建的變數以 "$" 開頭。你不可以新製造一個以 "$" 開頭的變數(但你可以改變他的值)。
-
$0 目前的 script 名稱
-
$1 第一個引數
-
$2 第二個引數
-
...
-
$argc
傳給 script 的引數的個數(至少是 1,因為 $0 永遠會存在)
-
$argv
所有引數的陣列,可存取所有的引數
-
$curfont
目前字型的檔名
-
$firstfont
字型 list 中的第一個字型檔名(能被 Open() 使用)。如果目前並無任何載入的字型,將會傳回空字串。這可用來決定目前是否有載入任何字型。
-
$nextfont
在字型 list 上排在 $curfont 之後的字型(如果僅載入一個字型,則這個變數的值為空字串)。
-
$fontchanged
傳回 1,如果目前字型有修改過,否則傳回 0(存檔後亦會是 0)。
-
$fontname
postscript FontName 欄位的字型名。
-
$familyname
postscript FamilyName 欄位的字型名。
-
$fullname
postscript FullName 欄位的字型名。
-
$fondname
設定這個變數將會決定產生 Mac Family 字型時的 FOND。
-
$weight
postscript Weight 欄位的名稱。
-
$copyright
postscript Notice 欄位的名稱。
-
$filename
字型檔檔名。
-
$fontversion
字型版本號字串。
-
$cidfontname
傳回 cid-keyed 最上層的字型名(或傳回 0,如果沒有的話)。
可以用於測試是否為 cid keyed 字型。
-
$cidfamilyname, $cidfullname, $cidweight, $cidcopyright
類似上一項。
-
$mmcount
如果不是 multiple master 字型則傳回 0。否則傳回其他值。
-
$italicangle postscript 料體角度(italic angle)欄位的值。
-
$curcid 傳回目前字型的字型名。
-
$firstcid 傳回 cid 字型的第一個字型的字型名。
cid font
-
$nextcid
傳回 cid 字型的次一個字型的字型名(如果這是最後一個 sub-font 則傳回空字串)。
-
$macstyle
傳回 macstyle 欄位的(一組位元表示這個字型是粗體、料體或緊密體(condensed)等。
-
$bitmaps
傳回陣列,包含了點陣字的像素大小(如果字型資料含有 greymaps,則會顯示成:
(<BitmapDepth><<16)|<PixelSize>)
-
$selection
傳回一陣列,含目前字型的每個字(glyph)的進入點,顯示這個 glyph 是入已被點選(0=>沒被點選 1=>已被點選)
-
$panose
傳回一陣列,含有字型的十個 panose 值。
-
$trace
如果被設成 1,則 FontForge 會追蹤每個程序呼叫。
-
$version
傳回一個字串,含 fontforge 的目前版本。這會看起來像 "020817" 之類的。
-
$<喜好設定項目>(例如
$AutoHint)讓你檢查喜好設定(Preference)的內容(使用 SetPref 來設定。)
以下的例子皆會執行字型的載入:
file = $firstfont
while ( file != "" )
Open(file)
/* Do Stuff */
file = $nextfont
endloop
內建的程序非常類似功能選單上的項目名稱。通常這裡只簡單的描述,詳細請見各功能選單的選項。
-
Print(arg1,arg2,arg3,...)
-
這在功能選單上並沒有相對應的項目。他會印出所有的引數至標準輸出,縱使沒有目前字型亦可執行。
-
PostNotice(str)
-
當從圖形界面啟動時,將會跳出顯示視窗來顯示這些定串(這個視窗不會影響原程式的執行,而且會在約一分鐘後消失)。當從命令列執行時,這些字串將會顯示在標準輸出。
-
Error(str)
-
印出 str 字串做為錯誤訊息,並中止目前的程式。
-
AskUser(question[,default-answer])
-
詢問使用者問題,並傳回答案(一個字串)。預設的回答(default-answer)也可以被指定。
-
Array(size)
-
配置一定大小的陣列。
a = Array(10)
i = 0;
while ( i<10 )
a[i] = i++
endloop
a[3] = "string"
a[4] = Array(10)
a[4][0] = "Nested array";
-
SizeOf(arr)
-
傳回陣列中的元素個數。
-
TypeOf(any)
-
傳回引數的型態。
-
"Integer"
-
"Real"
-
"Unicode"
-
"String"
-
"Array"
-
"Void"
(以下的型態為內部使用,我不認為使用者會看到他們。列出來只是求完整)
-
"LValue"
-
Strsub(str,start[,end])
-
傳回字串引數中的一個子字串。子字串從 start 的位置,止於 end 的位置(如果 end 省略的話,則代表剩下字串的最後位置),因此
Strsub("abcdef",2,3) == "c" 及 Strsub("abcdef",2) ==
"cdef"
-
Strlen(str)
-
傳回字串的長度。
-
Strstr(haystack,needle)
-
傳回字串 needle 在字串 haystack 中第一次出現的索引位置(如找不到則傳回 -1)。
-
Strrstr(haystack,needle)
-
傳回 needle 字串在 haystack 字串中最後一次出現的索引位置(如找不到則傳回 -1)。
-
Strcasestr(haystack,needle)
-
傳回字串 needle 在字串 haystack 中第一次出現的索引位置,並忽略大小寫(如找不到則傳回 -1)。
-
Strcasecmp(str1,str2)
-
比較兩字串,並忽略大小寫,如兩字串相等則傳回 0,如 str1<str2 則傳回負值,如 str1>str2 則傳回正值。
-
Strtol(str[,base])
-
盡可能的分析 str 的出現,並轉換為數值。第二個引數指定其底數表示法(預設值是 10 進位),他的行為如同 strtol(3)。
-
Strskipint(str[,base])
-
盡可能的分析 str 的出現,傳回第一個字元無法分析時的位移。
-
Strtod(str)
-
轉換一字串為浮點數。
-
LoadPrefs()
-
載入使用者的喜好設定。這在以前是會自動載入。但目前則是圖形界面時自動載入,但命令列直譯式語言時必需指定才會載入。
-
SavePrefs()
-
儲存目前的喜好設定。這在以前 SetPref 被呼叫時就會儲存,但目前在直譯語言則需指定才會儲存。
-
GetPref(str)
-
取得喜好設定值,str 是喜好設定項目。只有 boolean, integer, real, string 及 file 喜好設定項會被傳回。Boolean 及 real 項目會傳回整數值,file 項目會傳回字串。編碼(NewCharset)會傳回 magic 數,這在 get/set Pref 之外是沒有什麼意義的。
-
SetPrefs(str,val[,val2])
-
設定喜好設定項目,str 是項目名。如果項目是 real 型態則第二個引數會被傳遞,他的值將會是 val/val2。
-
DefaultOtherSubrs()
-
使用 Adobe 版本的 OtherSubrs 程序來傳回。
-
ReadOtherSubrsFile(filename)
-
讓 Type1 字型讀入一個新的 PostScript subroutines 用於 OtherSubrs 陣列。這個檔案格式比應有的格式複雜一點(因為我想不出如何分析 OtherSubrs 陣列為各別的 subroutines)。
-
這個 subroutine list 不應使用 [ ] 來表示。。
-
每一個 subroutine 應使用一行 '%%%%' 做為開始(其後會含有更多的東西)。
-
Subroutines 必需依一定的次序,並且有實際預期的意義。
-
假如你不希望去調整 hints,將最前面三個 subroutines 設為 "{}"
-
最多可指定 14 個 subroutines(0-13)。
-
任何第一個 subroutine 之前的文字,會被當成是版權宣告。
% Copyright (c) 1987-1990 Adobe Systems Incorporated.
% All Rights Reserved
% This code to be used for Flex and Hint Replacement
% Version 1.1
%%%%%%
{systemdict /internaldict known
1183615869 systemdict /internaldict get exec
...
%%%%%%
{gsave currentpoint newpath moveto} executeonly
%%%%%%
{currentpoint grestore gsave currentpoint newpath moveto} executeonly
%%%%%%
{systemdict /internaldict known not
{pop 3}
...
-
GetEnv(str)
-
傳回 unix 系統的環境變數內容。
-
FileAccess(filename[,prot])
-
正如 unix 系統的存取系統呼叫。如果檔案存在,傳回 0,不存我傳回 -1。如果 prot(protection) 被省略,則會檢查讀取權限。
-
WriteStringToFile("string","Filename"[,append])
-
建立一個名為 "Filename" 的檔案,並寫入 string。如果附加(append)的旗標存在而且非 0,則會附加於檔案最後。This deals with null-terminated strings, not with byte arrays. 失敗傳回 -1,否則寫入。
-
ReadStringFromFile("filename")
-
把整個檔案讀入於一字串。如果檔案不存在或是空檔案,則傳回空字串。傳回的字串會有足夠的空間存放檔案內容並加上一個 NUL byte。如果檔案含有 NUL,fontforge 會認為讀到這就結束。
-
UnicodeFromName(name)
-
查詢 FontForge 的內部資料庫關於字(glyph)的名稱(name),並傳回其相對應的 unicode 值。如果找不到此一名稱,則傳回 -1。這不會經由目前字型(如果有的話)來查詢。
-
Chr(int)
Chr(array)
-
指定一整數 [0,255] 並傳回其對應的字元字串。FontForge 內部以 utf8 編碼來解譯字串(事實上,FontForge 通常幾乎是使用 ASCII-US)。如果指定的是陣列,必須是整數的陣列,這將會傳回字串。
-
Ord(string[,pos])
-
傳回整數陣列,代表指定字串中各字元的編碼。如果 pos 也有指定,他必須是小於字串長度的整數,此時會傳回此指定位置字元的整數編碼。
-
Real(int)
-
轉換整數為浮點數。
-
Round(real)
-
轉換浮點數為捨去小數點後最相近的整數值。
-
Floor(real)
-
轉換浮點數為小於此浮點數的最大整數。
-
Ceil(real)
-
轉換浮點數為大於此浮點數的最小整數。
-
Int(real)
-
使用標準 C 的轉換方式將浮點數轉換為整數。
-
UCodePoint(int)
-
轉換引數為 unicode 編碼位置(一個特殊的型態,用於許多指令中)。
-
ToString(arg)
-
轉換引數為字串(此輸出即為 Print() 的輸出)。
-
IsNan(real)
-
傳回此浮點數是否為 nan。
-
IsFinite(real)
-
傳回此浮點數是否為有限(非無限亦非 nan)。
-
Sqrt(val)
-
傳回平方根。
-
Exp(val)
-
傳回 e^val
-
Log(val)
-
傳回 val 的自然對數。
-
Pow(val1,val2)
-
傳回 val1^val2
-
Sin(val)
-
傳回 val 的 sine 值。
-
Cos(val)
-
傳回 val 的 cosine 值。
-
Tan(val)
-
傳回 val 的 tangent 值。
-
ATan2(val1,val2)
-
傳回 arc-tangent 值。詳請參考 atan2(3)。
-
Utf8(int)
-
將整數 [0,0x10ffff] 轉換為其相對應的 unicode 編碼位置的 utf8 字串。如果指定陣列,則會傳回含此 unicdoe 編碼位置的所有 utf8 字串(但這不包括 surrogates)。
-
Rand()
-
傳回整數亂數。
-
-
FontsInFile(filename)
-
傳回一字串陣列,含此字型的所有字型的名稱。通常一個字型檔只含一個字型,但有些(mac 字型組(suitcases),dfonts,ttc 檔,svg 檔,等等)可能含多數字型在一個字型檔中。如果這個字型檔不含任何字型(或此字型檔並不存在,或並無字型名稱)則傳回一個長度為 0 的陣列。
-
Open(filename[,flags])
-
這會使名為 filename 的字型檔成為目前字型。如果此字型檔尚未載入記憶體,此時會載入。這無需在有目前字型的情況下被執行。
當載入的是 ttc 檔(mac suitcase, dfont, svg, 等),可以經由小括號來選定特定的字型名來載入,例如 Open("gulim.ttc(Dotum)")
flags 選項目前只有一個旗標:
-
1 =>
不管 fstype 如何設定,使用者都被假定有檢視這個字型的授權。
-
New()
-
產生一個新字型。在沒有目前字型的情況也能被執行。
-
Close()
-
這會釋出目前字型所佔用的記憶體並把目前字型從載入字型的清單中移除。執行過後將會沒目前字型。
-
Save([filename])
-
如果沒有指定檔名,那麼存檔成目前字型的 sfd 檔案(如果字型無 sfd 檔將會產生錯誤)。如果有引數,那將會是執行 SaveAs 的動作,存目前字型為所指定的檔名。
[譯註] GUI 界面的情形下,如無 sfd 檔,會跳出視窗要使用者輸入檔名而非如 script 一樣發出錯誤訊息。
-
Generate(filename[,bitmaptype[,fmflags[,res[,mult-sfd-file]]]])
-
產生字型。字型的型態是取決於延伸檔名。有效的延伸檔名為:
點陣字的型態可能是:
Note: If you request bitmap output then all strikes in the current font database
will be output, but this command will not create bitmaps, so if there are
no strikes in your font database, no strikes will be output (even if you
ask for them). If you wish to output bitmaps you must first create them with
the BitmapsAvail scripting command or
Element->Bitmaps Avail.
fmflags 旗標控制
-
-1 =>
預設值(對於 postscript 字型會產生 afm 檔,但不會產生 pfm 檔。完整的 'post' 表格,ttf hints)
-
fmflags&1 =>
產生一個 afm 檔(假如你生成 multiple master 字型,那麼這個設定會讓你產生多個 afm 檔(一個是 master 主檔,一個是這個字型的預設版本)及一個 amfm 檔)
-
fmflags&2 => 產生一個 pfm 檔
-
fmflags&4 => 產生一個精簡版的 'post' 表格,裡頭沒有 glyph 名稱的資訊
-
fmflags&8 => 不含 ttf instructions
-
fmflags&0x10 =>
對於 apple 及 ms/adobe 的 true/open type 檔案定義不同的地方,使用 apple 的定義(否則使用 ms/adobe 的)
目前,這會影響所嵌入的點陣字(Apple 稱這些表格為 'bdat',ms/adobe 則稱為 'EBDT'),'name' 表格的 PostScript 名(Apple 認為只能出現一次,ms/adobe 則認為至少兩次),及不管是 morx/feat/kern/opbd/prop/lcar 或 GSUB/GPOS/GDEF 表格皆會被產生。
-
fmflags&0x20 => 產生一個 'PfEd' 表格,儲存 glyph 的註解
-
fmflags&0x40 => 產生一個 'PfEd' 表格,儲存 glyph 的顏色
-
fmflags&0x80 =>
產生能同時在 Apple 及 MS 平台運作的必要表格
假如 OpenType 表格存在,Apple Mac 10.4 (Tigger) 這個地方弄錯了,AAT 表格會被忽略 -- 別人大約是這樣告訴我(我無法親自做這個測試)。很不幸的,Apple 並沒有實作完整的 OpenType,因此結果總是會錯誤。
-
假如你不需要 OpenType 及 Apple 的表格(正如舊的 'kern' 表格),那麼 0x80 及 0x10 兩個同時設定。
-
fmflags&0x100 =>
產生一個字(glyph)的對應表(GID=>glyph name, unicode map)。這個對應表檔案的延伸檔名將會是 ".g2n"。
-
fmflags&0x200 =>
產生一個 TeX 表格,包括(幾乎所有)的 TeX 字型描述(font metrics)資訊
-
fmflags&0x400 => 產生一個 ofm 檔 (給 omega 使用)
-
fmflags&0x10000 => 產生一個 tfm 檔
-
fmflags&0x40000 => 不調整 hints
-
fmflags&0x80000 => 不包括 postscript hints
-
fmflags&0x200000 => round postscript coordinates
res 引數調整 bdf 字型的解析度。-1 代表由 fontforge 自行去預測。
假如檔名含有 "%s" 及 延伸檔名是 ".pf[ab]",那麼 "mult-sfd-file" 可以出現。這種檔名代表把目前的現有編碼對應至各子字型(subfont)中。這裡有個例子。假如這個對應檔不存在,FontForge 會去預設的搜尋路徑去尋找所需要的檔案,如果找不到,那麼字型將不會被產生。
-
GenerateFamily(filename,bitmaptype,fmflags,array-of-font-filenames)
-
從所載入的字型檔中產生各字型陣列中字型的 mac font family (FOND)。filename,bitmaptype,fmflags 同前所述。
#!/usr/local/bin/fontforge
a = Array($argc-1)
i = 1
j = 0
while ( i < $argc )
# Open each of the fonts
Open($argv[i], 1)
# and store the filenames of all the styles in the array
a[j] = $filename
j++
i++
endloop
GenerateFamily("All.otf.dfont","dfont",16,a)
-
ControlAfmLigatureOutput(script,lang,ligature-tag-list)
-
所有三個引數都必需是字串。前兩個引數的字串必需少於四個字元,第三個引數包含由逗點分開且少於四個字元的字串清單(list)中。連體字(ligature)在以下的情況下才會被置於 AFM 檔中:
-
他們的 tags 能和 list 其中之一的進入點配合
-
他們在所指定的語言及直譯程式中被啟動("*" 在 script 及 lang 中皆代表通用字元)
預設的設定是:
ControlAfmLigatureOutput("*","dflt","liga,rlig")
-
Import(filename[,toback[,flags]])
-
可匯入點陣字或背景圖檔進入各 glyph 中。可有一或二個引數。第一個引數必須為檔名字串。延伸檔名指示了如何匯入的方式。
-
延伸檔名是 ".bdf" 則匯入 bdf 點陣字
-
延伸檔名是 ".pcf" 則匯入 pcf 點陣字
-
延伸檔名是 ".ttf" 則匯入 EBDT 點陣字或 bdat 表格由 ttf 中找尋點陣字
-
延伸檔名是 ".pk" 則匯入 metafont pk 點陣字,預設會置於背景
-
否則,延伸檔名是其他圖檔,則會載入圖檔置於背景。
-
如果檔名包含 "*",則需視辨識的樣本是否認得,如果認得,所有符合的圖檔將會被正確載入並置於背景
-
否則,將會需要數個檔名(各檔名間由分號來分隔),第一個圖檔將會置於第一個被選取的 glyph 的背景,第二個圖檔置於第二個被選取的 glyph 背景,依此類推。
-
如果延伸檔名是 "eps",則 eps 圖檔將會被合併於前景中。The file may be specified as for images (except the extension should be "eps" rather than an image extension). FontForge 對於 eps 檔案的讀取能力有限。
-
如果延伸檔名是 "svg",那麼 svg 檔將會被前入前景。
第二個引數如果存在,他必須是一個整數。假如第一個引數是點陣字,那麼第二個引數控制他匯入 bitmap list (0) 或布滿 glyph 的背景 (1)。對於 eps 及 svg 檔,這個引數控制曲線置於 glyph 前景或背景層。
假如存在第三個引數,他也必須是整數,他提供一組旗標來控制匯入 EPS 檔的行為。
-
8 => 修正方向
-
4 => 企圖使用 TeX 橡皮擦 (使用白色 pen 去塗抹筆畫)
-
2 => 刪資重疊(overlap)
-
Export(format[,bitmap-size])
-
對於目前字型中每個所選取的 glyph,這個指令會匯出這些 glyph 檔案至目前工作目錄。format 必須是一個字串,而且必須以以下字串為結尾:
-
eps -- 被選取的 glyphs 將會匯出其字框曲線為 eps 檔。這些檔案會被命名成 "<glyph-name>_<font-name>.eps".
-
pdf --
被選取的 glyphs 將會匯出其字框曲線為 pdf 檔。這些檔案會被命名成 "<glyph-name>_<font-name>.pdf"。
-
svg --
被選取的 glyphs 將會匯出其字框曲線為 svg 檔。這些檔案會被命名成 "<glyph-name>_<font-name>.svg"。
-
fig --
被選取的 glyphs 將會匯出其字框曲線為 xfig 檔(效果不佳)。這些檔案會被命名成 "<glyph-name>_<font-name>.fig"。
-
xbm --
第二個引數指定點陣字的大小,被選取的 glyph 會匯出 xbm 檔。這個檔案會被命名為 "<glyph-name>_<font-name>.xbm"。
-
bmp --
第二個引數指定點陣字的大小,被選取的 glyph 會匯出 bmp 檔。這個檔案會被命名為 "<glyph-name>_<font-name>.bmp"。
-
png --
第二個引數指定點陣字的大小,被選取的 glyph 會匯出 png 檔。這個檔案會被命名為 "<glyph-name>_<font-name>.png"。
格式可能為以上的檔案格式相一致,或可能含完整檔名(附上格式的控制),這些會以檔案格式為其延伸檔名:
"Glyph %n from font %f.svg"
"U+%U.bmp"
所有字元在格式字串裡,除了 % 外,將會如實的照列。假如碰到 % 後接以下的控制字元,他的行為是:
-
%n --
插入 glyph 名(或長名稱的情況,其前 40 個字元)
-
%f --
插入字型名(或其前 40 個字元)
-
%e --
插入 glyph 的編碼,以十進位整數表示。
-
%u --
插入 glyph 的 Unicdoe 編碼位置,以小寫的 16 進位表示。
-
%U --
插入 glyph 的 Unicdoe 編碼位置,以大寫的 16 進位表示
-
%% --
插入一個 %
-
MergeKern(filename)
-
從 afm 或 tfm 檔,載入 Kerning 資訊,並合併至目前字型中。
-
PrintSetup(type,[printer[,width,height]])
-
允許設定列印指令型態。其值為 0 至 5
-
0 => 由 lp 列印
-
1 => 由 lpr 列印
-
2 => 輸出至 ghostview
-
3 => 輸出為 PostScript 檔
-
4 => 其他列印指令
-
5 => 輸出為 pdf 檔
如果型態為 4(其他),而且第二個引數有指定,那麼這第二個引數必須含這些其他列印指令的字串
如果型態為 0(lp) 或 1(lpr),而且第二個引數有指定,那麼謙第二個引數必須含雷射印表機的名稱
(如果第二個引數是空字串,則設定無效)。
第三及第四個引數必須指定頁寬及頁高。單位是 1/72 inches(約 points),因此 8.5x11" 頁面是 612,792,而 A4 的頁面是(約)595,842。
-
PrintFont(type[,pointsize[,sample-text/filename[,output-file]]])
-
依據
PrintSetup
印出目前字型。其型態的值為(他的意義參考 section on printing):
-
0 =>
依指定的 pointsize 印出整個字型
-
1 =>
印出所選取的 glyph,並充滿整個頁面
-
2 =>
以數個不同大小印出所選取的字
-
3 =>
依所指定的大小,由檔案中印出文字範例
-
4 =>
印出文字範例,但第三個引數不當做檔名,而為文字範例本身(utf-8 編碼)
字的大小(pointsize)可以是一單獨的整數,或一整數的陣列。這只在型態 0, 3 及 4 意義。假如省略或設為 0,那會使用預設的大小。字型只會依單一值顯示。
如果選取列印型態 3,那麼你可以提供列印範例文字檔。這個檔可以是 ucs2 格式(以 0xfeff 起頭),或使用目前預設的編碼。空字串或省略的引數 FontForge 將會使用預設值。
假如你的 PrintSetup 指定印出至檔案(不管 PostScript 或 pdf),那麼第四個引數提供輸出檔的檔名。
-
Quit(status)
-
使 FontForge 傳指定的 status 而跳出(不企圖存檔)。在無目前字型時這個指令亦可以被執行。
-
Cut
-
拷貝所選取的字,並把他存於剪貼簿中,然後把原字刪除。
-
Copy
-
拷貝所選取的所有字。
-
CopyReference
-
拷貝所選取的字的參考(references),並存於剪貼簿中。
-
CopyWidth
-
拷貝所選取字的字寬,並存於剪貼簿中。
-
CopyVWidth
-
拷貝所選取字的直寫字寬,並存於剪貼簿中。
-
CopyLBearing
-
拷貝所選取字的左邊 bearing,並存於剪貼簿中。
-
CopyRBearing
-
拷貝所選取字的右邊 bearing,並存於剪貼簿中。
-
CopyGlyphFeatures(arg,...)
-
拷貝所選取字(僅僅一個)的特性(features),並存於剪貼簿中。
arg 引數可以是四個字元的 opentype tag 字串(例如 "kern"),或 mac 性質的設定字串(例如 "<1,1>")。或者,他也可以是一個整數,但必需是上面所說的其中一種的表示方法。或者,arg 也可以是字串或整數陣列(在這種情形可能只有一個引數)。
The feature 'kern' will match any kerning pair that has the currently selected
glyph as the first character of the two. The (made up) feature '_krn' will
match any kerning pair that has the currently selected glyph as the last
character of the two. Similary for 'vkrn' and '_vkn'.
-
Paste
-
貼上剪貼簿中的資料於目前字型所選取的字中(會移除原有的內容)。
-
Paste Into
-
貼上剪貼簿中的資料於目前字型中(這會合併原字及拷貝過來的新內容)
-
PasteWithOffset(xoff,yoff)
-
在執行 PasteInto() 前先平移貼簿中的資料 xoff,yoff。可以用於建立含重音符號的字。
-
SameGlyphAs
-
如果剪貼簿中含某單一字的參考資訊,則所有選取的字都會參考到這個字。
Adobe 建議你避免這麼做。使用參考來代替。在某種情況下(我想 pdf 檔是其中之一)一個字擁有多個編碼會產生問題(Acrobat 使用字的編碼對應來推算出 Unicode 字碼。但如果一個字有兩個 Unicode 字碼的情況下,將會使對應失敗)。
-
Clear
-
清除所有選取的字。
-
ClearBackground
-
清除所有選取字的背景。
-
CopyFgToBd
-
拷貝所有所選取的字的前景曲線至背景。
-
Join([fudge])
-
將所選取的字裡頭的開放路徑連結起來。如果有指定 fudge,則 endpoints 僅需要在其他欲合併的 udge em-units 之內即可。
-
UnlinkReference
-
移除所有選取字的參考。
-
SelectAll
-
選取所有的字。
-
SelectNone
-
取消所有字的選取。
-
SelectInvert()
-
反轉選取(有選的變不選,不選的變選取)。
-
Select(arg1, arg2, ...)
-
取消以前的選取,並重新選取成對引數(含)間的字。如果最後一個引數無法成對,那這個引數只選取單獨的一個字。引數的指定可能是:
-
一個整數,指定目前字型編碼的實際字的位置。
-
postscript unicode 字的名稱,這會對應至目前字型的編碼。
-
unicode 字碼(0u61),這會對應至目前字型的編碼。
-
假如引數只有一個,而且是個陣列,則所有陣列裡的元素將會被選取。因此,array[0] 將會選取編碼 0 的字,依此類推。陣列可以是不同的數目當做元素,但必須使用同一種格式,正如虛擬變數 $selection 所傳回的一樣。
-
SelectMore(arg1, arg2, ...)
-
和 Select() 同,但不取消前所選取的字,所以他會延續的選取字。
-
SelectFewer(arg1, arg2, ...)
-
和 SelectMore() 同,但他會讓前所選取的字減少。
[譯註]:即將前所選取的字,再選其中的幾個字,讓他取消選取。
-
SelectSingletons(arg1, ...)
-
不以成對引數間範圍來選取,而是依引數指定的各別的字來選取。
-
SelectMoreSingletons(arg1, ...)
-
-
SelectFewerSingletons(arg1, ...)
-
-
SelectIf(arg1,arg2, ...)
-
和 Select() 同,但所選取的字不在目前字型時會傳回錯誤碼,而不只是訊號。
-
0 => 無錯誤,也沒有選取任何字。
-
<正數> =>
無錯誤,所選取的字如期被選取。
-
-2 => 有錯誤,沒有任何字被選取
-
-1 =>
有錯誤,但之前至少有一個字被選取。
-
SelectChanged([merge])
-
選取所有經修改過的字。If merge is true, will or the current selection with the new one.
-
SelectHintingNeeded([merge])
-
選取所有 FontForge 認為這些字的 hints 必須更新者。
-
SelectByATT(type,tags,contents,search-type)
-
參考 Select By ATT menu command。type 的值可為:
"Position" |
Simple position |
"Pair" |
Pairwise positioning (but not kerning) |
"Substitution" |
Simple substitution |
"AltSubs" |
Alternate substitution |
"MultSubs" |
Multiple substitution |
"Ligature" |
Ligature |
"LCaret" |
Ligature caret |
"Kern" |
Kerning |
"VKern" |
Vertical Kerning |
"Anchor" |
Anchor class |
search_type 可為
-
Select Results
-
Merge Selection
-
Restrict Selection
-
-
Reencode(encoding-name[,force])
-
將目前字型依指定的編碼重新編碼,換定的編碼可能是:
緊密的,原有的,
iso8859-1, isolatin1, latin1, iso8859-2, latin2, iso8859-3, latin3, iso8859-4,
latin4, iso8859-5, iso8859-6, iso8859-7, iso8859-8, iso8859-9, iso8859-10,
isothai, iso8859-13, iso8859-14, iso8859-15, latin0, koi8-r, jis201, jisx0201,
AdobeStandardEncoding, win, mac, symbol, wansung, big5, johab, jis208, jisx0208,
jis212, jisx0212, sjis, gh2312, gb2312packed, unicode, iso10646-1,
TeX-Base-Encoding, 使用者自訂。
你亦可指定強迫轉換為某種編碼。
注意:某些編碼是由 glyph
名稱來指定(例如:使用者自訂以 postscript 編碼陣列為編碼),其他是由 unicode
字碼清單來指定(大部份的 AdobeStandard、TeX
及使用者自訂的內建編碼)。如果你重編碼至有 glyph 名稱的方式,ff 首先會將
glyphs 移到適當的位置,然後強行將所有 glyphs
名稱修正為正確的。最明顯的例子就是 "fi" 連體字:AdobeStandard
認為他應該是名為 "fi",但現代的字型則傾向名為
"f_i"。重編碼為 AdobeStandard 會把這些字移到正確的地方,並把他名為 "fi"。
-
SetCharCnt(cnt)
-
設定字型的編碼位置數量。
-
LoadEncodingFile(filename)
-
-
LoadTableFromFile(tag,filename)
-
兩個引數都必須是字串,第一個引數必須是四個字元的表格標籤。檔案會被讀入,並保存於所指定標籤的字型表格內容,不要使用 ff 認為是標籤的檔名!
-
SaveTableToFile(tag,filename)
-
兩個引數都必須是字串,第一個引數必須是四個字元的表格標籤。會搜尋所有的表格清單,找到指定標籤的表格後存入指定的檔案。
-
RemovePreservedTable(tag)
-
搜尋現有的表格,找到指定標籤的表格後將他從字型中刪除。
-
HasPreservedTable(tag)
-
如果字型含有所指定標籤的表格,傳回真。
-
SetFontOrder(order)
-
Sets the font's order. Order must be either 2 (quadratic) or 3 (cubic). It
returns the old order.
指定字型階次。字型階次必須是 2 (二次,quadratic) 或 3 (三次,cubic)。並傳回舊有的字型階次。
-
SetFontHasVerticalMetrics(flag)
-
設定字型是否有直寫字型描述。0 代表沒有,其他的值代表有,並傳回舊有的設定值。
-
SetFontNames(fontname[,family[,fullname[,weight[,copyright-notice[,fontversion]]]]])
-
設定各種和字型相關的 postscript 名稱。假如省略(或空字串),將會使用原有的名稱。
-
SetFondName(fondname)
-
Sets the FOND name of the font.
-
SetItalicAngle(angle[,denom])
-
設定 postscript 斜體角度欄位。假如 denom 有指定,則角度會被除以 denom(得到他的實際值)。角度的單位必須是度。
-
SetMacStyle(val)
SetMacStyle(str)
-
引數可以是整數或字串。如果是整數,他是一組位元,表示的方式如 mac 的定義
| 0x01 |
粗體(Bold) |
| 0x02 |
斜體(Italic) |
| 0x04 |
底線(Underline) |
| 0x08 |
描邊(Outline) |
| 0x10 |
陰影(Shadow) |
| 0x20 |
長體(Condensed) |
| 0x40 |
平體(Extended) |
| -1 |
FontForge 將自行由 fontname 猜測他的風格 |
位元 0x20 及 0x40 (condensed and extended) 不能同時設定。
如果引數是字串,這個字串必須是相關的風格名,例如 "Bold Italic Condensed"
-
SetTTFName(lang,nameid,utf8-string)
-
設定 MS 平台的 truetype 名稱。lang 必須是 MS 支援的
language/locales
之一,nameid 必須是
small
integers used to indicate a standard name
之一,最後一個引數必須是 utf8 編碼字串,這將會成為進入點。空字串("")可用於清除進入點。
例子:設定 SubFamily 字串為 American English language/locale
SetTTFName(0x409,2,"Bold Oblique")
-
GetTTFName(lang,nameid)
-
lang 及 nameid 引數同上。這會傳回目前的值為 utf8 編碼字串。不存在的組合將會傳回空字串 ""。
-
SetPanose(array) SetPanose(index,value)
-
設定字型的 panose 值。他可以是含 10 個設定整數的陣列,也可以是兩個整數而設定為
font.panose[index] = value
-
SetOS2Value(field-name,field-value)
-
設定 OS/2 表格的其中一個欄位內容。field-name 必須是以下所列出的字串之一:
Weight, Width, FSType, IBMFamily, VendorID, Panose,
WinAscent, WinAscentIsOffset
功能選單上有相等於 WinAscent 欄位 & []Offset 的檢查視窗
Font Info->OS/2->Misc.
其中 WinAscentOffset 控制 WinAscent 為絕對數值或相對的某數的相對數值。
WinDescent, WinDescentIsOffset,
TypoAscent, TypoAscentIsOffset,
TypoDescent, TypoDescentIsOffset,
HHeadAscent, HHeadAscentIsOffset,
HHeadDescent, HHeadDescentIsOffset,
TypoLineGap, HHeadLineGap, VHeadLineGap,
SubXSize, SubYSize, SubXOffset, SubYOffset
Sets the Subscript x/y sizes/offsets.
SupXSize, SupYSize, SupXOffset, SupYOffset
Sets the Superscript x/y sizes/offsets.
StrikeOutSize, StrikeOutPos
通常第二個引數是整數,但 VendorID 是四個字元的 ASCII 字串,而 Panose 是 10 個元素的整數陣列。
-
GetOS2Value(field-name)
-
引數和 tag 字串是一組的。
VendorId 傳回一個字串,Panose 傳回一個陣列。其他傳回整數。
-
SetMaxpValue(field-name,value)
-
field-name 必須是以下之一的字串:
Zones, TwilightPntCnt,
StorageCnt, MaxStackDepth, FDEFs, 或 IDEFs。Value 必須是一個整數。
-
GetMaxpValue(field-name)
-
field-name 同上。
-
SetUniqueID(value)
-
設定 postscript uniqueid。如果設定為 0,那麼 FontForge 將會自動取一個合理的亂數為其值。
-
SetTeXParams(type,design-size,slant,space,stretch,shrink,xheight,quad,extraspace[...])
-
設定 TeX(內文)字型引數。
Type 可以是 1、2 或 3,代表他是一般內文、數學或延伸數學字型。
DesignSize 是字型原來設計時的點數大小。
其餘的引數的描述,請參考 Knuth 的 The MetaFont Book,頁 98-100。
Slant 是由百分比來表示的。其他的是由 em-units 來表示。
如果 type 是 1,那麼其餘九個引數都必須要指定。如果 type 是 2,則需 24 個引數(多出來的 15 個引數請參考 the metafont book)。如果 type 是 3,則需要 15 個引數。
-
GetTeXParam(index)
-
如果 index == -1,則 tex 字型的 type 必須指定(text==0, math==1, math extended=2)
否則,index 是用於索引 tex 字型引數陣列。
-
SetCharName(name[,set-from-name-flag])
-
設定目前選取的字的名稱。如果 set-from-name-flag 沒有指定或有指定且指定為 true,那麼也會同時設定 unicode 值及符合此名稱的連體字字串。
-
SetUnicodeValue(uni[,set-from-value-flag])
-
設定目前選取的字的 unicode。如果 set-from-name-flag 沒有指定或有指定且指定為 true,那麼也會同時設定字的名稱及符合此 unicode 的連體字字串。
-
SetCharColor(color)
-
設定目前選取的字的顏色(由 24 bit rgb(0xff0000 是紅色)來表示,-2 代表預設的顏色)。
-
SetCharComment(comment)
-
設定目前選取的字的註解。註解最後會轉成 uniocde 編碼。
-
BitmapsAvail(sizes)
-
控制字型資料庫中所儲存點陣字的大小。傳回大小的陣列。如果所指定的大小並不存在於字型資料庫裡頭,將會自動產生。如果沒有指定的大小存在於字型資料庫裡頭,那麼將不會去做任何動作。
如果你需要指定 greymap fonts,那麼 low-order 16 bits 代表像素大小(pixel size),high order 16 bits 代表 bits/pixel。因此,0x8000c 代表 12 pixel 字型,每個 pixel 8 bits,0xc 或 0x1000c 代表 12 pixel 的點陣字型。
-
BitmapsRegen(sizes)
-
允許更新所指定閱已存在於字型中的的點陣字。所有選取的字將會被再產生所指定 pixel 大小的點陣字。
-
ApplySubstitution(script,lang,tag)
-
All three arguments must be strings of no more that four characters (shorter
strings will be padded with blanks to become 4 character strings). For each
selected glyph this command will look up that glyph's list of substitutions,
and if it finds a substitution with the tag "tag" (and if that substitution
matches the script and language combination) then it will apply the
substitution-- that is it will find the variant glyph specified in the
substitution and replace the current glyph with the variant, and clear the
variant.
三個引數都必須是不超過 4 個字元的字串(少於 4 個字元的部份將會填入空白字元)。
FontForge 認得 "*" 這個通用字元(但 tag 引數不能使用)。所以,如果想取代所有的字其 tag 為 vertical variants 時:
SelectAll()
ApplySubstitution("*","*","vrt2")
-
Transform(t1,t2,t3,t4,t5,t6)
-
每個引數會除以 100,然後所選取的所有字會依此矩陣做變換(transform)。
-
HFlip([about-x])
-
All selected glyphs will be horizontally flipped about the vertical line
through x=about-x. If no argument is given then all selected glyphs will
be flipped about their central point.
-
VFlip([about-y])
-
All selected glyphs will be vertically flipped about the horizontal line
through y=about-y. If no argument is given then all selected glyphs will
be flipped about their central point.
-
Rotate(angle[,ox,oy])
-
依指定的角度旋轉所有被選取的字。如果最後二個引數有指定,他代表旋轉的中心點,否則將依字的中心點來旋轉。
-
Scale(factor[,yfactor][,ox,oy])
-
所有被選取的字會被縮放(縮放比例是百分比)
-
如果只有一個引數,會以字的中心點來做縮放。
-
二個引數,第一個代表 x 軸的縮放比例,第二個代表 y 軸的縮放比例。縮放的中心仍然是字的中心點。
-
with three arguments they will be scaled uniformly about the specified center
-
with four arguments they will be scaled differently about the specified center
-
Skew(angle[,ox,oy])
Skew(angle-num,angle-denom[,ox,oy])
-
All selected glyphs will be skewed by the given angle.
-
Move(delta-x,delta-y)
-
All selected glyphs will have their points moved the given amount.
-
MoveReference(delta-x,delta-y,[refname/ref-unicode]+)
-
References may be identified either by a string containing the name of the
glyph being refered to, or an integer containing the unicode code point of
the glyph being refered to, there may be an arbetrary (positive) number of
references specified. Each selected glyph will be searched for references
that match the name/unicode-values given, all references found will be moved
by the specified offsets.
MoveReference(300,0,"acute",0xb4)
Will move any acute or grave references 300 em-units horizontally from where
they currently are
-
PositionReference(x,y,[refname/ref-unicode]+)
-
References may be identified either by a string containing the name of the
glyph being refered to, or an integer containing the unicode code point of
the glyph being refered to, there may be an arbetrary (positive) number of
references specified. Each selected glyph will be searched for references
that match the name/unicode-values given, all references found will be at
the specified location.
PositionReference(0,0,"circumflex")
Will position any references to circumflex so that they are where the base
circumflex is
-
ScaleToEm(em-size)
ScaleToEm(ascent,descent)
-
Change the font's ascent and descent and scale everything in the font to
be in the same proportion to the new em (which is the sum of ascent and descent)
value that it was to the old value.
-
NonLinearTransform(x-expression,y-expression)
-
Takes two string arguments which must contain valid expressions of x and
y and transforms all selected glyphs using those expressions.
<e0> := "x" | "y" | "-" <e0> | "!" <e0> | "(" <expr> ")" |
"sin" "(" <expr> ")" | "cos" "(" <expr> ")" | "tan" "(" <expr> ")" |
"log" "(" <expr> ")" | "exp" "(" <expr> ")" | "sqrt" "(" <expr> ")" |
"abs" "(" <expr> ")" |
"rint" "(" <expr> ")" | "float" "(" <expr> ")" | "ceil" "(" <expr> ")"
<e1> := <e0> "^" <e1>
<e2> := <e1> "*" <e2> | <e1> "/" <e2> | <e1> "%" <e2>
<e3> := <e2> "+" <e3> | <e2> "-" <e3>
<e4> := <e3> "==" <e4> | <e3> "!=" <e4> |
<e3> ">=" <e4> | <e3> ">" <e4> |
<e3> "<=" <e4> | <e3> "<" <e4>
<e5> := <e4> "&&" <e5> | <e4> "||" <e5>
<expr> := <e5> "?" <expr> ":"
Example: To do a perspective transformation with a vanishing point at (200,300):
NonLinearTrans("200+(x-200)*abs(y-300)/300","y")
This command is not available in the default build, you must modify the file
configure-fontforge.h and then rebuild FontForge.
-
ExpandStroke(width)
ExpandStroke(width,line cap, line join)
ExpandStroke(width,line cap, line join,0,removeinternal /external flag)
ExpandStroke(width,calligraphic-angle,height-numerator,height-denom)
ExpandStroke(width,calligraphic-angle,height-numerator,height-denom, 0, remove
internal/external flag)
-
In the first format a line cap of "butt" and line join of "round" are
implied.
A value of 1 for remove internal/external will remove the internal contour,
a value of 2 will remove the external contour.
The first three calls simulate the PostScript "stroke" command, the two final
simulate a caligraphic pen.
-
Width
-
In the PostScript "stoke" command the width is the distance between the two
generated curves. To be more precise, at ever point on the original curve,
a point will be added to each of the new curves at width/2 units as measured
on a vector normal to the direction of the original curve at that point.
In a caligraphic pen, the width is the width of the pen used to draw the
curve.
-
Line-cap
-
Can have one of three values: 0=> butt, 1=>round, 2=>square
-
Line-join
-
Can have one of three values: 0=>miter, 1=>round, 2=>bevel
-
caligraphic-angle
-
the (fixed) angle at which the pen is held.
-
height-numerator/denominator
-
These two values specify a ratio between the height and the width
height = numerator * width / denominator
(the scripting language only deals in integers, so when fractions are needed
this kludge is used)
-
remove internal/external contour flags
-
1 => remove internal contour
2=> remove external contour
(you may not remove both contours)
4 => run remove overlap on result (buggy)
-
Outline(width)
-
Strokes all selected glyphs with a stroke of the specified width (internal
to the glyphs). The bounding box of the glyph will not change. In other words
it produces what the mac calls the "Outline Style".
-
Inline(width,gap)
-
Produces an outline as above, and then shrinks the glyph so that it fits
inside the outline. In other words, it produces an inlined glyph.
-
Shadow(angle,outline-width,shadow-width)
-
Converts the selected glyphs into shadowed versions of themselves.
-
Wireframe(angle,outline-width,shadow-width)
-
Converts the selected glyphs into wireframed versions of themselves.
-
RemoveOverlap()
-
Does the obvious.
-
OverlapIntersect()
-
Removes everything but the intersection.
-
FindIntersections()
-
Finds everywhere that splines cross and creates points there.
-
Simplify()
Simplify(flags,error[,tan_bounds[,bump_size[,error_denom,line_len_max]]])
-
With no arguments it does the obvious. If flags is -1 it does a
Cleanup, otherwise flags should be
a bitwise or of
-
1 -- Slopes may change at the end points.
-
2 -- Points which are extremum may be removed
-
4 -- Corner points may be smoothed into curves
-
8 -- Smoothed points should be snapped to a horizontal or vertical tangent
if they are close
-
16 -- Remove bumps from lines
The error argument is the number of font units by which the modified path
is allowed to stray from the true path.
The tan_bounds argument specifies the tangent of the angle between the curves
at which smoothing will stop (argument is multiplied by .01 before use).
And bump_size gives the maximum distance a bump can move from the line and
still be smoothed out.
If a fifth argument is given then it will be treated as the denominator of
the error term (so users can express fraction pixel distances).
Generally it is a bad idea to merge a line segment with any other than a
colinear line segment. The longer the line segment, the more likely that
such a merge will produce unpleasing results. The sixth argument, if present,
specifies the maximum length for lines which may be merged (anything longer
will not be merged).
-
NearlyHvCps([error[,err-denom]])
-
Checks for control points which are almost, but not quite horzontal or vertical
(where almost means (say) that
abs( (control point).x - point.x ) <
error, where error is either:
| .1 |
if no arguments are given |
| first-arg |
if one argument is given |
| first-arg/second-arg |
if two arguments are given |
-
NearlyHvLines([error[,err-denom]])
-
Checks for lines which are almost, but not quite horzontal or vertical (where
almost means (say) that
abs( (end point).x - (start point).x ) <
error, where error is either:
| .1 |
if no arguments are given |
| first-arg |
if one argument is given |
| first-arg/second-arg |
if two arguments are given |
-
NearlyLines(error)
-
Checks for splines that are nearly linear, and makes them so. A spline is
nearly linear if the maximum deviation of the spline from the line between
the spline's endpoints is less than error.
-
-
AddExtrema()
-
-
RoundToInt([factor])
-
Rounds all points/hints/reference-offsets to be integers. If the the "factor"
argument is specified then it rounds like
rint(factor * x) /
factor, in other words if you set factor to 100 then it will round
to hundredths.
-
RoundToCluster([within[,max]])
-
The first two provide a fraction that indicates a value within which similar
coordinates will be bundled together. Max indicates how many "within"s from
the center point it will go if there are a chain of points each within "within"
of the previous one. So
RoundToCluster(.1,5)
Will merge coordinates within .1 em-unit of each other. A sequence like
-.1,-.05,0,.05,.1,.15 will all be merged together because each
is within .1 of the next, and none is more than .5 from the center.
-
AutoTrace()
-
-
CorrectDirection([unlinkrefs])
-
If the an argument is present it must be integral and is treated as a flag
controlling whether flipped references should be unlinked before the
CorrectDirection code runs. If the argument is not present, or if it has
a non-zero value then flipped references will be unlinked.
-
DefaultATT(tag)
-
For all selected glyphs make a guess as to what might be an appropriate value
for the given tag. If the tag is "*" then FontForge will apply guesses for
all features it can.
-
AddATT(type,script-lang,tag,flags,variant)
AddATT("Position",script-lang,tag,flags,xoff,yoff,h_adv_off,v_adv_off)
AddATT("Pair",script-lang,tag,flags,name,xoff,yoff,h_adv_off,v_adv_off,xoff2,yoff2,h_adv_off2,v_adv_off2)
-
Allows you to add an Advanced Typography feature to a single selected glyph.
The first argument may be either: Position, Pair, Substitution, AltSubs,
MultSubs or Ligature. The second argument should be a script-lang list where
each 4-character script name is followed by a comma separated list of 4 character
language names (with the languages enclosed in curly braces) -- or the special
string "Nested". As:
grek{dflt} latn{dflt,VIT ,ROM }
The third arg should be a 4 character opentype feature tag (or apple
feature/setting).
The fourth argument should be the otf flags (or -1
to make FontForge guess appropriate flags).
-
0x0001 => RightToLeft
-
0x0002 => IgnoreBaseGlyphs
-
0x0004 => IgnoreLigatures
-
0x0008 => IgnoreMarks
-
0x00F0 => not defined
-
0xFF00 => not supported
The remaining argument(s) vary depending on the value of the first (type)
argument. For Position tags there are 4 integral arguments which specify
how this feature modifies the metrics of this glyph. For Pair type the next
argument is the name of the other glyph in the pair followed by 8 integral
arguments, the first 4 specify the changes in positioning to the first glyph,
the next four the changes for the second char. For substitution tags the
fifth argument is the name of another glyph which will replace the current
one. For an AltSubs tag the argument is a space separated list of glyph names
any of which will replace the current one. For a MultSubs the argument is
a space separated list of names all of which will replace the current one.
For a Ligature the argument is a space separated list of glyph names all
of which will be replaced by the current glyph.
-
RemoveATT(type,script-lang,tag)
-
Removes any feature tags which match the arguments (which are essentially
the same as above, except that any of them may be "*" which will match anything).
-
CheckForAnchorClass(name)
-
Returns 1 if the current font contains an Anchor class with the given name
(which must be in utf8).
-
AddAnchorClass(name,type,script-lang,tag,flags,merge-with)
-
These mirror the values of the Anchor class dialog of Element->Font Info.
The first argument should be a utf8 encoded name for the anchor class. The
second should be one of the strings "default", "mk-mk", or "cursive". The
third should be a script-lang string like:
grek{dflt} latn{dflt,VIT ,ROM }
The fourth arg should be a 4 character opentype feature tag. The fifth argument
should be the otf flags (or -1 to
make FontForge guess appropriate flags). The sixth and last argument should
be the name of another AnchorClass to be merged into the same lookup (or
a null string if this class merges with no other class yet).
-
RemoveAnchorClass(name)
-
Removes the named AnchorClass (and all associated points) from the font.
-
AddAnchorPoint(name,type,x,y[,lig-index])
-
Adds an AnchorPoint to the currently selected glyph. The first argument is
the name of the AnchorClass. The second should be one of the strings: "mark",
"basechar", "baselig", "basemark", "cursentry" or "cursexit". The next two
values specify the location of the point. The final argument is only present
for things of type "baselig".
-
BuildComposite()
-
-
BuildAccented()
-
-
BuildDuplicate()
-
-
AddAccent(accent[,pos])
-
There must be exactly one glyph selected. That glyph must contain at least
one reference (and the least recently added reference must be the base glyph
-- the letter on which the accent is placed). The first argument should be
either the glyph-name of an accent, or the unicode code point of that accent
(and it should be in the font). The second argument, if present indicates
how the accent should be positioned... if omitted a default position will
be chosen from the unicode value for the accent, this argument is the or
of the following flags:
| 0x100 |
Above |
| 0x200 |
Below |
| 0x400 |
Overstrike |
| 0x800 |
Left |
| 0x1000 |
Right |
| 0x4000 |
Center Left |
| 0x8000 |
Center Right |
| 0x10000 |
Centered Outside |
| 0x20000 |
Outside |
| 0x40000 |
Left Edge |
| 0x80000 |
Right Edge |
| 0x100000 |
Touching |
-
ReplaceWithReference([fudge])
-
Finds any glyph which contains an inline copy of one of the selected glyphs,
and converts that copy into a reference to the appropriate glyph. Selection
is changed to the set of glyphs which the command alters.
If specified the fudge argument specifies the error allowed
for coordinate differences.
-
MergeFonts(other-font-name[,flags])
-
Loads other-font-name, and extracts any glyphs from it which are not in the
current font and moves them to the current font. The flags argument is the
same as that for Open. Currently the only relevant flag is to say that you
do have a license to use a font with fstype=2.
-
InterpolateFonts(percentage,other-font-name[,flags])
-
Interpolates a font which is percentage of the way from the current font
to the one specified by other-font-name (note: percentage may be negative
or more than 100, in which case we extrapolate a font). This command changes
the current font to be the new font.
NOTE: You will need
to set the fontname of this new font. The flag argument is the same as for
Open.
-
DefaultUseMyMetrics()
-
Looks at all selected glyphs. If any glyph contains references, does not
have the "USE-MY-METRICS" bit set on any of those references, and if one
of those references has the same width as the current glyph, and has an identity
transformation matrix, then set the bit on that reference.
-
DefaultRoundToGrid()
-
Looks at all selected glyphs, if any reference is not positioned by point
matching, then FontForge will set the truetype "ROUND-TO-GRID" flag for the
reference.
-
-
AutoHint()
-
-
SubstitutionPoints()
-
-
AutoCounter()
-
-
DontAutoHint()
-
-
AutoInstr()
-
-
AddInstrs(thingamy,replace,instrs)
-
Where thingamy is a string, either "fpgm" or "prep" in which case it refers
to that truetype table (which will be created if need be), or a glyph-name
in which case it refers to that glyph, or a null string in which case any
selected characters will be used.
Where replace is an integer. If zero then the instructions will be appended
to any already present. If non-zero then the instructions will replace those
already present.
And instrs is a string containing fontforge's human readable version of tt
instructions, as "IUP[x]\nIUP[y]"
-
ClearInstrs()
-
From selected glyphs
-
ClearTable(tag)
-
Removes the table named tag. This may be 'fpgm', 'prep, 'cvt ', 'maxp' or
any user defined tables. It returns 1 if it found (and removed) the table,
0 if the table was not present.
-
FindOrAddCvtIndex(value[,sign-matters])
-
Returns the index in the cvt table of the given value. If the value does
not exist in the table it will be added, and an index at the end of the table
will be returned. Most tt instructions ignore the sign of items in the cvt
table, but a few care. Usually this command stores the absolute value of
value, but if sign-matters is present and non-zero a negative value can be
looked up (or added).
-
ReplaceCvtAt(index,value)
-
Change the cvt table at the given index to have the new value.
-
GetCvtAt(index)
-
Return the value in the cvt table at the given index.
-
PrivateToCvt()
-
Adds the standard numeric entries in the Private dictionary into the cvt
table.
-
ClearHints()
-
-
AddHHint(start,width)
-
Adds horizontal stem hint to any selected glyphs. The hint starts at location
"start" and is width wide. A hint will be added to all selected glyphs.
-
AddVHint(start,width)
-
Adds a vertical stem hint to any selected glyphs. The hint starts at location
"start" and is width wide. A hint will be added to all selected glyphs.
-
ClearCharCounterMasks()
-
Clears any counter masks from the (one) selected glyph.
-
SetCharCounterMask(cg,hint-index,hint-index,...)
-
Creates or sets the counter mask at index cg to contain the hints listed.
Hint index 0 corresponds to the first hstem hint, index 1 to the second hstem
hint, etc. vstem hints follow hstems.
-
ReplaceCharCounterMasks(array)
-
This requires that there be exactly one glyph selected. It will create a
set of counter masks for that glyph. The single argument must be an array
of twelve element arrays of integers (in c this would be "int array[][12]").
This is the format of a type2 counter mask. The number of elements in the
top level array is the number of counter groups to be specified. The nested
array thus corresponds to a counter mask, and is treated as an array of bytes.
Each bit in the byte specifies whether the corresponding hint is active in
this counter. (there are at most 96 hints, so at most 12 bytes).
Array[i][0]&0x80 corresponds to the first horizontal stem hint,
Array[i][0]&0x40 corresponds to the second, Array[i][1]&0x80 corresponds
to the eighth hint, etc.
-
ClearPrivateEntry(key)
-
Removes the entry indexed by the given key from the private dictionary of
the font.
-
ChangePrivateEntry(key,val)
-
Changes (or adds if the key is not already present) the value in the dictionary
indexed by key. (all values must be strings even if they represent numbers
in PostScript)
-
GetPrivateEntry(key)
-
Returns the entry indexed by key in the private dictionary. All return values
will be strings. If an entry does not exist a null string is returned.
-
HasPrivateEntry(key)
-
Returns whether key exists in the private dictionary.
-
SelectBitmap(size)
-
In a bitmap only font this selects which bitmap strike will be used for units
in the following metrics commands. If no bitmap is selected, then the units
should be in em-units, otherwise units will be in pixels of the given bitmap
strike. The size should be the pixelsize of the font. If you use anti-aliased
fonts then size should be set to (depth<<16)|pixel_size. A value of
-1 for size deselects all bitmaps (units become em-units).
-
SetWidth(width[,relative])
-
If the second argument is absent or zero then the width will be set to the
first argument, if the second argument is 1 then the width will be incremented
by the first, and if the argument is 2 then the width will be scaled by
<first argument>/100.0 . In bitmap only fonts see the comment at
SelectBitmap about units.
-
SetVWidth(vertical-width[,relative])
-
If the second argument is absent or zero then the vertical width will be
set to the first argument, if the second argument is 1 then the vertical
width will be incremented by the first, and if the argument is 2 then the
vertical width will be scaled by <first argument>/100.0 . In bitmap
only fonts see the comment at
SelectBitmap about units.
-
SetLBearing(lbearing[,relative])
-
If the second argument is absent or zero then the left bearing will be set
to the first argument, if the second argument is 1 then the left bearing
will be incremented by the first, and if the argument is 2 then the left
bearing will be scaled by <first argument>/100.0 . In bitmap only fonts
see the comment at SelectBitmap
about units.
-
SetRBearing(rbearing[,relative])
-
If the second argument is absent or zero then the right bearing will be set
to the first argument, if the second argument is 1 then the right bearing
will be incremented by the first, and if the argument is 2 then the right
bearing will be scaled by <first argument>/100.0 . In bitmap only fonts
see the comment at SelectBitmap
about units.
-
CenterInWidth()
-
-
AutoWidth(spacing)
-
Guesses at the widths of all selected glyphs so that two adjacent "I" glyphs
will appear to be spacing em-units apart. (if spacing is the negative of
the em-size (sum of ascent and descent) then a default value will be used).
-
AutoKern(spacing,threshold[,kernfile])
-
(AutoKern doesn't work well in general)
Guesses at kerning pairs by looking at all selected glyphs, or if a kernfile
is specified, FontForge will read the kern pairs out of the file.
-
SetKern(ch2,offset)
-
Sets the kern between any selected glyphs and the glyph ch2 to be offset.
The first argument may be specified as in Select(), the second is an integer
representing the kern offset.
-
RemoveAllKerns()
-
Removes all kern pairs and classes from the current font.
-
SetVKern(ch2,offset)
-
Sets the kern between any selected glyphs and the glyph ch2 to be offset.
The first argument may be specified as in Select(), the second is an integer
representing the kern offset.
-
VKernFromHKern()
-
Removes all vertical kern pairs and classes from the current font, and then
generates new vertical kerning pairs by copying the horizontal kerning data
for a pair of glyphs to the vertically rotated versions of those glyphs.
-
RemoveAllVKerns()
-
Removes all vertical kern pairs and classes from the current font.
-
-
MMInstanceNames()
-
Returns an array containing the names of all instance fonts in a multi master
set.
-
MMAxisNames()
-
Returns an array containing the names of all axes in a multi master set.
-
MMAxisBounds(axis)
-
Axis is an integer less than the number of axes in the mm font. Returns an
array containing the lower bound, default value and upper bound. Note each
value is multiplied by 65536 (because they need not be integers on the mac,
and ff doesn't support real values).
(The default value is a GX Var concept. FF simulates a reasonable value for
true multiple master fonts).
-
MMWeightedName()
-
Returns the name of the weighted font in a multi master set.
-
MMChangeInstance(instance)
-
Where instance is either a font name or a small integer. If passed a string
FontForge searches through all fonts in the multi master font set (instance
fonts and the weighted font) and changes the current font to the indicated
one. If passed a small integer, then -1 indicates the weighted font and values
between [0,$mmcount) represent that specific instance in the font set.
-
MMChangeWeight(weights)
-
Weights is an array of integers, one for each axis. Each value should be
65536 times the desired value (to deal with mac blends which tend to be small
real numbers). This command changes the current multiple master font to have
a different default weight, and sets that to be the current instance.
-
MMBlendToNewFont(weights)
-
Weights is an array of integers, one for each axis. Each value should be
65536 times the desired value (to deal with mac blends which tend to be small
real numbers). This command creates a completely new font by blending the
mm font and sets the current font to the new font.
-
-
CIDChangeSubFont(new-sub-font-name)
-
If the current font is a cid keyed font, this command changes the active
sub-font to be the one specified (the string should be the postscript FontName
of the subfont)
-
CIDSetFontNames(fontname[,family[,fullname[,weight[,copyright-notice]]]])
-
Sets various postscript names associated with the top level cid font. If
a name is omitted (or is the empty string) it will not be changed. (this
is just like SetFontNames except it works on the top level cid font rather
than the current font).
-
CIDFlatten()
-
Flattens a cid-keyed font.
-
CIDFlattenByCMap(cmap-filename)
-
Flattens a cid-keyed font, producing a font encoded with the result of the
CMAP file.
-
ConvertToCID(registry, ordering, supplement)
-
Converts current font to a CID-keyed font using given registry, ordering
and supplement. registry and ordering must be strings, supplement must be
a integer.
-
ConvertByCMap(cmapfilename)
-
Converts current font to a CID-keyed font using specified CMap file. cmapfilename
must be a path name of a file conforming Adobe CMap File Format.
-
CharCnt()
-
Returns the number of encoding slots (or encoding slots + unencoded glyphs)
in the current font
-
InFont(arg)
-
Returns whether the argument is in the font. The argument may be an integer
in which case true is returned if the value is >= 0 and < total number
of glyphs in the font. Otherwise if the argument is a unicode code point
or a postscript glyph name, true is returned if that glyph is in the font.
-
WorthOutputting([arg])
-
If there is no argument then a single glyph should be selected and the function
applies to that glyph, otherwise arg is as above. This returns true if the
glyph contains any splines, references, images or has had its width set.
-
DrawsSomething([arg])
-
Arg is as above. This returns true if the glyph contains any splines, references
or images.
-
GlyphInfo(str)
GlyphInfo("Kern",glyph-spec)
GlyphInfo("VKern",glyph-spec)
GlyphInfo(str,script,lang,tag)
-
There must be exactly one glyph selected in the font, and this returns
information on it. The information returned depends on str with the obvious
meanings:
-
"Name" returns the glyph's name
-
"Unicode" returns the glyph's unicode encoding
-
"Encoding" returns the glyph's encoding in the current font
-
"Width" returns the glyph's width
-
"VWidth" returns the glyph's Vertical width
-
"TeXHeight" returns the tex_height field (a value of 0x7fff indicates that
a default value will be used)
-
"TeXDepth" returns the tex_depth field (a value of 0x7fff indicates that
a default value will be used)
-
"TeXSubPos" returns the tex_sub_pos field (a value of 0x7fff indicates that
a default value will be used)
-
"TeXSuperPos" returns the tex_super_pos field (a value of 0x7fff indicates
that a default value will be used)
-
"LBearing" returns the glyph's left side bearing
-
"RBearing" returns the glyph's right side bearing
-
"BBox" returns a 4 element array containing [minimum-x-value, minimum-y-value,
maximum-x-value, maximum-y-value] of the glyph.
-
"Kern" (there must be a second argument here which specifies another glyph
as in Select()) Returns the kern offset between the two glyphs (or 0 if none).
-
"VKern" (there must be a second argument here which specifies another glyph
as in Select()) Returns the vertical kern offset between the two glyphs (or
0 if none).
-
"Xextrema" (there must be a second argument here which specifies the vertical
position) Returns a two element array containing the minimum and maximum
horizontal positions on the contours of the glyph at the given vertical position.
If the position is beyond the glyph's bounding box the minimum value will
be set to 1 and the max to 0 (ie. max<min which is impossible).
-
"Yextrema" (there must be a second argument here which specifies the horizontal
position) Returns a two element array containing the minimum and maximum
vertical positions on the contours of the glyph at the given horizontal position.
If the position is beyond the glyph's bounding box the minimum value will
be set to 1 and the max to 0 (ie. max<min which is impossible).
-
"Color" returns the glyph's color as a 24bit rgb value (or -2 if no color
has been assigned to the glyph).
-
"Comment" returns the glyph's comment (it will be converted from unicode
into the default encoding).
-
"Changed" returns whether the glyph has been changed since the last save
or load.
-
"DontAutoHint" returns the status of the "Don't AutoHint" flag.
-
"Position" takes three additional arguments, a script, a language and a tag
(all 4 character strings) and returns whether the glyph has a Position alternate
with that tag.
-
"Pair" takes three additional arguments, a script, a language and a tag (all
4 character strings) and returns whether the glyph has a Pairwise positioning
alternate with that tag.
-
"Substitution" takes three additional arguments, a script, a language and
a tag (all 4 character strings) and returns the name of the Simple Substitution
alternate with that tag (or a null string if there is none).
-
"AltSubs" takes three additional arguments, a script, a language and a tag
(all 4 character strings) and returns a space separated list of the names
of all alternate substitutions with that tag (or a null string if there is
none).
-
"MultSubs" takes three additional arguments, a script, a language and a tag
(all 4 character strings) and returns a space separated list of all the names
of all glyphs this glyph gets decomposed into with that tag (or a null string
if there is none).
-
"Ligature" takes three additional arguments, a script, a language and a tag
(all 4 character strings) and returns a space separated list of the names
of all components with that tag (or a null string if there is none).
-
"GlyphIndex" returns the index of the current glyph in the ttf 'glyf' table,
or -1 if it has been created since. This value may change when a
truetype/opentype font is generated (to the index in the generated
font).
-
"LayerCount" returns the number of layers in the glyph. This will always
be 2 (foreground & background) except in the case of a multilayered font.
-
"RefCount" returns the number of references in the glyph
-
"RefNames" returns an array containing the names of all glyphs refered to.
This may contain 0 elements. This may contain a glyph twice ("colon" might
refer twice to period)
-
"RefTransform" returns an array of arrays. The bottom most arrays are 6 element
(real) transformation matrices which are applied to their respective glyphs.
Examples:
Select("A")
lbearing = CharInfo("LBearing")
kern = CharInfo("Kern","O")
Select(0u410)
SetLBearing(lbearing)
SetKern(0u41e,kern)
Select("a")
verta = CharInfo("Substitution","*","dflt","vrt2")
-
CharInfo(str)
-
Depreciated name for GlyphInfo
-
SetGlyphTeX(height,depth[,subpos,suppos])
-
Sets the tex_height and tex_depth fields of this glyph. And the subscript
pos and superscript pos for math fonts.
-
GetPosSub(feature-tag,script,lang)
-
One glyph must be selected, this returns information about GPOS/GSUB features
attached to this glyph (It will not return information about class based
kerning or contextual features -- nothing that applies to the font as a whole
-- just things relating to the current glyph). The arguments must be 4 letter
strings (or the special string "*" which acts as a wildcard). It returns
an Array of Arrays (with one entry for each feature which matches the arguments).
If nothing matches a 0 length array will be returned.
Each sub-array contains the following information
-
The feature tag (a string)
-
The script/language string of this feature
-
The type (As a string, One of
Position, Pair, Substitution, AltSubs,
MultSubs or Ligature)
The remaining entries depend on the type.
-
For Positions
-
There will be 4 numbers indicating respectively the contents of a GPOS value
record (dx,dy,d_horizontal_advance,d_vertical_advance)
-
For Pairs
-
A string containing the name of the other glyph in the pair
A list of 8 numbers indicating the contents of two GPOS value records (the
first four numbers control the current glyph, the next four numbers control
the second glyph)
-
For Substitutions
-
A string containing the name of a glyph with which the current glyph is to
be replaced.
-
For the others
-
A set of glyph names, one for each component.
Examples:
>Select("ffl")
>Print( GetPosSub("liga","*","*"))
[[liga,latn{dflt} ,Ligature,f,f,l],
[liga,latn{dflt} ,Ligature,ff,l]]
>Select("T")
>Print( GetPosSub("*","*","*"))
[[kern,latn{dflt} ,Pair,u,0,0,-76,0,0,0,0,0],
[kern,latn{dflt} ,Pair,e,0,0,-92,0,0,0,0,0],
[kern,latn{dflt} ,Pair,a,0,0,-92,0,0,0,0,0],
[kern,latn{dflt} ,Pair,o,0,0,-76,0,0,0,0,0]]
>Select("onehalf")
>Print( GetPosSub("frac","latn","dflt"))
[[frac,latn{dflt} ,Ligature,one,slash,two],
[frac,latn{dflt} ,Ligature,one,fraction,two]]
Example 1:
#Set the color of all selected glyphs to be yellow
#designed to be run within an interactive fontforge session.
foreach
SetCharColor(0xffff00)
endloop
Example 2:
#!/usr/local/bin/fontforge
#Take a Latin font and apply some simple transformations to it
#prior to adding cyrillic letters.
#can be run in a non-interactive fontforge session.
Open($1);
Reencode("KOI8-R");
Select(0xa0,0xff);
//Copy those things which look just like latin
BuildComposit();
BuildAccented();
//Handle Ya which looks like a backwards "R"
Select("R");
Copy();
Select("afii10049");
Paste();
HFlip();
CorrectDirection();
Copy();
Select(0u044f);
Paste();
CopyFgToBg();
Clear();
//Gamma looks like an upside-down L
Select("L");
Copy();
Select(0u0413);
Paste();
VFlip();
CorrectDirection();
Copy();
Select(0u0433);
Paste();
CopyFgToBg();
Clear();
//Prepare for editing small caps K, etc.
Select("K");
Copy();
Select(0u043a);
Paste();
CopyFgToBg();
Clear();
Select("H");
Copy();
Select(0u043d);
Paste();
CopyFgToBg();
Clear();
Select("T");
Copy();
Select(0u0442);
Paste();
CopyFgToBg();
Clear();
Select("B");
Copy();
Select(0u0432);
Paste();
CopyFgToBg();
Clear();
Select("M");
Copy();
Select(0u043C);
Paste();
CopyFgToBg();
Clear();
Save($1:r+"-koi8-r.sfd");
Quit(0);
The Execute Script dialog
This dialog allows you to type a script directly in to FontForge and then
run it. Of course the most common case is that you'll have a script file
somewhere that you want to execute, so there's a button [Call] down at the
bottom of the dlg. Pressing [Call] will bring up a file picker dlg looking
for files with the extension *.pe (you can change that by typing a wildcard
sequence and pressing the [Filter] button). After you have selected your
script the appropriate text to text to invoke it will be placed in the text
area.
The current font of the script will be set to whatever font you invoked it
from.
The Scripts Menu
You can use the preference dialog to create a list of frequently used scripts.
Invoke File->Preferences and select the
Scripts tag. In this dialog are ten possible entries, each one should have
a name (to be displayed in the menu) and an associated script file to be
run.
After you have set up your preferences you can invoke scripts from the font
view, either directly from the menu (File->Scripts-><your name>)
or by a hot key. The first script you added will be invoked by Cnt-Alt-1,
then second by Cnt-Alt-2, and the tenth by Cnt-Alt-0.
The current font of the script will be set to whatever font you invoked it
from.
-- Prev -- TOC --
Next --