I use the Constantia font (that came with Windows 7) for my book and would like to prepare graphics for this book using the same font in Mathematica. Problem is that that Constantia by default outputs oldstyle digits. I know that, e.g. in XeTeX, it is possible to control whether oldstyle or normal digits are used for output.
Is it possible to control style of digits in Mathematica?
For ticks, there is a workaround, but it requires a bit of programming. First, there is an auxiliary function.
getDigits[n_Integer] := IntegerDigits[n]
getDigits[0.] := {0}
getDigits[n_Real] :=
With[{rd = RealDigits[n]},
Join[Take[rd[[1]], rd[[2]]], {"."},
Drop[rd[[1]], rd[[2]]] ] /. {".", z___} -> {0, ".", z} /. {a__,
0 ..} -> {a} /. {a__, Repeated[0, {4, 150}], q__} -> {a} /.
{b__, "."} -> {b}]
Attributes[getDigits] = Listable
getDigits[{14.3, 2, 274, 2345.67}]
{{1, 4, ".", 3}, {2}, {2, 7, 4}, {2, 3, 4, 5, ".", 6, 7}}
Then, a function like this:
ConstantiaTicks[a_?VectorQ, opts : OptionsPattern[Style]] :=
Transpose@{a,
Style[#, FontFamily -> "Constantia",
Sequence @@ {opts}] & /@ (StringJoin /@
Map[ToString[
Style[Which[IntegerQ[#],
FromCharacterCode[# + 8320], # === ".", "."]]] &,
(getDigits[a]), {2}])}
Yields the following result:
This can then be used in a FrameTicks
or Ticks
option. Of course it does mean specifying your ticks rather than letting Mathematica work out their values automatically. It also means taking the default tick length unless you want to have another argument to ConstantiaTicks
that specifies that.