Skip to content

Commit

Permalink
Reinstate support for Pango 1.44+ (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara authored and akoeplinger committed Oct 3, 2019
1 parent cda407b commit 39e8512
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 16 deletions.
3 changes: 1 addition & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 36 additions & 14 deletions src/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -234,7 +243,7 @@ GdipPrivateAddFontFile (GpFontCollection *fontCollection, GDIPCONST WCHAR *filen

fclose (fileHandle);
FcConfigAppFontAddFile (fontCollection->config, file);

GdipFree (file);
return Ok;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/text-pango.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 39e8512

Please sign in to comment.