hwValidateCodePoint function

void hwValidateCodePoint(
  1. int codePoint,
  2. String source
)

Throws a GeneratorError when codePoint is no glyph a widget can be generated for, naming source as what holds it.

A value outside the Unicode range is not a codepoint at all and comes out as a literal neither Kotlin nor Swift compiles; a surrogate is half of one and has no glyph of its own, which the rendered code would only find out at runtime.

Implementation

void hwValidateCodePoint(int codePoint, String source) {
  if (codePoint < 0 || codePoint > 0x10FFFF) {
    throw GeneratorError(
      '$source names the codepoint $codePoint, which is outside the Unicode '
      'range 0x0 to 0x10FFFF.',
    );
  }
  if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
    throw GeneratorError(
      '$source names the codepoint ${hwCodePointLiteral(codePoint)}, which is '
      'a surrogate: half of a codepoint rather than a glyph of its own.',
    );
  }
}