Skip to main content

textshaperlib 0.1.1 copy "textshaperlib: ^0.1.1" to clipboard
textshaperlib: ^0.1.1 copied to clipboard

Contextual OpenType text shaping and original glyph contours for Dart, powered by HarfBuzz.

example/main.dart

import 'dart:io';
import 'dart:typed_data';

import 'package:textshaperlib/textshaperlib.dart';

/// Prints glyph placements for a user-supplied font without a Flutter runtime.
Future<void> main(List<String> arguments) async {
  if (arguments.length != 2) {
    stderr.writeln('Usage: dart run example/main.dart font.ttf "Text to shape"');
    exitCode = 64;
    return;
  }
  await TextShaperLib.initialize();
  final Uint8List bytes = await File(arguments[0]).readAsBytes();
  final ShapedText text = TextShaperLib.shape(font: bytes, text: arguments[1], fontSize: 32);
  for (final ShapedGlyph glyph in text.glyphs) {
    stdout.writeln('glyph=${glyph.id} cluster=${glyph.cluster} advance=(${glyph.xAdvance}, ${glyph.yAdvance}) offset=(${glyph.xOffset}, ${glyph.yOffset})');
  }
}
0
likes
160
points
840
downloads
screenshot

Documentation

API reference

Publisher

verified publisherfocale-editor.app

Weekly Downloads

Contextual OpenType text shaping and original glyph contours for Dart, powered by HarfBuzz.

Repository (GitHub)
View/report issues
Contributing

Topics

#text-shaping #typography #opentype #harfbuzz #native-assets

License

MIT (license)

Dependencies

code_assets, crypto, ffi, hooks, native_toolchain_c, web, zcodec

More

Packages that depend on textshaperlib