Check-in [75f5c2c704]

Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Editorial pass on 507
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 75f5c2c7044300a86a970e49750c99dbc9816452cdbda3a18921d6e8fbe5a96f
User & Date: dkf 2018-12-13 11:00:29.084
Context
2018-12-14
14:30
Docuement current (failed) approach to set write metadata. check-in: bbe903ab13 user: oehhar tags: trunk
2018-12-13
13:37
New TIP 530 check-in: 99daffc5b5 user: leon tags: trunk
11:00
Editorial pass on 507 check-in: 75f5c2c704 user: dkf tags: trunk
2018-12-11
10:42
TIP 429: Added implementation link check-in: 23b8985271 user: oehhar tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/507.md.
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

# Abstract

Tk needs scalable images on high resolution mobile devices. This TIP proposes to let Tk be able to read an [SVG][] image (plus information about orientation and pixel scale) and make it into a photo image. It is therefore a (lossy and single direction) conversion operation from an [SVG][] format to a pixel format.

# Rationale

Tk is running on desktop and mobile devices. The out of the box image formats
do not scale and are to tiny on high res mobile devices.
The same goes for the image formats provided by the Img extension.






There is already a tk image extension [tksvg][]. The implementation is using [nanosvg][]. It has no other external dependencies and is only 2 header files.

[nanosvg][] was choosen because it:

- has a suitable license
- is written in 2 plain C header files and can be easily included
- is really lightweight
- is tested with tksvg
- can render images
- has no other external dependencies

# Specification

The already existing [tksvg][] extension will be adapted and included in Tk.
A new image format will be created. The image format name is **svg**.
The new format will support a small list of options.
If there is a better implementation with p.e. full [SVG][] support, the interface can be reused and the limitations in the description can be removed.



A description of the features and limitations of the current implementation is in section [Supported SVG](#Supported-SVG). It will be also described in the photo(n) man page.

The **svg** image format has the following format suboptions:

 > **svg** **-dpi** _dpiValue_ **-scale** _scaleValue_ **-unit** _unitValue_

*dpiValue* is used in conversion between given coordiantes and screen resolution. The value must be greater then 0.0. The default value is 96.

*scaleValue* is used to scale the resulting image. The value must be greater then 0.0. The default value is 1.

*unitValue* is the unit of all coordinates in the svg data. Available units are px (default, coordinates in pixel), pt (1/72 inch), pc (12 pt), mm, cm and in.

The given format options are only used at creation time of the image and are not preserved in the image. This means that:

  1. `$img data -format svg` triggers the error _"image string format
     "svg" is not supported"_; Tk cannot convert a photo image into an
     [SVG][].

  2. In this:

        $img configure -format {svg -scale 2}
        $img configure -format {svg -dpi 96}

    the second call takes `-scale` as the default value (1).




<a name="Supported-SVG"></a>
# Supported SVG

The **svg** format supports a wide range of [SVG][] features, however some features (e.g. 'text') are missing and silently ignored when reading the [SVG][] data.

## Elements







|
|
|

>
>
>
>
>
|













|

|
>
>
>






|

|

|













>
>
>







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

# Abstract

Tk needs scalable images on high resolution mobile devices. This TIP proposes to let Tk be able to read an [SVG][] image (plus information about orientation and pixel scale) and make it into a photo image. It is therefore a (lossy and single direction) conversion operation from an [SVG][] format to a pixel format.

# Rationale

Tk is running on desktop and mobile devices. However, the out-of-the-box photo
image formats do not scale and are too tiny on high resolution mobile devices.
The same goes for the image formats provided by the [Img][] extension.

The response to this challenge in general (on the web, in applications, etc.)
has been to adopt the [SVG][] format, as that is scalable and does not
typically depend on being rendered at a particular resolution.
Moreover, there is already a Tk image extension to do the conversion,
[tksvg][]. The implementation is using the [nanosvg][] library It has no other
external dependencies and is only 2 header files.

[nanosvg][] was choosen because it:

- has a suitable license
- is written in 2 plain C header files and can be easily included
- is really lightweight
- is tested with tksvg
- can render images
- has no other external dependencies

# Specification

The already existing [tksvg][] extension will be adapted and included in Tk.
A new photo image format will be created. The photo image format name is **svg**.
The new format will support a small list of options.
Note that scope still exists in the future for full integration of SVG as its
own full image type (which would allow more options for rendering) instead of
having the side-trip via the photo image's pixel buffer, but this is out of
scope of this TIP.
A description of the features and limitations of the current implementation is in section [Supported SVG](#Supported-SVG). It will be also described in the photo(n) man page.

The **svg** image format has the following format suboptions:

 > **svg** **-dpi** _dpiValue_ **-scale** _scaleValue_ **-unit** _unitValue_

*dpiValue* is used in conversion between given coordiantes and screen resolution. The value must be greater then 0.0. The default value is `96`.

*scaleValue* is used to scale the resulting image. The value must be greater then 0.0. The default value is `1.0`.

*unitValue* is the unit of all coordinates in the svg data. Available units are `px` (default, coordinates in pixel), `pt` (1/72 inch), `pc` (12 pt), `mm`, `cm` and `in`.

The given format options are only used at creation time of the image and are not preserved in the image. This means that:

  1. `$img data -format svg` triggers the error _"image string format
     "svg" is not supported"_; Tk cannot convert a photo image into an
     [SVG][].

  2. In this:

        $img configure -format {svg -scale 2}
        $img configure -format {svg -dpi 96}

    the second call takes `-scale` as the default value (1).

There is no intention to provide a reverse mechanism for saving a photo image
as an SVG image.

<a name="Supported-SVG"></a>
# Supported SVG

The **svg** format supports a wide range of [SVG][] features, however some features (e.g. 'text') are missing and silently ignored when reading the [SVG][] data.

## Elements
217
218
219
220
221
222
223
224
225
# Copyright

This document has been placed in the public domain.

[nanosvg]: <https://github.com/memononen/nanosvg>
[tksvg]: <https://github.com/auriocus/tksvg>
[SVG]: <http://www.w3.org/TR/SVG11/>









|
<
228
229
230
231
232
233
234
235

# Copyright

This document has been placed in the public domain.

[nanosvg]: <https://github.com/memononen/nanosvg>
[tksvg]: <https://github.com/auriocus/tksvg>
[SVG]: <http://www.w3.org/TR/SVG11/>
[Img]: <https://sourceforge.net/projects/tkimg/>