1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-20 09:45:12 +03:00
aports/testing/libgdiplus/pango.patch
Adeel 3535f835bd testing/libgdiplus: add pango dependency
Without pango support, libgdiplus offers basic text rendering and lacks
advanced typography features like emphasis.
2021-01-24 04:13:01 +00:00

133 lines
4.3 KiB
Diff

From 8f42e17e92c562cc243844b8a004cd03144b1384 Mon Sep 17 00:00:00 2001
From: Filip Navara <filip.navara@gmail.com>
Date: Thu, 3 Oct 2019 14:25:27 +0200
Subject: [PATCH] Reinstate support for Pango 1.44+
---
configure.ac | 3 +--
src/font.c | 50 ++++++++++++++++++++++++++++++++++--------------
src/text-pango.c | 1 +
3 files changed, 38 insertions(+), 16 deletions(-)
diff --git a/configure.ac b/configure.ac
index 38667dd9..71b0edef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,12 +59,11 @@ cairo_info="`pkg-config --modversion cairo ` (system)"
GDIPLUS_PKG_REQ="cairo"
PANGO_REQUIRED_VERSION="1.40.14"
-PANGO_MAX_VERSION="1.43"
if test $text_v = "pango"; then
PKG_CHECK_MODULES(PANGO, pango >= $PANGO_REQUIRED_VERSION)
fi
if test $text_v = "default"; then
- PKG_CHECK_MODULES(PANGO, pango >= $PANGO_REQUIRED_VERSION && pango <= $PANGO_MAX_VERSION,
+ PKG_CHECK_MODULES(PANGO, pango >= $PANGO_REQUIRED_VERSION,
[text_v=pango], [text_v=cairo])
fi
if test $text_v = "pango"; then
diff --git a/src/font.c b/src/font.c
index e4e160c7..6f586acd 100644
--- a/src/font.c
+++ b/src/font.c
@@ -36,6 +36,15 @@
#include "general-private.h"
#include "graphics-private.h"
+#ifdef USE_PANGO_RENDERING
+#if defined(PANGO_VERSION_CHECK)
+#if PANGO_VERSION_CHECK(1,44,0)
+#define PANGO_DEPRECATED_FREETYPE_DEPENDENCY
+#include <hb-ot.h>
+#endif
+#endif
+#endif
+
/* Generic fonts families */
#if GLIB_CHECK_VERSION(2,32,0)
static GMutex generic;
@@ -234,7 +243,7 @@ GdipPrivateAddFontFile (GpFontCollection *fontCollection, GDIPCONST WCHAR *filen
fclose (fileHandle);
FcConfigAppFontAddFile (fontCollection->config, file);
-
+
GdipFree (file);
return Ok;
}
@@ -326,8 +335,8 @@ gdip_createPrivateFontSet (GpFontCollection *font_collection)
{
FcObjectSet *os = FcObjectSetBuild (FC_FAMILY, FC_FOUNDRY, FC_FILE, NULL);
FcPattern *pat = FcPatternCreate ();
- FcFontSet *col = FcFontList (font_collection->config, pat, os);
-
+ FcFontSet *col = FcFontList (font_collection->config, pat, os);
+
if (font_collection->fontset)
FcFontSetDestroy (font_collection->fontset);
@@ -736,12 +745,6 @@ enum fsSelection {
fsSelectionOblique = (1 << 9),
};
-#if defined(PANGO_VERSION_CHECK)
-#if PANGO_VERSION_CHECK(1,44,0)
-#define PANGO_DEPRECATED_FREETYPE_DEPENDENCY
-#endif
-#endif
-
#if !defined(USE_PANGO_RENDERING) || !defined (PANGO_DEPRECATED_FREETYPE_DEPENDENCY)
static void
gdip_get_fontfamily_details_from_freetype (GpFontFamily *family, FT_Face face)
@@ -808,14 +811,33 @@ gdip_get_pango_font_description (GpFont *font)
static void
gdip_get_fontfamily_details_from_harfbuzz (GpFontFamily *family, hb_font_t *font)
{
+ hb_font_t *subfont;
hb_font_extents_t font_extents;
- hb_font_get_extents_for_direction (font, HB_DIRECTION_LTR, &font_extents);
+ hb_face_t *face;
+ hb_position_t position;
+
+ face = hb_font_get_face (font);
+ family->height = hb_face_get_upem (face);
+
+ subfont = hb_font_create (face);
- family->celldescent = -font_extents.descender;
- family->cellascent = font_extents.ascender;
- family->linespacing = family->cellascent + family->celldescent + font_extents.line_gap;
+ hb_font_set_scale (subfont, family->height, family->height);
+ hb_font_get_h_extents (subfont, &font_extents);
+
+ family->linespacing = font_extents.line_gap + font_extents.ascender - font_extents.descender;
+
+ if (hb_ot_metrics_get_position (subfont, HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_ASCENT, &position)) {
+ family->cellascent = position;
+ } else {
+ family->cellascent = font_extents.ascender;
+ }
+ if (hb_ot_metrics_get_position (subfont, HB_OT_METRICS_TAG_HORIZONTAL_CLIPPING_DESCENT, &position)) {
+ family->celldescent = position;
+ } else {
+ family->celldescent = -font_extents.descender;
+ }
- family->height = hb_face_get_upem (hb_font_get_face (font));
+ hb_font_destroy (subfont);
}
#endif
diff --git a/src/text-pango.c b/src/text-pango.c
index 1baa9762..938a0d23 100644
--- a/src/text-pango.c
+++ b/src/text-pango.c
@@ -652,6 +652,7 @@ pango_MeasureString (GpGraphics *graphics, GDIPCONST WCHAR *stringUnicode, INT l
} else {
// Nothing was fitted. Most likely either the input length was zero or LineLimit prevented fitting any lines (the height of the first line is greater than the height of the bounding box).
charsFitted = 0;
+ lines = 0;
}
*codepointsFitted = charsFitted;
}