MCPcopy Create free account
hub / github.com/Kitware/VTK / SetMathTextFont

Method SetMathTextFont

Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx:929–959  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

927
928//------------------------------------------------------------------------------
929bool 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//------------------------------------------------------------------------------
962bool vtkMatplotlibMathTextUtilities::RenderOneCell(vtkImageData* image, int bbox[4],

Callers 2

GetMetricsMethod · 0.95
RenderStringMethod · 0.95

Calls 1

CheckForErrorMethod · 0.95

Tested by

no test coverage detected