2011-09-13 44 views
8

我爲我的書使用了Constantia字體(與Windows 7一起提供),並且希望在Mathematica中使用相同的字體爲本書準備圖形。問題在於Constantia默認輸出oldstyle digits。我知道,例如在XeTeX中,可以控制是使用oldstyle還是normal數字輸出。是否可以控制Mathematica中的數字樣式?

是否可以控制Mathematica中的數字樣式?

+0

「老式」是什麼意思?你爲什麼不找一個數字更吸引你的字體呢? – DavidC

+0

@David查看我在文中插入的鏈接 –

+0

@Sjoerd謝謝。這有助於澄清事情。 – DavidC

回答

3

對於ticks,有一種解決方法,但它需要一些編程。 首先,有一個輔助功能。

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}} 

然後,這樣的功能:

ConstantiaTicks[a_?VectorQ, opts : OptionsPattern[Style]] := 
[email protected]{a, 
    Style[#, FontFamily -> "Constantia", 
     Sequence @@ {opts}] & /@ (StringJoin /@ 
     Map[ToString[ 
     Style[Which[IntegerQ[#], 
      FromCharacterCode[# + 8320], # === ".", "."]]] &, 
    (getDigits[a]), {2}])} 

產生以下結果: enter image description here

這然後可以在FrameTicksTicks選項一起使用。當然,這意味着指定你的刻度而不是讓Mathematica自動計算出它們的值。這也意味着採用默認的滴答時間長度,除非您想要指定ConstantiaTicks的另一個參數。

9

我覺得這很難。康士坦奇亞是直接使用Mathematica中:

Style["", FontFamily -> "Constantia", FontSize -> 100] 

enter image description here

然而,字體是專門設計來被平衡這種方式。如果您調整大小和使用FontSize和字母的位置AdjustmentBox你得到這樣的:

shift = {0, 0, 0, -1, -1, -1, 0.0, -1, 0.0, -1} 0.5; 
s = 0.65; 
sizeScale = {1, 1, 1, s, s, s, s, s, s, s, s}; 
Row[Table[ 
    AdjustmentBox[ 
    Style[num, FontFamily -> "Constantia", 
    FontSize -> 100 sizeScale[[num + 1]]], 
    BoxBaselineShift -> shift[[num + 1]]], {num, 0, 
    9}] 
] // DisplayForm 

enter image description here

你看到位移和縮放的字母有不同的體重。字體重量可以調整,但只能非常粗略地調整。通常你只有普通和粗體樣式。所以,你可以得到儘可能接近這樣的:

body = {Plain, Plain, Plain, Bold, Bold, Bold, Bold, Bold, Bold, Bold}; 
Row[Table[ 
    AdjustmentBox[ 
    Style[num, FontFamily -> "Constantia" , 
    FontWeight -> body[[num + 1]], 
    FontSize -> 100 sizeScale[[num + 1]]], 
    BoxBaselineShift -> shift[[num + 1]]], {num, 0, 
    9}]] // DisplayForm 

enter image description here

有所好轉,但仍然難看。我認爲一個完整的新信件設計是必要的,爲此工作。也許正常的字母可以在字體表的更遠處找到?


UPDATE

實測值設定的替代號碼。他們位於字體表中的位置8320 - 8329。你應該能夠使用字體工具來切換它們。

Style[FromCharacterCode[Range[8320, 8329]],FontFamily -> "Constantia", FontSize -> 100] 

enter image description here

+1

感謝您的答案,但是,當然,這種方法不適用於軸蜱,因爲它們是由Plot,Plot3D等命令自動生成 – Igor

+0

@Igor請看我的更新 –

+0

謝謝@Sjoerd C. de Vries! – Igor

2

我搶FontForge。較新的版本(我似乎記得)有一個深層隱藏的菜單選項來應用一個映射並將其壓扁爲字體,因此您可以選擇lnum(大寫數字),並輕鬆輸出Constantia版本,已經在Mathematica之外製作了樣式數字。或者,少一點高科技,在Font-forge中,您可以複製並粘貼小寫字母上的襯裏或表格數字。

Font-forge看起來不太好看,但是它有些鬆懈,因爲它實際上非常好,並且對於調整字體非常方便。

作爲替代解決方案,您是否想過將Mathematica中的數據導出到平面文件並使用TikZ將其原生地呈現在XeTeX中?這是我通常使用的方法,輸出確實非常出色。

相關問題