From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106764 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Re: Bounding box of picture returned by textext() in METAPOST Date: Sun, 5 Apr 2020 18:04:17 +0200 Message-ID: <7AFEBA8A-C9CA-4873-8046-45EEFA37146B@rna.nl> References: <310B3D8E-5C62-481F-8FAC-EA9625AAD94B@rna.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="===============2844099652200009858==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="91262"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Apr 05 18:07:04 2020 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 1jL7nc-000Ng2-IF for gctc-ntg-context-518@m.gmane-mx.org; Sun, 05 Apr 2020 18:07:04 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id F130E182B05; Sun, 5 Apr 2020 18:04:23 +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 kEbzaqVJBJa0; Sun, 5 Apr 2020 18:04:23 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0488E1830AB; Sun, 5 Apr 2020 18:04:23 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 1184F1830B3 for ; Sun, 5 Apr 2020 18:04:22 +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 AAXysz9YMQI9 for ; Sun, 5 Apr 2020 18:04:21 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=213.125.118.53; helo=mail.rna.nl; envelope-from=gerben.wierda@rna.nl; receiver= Original-Received: from mail.rna.nl (mail.rna.nl [213.125.118.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 2043F1830AB for ; Sun, 5 Apr 2020 18:04:21 +0200 (CEST) Original-Received: from hermione.rna.nl (hermione.rna.nl [192.168.2.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.rna.nl (Postfix) with ESMTPSA id 01FA93CDFF14 for ; Sun, 5 Apr 2020 18:04:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586102658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iDG9Prvophm/aUGuTTdUnoIlz34OpXwPzAhrL4Z1ZJc=; b=HcHX0YkaVbbIXRqGFh+YLKs2V0b9I2HPvlVbpIZGQfU8NGzE/IqnKvW5/I/4r+aD0bC2vl 3z+2l1luRT9VFxOWIv+im0L3im8UBpRBUH3LZG3gm/gKPoq21P5cBlvgYqFd9KT0JCIT01 GS/fnHDFR2WZrrpgEYFoItgx0khuXMANSyRILzEqx0+sSEkuSoPOIQjhTXyC6jBoA8S4oz 0MXg6uy2uykjXwL4j2phCTF4Kq999vBTqvhcfeGUkwyhjd3hf4p4OltQa/AK+/AGxrvacw Bw5oVKPM/oPzu7/wxBs2/2Hy5QRB840rRIuk7Z9g0xh1UAaArWp7wL1fsuetMg== In-Reply-To: <310B3D8E-5C62-481F-8FAC-EA9625AAD94B@rna.nl> X-Mailer: Apple Mail (2.3445.104.14) 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:106764 Archived-At: --===============2844099652200009858== Content-Type: multipart/alternative; boundary="Apple-Mail=_A8DE5180-995D-451D-A125-AC835400BCC2" --Apple-Mail=_A8DE5180-995D-451D-A125-AC835400BCC2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Nobody? > On 4 Apr 2020, at 22:58, Gerben Wierda wrote: >=20 > I have this METAPOST macro: >=20 > vardef makeTeXLabel( expr w, h, name) =3D > if debugProgram or debugLabels: show "NAME makeTeXLabel:", name, = tostring 0.8w, tostring 0.8h; fi > save p; picture p; > p :=3D textext( "\startframedtext[middle]" & > "[align=3Dmiddle,frame=3Don" & > ",width=3D" & tostring 0.8w & "bp" & > ",height=3D" & tostring 0.8h & "bp]" & > name & "\stopframedtext"); > save b; path b; b :=3D boundingbox p; > save dim; pair dim; > dim :=3D (urcorner b) - (llcorner b); > save width, height; numeric width, height; > width :=3D xpart dim; > height =3D ypart dim; > if debugLabels: show "PLACE:", w, h, width, height; fi > if (width > 0.8w) or (height > 0.8h): > if (width > height): > if debugLabels: show "XSCALING:", (0.8w/width,0.8w/width); fi > p:=3D p xyscaled (0.8w/width,0.8w/width); > else: > if debugLabels: show "YSCALING:", (0.8h/height,0.8h/height); fi > p:=3D p xyscaled (0.8h/height,0.8h/height); > fi > fi > p > enddef; >=20 > It gets called with w=3D133 and h=3D53 (I am working in METAPOST = native units, so bp) >=20 > So, the textext() command gets something like 106bp x 42bp, which = seems to be the case: >=20 > metapost log > >> "NAME makeTeXLabel:" > metapost log > >> "My 'Application' Function" > metapost log > >> "106.40000000000001" > cld > tex > w : - : \MPLIBsetNtextX{1}{\startframedtext = [middle][align=3Dmiddle,frame=3Don,width=3D106.40000000000001bp,height=3D4= 2.400000000000006bp]My 'Application' Function\stopframedtext } > cld > tex > F : - : \startblankhandling > cld > tex > w : - : \setblankcategory{6} > cld > tex > F : - : \flushblankhandling > cld > tex > F : - : \stopblankhandling > metapost log > >> "42.400000000000006" > metapost log > >> "PLACE:" > metapost log > >> 133 > metapost log > >> 53 > metapost log > >> 511.08659908200002 > metapost log > >> 42.399990514000002 >=20 > But the bounding box is 511bp wide (something like 7in or 18cm, = probably textwidth) but I=E2=80=99m asking for a box that is 106bp wide. >=20 > What happens here? And how do I get it right?=20 >=20 > G >=20 >=20 > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > maillist : ntg-context@ntg.nl / = http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > = __________________________________________________________________________= _________ --Apple-Mail=_A8DE5180-995D-451D-A125-AC835400BCC2 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Nobody?

On 4 Apr 2020, at 22:58, Gerben = Wierda <gerben.wierda@rna.nl> wrote:

I have this METAPOST = macro:

vardef makeTeXLabel( expr w, h, name) = =3D
  if = debugProgram or debugLabels: show "NAME makeTeXLabel:", name, tostring = 0.8w, tostring 0.8h; fi
  save p; picture p;
  p :=3D textext( = "\startframedtext[middle]" &
    = "[align=3Dmiddle,frame=3Don" &
    ",width=3D"= & tostring 0.8w & "bp" &
    = ",height=3D" & tostring 0.8h & "bp]" &
  =   name & "\stopframedtext");
  save b; path b; b :=3D = boundingbox p;
  save dim; pair = dim;
  dim :=3D = (urcorner b) - (llcorner b);
  save width, height; numeric width, = height;
  width = :=3D xpart dim;
  height = =3D ypart dim;
  if = debugLabels: show "PLACE:", w, h, width, height; = fi
  if = (width > 0.8w) or (height > 0.8h):
    if (width > = height):
    =   if debugLabels: show "XSCALING:", (0.8w/width,0.8w/width); = fi
    =   p:=3D p xyscaled (0.8w/width,0.8w/width);
    else:
      if debugLabels: show = "YSCALING:", (0.8h/height,0.8h/height); fi
      p:=3D p xyscaled = (0.8h/height,0.8h/height);
    fi
  fi
  p
enddef;

It gets called with w=3D133 and h=3D53 = (I am working in METAPOST native units, so bp)

So, the textext() command gets = something like 106bp x 42bp, which seems to be the case:

metapost log    > >> = "NAME makeTeXLabel:"
metapost log    > = >> "My 'Application' Function"
metapost log  =   > >> "106.40000000000001"
cld             > = tex > w : - : \MPLIBsetNtextX{1}{\startframedtext = [middle][align=3Dmiddle,frame=3Don,width=3D106.40000000000001bp,height=3D4= 2.400000000000006bp]My 'Application' Function\stopframedtext }
cld             > = tex > F : - : \startblankhandling
cld   =           > tex > w : - : = \setblankcategory{6}
cld         =     > tex > F : - : \flushblankhandling
cld             > = tex > F : - : \stopblankhandling
metapost log  =   > >> "42.400000000000006"
metapost = log    > >> "PLACE:"
metapost = log    > >> 133
metapost log  =   > >> 53
metapost log  =   > >> 511.08659908200002
metapost = log    > >> 42.399990514000002

But the = bounding box is 511bp wide (something like 7in or 18cm, probably = textwidth) but I=E2=80=99m asking for a box that is 106bp = wide.

What = happens here? And how do I get it right? 

G


___________________________________________________= ________________________________
If your question is of = interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : = https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
_______________________________________________________________= ____________________

= --Apple-Mail=_A8DE5180-995D-451D-A125-AC835400BCC2-- --===============2844099652200009858== 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== --===============2844099652200009858==--