From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/115129 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Nedeljkovic via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Changing font and font size inside textex Date: Tue, 31 May 2022 15:18:28 +0200 Message-ID: References: <043d95df-7e79-80b2-476b-4ae17b0febef@telus.net> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2819718490300937418==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7896"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Nedeljkovic , mailing list for ConTeXt users To: Max Chernoff Original-X-From: ntg-context-bounces@ntg.nl Tue May 31 15:19:32 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nw1mU-0001jh-LZ for gctc-ntg-context-518@m.gmane-mx.org; Tue, 31 May 2022 15:19:30 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 746A728A1CA; Tue, 31 May 2022 15:18:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B50psk0nI0kn; Tue, 31 May 2022 15:18:45 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id C417228A1CF; Tue, 31 May 2022 15:18:45 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id C530028A1C9 for ; Tue, 31 May 2022 15:18:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kNtaxckbQth2 for ; Tue, 31 May 2022 15:18:41 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.222.176; helo=mail-qk1-f176.google.com; envelope-from=tsar.srb@gmail.com; receiver= Original-Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id C480C28A18B for ; Tue, 31 May 2022 15:18:41 +0200 (CEST) Original-Received: by mail-qk1-f176.google.com with SMTP id 190so13064035qkj.8 for ; Tue, 31 May 2022 06:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cWe0fCMNHCWknOxRiMgmG8nzD/PuVqgdYMgL6bfuxkY=; b=cMq98iXBxWsBPu8b0SIXyLhfpXssn0dH0Qb64sZbVoJAmSaSIk3Hj/76hzPk+UHYWl nUKcPsZF98v6/+qzL4HAFmpNUGZUkIkpbD/Sf0ao2HakhZS4ciwlgD94+qB14inzgFwg Nt76wsWWHKhE2p6rmTBWLuNCQp7vW3xZL7kUdngSwr5eAp2D6Oe4AKAws+00OETEinqK HJdiewccHC/e9MVoSe2QIiiz/KjOiJ+ezqdesPcVLj8Ee/h2+BdtH0eClqeJoulpqjht h2z5uPOJSdfXp84RbQ2AjnBlkaz/bUfGRZAf1iJcKbqdv5+QbNH4eBWTugWl2A1JduGa ACqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cWe0fCMNHCWknOxRiMgmG8nzD/PuVqgdYMgL6bfuxkY=; b=OR5VhleN1wcwEFcmNKojeiR3yWmLRp+bUtH0Yi309io1LvuEZft7R71eRJVCz2Nr6i RyUKJnOADoVZYHnIJZpfskFEvVME/XSnu7GXnyP5WljBFHElE8Vce+jYdEwfEdxoqe5U zOS6GDRrrT2GKj/8iAs10pa9XRARp83YJGgOZjF1dqZfn96q1pZEHHem0Gpg3K80vAGq min2n0u/aZdpG+nfzyD5z5oaFbN29RnEytEVXyvenmmYObW8A1geoS7jVtV0TbI3x4tA 3y54ZZIOHVgpeeVbIqeqi72VQ/UseRjC3H2leA23c31QksjsMPFO9tL1aaF9DPznCgAK 3HxA== X-Gm-Message-State: AOAM5317ZiAZajO7WcF5v/6vUtadyYPfLdd9evyN9AWZQ1pU151xYrlK T2LjI02ZEOI7nikWsTNIxOL3N/jrs9FpX6LkKL8= X-Google-Smtp-Source: ABdhPJxtqxs/E9mxnyQtRQIcY/aaWrq7vo++eZSPMBQ/cPCpCljw2ThNf8pveEkkRQMqVdZ7SStzem8XXtu/A5E09D4= X-Received: by 2002:a05:620a:2699:b0:47d:753c:b8ff with SMTP id c25-20020a05620a269900b0047d753cb8ffmr41323715qkp.763.1654003119358; Tue, 31 May 2022 06:18:39 -0700 (PDT) In-Reply-To: <043d95df-7e79-80b2-476b-4ae17b0febef@telus.net> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:115129 Archived-At: --===============2819718490300937418== Content-Type: multipart/alternative; boundary="00000000000063062305e04e9c71" --00000000000063062305e04e9c71 Content-Type: text/plain; charset="UTF-8" Thank you, I'll try that later. On Tue, May 31, 2022 at 9:42 AM Max Chernoff wrote: > > Thanks Max that works perfectly! But It would still be useful if I could > > change families inside a MPpage. > > Sure, but you'll need to store the x-heights first: > > \starttexdefinition storexheight [#1] > % Placing the first use of \switchtobodyfont inside a group messes > % with the definitions, so we need to reset the font family > manually. > \edef\oldfontclass{\fontclass} > > \switchtobodyfont[#1] > \expandafter\newcount\csname #1_xheight\endcsname > \global\csname #1_xheight\endcsname=\numexpr 100 * > \number\dimexpr1em\relax / \number\dimexpr1ex\relax \relax > > \switchtobodyfont[\oldfontclass] > \stoptexdefinition > > \starttexdefinition setxheight [#1][#2] > % Combining these two lines into one sometimes fails. No idea why. > \switchtobodyfont[#1] > \switchtobodyfont[\the\dimexpr#2 * \csname #1_xheight\endcsname / > 100 \relax] > \stoptexdefinition > > \storexheight[adventor] > \storexheight[pagella] > \storexheight[heros] > > \starttext > \startMPpage > draw textext.origin("\setxheight[adventor][1cm]Hello!"); > > draw (0, 1cm) -- (6cm, 1cm); > \stopMPpage > > \startMPpage > draw textext.origin("\setxheight[pagella][1cm]Hello!"); > > draw (0, 1cm) -- (6cm, 1cm); > \stopMPpage > > \startMPpage > draw textext.origin("\setxheight[heros][6pt]Hello!"); > draw textext.origin("\setxheight[heros][24pt]Hello!"); > > draw (0, 6pt) -- (6cm, 6pt); > draw (0, 24pt) -- (6cm, 24pt); > \stopMPpage > \stoptext > > It's pretty ugly code, but it seems to work alright. > > -- Max > > --00000000000063062305e04e9c71 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you, I'll try that later.

