pcb-rnd knowledge pool
Alien format: text test cases
alien_text by Tibor 'Igor2' Palinkas on 2020-05-17 | Tags: howto, text, test, input, alien, file, format |
Abstract: This article describes a series of proper test cases that provides the easier way for completly reverse engineering and testing support for text loaded from an alien format.
t_base.*: base/alignment
The base test case demonstrates text alignment and scaling. It has the same text string: M_AWjgi.,Q_Tx_M . The character 'x', is replaced with an unique digit or letter, so each text has an identifier in its string that makes it easier to find it in the file and on the screen.
It is important to use this exact test string: it is designed so that properties of the input font can be determined: M is traditionally the base height of the font (the 'em' unit), A and W should be wide characters while j and i are normally narrower - unless the font uses fixed width characters. j and g helps determining if there is base-lining. Punctuation . and , helps detecting if anything unusual is done to punctuation. The center of the string will be somewhere between i and Q normally; Q provides a good reference point for "pixel counting". The unique identifier, _Tx_ helps matching up strings between screen and file. The final M helps determining the right side of the bounding box.
Whenever a text object is placed, the placement reference point, the exact coord that ends up in the file, must be marked with two perpendicular lines in an "L" shape, with the common point being exactly at the location the file has for the text object coordinate. This is often done by creating the text objects (with the proper alignment, see below) in the GUI then saving the file, reading out the coordinates for each text and drawing the "L" marks. It's extremely important that the "L" mark is numerically at the coordinate where the text is placed - do not manually place or move it on the GUI for any of the test cases!
Make sure the "L" mark is as thin as possible so finding the corner is easier.
Each test file must be:
- saved in the alien format
- exported in an image format; prefer gerber; if that's not available use high resolution png or large screen screenshot.
- if gerber is not possible, draw horizontal and vertical rulers in each test case so it will be possible to determine the DPI by pixel counting; the ruler should be of short line segments placed at regular, round interval in the native unit of the format (e.g. 10 mil or 0.5mm). Each ruler must be at least 200mil or 5mm long. Example: ruler.lht
The base/alignment test file contains the following text objects:
- if there's both vertical and horizontal alignment options, then a text object (and L mark) for each combination; e.g. if there are 3 horizontal and 3 vertical alignments, this means 9 text objects
- if there's only horizontal or only vertical alignment, then a simple series of text objects for all possible values of that one alignment; e.g. if only horizontal alignment is possible to left, right and center, that means 3 text objects
- if the format does not support text alignment, the test file contains exactly one text object.
Leave plenty of room between the text objects. Ideally text objects should be in a vertical row with at least 4..6x the height of the text object left empty between two text object.
Here is an example in BXL format . You can load it in pcb-rnd and/or use bxl2txt from util/ to convert it to text.
t_scale.*: Scaling
Pick the default text alignment, place a text with the original size with text ID 0 (so the text string is M_AWjgi.,Q_T0_M ), with the L marker drawn. Then, depending on the features of the EDA system:
- if it is possible to scale text independently in horizontal and vertical direction, make three copies of the text (using unique IDs in the string!) with one scaled 2x on width, and the other scaled 2x in height, and the third scaled 2x both in width and height.
- if the software supports only global scaling, so width and height are always scaled by the same factor, have only one copy of the original text object and scale it 2x.
- if it is not possible to scale text objects, do not make this test case.
- if you can export in gerber, or the png export has color, it's best if the "L" marks are on a different layer, over the text objects, so it's easier to find them. Make sure the "L" mark and the text is on the same side of the board - e.g. use top copper for text and top silk for the "L" mark.
t_base_rot.* and t_scale_rot.*: rotation
Take t_base.* and t_scale.* and rotate every text by 20 degrees. Do this by editing the file and not by using the GUI. This is important: we want the same coordinates and the same L marks in the resulting files.
Once the file is edited, run the software to make the export.
t_base_mirx.* and t_scale_mirx.*: x mirror
Take t_base.* and t_scale.* and apply X mirror on each text. X mirror is when the X coordinates are affected by the Y coordinates are not. That is, mirroring over the Y axis. Do this by editing the file and not by using the GUI. This is important: we want the same coordinates and the same L marks in the resulting files.
Once the file is edited, run the software to make the export.
If the software/format doesn't support x mirroring, skip this test case.
t_base_miry.* and t_scale_miry.*: y mirror
Take t_base.* and t_scale.* and apply Y mirror on each text. Y mirror is when the Y coordinates are affected by the X coordinates are not. That is, mirroring over the X axis. Do this by editing the file and not by using the GUI. This is important: we want the same coordinates and the same L marks in the resulting files.
Once the file is edited, run the software to make the export.
If the software/format doesn't support y mirroring, skip this test case.
t_base_rotmir.*: rotation+mirror
Take t_baserot.* and apply X or Y mirror on each text. Apply only one of the mirrors and apply the same one on all text objects. Do this by editing the file and not by using the GUI. This is important: we want the same coordinates and the same L marks in the resulting files.
Once the file is edited, run the software to make the export.
If the software/format doesn't support x mirroring, skip this test case.