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

Method PrepareMetaData

Rendering/FreeType/vtkFreeTypeTools.cxx:1036–1105  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1034
1035//------------------------------------------------------------------------------
1036bool vtkFreeTypeTools::PrepareMetaData(vtkTextProperty* tprop, int dpi, MetaData& metaData)
1037{
1038 // Text properties
1039 metaData.textProperty = tprop;
1040 this->MapTextPropertyToId(tprop, &metaData.textPropertyCacheId);
1041
1042 metaData.scaler.face_id = reinterpret_cast<FTC_FaceID>(metaData.textPropertyCacheId);
1043 metaData.scaler.width = tprop->GetFontSize() * 64; // 26.6 format point size
1044 metaData.scaler.height = tprop->GetFontSize() * 64;
1045 metaData.scaler.pixel = 0;
1046 metaData.scaler.x_res = dpi;
1047 metaData.scaler.y_res = dpi;
1048
1049 FT_Size size;
1050 if (!this->GetSize(&metaData.scaler, &size))
1051 {
1052 return false;
1053 }
1054
1055 metaData.face = size->face;
1056 metaData.faceHasKerning = (FT_HAS_KERNING(metaData.face) != 0);
1057
1058 // Store an unrotated version of this font, as we'll need this to get accurate
1059 // ascenders/descenders (see CalculateBoundingBox).
1060 if (tprop->GetOrientation() != 0.0)
1061 {
1062 vtkNew<vtkTextProperty> unrotatedTProp;
1063 unrotatedTProp->ShallowCopy(tprop);
1064 unrotatedTProp->SetOrientation(0);
1065 this->MapTextPropertyToId(unrotatedTProp, &metaData.unrotatedTextPropertyCacheId);
1066
1067 metaData.unrotatedScaler.face_id =
1068 reinterpret_cast<FTC_FaceID>(metaData.unrotatedTextPropertyCacheId);
1069 metaData.unrotatedScaler.width = tprop->GetFontSize() * 64; // 26.6 format point size
1070 metaData.unrotatedScaler.height = tprop->GetFontSize() * 64;
1071 metaData.unrotatedScaler.pixel = 0;
1072 metaData.unrotatedScaler.x_res = dpi;
1073 metaData.unrotatedScaler.y_res = dpi;
1074 }
1075 else
1076 {
1077 metaData.unrotatedTextPropertyCacheId = metaData.textPropertyCacheId;
1078 metaData.unrotatedScaler = metaData.scaler;
1079 }
1080
1081 // Rotation matrices:
1082 metaData.faceIsRotated = (fabs(metaData.textProperty->GetOrientation()) > 1e-5);
1083 if (metaData.faceIsRotated)
1084 {
1085 float angle =
1086 vtkMath::RadiansFromDegrees(static_cast<float>(metaData.textProperty->GetOrientation()));
1087 // 0 -> orientation (used to adjust kerning, PR#15301)
1088 float c = cos(angle);
1089 float s = sin(angle);
1090 metaData.rotation.xx = (FT_Fixed)(c * 0x10000L);
1091 metaData.rotation.xy = (FT_Fixed)(-s * 0x10000L);
1092 metaData.rotation.yx = (FT_Fixed)(s * 0x10000L);
1093 metaData.rotation.yy = (FT_Fixed)(c * 0x10000L);

Callers 5

GetBoundingBoxMethod · 0.95
GetMetricsMethod · 0.95
RenderStringInternalMethod · 0.95
StringToPathInternalMethod · 0.95

Calls 7

MapTextPropertyToIdMethod · 0.95
GetSizeMethod · 0.95
cosFunction · 0.50
sinFunction · 0.50
GetOrientationMethod · 0.45
ShallowCopyMethod · 0.45
SetOrientationMethod · 0.45

Tested by

no test coverage detected