On Tue, May 31, 2022 at= 9:42 AM Max Chernoff <mseven@telus.= net> wrote:
> Thanks Max that works perfectly! But It would still be useful if I = could
> change families inside a MPpage.

Sure, but you'll need to store the x-heights first:

=C2=A0 =C2=A0 =C2=A0\starttexdefinition storexheight [#1]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0% Placing the first use of \switchtobodyf= ont inside a group messes
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0% with the definitions, so we need to res= et the font family manually.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\edef\oldfontclass{\fontclass}

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\switchtobodyfont[#1]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\expandafter\newcount\csname #1_xheight\e= ndcsname
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\global\csname #1_xheight\endcsname=3D\nu= mexpr 100 * \number\dimexpr1em\relax / \number\dimexpr1ex\relax \relax

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\switchtobodyfont[\oldfontclass]
=C2=A0 =C2=A0 =C2=A0\stoptexdefinition

=C2=A0 =C2=A0 =C2=A0\starttexdefinition setxheight [#1][#2]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0% Combining these two lines into one some= times fails. No idea why.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\switchtobodyfont[#1]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\switchtobodyfont[\the\dimexpr#2 * \csnam= e #1_xheight\endcsname / 100 \relax]
=C2=A0 =C2=A0 =C2=A0\stoptexdefinition

=C2=A0 =C2=A0 =C2=A0\storexheight[adventor]
=C2=A0 =C2=A0 =C2=A0\storexheight[pagella]
=C2=A0 =C2=A0 =C2=A0\storexheight[heros]

=C2=A0 =C2=A0 =C2=A0\starttext
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\startMPpage
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw textext.origin("\= setxheight[adventor][1cm]Hello!");

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw (0, 1cm) -- (6cm, 1cm)= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\stopMPpage

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\startMPpage
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw textext.origin("\= setxheight[pagella][1cm]Hello!");

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw (0, 1cm) -- (6cm, 1cm)= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\stopMPpage

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\startMPpage
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw textext.origin("\= setxheight[heros][6pt]Hello!");
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw textext.origin("\= setxheight[heros][24pt]Hello!");

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw (0, 6pt) -- (6cm, 6pt)= ;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0draw (0, 24pt) -- (6cm, 24p= t);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0\stopMPpage
=C2=A0 =C2=A0 =C2=A0\stoptext

It's pretty ugly code, but it seems to work alright.

-- Max

--00000000000063062305e04e9c71-- --===============2819718490300937418== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2819718490300937418==--