Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Regression: CUPS adds non-custom PageSize to filter options for custom media size #3764

Closed

Description

@michaelrsweet

Version: 1.4-current
CUPS.org User: mike

Currently a print job with a custom page size, e.g., "-o media=Custom.WIDTHxHEIGHT", will end up getting a standard page size in the filter options if the custom size matches a standard page size. This can cause problems for some drivers since the wrong margins might get used.

Activity

  1. michaelrsweet commented on Jan 3, 2011

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

  2. michaelrsweet commented on Jan 6, 2011

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

  3. michaelrsweet commented on Jan 6, 2011

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

  4. michaelrsweet commented on Jan 6, 2011

    @michaelrsweet
    ContributorAuthor

    "str3764.patch":

    Index: cups/pwg-ppd.c

    --- cups/pwg-ppd.c (revision 9413)
    +++ cups/pwg-ppd.c (working copy)
    @@ -1015,55 +1015,59 @@
    closest = NULL;
    dclosest = 999999999;

    • for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
    • if (!ppd_name || strncasecmp(ppd_name, "Custom.", 7) ||
    •  strncasecmp(ppd_name, "custom_", 7))
      
      {
    • /*
    • * Adobe uses a size matching algorithm with an epsilon of 5 points, which
    • * is just about 176/2540ths...

    - */

    • dwidth = size->width - jobsize.width;

    - dlength = size->length - jobsize.length;

    • if (dwidth <= -176 || dwidth >= 176 || dlength <= -176 || dlength >= 176)

    - continue;

    • if (margins_set)

    • for (i = pwg->num_sizes, size = pwg->sizes; i > 0; i --, size ++)
      {
      /*

    •  \* Use a tighter epsilon of 1 point (35/2540ths) for margins...
      
    •  \* Adobe uses a size matching algorithm with an epsilon of 5 points, which
      
    •  * is just about 176/2540ths...
      

      */

    •  dleft   = size->left - jobsize.left;
      
    •  dright  = size->right - jobsize.right;
      
    •  dtop    = size->top - jobsize.top;
      
    •  dbottom = size->bottom - jobsize.bottom;
      
    •  dwidth  = size->width - jobsize.width;
      
    •  dlength = size->length - jobsize.length;
      
    •  if (dleft <= -35 || dleft >= 35 || dright <= -35 || dright >= 35 ||
      
    •      dtop <= -35 || dtop >= 35 || dbottom <= -35 || dbottom >= 35)
      
    •  if (dwidth <= -176 || dwidth >= 176 || dlength <= -176 || dlength >= 176)
      
    • continue;

    •  if (margins_set)
      
      {
    •    dleft   = dleft < 0 ? -dleft : dleft;
      
    •    dright  = dright < 0 ? -dright : dright;
      
    •    dbottom = dbottom < 0 ? -dbottom : dbottom;
      
    •    dtop    = dtop < 0 ? -dtop : dtop;
      
    • dmin = dleft + dright + dbottom + dtop;
    •   /*
      
    • * Use a tighter epsilon of 1 point (35/2540ths) for margins...
    • */
    •    if (dmin < dclosest)
      
    • dleft = size->left - jobsize.left;
    • dright = size->right - jobsize.right;
    • dtop = size->top - jobsize.top;
    • dbottom = size->bottom - jobsize.bottom;
    • if (dleft <= -35 || dleft >= 35 || dright <= -35 || dright >= 35 ||
    •   dtop <= -35 || dtop >= 35 || dbottom <= -35 || dbottom >= 35)
      
      {
    • dclosest = dmin;
      
    • closest  = size;
      
    • dleft   = dleft < 0 ? -dleft : dleft;
      
    • dright  = dright < 0 ? -dright : dright;
      
    • dbottom = dbottom < 0 ? -dbottom : dbottom;
      
    • dtop    = dtop < 0 ? -dtop : dtop;
      
    • dmin    = dleft + dright + dbottom + dtop;
      
    • if (dmin < dclosest)
      
    • {
      
    •   dclosest = dmin;
      
    •   closest  = size;
      
    • }
      
    • continue;
      

      }

    • continue;
      }
    • }
    • if (exact)
    •  *exact = 1;
      
    •  if (exact)
      
    • *exact = 1;
    • DEBUG_printf(("1_pwgGetPageSize: Returning "%s"", size->map.ppd));
    •  DEBUG_printf(("1_pwgGetPageSize: Returning \"%s\"", size->map.ppd));
      
    • return (size->map.ppd);
    •  return (size->map.ppd);
      
    • }
      }

    if (closest)

  5. added this to the Stable milestone on Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions