如何使文本适合具有特定宽度的 MetaFun 框?
现在我有
\startuseMPgraphic{MPBoxFrame}
% Useful values
numeric w, h, o, b ;
w := 4.5cm ; h := OverlayHeight ; o := BodyFontSize ;
b := 1pt ; % border size
drawoptions (withpen pencircle scaled b withcolor blue) ;
draw (0,h)--(0,0)--(w,0)--(w,h)--(0,h) ;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\defineoverlay[MPBoxFrame][\useMPgraphic{MPBoxFrame}]
\defineframedtext[BoxFramedText][frame=off,
background=MPBoxFrame,
offset=\bodyfontsize,
width=\textwidth]
\definestartstop[SpecificWidthBox][alternative=empty,
before=\startBoxFramedText,
after=\stopBoxFramedText]
\starttext
\startSpecificWidthBox
This is a looooooooong text that I need to fit in the box.
\stopSpecificWidthBox
\stoptext
生产:
答案1
答案2
根据记录,正如@Dave Jarvis 提到的,框架可以完成这项工作。
\startuseMPgraphic{MPBox}
draw OverlayBox
withpen pencircle scaled OverlayLineWidth
withcolor OverlayLineColor;
setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic
\defineoverlay[MPBoxOverlay][\useMPgraphic{MPBox}]
\defineframedtext[MPBoxFramed]
[
frame=off,
background=MPBoxOverlay,
offset=\bodyfontsize,
framecolor=red,
rulethickness=0.5pt,
width=100mm,
]
\starttext
\startMPBoxFramed
\input knuth
\stopMPBoxFramed
\stoptext