I'm trying to overlay glyphs from different fonts, but it's hard to get them to line up. I'm sure they ought to line up better than this. How can I do that?
Graphics[
{Opacity[0.1],
{Text[Style["a", FontFamily -> "Helvetica", 240]],
Text[Style["a", FontFamily -> "Arial", 240]]}
}]
Also, I'm interested in drawing the outline - here I've selected them, but I'd like to draw them.
Edit: Thanks! With your help I was able to achieve most of what I was trying to:
Manipulate[
Graphics[{{{Opacity[opacity],
Text[Style["Greats", Red, FontFamily -> "Helvetica", 180], {0,
0}, {Center, Baseline}]}, {Opacity[1 - opacity],
Text[Style["Greats", Blue, FontFamily -> "Arial", 180], {0,
0}, {Center, Baseline}]}}}], {opacity, 0.1, 1, 0.1}]
By default the text is centered (horizontally and vertically) at a point, and the fonts have characters of different heights, resulting in shifted text. For example compare the following:
Graphics[{Opacity[
0.1], {Text[
Style["agÄ", FontFamily -> "Helvetica", 240,
Background -> RGBColor[0.8, 0, 0, 0.2]]],
Text[Style["agÄ", FontFamily -> "Arial", 240,
Background -> RGBColor[0, 0, 0.8, 0.2]]]}
}]
Graphics[{Opacity[
0.1], {Text[
Style["agA", FontFamily -> "Helvetica", 240,
Background -> RGBColor[0.8, 0, 0, 0.2]]],
Text[Style["agA", FontFamily -> "Arial", 240,
Background -> RGBColor[0, 0, 0.8, 0.2]]]}
}]
If you position the text along an edge, it might work better for you, although it's by no means guaranteed:
Graphics[{Opacity[
0.1], {Text[
Style["a", FontFamily -> "Helvetica", 240], {0, 0}, {Center,
Bottom}],
Text[Style["a", FontFamily -> "Arial", 240], {0, 0}, {Center,
Bottom}]}}]
Edit
Using Baseline
as suggested by Heike:
Graphics[{Opacity[
0.1], {Text[
Style["a", FontFamily -> "Helvetica", 240], {0, 0}, {Center,
Baseline}],
Text[Style["a", FontFamily -> "Arial", 240], {0, 0}, {Center,
Baseline}]}}]
Regarding your first question, welcome to the world of different fonts. They have different metrics and that is just how it is. You could use Overlay
or one of the graphics options like ImagePadding
to shift one over the other.
On your second question, the second "neat example" in the documentation on JoinedCurve
shows how to do this using ExportString
and ImportString
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With