0
$\begingroup$

Does anyone know how to combine the FontWeight option with Text[] items in Mathematica? It works fine with Style[], according the documentation. However when I feed this to Text[] (to then feed into the Graphics[] function), the weighting disappears and only assumes one of two weights.

Thanks in advance

$\endgroup$
1
$\begingroup$

You have to do something like

Text[Style["some text", FontWeight -> weight]]

See this example from the documentation of Text:

Graphics[{Text[Style["ABCDEF", Large, Bold, Red], {0, 0}, 
   Automatic, {2, 1}], Circle[]}]

which produces Bold text using FontWeight

The documentation of Bold says:

Bold is effectively equivalent to FontWeight->Bold

Edit This might indeed be a bug. Even if the system supports multiple font weights, in Graphics there really only seem two to be available.

weights = {"Thin", "Light", "Plain", "Medium", "SemiBold", "Heavy", "Black", "Fat"};

Row@Table[Style["A", Large, FontWeight -> w], {w, weights}]

enter image description here

Row@Table[ImageCrop@Graphics[#]&@Text@Style["A", Large, FontWeight->w], {w,weights}]

enter image description here

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ that doesn't work though. If you try to feed "Heavy", "Black", or "Fat", these are all identical to entering a Fontweight-> "Bold", as I could have elaborated a bit more on in the original question. I need heavier weights, but thank you anyways $\endgroup$ – Wai-Ga D Ho Jun 18 at 20:53
  • 2
    $\begingroup$ @Wai-GaDHo From the docs: "Standard settings are Plain and Bold. For some fonts and on some computer systems, additional settings are supported, such as [...] "Heavy", "Black", and "Fat"". You are probably trying to use a font combination that does not support those attributes. $\endgroup$ – MarcoB Jun 18 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.