stbtt_FindMatchingFont function

  1. @Native<Int Function(Pointer<ma_uint8>, Pointer<Char>, Int)>(ffi.Pointer<ffi.UnsignedChar>, ffi.Pointer<ffi.Char>, ffi.Int)>()
int stbtt_FindMatchingFont(
  1. Pointer<ma_uint8> fontdata,
  2. Pointer<Char> name,
  3. int flags$1
)

///////////////////////////////////////////////////////////////////////////

Finding the right font...

You should really just solve this offline, keep your own tables of what font is what, and don't try to get it out of the .ttf file. That's because getting it out of the .ttf file is really hard, because the names in the file can appear in many possible encodings, in many possible languages, and e.g. if you need a case-insensitive comparison, the details of that depend on the encoding & language in a complex way (actually underspecified in truetype, but also gigantic).

But you can use the provided functions in two possible ways: stbtt_FindMatchingFont() will use case-sensitive comparisons on unicode-encoded names to try to find the font you want; you can run this before calling stbtt_InitFont()

stbtt_GetFontNameString() lets you get any of the various strings from the file yourself and do your own comparisons on them. You have to have called stbtt_InitFont() first.

Implementation

@ffi.Native<
  ffi.Int Function(
    ffi.Pointer<ffi.UnsignedChar>,
    ffi.Pointer<ffi.Char>,
    ffi.Int,
  )
>()
external int stbtt_FindMatchingFont(
  ffi.Pointer<ffi.UnsignedChar> fontdata,
  ffi.Pointer<ffi.Char> name,
  int flags$1,
);