File: test_type1.py

package info (click to toggle)
plplot 5.15.0%2Bdfsg2-15
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 31,396 kB
  • sloc: ansic: 79,703; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 74; sed: 34; fortran: 6
file content (109 lines) | stat: -rwxr-xr-x 3,093 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python3

# Copyright 2010-2016 Alan W. Irwin
# This file is part of PLplot.

# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; version 2 of the License.

# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.

# You should have received a copy of the GNU Library General Public License
# along with the file PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

# Plots the first 256 unicode glyphs.
# N.B. If ps.c is edited to #define PL_TEST_TYPE1 (which interprets
# unicode in the range from 0 to 255 directly as Type1 font indices) and
# if the -dev ps -drvopt hrshsym=0 command-line options are used, then
# the results are similar to the results obtained from the historical
# gfontview application that is no longer available under Linux.

# Append to effective python path so that can find plplot modules.
from plplot_python_start import *

import sys
import plplot as w

# Parse and process command line arguments
w.plparseopts(sys.argv, w.PL_PARSE_FULL)

# Initialize plplot
w.plinit()

# main
#
# Displays all available Type1 glyphs.

family = (
"sans-serif",
"serif",
"monospace",
"script",
"symbol",
)
style = (
"upright",
"italic",
"oblique",
)
weight = (
"medium",
"bold",
)
def main(w):


    FCI_COMBINATIONS = 30
    w.plsfont(0, 0, 0)
    for index_fci in range(0,FCI_COMBINATIONS):
        family_index = index_fci % 5
        style_index = (index_fci/5) % 3
        weight_index = ((index_fci/5)/3) % 2
        title = "Type 1 glyphs for family = " + family[family_index] + ", style = " + style[style_index] + ", weight = " + weight[weight_index]
        w.pladv(0)

# Set up viewport and window

        w.plcol0(2)
        w.plvpor(0.1, 1.0, 0.1, 0.9)
        w.plwind(0.0, 1.0, 0.0, 1.0)

# Draw the grid using w.plbox

        w.plbox("bcg", 1./16., 0, "bcg", 1./16., 0)

# Write the digits below the frame

        w.plcol0(15)
        for i in range(16):
            w.plmtex("b", 1.5, ((i+0.5)/16.), 0.5, str(i))

        k = 0
        w.plmtex("t", 1.5, 0.5, 0.5, title)
        for i in range(16):

            # Write the digits to the left of the frame

            w.plmtex("lv", 1.0, (1.0 - (i+0.5)/16.), 1.0, str(16 * i))

            w.plsfont(family_index, style_index, weight_index)
            for j in range(16):
                x = (j+0.5)/16.
                y = 1. - (i+0.5)/16

                # Display the Type 1 glyph corresponding to k
                glyph_string = unichr(k).encode('utf-8')
                # Escape the escape.
                if glyph_string == "#":
                    glyph_string = "##"
                w.plptex(x, y, 1., 0., 0.5, glyph_string)
                k = k + 1
            w.plsfont(0, 0, 0)

main(w)
w.plend()