From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu Newsgroups: gmane.emacs.devel Subject: Re: How to walk a Lisp_String? Date: Fri, 02 Sep 2022 16:31:13 +0800 Message-ID: <87bkrykwj2.fsf@yahoo.com> References: <87a67jw1kw.fsf@elite.giraud> <83o7vzqey8.fsf@gnu.org> <83mtbjqemd.fsf@gnu.org> <87ler2963r.fsf@elite.giraud> <875yi6mvlx.fsf@yahoo.com> <875yi68e15.fsf@elite.giraud> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24808"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Manuel Giraud Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 02 10:35:29 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oU29A-0006C0-QG for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Sep 2022 10:35:28 +0200 Original-Received: from localhost ([::1]:52426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oU294-0005WB-QB for ged-emacs-devel@m.gmane-mx.org; Fri, 02 Sep 2022 04:35:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46800) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oU25G-0003ao-I3 for emacs-devel@gnu.org; Fri, 02 Sep 2022 04:31:30 -0400 Original-Received: from sonic312-23.consmr.mail.ne1.yahoo.com ([66.163.191.204]:42551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oU25E-0005mj-N6 for emacs-devel@gnu.org; Fri, 02 Sep 2022 04:31:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1662107482; bh=OTNw07B9ATGBhlQXrSOB3G2QW+9IFVuK1yVXR8C0sdY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=Engm9D70v55Lv9fNiJmcGzXVio0ObZTvAx+lDpbvpWId8H9cxdqR6f70fdLdouwp8Md5q+r/v4g3WJoXf6qE9xFsQIdCVL1QOQGxJlecqB6qwpsHLAhDml1+6dN3A+aYjY/WELOhNRy0w/H2AU4FJd+p3Y9M3IZmsHwOG0rWwTHJIE8eSx+5o4odAlAKGI8ILcX2Kp8SEouKftTU+XiVMkDAv5TliQhoeNV7fuvSN8GNYXCszB6EX0uaneg6RqaQ7baYRdK2av2WjYnevLTBwVw2a0YDzkMt+hhP4lnuaf0nQ75GF6JgLzSqpIGotEWDONFDyFmCUhNruZfm0wAsUw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1662107482; bh=pSxW2dOBd22KsflzJkyhCyBVzd+lXOkn4C6fQf63hUq=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Y3Khib2J8yuG/kzUpjjVfqdr32utOJ2fPCuV2/DFEIczR2jub7z/xM59uzt7tURZnPhQGbHScmgxdbNK38jUbPJPNCn6/rmcbC6TL9+02GvH0qTtAs5LMpmQHr4Qgz2k2mMuyrgE1Ml2bWvqlS/WjfRSBdksyBWONRf85YJQi9sJIE7XMFNsFcYyThGi3Srfc1DEgctjq+uE2aTcBBfsbveSGs71w0J8h/T5JA+K1DI6d2wDztNWu+YH3tsc2NiJMUyGB9IzIbDAQxrAlszMZ9F9y/wTcwI26CLahc/H4SQbgC3h5E2vLY9QS2aQ1TMRYK7oZnFeKhLWMu/Z435JoQ== X-YMail-OSG: PqYr8lYVM1ngeeVpDXt7PXGZDN1_xVfB3v2Oqe63jVFPXSGODmYz2thKP5IgkzO .abkEC90DmDcwueD953U8VreGcRdtqM_eh.Sa16efnhnCiaXTooUAeM69R0BqxJcVsOXvHusfBnS 7mERbsXHL.Em3slTm48B1GfgDmy4Ik80dayM4rGUYQNsbZsRjHzFL.Nk5kYpWdiG5gZK7VqMe9qD Wj_3tYO.Ie2SIc5iBqwGhgn4OaN7al84BmnBoTtuKZZwN8SmWfkwxOc1ugANfW6wMQxKBc4KWRtc EZ3lAeS7HRn8y6HlDWOEdqEDg4W_e4BF7qjlkU94aq7fMRHmRpEMoHFBcfU.AWbiz2VofUCI4b3o 9VFGidzD9U2.129zp1HFqIhWdBR0Ixn1cL2gkPsluxT0TT2IP_zAgz.gk5KtTO4rldKl3hdZFbhU Ew5T3in_US5Z_tkkZkaU_ux83OB_r7C8syd0VzwsU3STc8Yavsg4NhgvMGqF7MC.o._xYXL.i0dr If4dXn77fGV.Rthecc30aNzpPk7wMNzHWtGmcHRrFP9_4cHtWLW55de7CSVYK3TwKsJiEcPxwoHO Cg0qlIhEg9LIaG0G62Le2OTgCoK0MtVrxpogglhu2XTmQzW3FmsY26TFWOULxrgLzH6AHIWkERGb oDhiHjbnsJdiag9PCtuDKx8L0Z8AMa39oWEkgAW_hBxnp3JFg96OZOPDINSfYf.ndHUInbyl3Jhk PWfAI3u_XwJWh5bcdGI87FMIy2.5LfHMo1yfYzkBQm5uZPVFeCv3IqDfn.t8rmmmsoQpCqPw5CtK 24kIeJqPmLMJYrdrTRbwCD9W3JOvKP6OXukDa8kW03 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Fri, 2 Sep 2022 08:31:22 +0000 Original-Received: by hermes--canary-production-sg3-6bb8946c47-nbhdn (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 642c0b71a21adec69e230b30285cfd43; Fri, 02 Sep 2022 08:31:18 +0000 (UTC) In-Reply-To: <875yi68e15.fsf@elite.giraud> (Manuel Giraud's message of "Fri, 02 Sep 2022 08:51:34 +0200") X-Mailer: WebService/1.1.20595 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Received-SPF: pass client-ip=66.163.191.204; envelope-from=luangruo@yahoo.com; helo=sonic312-23.consmr.mail.ne1.yahoo.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:294521 Archived-At: Manuel Giraud writes: > Po Lu writes: > >> Manuel Giraud writes: >> >>> Finally, I'd like to walk this Lisp_String and call FACE_FOR_CHAR for >>> each charater of this frame. And then be able to call XftDrawStringUtf8 >>> (or XmbDrawString) on each substring/font pair. WDYT? >> >> That won't work correctly since glyphs do not correspond to >> characters. >> >> After you obtain the substring containing characters that can be >> displayed with a single font, you should pass it to the font driver's >> `shape' function, and then give the resulting glyphs and offsets to >> XftDrawGlyphs. > > Thanks for those hints. What is a "font driver's `shape' function"? See i.e. xftfont_shape in xftfont.c. > Ok. I've said XftDrawStringUtf8 because this is what is currently used > in lwlib for cairo or xft. That is definitely a bad thing. The Cairo emulation of XftDrawStringUtf8 uses the Cairo toy text API, which is something that the Cairo developers tell you not to use: The functions with text in their name form cairo's toy text API. The toy API takes UTF-8 encoded text and is limited in its functionality to rendering simple left-to-right text with no advanced features. That means for example that most complex scripts like Hebrew, Arabic, and Indic scripts are out of question. No kerning or correct positioning of diacritical marks either. The font selection is pretty limited too and doesn't handle the case that the selected font does not cover the characters in the text. This set of functions are really that, a toy text API, for testing and demonstration purposes. Any serious application should avoid them. The Xft function itself is much worse than the Cairo emulation.