------------------------------------------------------------------------------
| 927 | |
| 928 | //------------------------------------------------------------------------------ |
| 929 | bool vtkMatplotlibMathTextUtilities::SetMathTextFont(vtkTextProperty* tprop) |
| 930 | { |
| 931 | vtkPythonScopeGilEnsurer gilEnsurer; |
| 932 | vtkSmartPyObject mplBase(PyImport_ImportModule("matplotlib")); |
| 933 | if (this->CheckForError(mplBase)) |
| 934 | { |
| 935 | return false; |
| 936 | } |
| 937 | vtkSmartPyObject rcParams(PyObject_GetAttrString(mplBase, "rcParams")); |
| 938 | |
| 939 | // See https://matplotlib.org/stable/tutorials/text/mathtext.html for available fonts |
| 940 | // Default is dejavusans |
| 941 | switch (tprop->GetFontFamily()) |
| 942 | { |
| 943 | case VTK_TIMES: |
| 944 | // stix is designed to work well with Times New Roman |
| 945 | PyDict_SetItemString(rcParams, "mathtext.fontset", PyUnicode_FromString("stix")); |
| 946 | break; |
| 947 | default: |
| 948 | PyDict_SetItemString(rcParams, "mathtext.fontset", PyUnicode_FromString("dejavusans")); |
| 949 | break; |
| 950 | } |
| 951 | |
| 952 | if (tprop->GetShadow()) |
| 953 | { |
| 954 | vtkWarningMacro(<< "Text shadow is not supported with math text."); |
| 955 | tprop->ShadowOff(); |
| 956 | } |
| 957 | |
| 958 | return true; |
| 959 | } |
| 960 | |
| 961 | //------------------------------------------------------------------------------ |
| 962 | bool vtkMatplotlibMathTextUtilities::RenderOneCell(vtkImageData* image, int bbox[4], |
no test coverage detected