aboutsummaryrefslogtreecommitdiffstats
path: root/main/libxft
diff options
context:
space:
mode:
authorLeo <thinkabit.ukim@gmail.com>2021-08-27 10:01:26 -0300
committerLeo <thinkabit.ukim@gmail.com>2021-08-27 23:19:32 +0000
commit5d05e3c4e128a0eef06595973a9e1b80cff4a280 (patch)
tree89f2f3cf1fa982f45e16e4cb34071a547883eee3 /main/libxft
parent803cbee889ba3645a56cbab485b4dc5ede28be64 (diff)
main/libxft: upgrade to 2.3.4
Diffstat (limited to 'main/libxft')
-rw-r--r--main/libxft/APKBUILD12
-rw-r--r--main/libxft/emoji.patch617
2 files changed, 388 insertions, 241 deletions
diff --git a/main/libxft/APKBUILD b/main/libxft/APKBUILD
index 4929b10b7ac..10a725cc4e6 100644
--- a/main/libxft/APKBUILD
+++ b/main/libxft/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libxft
-pkgver=2.3.3
-pkgrel=1
+pkgver=2.3.4
+pkgrel=0
pkgdesc="FreeType-based font drawing library for X"
url="http://xorg.freedesktop.org/"
arch="all"
@@ -16,7 +16,6 @@ source="https://www.x.org/releases/individual/lib/libXft-$pkgver.tar.bz2
builddir="$srcdir/libXft-$pkgver"
build() {
- cd "$builddir"
./configure \
--build=$CBUILD \
--host=$CHOST \
@@ -26,10 +25,11 @@ build() {
}
package() {
- cd "$builddir"
make DESTDIR="$pkgdir" install
install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
-sha512sums="28fdaf3baa3b156a4a7fdd6e39c4d8026d7d21eaa9be27c9797c8d329dab691a1bc82ea6042f9d4729a9343d93787536fb7e4b606f722f33cbe608b2e79910e8 libXft-2.3.3.tar.bz2
-d17758faaad59e00820792a8938e93aa7a2dcbe5fe7d8ece6b96f2651b1a1275b54395202211a92504ff87319e7b5e43250b2cb28c96a7ac31a602c3d95f6916 emoji.patch"
+sha512sums="
+5bb019750982ed4643880efd7368bc226ad49cfa8c0c8c6d4614dfeed74f588c65e1ba69adcc12284ec07d841e5b58fc1c27f3fddf83fe1a2837b29dd9ecec51 libXft-2.3.4.tar.bz2
+fd1abcb83aa44c524dc24dca9072c4370f4716a122fed55f4de6490cb179a6ea11192d4f0ba64c822c6d4eefaeaa94796da81db4ebcf32807706f45469b304a0 emoji.patch
+"
diff --git a/main/libxft/emoji.patch b/main/libxft/emoji.patch
index b2214321c63..5c594ccdb61 100644
--- a/main/libxft/emoji.patch
+++ b/main/libxft/emoji.patch
@@ -1,12 +1,252 @@
-Author: Maxime Coste <mawww@kakoune.org>
-URL: https://gitlab.freedesktop.org/xorg/lib/libxft/-/merge_requests/1 https://gitlab.freedesktop.org/xorg/lib/libxft/-/commit/7808631e7a9a605d5fe7a1077129c658d9ec47fc
-Summary: Add support for BGRA glyphs and scaling
-----
+From 723092ece088559f1af299236305911f4ee4d450 Mon Sep 17 00:00:00 2001
+From: Maxime Coste <mawww@kakoune.org>
+Date: Thu, 28 Jan 2021 19:59:10 +1100
+Subject: [PATCH 1/3] Introduce a _XftCompositeString helper function
+
+Dispatch to XRenderCompositeString{8,16,32} based off the given width.
+
+Signed-off-by: Maxime Coste <mawww@kakoune.org>
+---
+ src/xftrender.c | 61 ++++++++++++++++++++++++++++++++++---------------
+ 1 file changed, 43 insertions(+), 18 deletions(-)
+
+diff --git a/src/xftrender.c b/src/xftrender.c
+index a352737..181c27a 100644
+--- a/src/xftrender.c
++++ b/src/xftrender.c
+@@ -25,6 +25,47 @@
+ #define NUM_LOCAL 1024
+ #define NUM_ELT_LOCAL 128
+
++/*
++ * Dispatch glyph drawing to the correct XRenderCompositeString function
++ */
++static void
++_XftCompositeString (Display *dpy,
++ int op,
++ Picture src,
++ Picture dst,
++ XRenderPictFormat *format,
++ GlyphSet glyphset,
++ int srcx,
++ int srcy,
++ int dstx,
++ int dsty,
++ int charwidth,
++ unsigned int *chars,
++ int nchars)
++{
++ if (nchars == 0)
++ return;
++
++ switch (charwidth) {
++ case 1:
++ default:
++ XRenderCompositeString8 (dpy, op,
++ src, dst, format, glyphset,
++ srcx, srcy, dstx, dsty, (char*)chars, nchars);
++ break;
++ case 2:
++ XRenderCompositeString16(dpy, op,
++ src, dst, format, glyphset,
++ srcx, srcy, dstx, dsty, (unsigned short*)chars, nchars);
++ break;
++ case 4:
++ XRenderCompositeString32(dpy, op,
++ src, dst, format, glyphset,
++ srcx, srcy, dstx, dsty, (unsigned int*)chars, nchars);
++ break;
++ }
++}
++
+ /*
+ * Use the Render extension to draw the glyphs
+ */
+@@ -114,24 +155,8 @@ XftGlyphRender (Display *dpy,
+ case 4: char32[i] = (unsigned int) wire; break;
+ }
+ }
+- switch (width) {
+- case 1:
+- default:
+- XRenderCompositeString8 (dpy, op,
+- src, dst, font->format, font->glyphset,
+- srcx, srcy, x, y, char8, nglyphs);
+- break;
+- case 2:
+- XRenderCompositeString16(dpy, op,
+- src, dst, font->format, font->glyphset,
+- srcx, srcy, x, y, char16, nglyphs);
+- break;
+- case 4:
+- XRenderCompositeString32(dpy, op,
+- src, dst, font->format, font->glyphset,
+- srcx, srcy, x, y, char32, nglyphs);
+- break;
+- }
++ _XftCompositeString(dpy, op, src, dst, font->format, font->glyphset,
++ srcx, srcy, x, y, width, chars, nglyphs);
+ if (chars != char_local)
+ free (chars);
+ bail1:
+--
+GitLab
+
+
+From e0fc4ce7e87ab9c4b47e5c8e693f070dfd0d2f7b Mon Sep 17 00:00:00 2001
+From: Maxime Coste <mawww@kakoune.org>
+Date: Thu, 28 Jan 2021 20:05:13 +1100
+Subject: [PATCH 2/3] Introduce a _XftCompositeText helper function
+
+Dispatch to XRenderCompositeText{8,16,32} based off the given width.
+
+Signed-off-by: Maxime Coste <mawww@kakoune.org>
+---
+ src/xftrender.c | 83 +++++++++++++++++++++++++++++--------------------
+ 1 file changed, 49 insertions(+), 34 deletions(-)
+
+diff --git a/src/xftrender.c b/src/xftrender.c
+index 181c27a..5852b2e 100644
+--- a/src/xftrender.c
++++ b/src/xftrender.c
+@@ -164,6 +164,49 @@ bail1:
+ _XftFontManageMemory (dpy, pub);
+ }
+
++/*
++ * Dispatch glyph drawing to the correct XRenderCompositeText function
++ */
++static void
++_XftCompositeText (Display *dpy,
++ int op,
++ Picture src,
++ Picture dst,
++ XRenderPictFormat *format,
++ int srcx,
++ int srcy,
++ int dstx,
++ int dsty,
++ int eltwidth,
++ XGlyphElt8 *elts,
++ int nelt)
++{
++ if (nelt == 0)
++ return;
++
++ switch (eltwidth) {
++ case 1:
++ default:
++ XRenderCompositeText8 (dpy, op,
++ src, dst, format,
++ srcx, srcy, dstx, dsty,
++ (XGlyphElt8*)elts, nelt);
++ break;
++ case 2:
++ XRenderCompositeText16(dpy, op,
++ src, dst, format,
++ srcx, srcy, dstx, dsty,
++ (XGlyphElt16*)elts, nelt);
++ break;
++ case 4:
++ XRenderCompositeText32(dpy, op,
++ src, dst, format,
++ srcx, srcy, dstx, dsty,
++ (XGlyphElt32*)elts, nelt);
++ break;
++ }
++}
++
+ _X_EXPORT void
+ XftGlyphSpecRender (Display *dpy,
+ int op,
+@@ -345,23 +388,9 @@ XftGlyphSpecRender (Display *dpy,
+ elts[nelt].nchars = n;
+ nelt++;
+ }
+- switch (width) {
+- case 1:
+- XRenderCompositeText8 (dpy, op, src, dst, font->format,
+- srcx, srcy, glyphs[0].x, glyphs[0].y,
+- elts, nelt);
+- break;
+- case 2:
+- XRenderCompositeText16 (dpy, op, src, dst, font->format,
+- srcx, srcy, glyphs[0].x, glyphs[0].y,
+- (XGlyphElt16 *) elts, nelt);
+- break;
+- case 4:
+- XRenderCompositeText32 (dpy, op, src, dst, font->format,
+- srcx, srcy, glyphs[0].x, glyphs[0].y,
+- (XGlyphElt32 *) elts, nelt);
+- break;
+- }
++ _XftCompositeText(dpy, op, src, dst, font->format,
++ srcx, srcy, glyphs[0].x, glyphs[0].y,
++ width, elts, nelt);
+
+ if (elts != elts_local)
+ free (elts);
+@@ -635,23 +664,9 @@ XftGlyphFontSpecRender (Display *dpy,
+ elts[nelt].nchars = n;
+ nelt++;
+ }
+- switch (width) {
+- case 1:
+- XRenderCompositeText8 (dpy, op, src, dst, format,
+- srcx, srcy, glyphs[0].x, glyphs[0].y,
+- elts, nelt);
+- break;
+- case 2:
+- XRenderCompositeText16 (dpy, op, src, dst, format,
+- srcx, srcy, glyphs[0].x, glyphs[0].y,
+- (XGlyphElt16 *) elts, nelt);
+- break;
+- case 4:
+- XRenderCompositeText32 (dpy, op, src, dst, format,
+- srcx, srcy, glyphs[0].x, glyphs[0].y,
+- (XGlyphElt32 *) elts, nelt);
+- break;
+- }
++ _XftCompositeText(dpy, op, src, dst, format,
++ srcx, srcy, glyphs[0].x, glyphs[0].y,
++ width, elts, nelt);
+
+ if (elts != elts_local)
+ free (elts);
+--
+GitLab
+
+
+From d385aa3e5320d18918413df0e8aef3a713a47e0b Mon Sep 17 00:00:00 2001
+From: Maxime Coste <mawww@kakoune.org>
+Date: Tue, 22 Oct 2019 22:46:49 +1100
+Subject: [PATCH 3/3] Add support for BGRA glyphs display and scaling
+
+Display is done using an XRender Picture, as XRender
+glyphs are incompatible with BGRA rendering due to
+their use of the glyph bitmap as a mask.
+
+Scaling is done by averaging all relevant pixel, which gives
+much better result than nearest pixel sampling while staying
+simple enough and not too computationally expensive.
+
+This enables color emoji rendering support.
+
+Fixes: #6
+
+Signed-off-by: Maxime Coste <mawww@kakoune.org>
+---
+ src/xftfreetype.c | 18 +++-
+ src/xftglyphs.c | 234 +++++++++++++++++++++++++++++++++++++++++++---
+ src/xftint.h | 2 +
+ src/xftrender.c | 69 +++++++++++---
+ 4 files changed, 293 insertions(+), 30 deletions(-)
+
diff --git a/src/xftfreetype.c b/src/xftfreetype.c
-index a3b83329914f2820a76349d7a77b648e0e864d3b..a639a03aaeeffb1c3c1fc70a222539d3b1dce2e3 100644
+index 1f79a81..4325d65 100644
--- a/src/xftfreetype.c
+++ b/src/xftfreetype.c
-@@ -514,7 +514,7 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
+@@ -523,7 +523,7 @@ XftFontInfoFill (Display *dpy, _Xconst FcPattern *pattern, XftFontInfo *fi)
/*
* Compute glyph load flags
*/
@@ -15,7 +255,7 @@ index a3b83329914f2820a76349d7a77b648e0e864d3b..a639a03aaeeffb1c3c1fc70a222539d3
#ifndef XFT_EMBEDDED_BITMAP
#define XFT_EMBEDDED_BITMAP "embeddedbitmap"
-@@ -766,6 +766,7 @@ XftFontOpenInfo (Display *dpy,
+@@ -775,6 +775,7 @@ XftFontOpenInfo (Display *dpy,
FcChar32 hash_value;
FcChar32 rehash_value;
FcBool antialias;
@@ -23,7 +263,7 @@ index a3b83329914f2820a76349d7a77b648e0e864d3b..a639a03aaeeffb1c3c1fc70a222539d3
int max_glyph_memory;
int alloc_size;
int ascent, descent, height;
-@@ -822,12 +823,16 @@ XftFontOpenInfo (Display *dpy,
+@@ -831,12 +832,18 @@ XftFontOpenInfo (Display *dpy,
if (!(face->face_flags & FT_FACE_FLAG_SCALABLE))
antialias = FcFalse;
@@ -36,22 +276,14 @@ index a3b83329914f2820a76349d7a77b648e0e864d3b..a639a03aaeeffb1c3c1fc70a222539d3
{
- if (antialias)
+ if (color)
++ {
+ format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
++ }
+ else if (antialias)
{
switch (fi->rgba) {
case FC_RGBA_RGB:
-@@ -842,9 +847,7 @@ XftFontOpenInfo (Display *dpy,
- }
- }
- else
-- {
- format = XRenderFindStandardFormat (dpy, PictStandardA1);
-- }
-
- if (!format)
- goto bail2;
-@@ -959,6 +962,13 @@ XftFontOpenInfo (Display *dpy,
+@@ -968,6 +975,13 @@ XftFontOpenInfo (Display *dpy,
* which doesn't happen in XftFontInfoFill
*/
font->info.antialias = antialias;
@@ -66,7 +298,7 @@ index a3b83329914f2820a76349d7a77b648e0e864d3b..a639a03aaeeffb1c3c1fc70a222539d3
* bump XftFile reference count
*/
diff --git a/src/xftglyphs.c b/src/xftglyphs.c
-index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0bb6697f9 100644
+index b536df4..e0bad10 100644
--- a/src/xftglyphs.c
+++ b/src/xftglyphs.c
@@ -26,6 +26,8 @@
@@ -91,13 +323,10 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
int width, height, pitch;
if ( slot->format != FT_GLYPH_FORMAT_BITMAP )
-@@ -88,9 +92,18 @@ _compute_xrender_bitmap_size( FT_Bitmap* target,
+@@ -91,6 +95,16 @@ _compute_xrender_bitmap_size( FT_Bitmap* target,
- // compute the size of the final bitmap
- ftbit = &slot->bitmap;
--
- width = ftbit->width;
- height = ftbit->rows;
+ width = (int)ftbit->width;
+ height = (int)ftbit->rows;
+
+ if ( matrix && mode == FT_RENDER_MODE_NORMAL )
+ {
@@ -105,13 +334,13 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
+ vector.y = ftbit->rows;
+ FT_Vector_Transform(&vector, matrix);
+
-+ width = vector.x;
-+ height = vector.y;
++ width = (int)vector.x;
++ height = (int)vector.y;
+ }
pitch = (width+3) & ~3;
switch ( ftbit->pixel_mode )
-@@ -112,6 +125,10 @@ _compute_xrender_bitmap_size( FT_Bitmap* target,
+@@ -112,6 +126,10 @@ _compute_xrender_bitmap_size( FT_Bitmap* target,
}
break;
@@ -122,7 +351,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
case FT_PIXEL_MODE_LCD:
if ( mode != FT_RENDER_MODE_LCD )
return -1;
-@@ -142,6 +159,105 @@ _compute_xrender_bitmap_size( FT_Bitmap* target,
+@@ -142,6 +160,105 @@ _compute_xrender_bitmap_size( FT_Bitmap* target,
return pitch * height;
}
@@ -158,7 +387,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
+ int sample_count;
+
+ if ( src_pitch < 0 )
-+ src_buf -= src_pitch*(source->rows-1);
++ src_buf -= src_pitch * (source->rows - 1);
+
+ FT_Matrix_Invert(&inverse);
+
@@ -228,7 +457,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
/* this functions converts the glyph bitmap found in a FT_GlyphSlot
* into a different format (see _compute_xrender_bitmap_size)
*
-@@ -244,6 +360,11 @@ _fill_xrender_bitmap( FT_Bitmap* target,
+@@ -244,6 +361,11 @@ _fill_xrender_bitmap( FT_Bitmap* target,
}
break;
@@ -240,7 +469,63 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
case FT_PIXEL_MODE_LCD:
if ( !bgr )
{
-@@ -365,6 +486,8 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -339,6 +461,55 @@ _fill_xrender_bitmap( FT_Bitmap* target,
+ }
+ }
+
++/* This function creates a Picture for the given glyph on the default root window
++ * It will only work in Xinerama mode
++ *
++ * dpy :: target display
++ *
++ * format :: target pixmap format
++ *
++ * width :: picture width
++ *
++ * width :: picture height
++ *
++ * data :: bitmap data
++ *
++ */
++static Picture
++_create_glyph_bgra_picture (Display *dpy,
++ XRenderPictFormat *format,
++ int width,
++ int height,
++ unsigned char *data)
++{
++ XImage image = {
++ width, height, 0, ZPixmap, (char *)data,
++ dpy->byte_order, dpy->bitmap_unit, dpy->bitmap_bit_order, 32,
++ 32, 0, 32,
++ 0, 0, 0
++ };
++ Picture picture;
++ Pixmap pixmap;
++ GC gc;
++
++ pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), width, height, 32);
++ if (!pixmap)
++ return None;
++
++ gc = XCreateGC(dpy, pixmap, 0, NULL);
++ if (!gc)
++ return None;
++
++ XInitImage(&image);
++ XPutImage(dpy, pixmap, gc, &image, 0, 0, 0, 0, width, height);
++ picture = XRenderCreatePicture(dpy, pixmap, format, 0, NULL);
++
++ XFreeGC(dpy, gc);
++ XFreePixmap(dpy, pixmap);
++
++ return picture;
++}
++
+ _X_EXPORT void
+ XftFontLoadGlyphs (Display *dpy,
+ XftFont *pub,
+@@ -365,6 +536,8 @@ XftFontLoadGlyphs (Display *dpy,
FT_Vector vector;
FT_Face face;
FT_Render_Mode mode = FT_RENDER_MODE_MONO;
@@ -249,7 +534,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
if (!info)
return;
-@@ -374,6 +497,8 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -374,6 +547,8 @@ XftFontLoadGlyphs (Display *dpy,
if (!face)
return;
@@ -258,7 +543,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
if (font->info.antialias)
{
switch (font->info.rgba) {
-@@ -390,6 +515,8 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -390,6 +565,8 @@ XftFontLoadGlyphs (Display *dpy,
}
}
@@ -267,7 +552,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
while (nglyph--)
{
glyphindex = *glyphs++;
-@@ -440,7 +567,7 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -440,7 +617,7 @@ XftFontLoadGlyphs (Display *dpy,
/*
* Compute glyph metrics from FreeType information
*/
@@ -276,7 +561,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
{
/*
* calculate the true width by transforming all four corners.
-@@ -487,7 +614,7 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -487,7 +664,7 @@ XftFontLoadGlyphs (Display *dpy,
* Clip charcell glyphs to the bounding box
* XXX transformed?
*/
@@ -285,7 +570,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
{
if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
-@@ -519,18 +646,20 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -519,18 +696,20 @@ XftFontLoadGlyphs (Display *dpy,
}
}
@@ -307,7 +592,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
{
if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT)
{
-@@ -613,14 +742,27 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -613,14 +792,27 @@ XftFontLoadGlyphs (Display *dpy,
}
}
@@ -316,10 +601,10 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
if ( size < 0 )
continue;
- xftg->metrics.width = local.width;
- xftg->metrics.height = local.rows;
-- xftg->metrics.x = - glyphslot->bitmap_left;
-- xftg->metrics.y = glyphslot->bitmap_top;
+ xftg->metrics.width = (unsigned short)local.width;
+ xftg->metrics.height = (unsigned short)local.rows;
+- xftg->metrics.x = (short)(- glyphslot->bitmap_left);
+- xftg->metrics.y = (short)( glyphslot->bitmap_top);
+ if (transform)
+ {
+ vector.x = - glyphslot->bitmap_left;
@@ -327,18 +612,18 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
+
+ FT_Vector_Transform(&vector, &font->info.matrix);
+
-+ xftg->metrics.x = vector.x;
-+ xftg->metrics.y = vector.y;
++ xftg->metrics.x = (short)vector.x;
++ xftg->metrics.y = (short)vector.y;
+ }
+ else
+ {
-+ xftg->metrics.x = - glyphslot->bitmap_left;
-+ xftg->metrics.y = glyphslot->bitmap_top;
++ xftg->metrics.x = (short)(- glyphslot->bitmap_left);
++ xftg->metrics.y = (short)( glyphslot->bitmap_top);
+ }
/*
* If the glyph is relatively large (> 1% of server memory),
-@@ -645,9 +787,12 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -645,9 +837,12 @@ XftFontLoadGlyphs (Display *dpy,
local.buffer = bufBitmap;
@@ -354,15 +639,15 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
/*
* Copy or convert into local buffer.
-@@ -662,6 +807,7 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -662,6 +857,7 @@ XftFontLoadGlyphs (Display *dpy,
*/
glyph = (Glyph) glyphindex;
+ xftg->picture = 0;
- xftg->glyph_memory = size + sizeof (XftGlyph);
+ xftg->glyph_memory = (size_t)size + sizeof (XftGlyph);
if (font->format)
{
-@@ -685,15 +831,35 @@ XftFontLoadGlyphs (Display *dpy,
+@@ -685,15 +881,21 @@ XftFontLoadGlyphs (Display *dpy,
}
}
}
@@ -378,23 +663,9 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
- (char *) bufBitmap, size);
+
+ if (glyphslot->bitmap.pixel_mode == FT_PIXEL_MODE_BGRA)
-+ {
-+ Pixmap pixmap = XCreatePixmap(dpy, DefaultRootWindow(dpy), local.width, local.rows, 32);
-+ GC gc = XCreateGC(dpy, pixmap, 0, NULL);
-+ XImage image = {
-+ local.width, local.rows, 0, ZPixmap, (char *)bufBitmap,
-+ dpy->byte_order, dpy->bitmap_unit, dpy->bitmap_bit_order, 32,
-+ 32, local.width * 4 - local.pitch, 32,
-+ 0, 0, 0
-+ };
-+
-+ XInitImage(&image);
-+ XPutImage(dpy, pixmap, gc, &image, 0, 0, 0, 0, local.width, local.rows);
-+ xftg->picture = XRenderCreatePicture(dpy, pixmap, font->format, 0, NULL);
-+
-+ XFreeGC(dpy, gc);
-+ XFreePixmap(dpy, pixmap);
-+ }
++ xftg->picture = _create_glyph_bgra_picture(dpy, font->format,
++ local.width, local.rows,
++ bufBitmap);
+ else
+ XRenderAddGlyphs (dpy, font->glyphset, &glyph,
+ &xftg->metrics, 1,
@@ -402,7 +673,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
}
else
{
-@@ -744,7 +910,9 @@ XftFontUnloadGlyphs (Display *dpy,
+@@ -744,7 +946,9 @@ XftFontUnloadGlyphs (Display *dpy,
{
if (font->format)
{
@@ -414,7 +685,7 @@ index 4b5fb82e570ed6df9de1fbd6aa0c72f5524042bf..af2e3c1d2a5c4f62019c5fb869cda3d0
glyphBuf[nused++] = (Glyph) glyphindex;
if (nused == sizeof (glyphBuf) / sizeof (glyphBuf[0]))
diff --git a/src/xftint.h b/src/xftint.h
-index c06ac3cba2430eac98fe217e4a6e923ce2c6649a..b263520d4bb89fc395628d5c35f926c5e9edc8a4 100644
+index ced9a02..1af40fe 100644
--- a/src/xftint.h
+++ b/src/xftint.h
@@ -85,6 +85,7 @@ typedef struct _XftGlyph {
@@ -434,46 +705,10 @@ index c06ac3cba2430eac98fe217e4a6e923ce2c6649a..b263520d4bb89fc395628d5c35f926c5
int lcd_filter; /* lcd filter */
FT_Matrix matrix; /* glyph transformation matrix */
diff --git a/src/xftrender.c b/src/xftrender.c
-index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a72071b95b 100644
+index 5852b2e..bd001be 100644
--- a/src/xftrender.c
+++ b/src/xftrender.c
-@@ -25,6 +25,35 @@
- #define NUM_LOCAL 1024
- #define NUM_ELT_LOCAL 128
-
-+/*
-+ * Dispatch glyph drawing to the correct XRenderCompositeString function
-+ */
-+static void
-+_XftCompositeString (Display *dpy, int op, Picture src, Picture dst, XRenderPictFormat* format, GlyphSet glyphset, int srcx, int srcy, int dstx, int dsty, int charwidth, unsigned int* chars, int nchars)
-+{
-+ if (nchars == 0)
-+ return;
-+
-+ switch (charwidth) {
-+ case 1:
-+ default:
-+ XRenderCompositeString8 (dpy, op,
-+ src, dst, format, glyphset,
-+ srcx, srcy, dstx, dsty, (char*)chars, nchars);
-+ break;
-+ case 2:
-+ XRenderCompositeString16(dpy, op,
-+ src, dst, format, glyphset,
-+ srcx, srcy, dstx, dsty, (unsigned short*)chars, nchars);
-+ break;
-+ case 4:
-+ XRenderCompositeString32(dpy, op,
-+ src, dst, format, glyphset,
-+ srcx, srcy, dstx, dsty, (unsigned int*)chars, nchars);
-+ break;
-+ }
-+}
-+
- /*
- * Use the Render extension to draw the glyphs
- */
-@@ -43,12 +72,14 @@ XftGlyphRender (Display *dpy,
+@@ -84,12 +84,14 @@ XftGlyphRender (Display *dpy,
int nglyphs)
{
XftFontInt *font = (XftFontInt *) pub;
@@ -489,7 +724,7 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
char *char8;
unsigned short *char16;
unsigned int *char32;
-@@ -100,43 +131,75 @@ XftGlyphRender (Display *dpy,
+@@ -141,22 +143,46 @@ XftGlyphRender (Display *dpy,
if (!chars)
goto bail1;
}
@@ -507,14 +742,21 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
- switch (width) {
- case 1: char8[i] = (char) wire; break;
- case 2: char16[i] = (unsigned short) wire; break;
-- case 4: char32[i] = (unsigned long) wire; break;
+- case 4: char32[i] = (unsigned int) wire; break;
+ glyph = font->glyphs[wire];
+ if (glyph->picture)
+ {
-+ _XftCompositeString(dpy, op, src, dst, font->format, font->glyphset, srcx, srcy, x, y, width, chars, j);
-+ XRenderComposite(dpy, PictOpOver, glyph->picture, None, dst, 0, 0, 0, 0, dstx, dsty - glyph->metrics.y, glyph->metrics.width, glyph->metrics.height);
-+ x = dstx = dstx + glyph->metrics.xOff;
-+ x = dsty = dsty + glyph->metrics.yOff;
++ _XftCompositeString(dpy, op, src, dst, font->format, font->glyphset,
++ srcx, srcy, x, y, width, chars, j);
++ XRenderComposite(dpy, PictOpOver, glyph->picture, None,
++ dst, 0, 0, 0, 0, dstx, dsty - glyph->metrics.y,
++ glyph->metrics.width, glyph->metrics.height);
++
++ dstx += glyph->metrics.xOff;
++ dsty += glyph->metrics.yOff;
++
++ x = dstx;
++ y = dsty;
+ j = 0;
+ }
+ else
@@ -522,70 +764,20 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
+ switch (width) {
+ case 1: char8[j] = (char) wire; break;
+ case 2: char16[j] = (unsigned short) wire; break;
-+ case 4: char32[j] = (unsigned long) wire; break;
++ case 4: char32[j] = (unsigned int) wire; break;
+ }
+ dstx += glyph->metrics.xOff;
+ dsty += glyph->metrics.yOff;
+ ++j;
}
}
-- switch (width) {
-+ _XftCompositeString(dpy, op, src, dst, font->format, font->glyphset, srcx, srcy, x, y, width, chars, j);
-+ if (chars != char_local)
-+ free (chars);
-+bail1:
-+ if (glyphs_loaded)
-+ _XftFontManageMemory (dpy, pub);
-+}
-+
-+/*
-+ * Dispatch glyph drawing to the correct XRenderCompositeText function
-+ */
-+static void
-+_XftCompositeText (Display *dpy, int op, Picture src, Picture dst, XRenderPictFormat* format, int srcx, int srcy, int dstx, int dsty, int eltwidth, XGlyphElt8* elts, int nelt)
-+{
-+ if (nelt == 0)
-+ return;
-+
-+ switch (eltwidth) {
- case 1:
- default:
-- XRenderCompositeString8 (dpy, op,
-- src, dst, font->format, font->glyphset,
-- srcx, srcy, x, y, char8, nglyphs);
-+ XRenderCompositeText8 (dpy, op,
-+ src, dst, format,
-+ srcx, srcy, dstx, dsty,
-+ (XGlyphElt8*)elts, nelt);
- break;
- case 2:
-- XRenderCompositeString16(dpy, op,
-- src, dst, font->format, font->glyphset,
-- srcx, srcy, x, y, char16, nglyphs);
-+ XRenderCompositeText16(dpy, op,
-+ src, dst, format,
-+ srcx, srcy, dstx, dsty,
-+ (XGlyphElt16*)elts, nelt);
- break;
- case 4:
-- XRenderCompositeString32(dpy, op,
-- src, dst, font->format, font->glyphset,
-- srcx, srcy, x, y, char32, nglyphs);
-+ XRenderCompositeText32(dpy, op,
-+ src, dst, format,
-+ srcx, srcy, dstx, dsty,
-+ (XGlyphElt32*)elts, nelt);
- break;
- }
-- if (chars != char_local)
-- free (chars);
--bail1:
-- if (glyphs_loaded)
-- _XftFontManageMemory (dpy, pub);
- }
-
- _X_EXPORT void
-@@ -251,9 +314,10 @@ XftGlyphSpecRender (Display *dpy,
+ _XftCompositeString(dpy, op, src, dst, font->format, font->glyphset,
+- srcx, srcy, x, y, width, chars, nglyphs);
++ srcx, srcy, x, y, width, chars, j);
+ if (chars != char_local)
+ free (chars);
+ bail1:
+@@ -319,9 +345,10 @@ XftGlyphSpecRender (Display *dpy,
g = 0;
/*
* check to see if the glyph is placed where it would
@@ -598,16 +790,16 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
{
if (x != glyphs[i].x || y != glyphs[i].y)
{
-@@ -267,7 +331,7 @@ XftGlyphSpecRender (Display *dpy,
+@@ -335,7 +362,7 @@ XftGlyphSpecRender (Display *dpy,
}
elts = elts_local;
- if (nelt > NUM_ELT_LOCAL)
+ if (!font->info.color && nelt > NUM_ELT_LOCAL)
{
- elts = malloc (nelt * sizeof (XGlyphElt8));
+ elts = malloc ((size_t)nelt * sizeof (XGlyphElt8));
if (!elts)
-@@ -275,7 +339,7 @@ XftGlyphSpecRender (Display *dpy,
+@@ -343,7 +370,7 @@ XftGlyphSpecRender (Display *dpy,
}
/*
@@ -616,46 +808,22 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
*/
nelt = 0;
x = y = 0;
-@@ -289,6 +353,11 @@ XftGlyphSpecRender (Display *dpy,
+@@ -357,6 +384,14 @@ XftGlyphSpecRender (Display *dpy,
g = 0;
if ((glyph = font->glyphs[g]))
{
+ if (glyph->picture)
+ {
-+ XRenderComposite(dpy, PictOpOver, glyph->picture, None, dst, 0, 0, 0, 0, glyphs[i].x, glyphs[i].y - glyph->metrics.y, glyph->metrics.width, glyph->metrics.height);
++ XRenderComposite(dpy, PictOpOver, glyph->picture, None,
++ dst, 0, 0, 0, 0,
++ glyphs[i].x, glyphs[i].y - glyph->metrics.y,
++ glyph->metrics.width, glyph->metrics.height);
+ continue;
+ }
if (!i || x != glyphs[i].x || y != glyphs[i].y)
{
if (n)
-@@ -320,23 +389,9 @@ XftGlyphSpecRender (Display *dpy,
- elts[nelt].nchars = n;
- nelt++;
- }
-- switch (width) {
-- case 1:
-- XRenderCompositeText8 (dpy, op, src, dst, font->format,
-- srcx, srcy, glyphs[0].x, glyphs[0].y,
-- elts, nelt);
-- break;
-- case 2:
-- XRenderCompositeText16 (dpy, op, src, dst, font->format,
-- srcx, srcy, glyphs[0].x, glyphs[0].y,
-- (XGlyphElt16 *) elts, nelt);
-- break;
-- case 4:
-- XRenderCompositeText32 (dpy, op, src, dst, font->format,
-- srcx, srcy, glyphs[0].x, glyphs[0].y,
-- (XGlyphElt32 *) elts, nelt);
-- break;
-- }
-+ _XftCompositeText(dpy, op, src, dst, font->format,
-+ srcx, srcy, glyphs[0].x, glyphs[0].y,
-+ width, elts, nelt);
-
- if (elts != elts_local)
- free (elts);
-@@ -535,7 +590,7 @@ XftGlyphFontSpecRender (Display *dpy,
+@@ -589,7 +624,7 @@ XftGlyphFontSpecRender (Display *dpy,
* check to see if the glyph is placed where it would
* fall using the normal spacing
*/
@@ -664,7 +832,7 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
{
if (pub != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
{
-@@ -560,7 +615,7 @@ XftGlyphFontSpecRender (Display *dpy,
+@@ -614,7 +649,7 @@ XftGlyphFontSpecRender (Display *dpy,
}
/*
@@ -673,42 +841,21 @@ index b280c03136d8d40dee086fba8e6411db7e0d33e4..9a789cb73f8db24fa685845a4f2cc6a7
*/
nelt = 0;
x = y = 0;
-@@ -578,6 +633,11 @@ XftGlyphFontSpecRender (Display *dpy,
+@@ -632,6 +667,14 @@ XftGlyphFontSpecRender (Display *dpy,
g = 0;
if ((glyph = font->glyphs[g]))
{
+ if (glyph->picture)
+ {
-+ XRenderComposite(dpy, PictOpOver, glyph->picture, None, dst, 0, 0, 0, 0, glyphs[i].x, glyphs[i].y - glyph->metrics.y, glyph->metrics.width, glyph->metrics.height);
++ XRenderComposite(dpy, PictOpOver, glyph->picture, None,
++ dst, 0, 0, 0, 0,
++ glyphs[i].x, glyphs[i].y - glyph->metrics.y,
++ glyph->metrics.width, glyph->metrics.height);
+ continue;
+ }
if (!i || pub != prevPublic || x != glyphs[i].x || y != glyphs[i].y)
{
if (n)
-@@ -610,23 +670,9 @@ XftGlyphFontSpecRender (Display *dpy,
- elts[nelt].nchars = n;
- nelt++;
- }
-- switch (width) {
-- case 1:
-- XRenderCompositeText8 (dpy, op, src, dst, format,
-- srcx, srcy, glyphs[0].x, glyphs[0].y,
-- elts, nelt);
-- break;
-- case 2:
-- XRenderCompositeText16 (dpy, op, src, dst, format,
-- srcx, srcy, glyphs[0].x, glyphs[0].y,
-- (XGlyphElt16 *) elts, nelt);
-- break;
-- case 4:
-- XRenderCompositeText32 (dpy, op, src, dst, format,
-- srcx, srcy, glyphs[0].x, glyphs[0].y,
-- (XGlyphElt32 *) elts, nelt);
-- break;
-- }
-+ _XftCompositeText(dpy, op, src, dst, format,
-+ srcx, srcy, glyphs[0].x, glyphs[0].y,
-+ width, elts, nelt);
-
- if (elts != elts_local)
- free (elts);
+--
+GitLab
+