From: Gerben Wierda <gerben.wierda@rna.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Bounding box of picture returned by textext() in METAPOST
Date: Sat, 4 Apr 2020 22:58:07 +0200 [thread overview]
Message-ID: <310B3D8E-5C62-481F-8FAC-EA9625AAD94B@rna.nl> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 2104 bytes --]
I have this METAPOST macro:
vardef makeTeXLabel( expr w, h, name) =
if debugProgram or debugLabels: show "NAME makeTeXLabel:", name, tostring 0.8w, tostring 0.8h; fi
save p; picture p;
p := textext( "\startframedtext[middle]" &
"[align=middle,frame=on" &
",width=" & tostring 0.8w & "bp" &
",height=" & tostring 0.8h & "bp]" &
name & "\stopframedtext");
save b; path b; b := boundingbox p;
save dim; pair dim;
dim := (urcorner b) - (llcorner b);
save width, height; numeric width, height;
width := xpart dim;
height = 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:= p xyscaled (0.8w/width,0.8w/width);
else:
if debugLabels: show "YSCALING:", (0.8h/height,0.8h/height); fi
p:= p xyscaled (0.8h/height,0.8h/height);
fi
fi
p
enddef;
It gets called with w=133 and h=53 (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=middle,frame=on,width=106.40000000000001bp,height=42.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’m asking for a box that is 106bp wide.
What happens here? And how do I get it right?
G
[-- Attachment #1.2: Type: text/html, Size: 5853 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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
___________________________________________________________________________________
next reply other threads:[~2020-04-04 20:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-04 20:58 Gerben Wierda [this message]
2020-04-05 16:04 ` Gerben Wierda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=310B3D8E-5C62-481F-8FAC-EA9625AAD94B@rna.nl \
--to=gerben.wierda@rna.nl \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).