English 中文(简体)
如何从方案上获得有关数学体选的信息
原标题:How to programmatically obtain information about font selection in Mathematica

如果我对<代码>SystemDialogInput[“Color”]进行评价,并选择彩色,请说红色的话,产出单位将RGBColor[1,00]

查看前小组,I可评价<代码>FrontEnd TokenExecute[“FontPanel”]。 如果我有某些案文强调,我可以改变从<代码>上登出的系统小组中突出案文(或细胞)的字句。 FrontEnd TokenExecute。 我所想知道的是,是否有办法在方案上归还所选择的字体环境,这种环境类似于<代码>SystemDialogInput[“Color”]? 例如,评价一些守则,其中包括在系统老板小组内选择假体环境,请说在老板小组中人工选择12字体,

“enterography

例如:

{FontFamily->"Arial",FontSize->12,FontWeight->Bold}

就在这一点上,我们重申,我谈论这样做,而没有在说明书中强调任何内容或内容。 其中一个问题似乎是——至少是——如果你在笔记中强调了一些内容,就只能选择字体。 文件中有一些例子(ref/CurrentValue):

Style["xxxx", FontFamily :> CurrentValue["ControlsFontFamily"], 
 FontSize :> CurrentValue["ControlsFontSize"]]

这表明,如果存在关于<代码>CurrentValue的适当论点,但“ControlsFontFamily”和“PanelFontFamily”并非本案的正确论点,则可以做出答复。

Also is it possible to programmatically list all fonts available on a particular computer?

<><>Edit>/strong>

@kguler对我的最后一句和问题第二部分作了答复——这可用于建立我自己的老板小组。 我在MacOS X10.6.8和Mma8.0.4上操作了“Heike”的代码,并照此办理。 注<代码>PropertyValue with ref/PropertyValue

enter image description here enter image description here

最佳回答

I think the example under Generalizations & Extentions on the help page for "FontChooser" in the documentation center does what you want. The code for that example is

Needs["GUIKit`"]

GUIRunModal[
 Widget["Panel", {
   Widget["FontChooser", {
     "showLogicalFonts" -> False,
     PropertyValue[{"chooser", "selectionModel"}, 
      Name -> "fontSelectionModel"], 
     BindEvent[{"fontSelectionModel", "change"},
      Script[updateFont[]]]
     }, Name -> "chooser"],
   Widget["TextField", {"text" -> ""}, Name -> "myTextField"],
   Script[
    fontExpr = {};
    updateFont[] := Module[{newFont},
      newFont = 
       PropertyValue[{"fontSelectionModel", "selectedFont"}];
      fontExpr = {
        FontFamily -> PropertyValue[{newFont, "family"}],
         FontSize -> PropertyValue[{newFont, "size"}], 
        FontWeight -> 
         If[PropertyValue[{newFont, "bold"}], "Bold", "Plain"], 
        FontSlant -> 
         If[PropertyValue[{newFont, "italic"}], "Italic", "Plain"]
        };
      SetPropertyValue[{"myTextField", "text"}, ToString[fontExpr]];
        ];
      ],
   BindEvent["endModal", Script[ fontExpr]]
   }]
 ] 
问题回答

很久以前,我就在MathGroup找到了(但现在我无法在那里找到确切的联系)。

fontlist = FE`Evaluate[FEPrivate`GetPopupList["MenuListFonts"]]

fontlist /. Rule[x_, y_] -> Style[x, 20, FontFamily -> y]

“Mma

EDIT:来文方是Wolfram s John Fultz。 这里是Mathegroup链接:

EDIT 2. 在窗户上,如果你没有突出的甄选,那么 default在指挥后移动的处所似乎就已执行。 缺席是下个牢房。 真是一把钥匙登入,在诊断后,在真心log的诊断中,先经体选择。 因此,如果你执行,

SelectionMove[InputNotebook[], After, Notebook]; 
 FrontEndExecute[FrontEndToken["FontPanel"]]

还将开始打字你的真心血清环境。 然而,在键盘入之前的任何改变都会破坏老环境。

EDIT3:利用Silvia的思想,使用看不见的笔记本,但在本笔记本中写给新囚室。 步骤: 选择一个封闭的新牢房,写一些东西,援引老板小组,掌握囚室的真心选择,删除囚室,归还被俘的体力选择:

 fontPanelReturn[] := {SelectionMove[EvaluationNotebook[], After, Notebook]; 
   NotebookWrite[EvaluationNotebook[], Cell["text", ShowCellBracket -> False, 
                CellOpen -> False, Magnification -> 0]];
   SelectionMove[EvaluationNotebook[], Before, CellContents]; 
   SelectionMove[EvaluationNotebook[], All, Word]; 
   FrontEndExecute[FrontEndToken["FontPanel"]]; 
  fontops = 
   AbsoluteOptions[
         NotebookSelection[EvaluationNotebook[]], {FontColor, FontFamily, 
        FontProperties, FontSize, FontSlant, FontTracking, 
        FontVariations, FontWeight, Background}];
 NotebookDelete[EvaluationNotebook[]];
 SelectionMove[EvaluationNotebook[], Next, Cell]; fontops}

采用

 fontPanelReturn[]

gives, (for example)

 {{Background -> None, FontColor -> Automatic, 
   FontFamily -> "Trebuchet MS", 
    FontProperties -> {"FontMonospaced" -> Automatic, 
    "FontSerifed" -> Automatic, "ScreenResolution" -> 72}, 
   FontSize -> 24, FontSlant -> "Italic", FontTracking -> "Plain", 
   FontVariations -> {"CapsType" -> Normal, 
   "CompatibilityType" -> Normal, "Masked" -> False, 
   "Outline" -> False, "RotationAngle" -> 0, "Shadow" -> False, 
   "StrikeThrough" -> False, "Underline" -> False}, 
   FontWeight -> "Bold"}}

EDIT 4:如果你改变Silvia的代码,以便你在引用真心的小组方言之前选择囚室,然后掌握囚室的选择(而不是笔记):

 inputFontSettings[] := 
    Module[{doc, opt}, 
    doc = CreateDocument[TextCell["text"], WindowSelected -> False, Visible -> False]; 
    SelectionMove[doc, Next, Cell]; 
    FrontEndTokenExecute[doc, "FontPanel"]; 
    opt = AbsoluteOptions[
    NotebookSelection[doc], {FontColor, FontFamily, FontProperties, 
    FontSize, FontSlant, FontTracking, FontVariations, FontWeight, 
    Background}]; NotebookClose[doc]; opt]

请允许我:

a. 设置一个看不见的斜体,并在其中设置一个样本。

- 设计;然后选择电池;

-> using FrontEnd TokenExecute[“FontPanel”] to Format;

- 研读;摘取你需要的自选;

-> paste it to where you want.


Here s how to implement this:

inputFontSettings[] :=
 Module[
  {doc, opt},
  doc = CreateDocument[TextCell["text"], WindowSelected -> False, Visible -> False];
  SelectionMove[doc, All, Notebook];
  FrontEndTokenExecute[doc, "FontPanel"];
  opt = Options@NotebookRead[doc];
  NotebookClose[doc];
  opt
 ]

请注意,如果使用固定字体大小,将不退还<代码>FontSize项。

关于列出所有现有字体的问题......

希望有人很快会用本地的数学方法chim,以获得一份所有现有字体清单。 在等待的时候,这里是利用 Java的方法:

Needs["JLink`"]
LoadJavaClass["java.awt.GraphicsEnvironment"];

fontFamilies[] :=
  JavaBlock @
    java`awt`GraphicsEnvironment`getLocalGraphicsEnvironment[] @ 
      getAvailableFontFamilyNames[]

“"hello"

鉴于技术差异, Java清单可能与数学清单完全不相称,但这是一个体面的开端。





相关问题
Solving vector equations in Mathematica

I m trying to figure out how to use Mathematica to solve systems of equations where some of the variables and coefficients are vectors. A simple example would be something like where I know A, V, and ...

Introspection of messages generated in Mathematica

Is there any way to get at the actual messages generated during the evaluation of an expression in Mathematica? Say I m numerically solving an ODE and it blows up, like so In[1] := sol = NDSolve[{x [...

Connecting points in Mathematica

I have a collection of points displayed in a graphic: alt text http://img69.imageshack.us/img69/874/plc1k1lrqynuyshgrdegvfy.jpg I d like to know if there is any command that will connect them ...

Mathematica, PDF Curves and Shading

I need to plot a normal distribution and then shade some specific region of it. Right now I m doing this by creating a plot of the distribution and overlaying it with a RegionPlot. This is pretty ...

Targeted Simplify in Mathematica

I generate very long and complex analytic expressions of the general form: (...something not so complex...)(...ditto...)(...ditto...)...lots... When I try to use Simplify, Mathematica grinds to a ...

热门标签