encodeGlyphTexels function

GlyphCurveTexture encodeGlyphTexels(
  1. List<QuadCurve> curves,
  2. GlyphBands bands, {
  3. int width = 256,
})

Packs curves + bands into texels (see the library header for the layout). Throws ArgumentError when the stream exceeds u16 addressability (65535 texels) - callers fall back to outline strips.

Implementation

GlyphCurveTexture encodeGlyphTexels(List<QuadCurve> curves, GlyphBands bands,
    {int width = 256}) {
  final texels = encodeGlyphStream(curves, bands);
  final texelCount = texels.length ~/ 4;
  final height = math.max(1, (texelCount + width - 1) ~/ width);
  final pixels = Uint8List(width * height * 4);
  pixels.setRange(0, texels.length, texels);
  return GlyphCurveTexture._(pixels, width, height, texelCount,
      bands.bandCount, bands.minX, bands.minY, bands.maxX, bands.maxY,
      bands.overflow);
}