]> granicus.if.org Git - graphviz/commitdiff
LASi plugin: support newer Pango weights introduced ≥1.24
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 5 Apr 2022 01:59:19 +0000 (18:59 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 10 Apr 2022 23:39:54 +0000 (16:39 -0700)
Squashes a number of compiler warnings that fail the upcoming CMake build of
this plugin. The version checks and mapping logic was derived from the Pango
docs¹ and the LASi.h header.

¹ https://docs.gtk.org/Pango/enum.Weight.html

plugin/lasi/gvrender_lasi.cpp

index 319f9544e3c0be954d034b62451e4136672b8c11..e2ada4befe430317b3ef9e71b5d56310d3886da7 100644 (file)
@@ -361,13 +361,28 @@ static void lasi_textspan(GVJ_t * job, pointf p, textspan_t * span)
            case PANGO_VARIANT_SMALL_CAPS: variant = SMALLCAPS; break;
        }
        switch (pango_font_description_get_weight(pango_font)) {
+#if PANGO_VERSION_CHECK(1, 24, 0)
+           case PANGO_WEIGHT_THIN: weight = ULTRALIGHT; break; // no exact match in LASi
+#endif
            case PANGO_WEIGHT_ULTRALIGHT: weight = ULTRALIGHT; break;
            case PANGO_WEIGHT_LIGHT: weight = LIGHT; break;
+#if PANGO_VERSION_CHECK(1, 36, 7)
+           case PANGO_WEIGHT_SEMILIGHT: weight = LIGHT; break; // no exact match in LASi
+#endif
+#if PANGO_VERSION_CHECK(1, 24, 0)
+           case PANGO_WEIGHT_BOOK: weight = NORMAL_WEIGHT; break; // no exact match in LASi
+#endif
            case PANGO_WEIGHT_NORMAL: weight = NORMAL_WEIGHT; break;
+#if PANGO_VERSION_CHECK(1, 24, 0)
+           case PANGO_WEIGHT_MEDIUM: weight = NORMAL_WEIGHT; break; // no exact match in LASi
+#endif
            case PANGO_WEIGHT_SEMIBOLD: weight = BOLD; break; /* no exact match in lasi */
            case PANGO_WEIGHT_BOLD: weight = BOLD; break;
            case PANGO_WEIGHT_ULTRABOLD: weight = ULTRABOLD; break;
            case PANGO_WEIGHT_HEAVY: weight = HEAVY; break;
+#if PANGO_VERSION_CHECK(1, 24, 0)
+           case PANGO_WEIGHT_ULTRAHEAVY: weight = HEAVY; break; // no exact match in LASi
+#endif
        }
     }
     else {