Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Can px-units be scaled? #427

@OnkelTem

Description

@OnkelTem

Currently, it's impossible to scale sizes specified with in px-units, e.g.: text-size: 13 will be always 13 at any dpi/ppi. While this is similar to how browsers treat px-sizes (at least before retina-displays era), for maps this would mean that scaling is not possible at all.

What I suggest is to consider a change which would allow for px-scaling. A quick patch:

diff --git a/lib/carto/tree/dimension.js b/lib/carto/tree/dimension.js
index 07232f2..7d762ee 100644
--- a/lib/carto/tree/dimension.js
+++ b/lib/carto/tree/dimension.js
@@ -11,7 +11,7 @@ tree.Dimension = function Dimension(value, unit, index) {

 tree.Dimension.prototype = {
     is: 'float',
-    physical_units: ['m', 'cm', 'in', 'mm', 'pt', 'pc'],
+    physical_units: ['m', 'cm', 'in', 'mm', 'pt', 'pc', 'px'],
     screen_units: ['px', '%'],
     all_units: ['m', 'cm', 'in', 'mm', 'pt', 'pc', 'px', '%'],
     densities: {
@@ -19,7 +19,8 @@ tree.Dimension.prototype = {
         mm: 25.4,
         cm: 2.54,
         pt: 72,
-        pc: 6
+        pc: 6,
+        px: 90.714 // the same as the default ppi
     },
     ev: function (env) {
         if (this.unit && !_.contains(this.all_units, this.unit)) {

This behavior is not necessary to trigger by default, instead a command-line switch can be added.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions