Introducing a logo for Shapes.
[shapes.git] / examples / applications / measuretext.shape
blob8fd8160322506aa3eb1c93e253631c85d9a5f490
1 /** This file is part of Shapes.
2  **
3  ** Shapes is free software: you can redistribute it and/or modify
4  ** it under the terms of the GNU General Public License as published by
5  ** the Free Software Foundation, either version 3 of the License, or
6  ** any later version.
7  **
8  ** Shapes is distributed in the hope that it will be useful,
9  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
10  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  ** GNU General Public License for more details.
12  **
13  ** You should have received a copy of the GNU General Public License
14  ** along with Shapes.  If not, see <http://www.gnu.org/licenses/>.
15  **
16  ** Copyright 2008 Henrik Tidefelt
17  **/
19 ##needs rtlogo_elements
21 rulerLength: 15cm
23 |** Give the line you want to measure as the first argument to bboxed, and
24 |** look in the resulting graphics to measure the text in <textSize> units.
26 @<< [bboxed line0 [rectangle (0cm,~1cm) (rulerLength,textSize+1cm)]]
29 |** The rest of this file just defines the ruler.
32  step: textSize
33 [[range 1 rulerLength/step-0.5].foldl
34  \ p e .> {
35    @<< [stroke (e*step,0)--(+(0,~3mm))]
36    @<< [shift (e*step-2mm,~9mm)] [] ( HotText << @text_size:8bp | [kerning [sprintf `%gsz´ e]] )
37    p
38  }
39  VOID]
43  step: 0.1*textSize
44 @width:0.3bp
46 [[range 1 rulerLength/step-0.5].foldl
47  \ p e .> {
48    @<< [stroke (e*step,textSize)--((+0mm),~1mm)]
49    p
50  }
51  VOID]
55  step: 0.5*textSize
56 @width:0.5bp
58 [[range 1 rulerLength/step-0.5].foldl
59  \ p e .> {
60    @<< [stroke (e*step,0.5*textSize)--((+0mm),~3mm)]
61    p
62  }
63  VOID]