From fdecfca9f41504f617900c93a90ceeef24e72a3c Mon Sep 17 00:00:00 2001 From: ZachNagengast Date: Mon, 6 Nov 2023 21:11:28 -0800 Subject: [PATCH] Update gray glyph blending logic and tests --- Tests/images/bitmap_font_stroke_basic.png | Bin 2676 -> 2733 bytes Tests/images/bitmap_font_stroke_raqm.png | Bin 2655 -> 2732 bytes Tests/images/default_font_freetype.png | Bin 3671 -> 3686 bytes src/_imagingft.c | 25 ++++++++++++++-------- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Tests/images/bitmap_font_stroke_basic.png b/Tests/images/bitmap_font_stroke_basic.png index 86b2d09f66e4a0b385c7e53210df882e1d4409a9..26aa3ab8ee74539d41b8f389f818c92fe7c01a74 100644 GIT binary patch delta 2725 zcmV;W3R?B_6s;AIB!6^CL_t(|ob8%@P}Nl$$3OR8xZuT$@*>E~B@}@`MwoE3Q3DBl zL#oYQq*ZrF=cc`EY-VP)t&X@^E~G~=Q+>sXAltvF@JDjywm~=;^Jb^zylnE z1|HxTH1Gh2Zs3*{ii!vc!C-JHCKJ)oTzMtSmQi2d+wSO5CQQI+#9+W;VZj1=dM?QX zE-t*O#kp84*zNpkV^vXDzFfdhF`4Ayho!q)M5LmkZ|#;XQeQ9m`C>2#h{Ym{7D-Q! z{9hvwwWzXf+keH9Avmq-2A(@tV6L0_jSvGx@FH}nncR7&h)8j?F zJ9fCR)qmBIo2!ke*rrY;DT%N!5)&yaW7DReCo&2TXW>F-&eZ-kG_ZU*`T4}eU^bJG zz|^U%SwnlfXW1+k;^HVP!)7BajM!L;ig^BcIy(XGxyP4Qb8@Jy^&_6NK1=0qp~vp zJx`u2&CR|}FmGz{h@Kw#^Pk0R_B__ek-cYUAhPA;$m_5B*Xq=%L7l+>1_NLKAOb=F zi-piopacw{`)mFR22ktG4hFqkt~2C;0X9KB%!echgB17!e5Y0$tcQs(93o&MYzNMq zp?|cLW5-y(p6%Pu!E106WWi7v3OR5;oCNmlp{R(C4$zJ+$B2huo<3qS*x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`tMomotzv2ldQA9SwxP_Nk zj?7GJ)|~f;#mdSaX*Hhk=;qm!^761{O9&~B?1T`uZw~_pcB`wGUk)LJ-~Kjb?rr+? zPMR!U+^xul%r7C0LQ+ph+hZr}`j$|F<*ugsHV%<7(=U!~F{?h0>7v0OzXW(9r z-fQ5}Qi)Icalia&Jr{RD(R&U2zym5O;{WsVELq~Z>n^H57YDsJ$m#=n^9t?*`V8Fb Z@qchD$`a#>j0*q&002ovPDHLkV1ntzSsnlY diff --git a/Tests/images/bitmap_font_stroke_raqm.png b/Tests/images/bitmap_font_stroke_raqm.png index 08029ce34beb40cacdb4a131257e709d42f6ec4a..be273d7cb6b5f7dff391fba138877cf2a161f1a0 100644 GIT binary patch delta 2724 zcmV;V3S0Hx6s#4HB!6>BL_t(|ob8%>Y}8d2$3HXE&Xg%r=!2F%rWS$LmWDQ#6$41A zEw55v_@FMZsgMzTtX)wNbrk|`h%sscD86V+SQpgD$}Ue`5lkT(+|?=tElROiUR^}m z(rRsc_K*AfO=mjuo0(D(x9K-Go&L@}_ug~Qx%b?2&+lgv5r6v8cVWKN0`%kJqTj%M z9Q_9Fh6V}>2n)kx@+uY!F)>_q6^j>BQ`6P%=uyUw#cal8!ft2YJUTls z$pkJgjMU;;>~>r(ezUQvC@fhb5TsZv^4Me2(IFyIR@S|C^Jb~3k-R)HnFPdcmjw%? zvs3=B5sF$=*?+qAq6pAymFfnbJzHS5kNM3I3kC2pw5yrieYc26VWB`F0IL;!^=c_C z?LO_DJAdgJ|GF?xizn8qnXX-XQ3U9Ps-o1@h3H87;UB$LsUHJR^;j=0Z~$BY?12@EV}H#WjrFUqy8iZcOf_)M3srS$ z>ZKLW2tju602l=?LoooaE9wUy(B2OG3k2>}#2q`>ySICLmrIL8va{K=iJTnm(PqQp zV9FGdlZl96*f4Imfh}7Qp{9n#iy1wd=x8D%$h{0^mM^EMh@>Q}Rt64a z_;BXTVSoE}FShFHt`Qa6_QA7mu=QDjeKy58cmXMc6Y%EqQ ziHS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Sx$VJ1RpqgykcfyogMd=GR)3oB-5$P-xT4j4wHH=eFXJBmd%XYDO04PxyIxJ@kGK zh#+XVGCx0G-U@eGN$EppXK7VcN}xW5_tLENhFTWSR@o?u9U~8Nxp*B8$5AL0KR+1r zP6wNf8jW0MyZlj5m(UYRN09-%ym*j?OH33L6g+7VmRuMR80bSeX@t?$)%^;@4~`^W zsgnVKlQny)yv>(l1u=Js|BO@up^dA;0`U}a^s zvp}eY=;(-wh(wltN9o-ZjTWV8z^+`O^By4u}wqwC|x6gc3-^%iH?SGh324*+ih#sXx3tgI}6_9QF{mBvVyX)?t5LAbx+ zG=_j|Ss-5DeGLUi9J~Z*!u%VvP;r9=V&Lflu1DxR5{Avo0<|NJ18l9B?X zB-B>Cpy>AzQCTha+}xXxsiZM5{MnOnV7N$Y`q+4t${O}XM0Z(bgkGHmy|>%k+j98W@kSxA)KB4bmdA*O6EcvXnsf)a>Viv zGMNk@WPa#(o6C%*3}|T8CLn#l;7m^YL;tq`+v8P;85ntCiL zYOeSZ(yl~;Q(s>X=zywf3V%XNuENiyY9qNqW%EGq2~%a=s>Wo!Kb19xv^=+W_~QVm z*~`n7SCOZUEslTIkZf=jZB^-XBDIqV<&D(oYF?Rbr z1Y(CkJj>4Ra$M(f)wHw}Gj*C6dRGg|^srSi- zxVf$Cy8mri_w3njFKs4177-Ww9Qf*+Hy78n)zt~W|BlwcqkH%71Lgmjo?iZlYocZi z&W+=|lMgoBwbNHKJ$o-SbPcmpfBPecV=2JF z`43ebJ$lrmC6b2HE7A}31z5@S+~$a+Qtz?4pU@lbG-&QUwSoOVAp*GPA!EYCahrYP Tym#E;-;Z1~wT9QgyyE{2EyFDh diff --git a/src/_imagingft.c b/src/_imagingft.c index 966ee0267..7c6be58bb 100644 --- a/src/_imagingft.c +++ b/src/_imagingft.c @@ -1092,19 +1092,26 @@ font_render(FontObject *self, PyObject *args) { if (color) { unsigned char *ink = (unsigned char *)&foreground_ink; for (k = x0; k < x1; k++) { - v = source[k] * convert_scale; - if (target[k * 4 + 3] < v) { - target[k * 4 + 0] = ink[0]; - target[k * 4 + 1] = ink[1]; - target[k * 4 + 2] = ink[2]; - target[k * 4 + 3] = v; + int src_alpha = source[k] * convert_scale; + if (src_alpha > 0) { + if (target[k * 4 + 3] > 0) { + target[k * 4 + 0] = BLEND(src_alpha, target[k * 4 + 0], ink[0], tmp); + target[k * 4 + 1] = BLEND(src_alpha, target[k * 4 + 1], ink[1], tmp); + target[k * 4 + 2] = BLEND(src_alpha, target[k * 4 + 2], ink[2], tmp); + target[k * 4 + 3] = CLIP8(src_alpha + MULDIV255(target[k * 4 + 3], (255 - src_alpha), tmp)); + } else { + target[k * 4 + 0] = ink[0]; + target[k * 4 + 1] = ink[1]; + target[k * 4 + 2] = ink[2]; + target[k * 4 + 3] = src_alpha; + } } } } else { for (k = x0; k < x1; k++) { - v = source[k] * convert_scale; - if (target[k] < v) { - target[k] = v; + int src_alpha = source[k] * convert_scale; + if (src_alpha > 0) { + target[k] = target[k] > 0 ? CLIP8(src_alpha + MULDIV255(target[k], (255 - src_alpha), tmp)) : src_alpha; } } }