From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/106744 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Gerben Wierda Newsgroups: gmane.comp.tex.context Subject: Bounding box of picture returned by textext() in METAPOST Date: Sat, 4 Apr 2020 22:58:07 +0200 Message-ID: <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="===============3918387849537505506==" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="32531"; mail-complaints-to="usenet@ciao.gmane.io" To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sat Apr 04 22:58:27 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 1jKps3-0008Mz-7n for gctc-ntg-context-518@m.gmane-mx.org; Sat, 04 Apr 2020 22:58:27 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2EA48183071; Sat, 4 Apr 2020 22:58:11 +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 7LUNGNiaJGtL; Sat, 4 Apr 2020 22:58:10 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 3B501183072; Sat, 4 Apr 2020 22:58:10 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 90536183070 for ; Sat, 4 Apr 2020 22:58:09 +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 hxsYiC5-qq7f for ; Sat, 4 Apr 2020 22:58:08 +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 DA84B182E26 for ; Sat, 4 Apr 2020 22:58:08 +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 4C80F36C0D8D for ; Sat, 4 Apr 2020 22:58:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rna.nl; s=dkim_rsa2048; t=1586033888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=nC19zG2Zb5K+1B31iKnJ/YkTtGhmYrFNymth75tSdgw=; b=cx0dExiX3AVD8yJS1m+f7fpRL4fL0J5sijJjc+p+z3oXxAbRG04e1y2GuOywH6LeEo9eLe mqACmHGeSq6AETra7ZBOprnmiUpmJqT8cRvZP1RpJs16EWHqad+ipXEvHOKxy/xlxx7Ftj vcDA6RAzMumkNCZCYAMWXpHgiMr06gV6G5sVsZeWguJOGbGjccgGlAAIeJdxvnnw1QmsDP R7oPhLexFGPt1ROXkFXeAimK0eD7U3C87wBllnQ1MpkelFGVCBVUWGUcAotpalTahhzKZZ Qz8g4DGUNWSBfEIvjEPGowKCRflahX/g1nrBvSXuadKlokFpgEkW4OUOLcZawQ== 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:106744 Archived-At: --===============3918387849537505506== Content-Type: multipart/alternative; boundary="Apple-Mail=_3F8B7BF4-6469-47F5-ADFC-528FBF27D944" --Apple-Mail=_3F8B7BF4-6469-47F5-ADFC-528FBF27D944 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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?=20 G --Apple-Mail=_3F8B7BF4-6469-47F5-ADFC-528FBF27D944 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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


= --Apple-Mail=_3F8B7BF4-6469-47F5-ADFC-528FBF27D944-- --===============3918387849537505506== 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== --===============3918387849537505506==--