writeTextConfig method
Write the text
contents given starting at x
, y
.
Implementation
int writeTextConfig({
required VectorGraphicsBuffer buffer,
required String text,
required String? fontFamily,
required double xAnchorMultiplier,
required int fontWeight,
required double fontSize,
required int decoration,
required int decorationStyle,
required int decorationColor,
}) {
buffer._checkPhase(_CurrentSection.text);
final int textId = buffer._nextTextId++;
assert(textId < kMaxId);
buffer._putUint8(_textConfigTag);
buffer._putUint16(textId);
buffer._putFloat32(xAnchorMultiplier);
buffer._putFloat32(fontSize);
buffer._putUint8(fontWeight);
buffer._putUint8(decoration);
buffer._putUint8(decorationStyle);
buffer._putUint32(decorationColor);
// font-family
if (fontFamily != null) {
// Newer versions of Dart will make this a Uint8List and not require the cast.
// ignore: unnecessary_cast
final Uint8List encoded = utf8.encode(fontFamily) as Uint8List;
buffer._putUint16(encoded.length);
buffer._putUint8List(encoded);
} else {
buffer._putUint16(0);
}
// text-value
// Newer versions of Dart will make this a Uint8List and not require the cast.
// ignore: unnecessary_cast
final Uint8List encoded = utf8.encode(text) as Uint8List;
buffer._putUint16(encoded.length);
buffer._putUint8List(encoded);
return textId;
}