[Harfbuzz-indic] easy test case generation with FontForge scripts
Bernard Massot
bmassot at free.fr
Sat Aug 6 03:57:15 PDT 2011
Hello,
I wrote FontForge scripts working together to generate test case sets
interactively with FontForge.
You have to give set name and test cases names in dialog boxes. To
define character sequence you have to type text in a dialog box, just
as if you were writing some document. To define expected glyphs, just
select them in FontForge's font view, one after all.
Installation
You need to copy the four FF scripts I attached in logical order to this
mail. In order to ease their calling I advise you to add them to the
"Scripts" entry of "File" menu (add them through the "Script Menu" entry
of "Preferences" dialog). All four scripts must be located in the same
directory.
Detailed usage
You should start FF from a terminal because generated C code is output
to standard output. Call scripts from FF's GUI. Using shortcuts
(ctrl+alt+number) can make process more efficient.
To create a set of test cases, open your TTF font with FF and follow
these steps:
1) call start_set.pe and give test set name
2) give a test case description
3) give character sequence by typing it
4) select exactly one glyph in the font view, then call record_glyph.pe
5) repeat step 4 as many times as you need glyphs
6) if you want to enter another test case, call start_case.pe, which
will bring you back to step 2
7) when your set is complete, call end_set.pe
8) you can start a new set by going to step 1
Then you get C code you can directly copy to test-shape-complex.c.
Example
As an example, I'm going to explain how to generate the following C
code:
static const test_set_t tests_devanagari3 = {
{"Lohit-Devanagari.ttf", 0},
{
{ "Ka Halant Ssa Halant",
{ 0x0915, 0x094D, 0x0937, 0x094D, 0},
{ 0x00C4, 0x007D, 0}
},
{ "Ja Halant Nya Halant",
{ 0x091C, 0x094D, 0x091E, 0x094D, 0},
{ 0x00C5, 0x007D, 0}
},
{{0}}
}
};
Steps are:
* open LohitDevanagari.ttf with FF
* call start_set.pe
* give "devanagari3" as set name
* give "Ka Halant Ssa Halant" as test description
* type "क्ष्" as string to test (don't trust rendering, actual
character sequence is <U+0915,U+094D,U+0937,U+094D>)
* select Kssa glyph (u0915_u094D_u0937.akhn)
* call record_glyph.pe
* select Halant glyph (u094D)
* call record_glyph.pe
* call start_case.pe
* give "Ja Halant Nya Halant" as test description
* type "ज्ञ्" as string to test (don't trust rendering, actual
character sequence is <U+091C,U+094D,U+091E,U+094D>)
* select Jnya glyph (u091C_u094D_u091E.akhn)
* call record_glyph.pe
* select Halant glyph (u094D)
* call record_glyph.pe
* call end_set.pe
You can close FF and copy source code to test-shaphe-complex.c.
I hope you will find these scripts useful.
--
Bernard Massot
-------------- next part --------------
_setname = AskUser("Test set name ?")
Print("Add following code to harfbuzz/test/test-shape-complex.c:\n")
# test set header
Print("static const test_set_t tests_" + _setname + " = {")
Print(' {"' + $filename:t + '", 0},')
Print(' {')
# start first case
_first = 1
start_case.pe()
-------------- next part --------------
if (_first)
_first = 0
else
# if not first test case, display last chosen glyphs
Print(" { " + _glyphs + "0}")
# test case footer
Print(" },")
endif
description = AskUser("Test description ?")
Print(' { "' + description + '",')
string = Ucs4(AskUser("Character string to test?"))
characters = " { "
i = 0
while (i < SizeOf(string))
hexa = StrSplit(ToString(UCodePoint(string[i])), "u")
characters += "0x" + hexa[1] + ", "
i++
endloop
characters += "0},"
Print(characters)
_glyphs = ""
-------------- next part --------------
_glyphs += ToString(GlyphInfo("GlyphIndex")) + ", "
-------------- next part --------------
# close last input test case
# display last chosen glyphs
Print(" { " + _glyphs + "0}")
# test case footer
Print(" },")
# test set footer
Print(" {{0}}")
Print(" }")
Print("};")
# main() function
Print()
Print("Also add this to main() function:")
Print(" TEST_SET (" + _setname + ");")
More information about the HarfBuzz-Indic
mailing list