]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
PPD cache did not reflect full set of media sizes.
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 23 Apr 2014 00:38:21 +0000 (00:38 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Wed, 23 Apr 2014 00:38:21 +0000 (00:38 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11826 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/ppd-cache.c
cups/pwg-media.c
cups/pwg-private.h

index 5c1a901596d7e369e808c4f0d0a6e599b0da4d8f..27bce5f89145d4abb098edea927d4e3c445c9df3 100644 (file)
@@ -750,8 +750,9 @@ _ppdCacheCreateWithPPD(ppd_file_t *ppd)     /* I - PPD file */
       * dimensions that are <= 0...
       */
 
-      if ((pwg_media = pwgMediaForSize(PWG_FROM_POINTS(ppd_size->width),
-                                       PWG_FROM_POINTS(ppd_size->length))) == NULL)
+      if ((pwg_media = _pwgMediaNearSize(PWG_FROM_POINTS(ppd_size->width),
+                                       PWG_FROM_POINTS(ppd_size->length),
+                                       0)) == NULL)
        continue;
 
       new_width      = pwg_media->width;
index ca0ed8fc514e0263413321f54ac1557974c6b7cd..7361f2bd0eeb87a3c793dc5ed28806c7a939460f 100644 (file)
@@ -911,6 +911,18 @@ pwg_media_t *_pwgMediaForPWG(const char *pwg)
 pwg_media_t *                          /* O - PWG media name */
 pwgMediaForSize(int width,             /* I - Width in hundredths of millimeters */
                int length)             /* I - Length in hundredths of millimeters */
+{
+  /*
+   * Adobe uses a size matching algorithm with an epsilon of 5 points, which
+   * is just about 176/2540ths...
+   */
+  return _pwgMediaNearSize(width, length, 176);        
+}
+
+pwg_media_t *                          /* O - PWG media name */
+_pwgMediaNearSize(int width,           /* I - Width in hundredths of millimeters */
+               int length,             /* I - Length in hundredths of millimeters */
+               int epsilon)            /* I - Match within this tolernace. PWG units */
 {
   int          i;                      /* Looping var */
   pwg_media_t  *media,                 /* Current media */
@@ -937,17 +949,13 @@ pwgMediaForSize(int width,                /* I - Width in hundredths of millimeters */
        i > 0;
        i --, media ++)
   {
-   /*
-    * Adobe uses a size matching algorithm with an epsilon of 5 points, which
-    * is just about 176/2540ths...
-    */
 
     dw = abs(media->width - width);
     dl = abs(media->length - length);
 
     if (!dw && !dl)
       return (media);
-    else if (dw < 176 && dl < 176)
+    else if (dw <= epsilon && dl <= epsilon)
     {
       if (dw <= best_dw && dl <= best_dl)
       {
index d012e308f98efdf1a3db1d85beef6351426c4cb2..274397fb3f18e8abce84f209d6dcdcfe5f5751a7 100644 (file)
@@ -66,6 +66,7 @@ extern pwg_media_t    *_pwgMediaForPWG(const char *pwg)
 extern pwg_media_t     *_pwgMediaForSize(int width, int length)
                            _CUPS_INTERNAL_MSG("Use pwgMediaForSize instead.");
 extern const pwg_media_t *_pwgMediaTable(size_t *num_media);
+extern pwg_media_t *_pwgMediaNearSize(int width, int length, int epsilon);
 
 #  ifdef __cplusplus
 }