[pango/pango2: 16/63] font description: Allow integer values for stretch
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 16/63] font description: Allow integer values for stretch
- Date: Fri, 10 Jun 2022 03:41:33 +0000 (UTC)
commit 1067d2e8678c989a088e6cf57eaa8f7d5c4c8e8f
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 20 13:53:36 2022 -0500
font description: Allow integer values for stretch
And do approximate matching for stretch like we do
for weight.
pango/pango-font-description.c | 17 +++++++++--------
pango/pango-font-description.h | 21 ++++++++++++---------
2 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/pango/pango-font-description.c b/pango/pango-font-description.c
index 89de07c9..86349d7d 100644
--- a/pango/pango-font-description.c
+++ b/pango/pango-font-description.c
@@ -758,7 +758,6 @@ pango_font_description_is_similar (const PangoFontDescription *a,
const PangoFontDescription *b)
{
return a->variant == b->variant &&
- a->stretch == b->stretch &&
a->gravity == b->gravity;
}
@@ -768,14 +767,16 @@ pango_font_description_compute_distance (const PangoFontDescription *a,
{
if (a->style == b->style)
{
- return abs((int)(a->weight) - (int)(b->weight));
+ return abs ((int)(a->weight) - (int)(b->weight)) +
+ abs ((int)(a->stretch) - (int)(b->stretch));
}
else if (a->style != PANGO_STYLE_NORMAL &&
b->style != PANGO_STYLE_NORMAL)
{
/* Equate oblique and italic, but with a big penalty
*/
- return 1000000 + abs ((int)(a->weight) - (int)(b->weight));
+ return 1000000 + abs ((int)(a->weight) - (int)(b->weight))
+ + abs ((int)(a->stretch) - (int)(b->stretch));
}
else
return G_MAXINT;
@@ -791,11 +792,11 @@ pango_font_description_compute_distance (const PangoFontDescription *a,
* for @desc than those of @old_match are, or if @old_match is %NULL,
* determines if @new_match is a match at all.
*
- * Approximate matching is done for weight and style; other style attributes
- * must match exactly. Style attributes are all attributes other than family
- * and size-related attributes. Approximate matching for style considers
- * %PANGO_STYLE_OBLIQUE and %PANGO_STYLE_ITALIC as matches, but not as good
- * a match as when the styles are equal.
+ * Approximate matching is done for weight, stretch and style; other style
+ * attributes must match exactly. Style attributes are all attributes other
+ * than family and size-related attributes. Approximate matching for style
+ * considers %PANGO_STYLE_OBLIQUE and %PANGO_STYLE_ITALIC as matches, but
+ * not as good a match as when the styles are equal.
*
* Note that @old_match must match @desc.
*
diff --git a/pango/pango-font-description.h b/pango/pango-font-description.h
index 21989e69..999a276c 100644
--- a/pango/pango-font-description.h
+++ b/pango/pango-font-description.h
@@ -130,17 +130,20 @@ typedef enum {
*
* An enumeration specifying the width of the font relative to other designs
* within a family.
+ *
+ * Stretch is specified as a numeric value ranging from 500 to 2000.
+ * This enumeration simply provides some common, predefined values.
*/
typedef enum {
- PANGO_STRETCH_ULTRA_CONDENSED,
- PANGO_STRETCH_EXTRA_CONDENSED,
- PANGO_STRETCH_CONDENSED,
- PANGO_STRETCH_SEMI_CONDENSED,
- PANGO_STRETCH_NORMAL,
- PANGO_STRETCH_SEMI_EXPANDED,
- PANGO_STRETCH_EXPANDED,
- PANGO_STRETCH_EXTRA_EXPANDED,
- PANGO_STRETCH_ULTRA_EXPANDED
+ PANGO_STRETCH_ULTRA_CONDENSED = 500,
+ PANGO_STRETCH_EXTRA_CONDENSED = 625,
+ PANGO_STRETCH_CONDENSED = 750,
+ PANGO_STRETCH_SEMI_CONDENSED = 875,
+ PANGO_STRETCH_NORMAL = 1000,
+ PANGO_STRETCH_SEMI_EXPANDED = 1125,
+ PANGO_STRETCH_EXPANDED = 1250,
+ PANGO_STRETCH_EXTRA_EXPANDED = 1500,
+ PANGO_STRETCH_ULTRA_EXPANDED = 2000
} PangoStretch;
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]