How to create a Text with certain size given in a specified way?
You can convert your Text
to Graphics
and then use any size
Show[ImageCrop@Graphics@Text@Style["Text Text", 80, Bold, FontFamily -> Times],
ImageSize -> 200]
You can change the font size to get a better resolution. With a little modification you can use it inside a canvas in the way you want.
insert[txt_String, col_, pos_List, angle_, size_] := Module[{text},
text = ColorReplace[ImageCrop@Graphics@Text@Style[txt, col, 80, Bold,
FontFamily -> Times], White];
Inset[text, pos, {0,0}, size, {Cos[angle], Sin[angle]}]]
Graphics[{
insert["Text Text", Red, {100, 100}, 0, 300],
insert["Text Text", Blue, {300, 100}, Pi/2, 200],
insert["Text Text", Green, {100, 100}, Pi/4, 300]},
PlotRange -> {{0, 400}, {0, 400}}, GridLines -> Automatic,
Frame -> True, ImageSize -> 400]
With proper control over size and position. pos
is the coordinate of your bottom left corner of the text.
You can convert text to FilledCurve
graphics primitives by converting via PDF. See here for example.
In the example below I get the bounding box of the resulting graphics using PlotRange
, then use Scale
and Translate
to size and position the text as required.
t = Style["Text Text", FontFamily -> "Times New Roman", 60];
g = ImportString[ExportString[t, "PDF"]][[1, 1]];
{{a, b}, {c, d}} = PlotRange @ Graphics[g, PlotRange -> All, PlotRangePadding -> None]
(* {{1.29598, 168.789}, {9.56801, 38.5115}} *)
Graphics[
Translate[Scale[g, 5/(b - a), {a, d}], {2, 3} - {a, d}],
PlotRange -> All, PlotRangePadding -> None, Frame -> True]