pixie/fontformats/opentype

  Source   Edit

See https://docs.microsoft.com/en-us/typography/opentype/spec/

Types

CmapTable = ref object
  version*: uint16
  numTables*: uint16
  encodingRecords*: seq[EncodingRecord]
  runeToGlyphId*: Table[Rune, uint16]
  glyphIdToRune*: Table[uint16, Rune]
  Source   Edit
EncodingRecord = object
  platformID*: uint16
  encodingID*: uint16
  offset*: uint32
  Source   Edit
GlyfTable = ref object
  offsets*: seq[uint32]
  Source   Edit
HeadTable = ref object
  majorVersion*: uint16
  minorVersion*: uint16
  fontRevision*: float32
  checkSumAdjustment*: uint32
  magicNumber*: uint32
  flags*: uint16
  unitsPerEm*: uint16
  created*: float64
  modified*: float64
  xMin*: int16
  yMin*: int16
  xMax*: int16
  yMax*: int16
  macStyle*: uint16
  lowestRecPPEM*: uint16
  fontDirectionHint*: int16
  indexToLocFormat*: int16
  glyphDataFormat*: int16
  Source   Edit
HheaTable = ref object
  majorVersion*: uint16
  minorVersion*: uint16
  ascender*: int16
  descender*: int16
  lineGap*: int16
  advanceWidthMax*: uint16
  minLeftSideBearing*: int16
  minRightSideBearing*: int16
  xMaxExtent*: int16
  caretSlopeRise*: int16
  caretSlopeRun*: int16
  caretOffset*: int16
  metricDataFormat*: int16
  numberOfHMetrics*: uint16
  Source   Edit
HmtxTable = ref object
  hMetrics*: seq[LongHorMetricRecord]
  leftSideBearings*: seq[int16]
  Source   Edit
KernPair = object
  left*: uint16
  right*: uint16
  value*: int16
  Source   Edit
KernSubTable = object
  version*: uint16
  length*: uint16
  coverage*: uint16
  nPairs*: uint16
  searchRange*: uint16
  entrySelector*: uint16
  rangeShift*: uint16
  kernPairs*: seq[KernPair]
  Source   Edit
KernTable = ref object
  version*: uint16
  nTables*: uint16
  subTables*: seq[KernSubTable]
  kerningPairs: Table[(uint16, uint16), float32]
  Source   Edit
LocaTable = ref object
  offsets*: seq[uint32]
  Source   Edit
LongHorMetricRecord = object
  advanceWidth*: uint16
  leftSideBearing*: int16
  Source   Edit
MaxpTable = ref object
  version*: float32
  numGlyphs*: uint16
  maxPoints*: uint16
  maxContours*: uint16
  maxCompositePoints*: uint16
  maxCompositeContours*: uint16
  maxZones*: uint16
  maxTwilightPoints*: uint16
  maxStorage*: uint16
  maxFunctionDefs*: uint16
  maxInstructionDefs*: uint16
  maxStackElements*: uint16
  maxSizeOfInstructions*: uint16
  maxComponentElements*: uint16
  maxComponentDepth*: uint16
  Source   Edit
NameRecord = object
  platformID*: uint16
  encodingID*: uint16
  languageID*: uint16
  nameID*: uint16
  length*: uint16
  offset*: uint16
  text*: string
  Source   Edit
NameTable = ref object
  format*: uint16
  count*: uint16
  stringOffset*: uint16
  nameRecords*: seq[NameRecord]
  Source   Edit
OpenType = ref object
  buf*: string
  version*: uint32
  numTables*: uint16
  searchRange*: uint16
  entrySelector*: uint16
  rangeShift*: uint16
  tableRecords*: Table[string, TableRecord]
  cmap*: CmapTable
  head*: HeadTable
  hhea*: HheaTable
  maxp*: MaxpTable
  hmtx*: HmtxTable
  name*: NameTable
  os2*: OS2Table
  loca*: LocaTable
  glyf*: GlyfTable
  kern*: KernTable
  gpos*: GposTable
  post*: PostTable
  cff*: CFFTable
  glyphPaths: Table[Rune, Path]
  Source   Edit
OS2Table = ref object
  version*: uint16
  xAvgCharWidth*: int16
  usWeightClass*: uint16
  usWidthClass*: uint16
  fsType*: uint16
  ySubscriptXSize*: int16
  ySubscriptYSize*: int16
  ySubscriptXOffset*: int16
  ySubscriptYOffset*: int16
  ySuperscriptXSize*: int16
  ySuperscriptYSize*: int16
  ySuperscriptXOffset*: int16
  ySuperscriptYOffset*: int16
  yStrikeoutSize*: int16
  yStrikeoutPosition*: int16
  sFamilyClass*: int16
  panose*: array[10, uint8]
  ulUnicodeRange1*: uint32
  ulUnicodeRange2*: uint32
  ulUnicodeRange3*: uint32
  ulUnicodeRange4*: uint32
  achVendID*: string
  fsSelection*: uint16
  usFirstCharIndex*: uint16
  usLastCharIndex*: uint16
  sTypoAscender*: int16
  sTypoDescender*: int16
  sTypoLineGap*: int16
  usWinAscent*: uint16
  usWinDescent*: uint16
  ulCodePageRange1*: uint32
  ulCodePageRange2*: uint32
  sxHeight*: int16
  sCapHeight*: int16
  usDefaultChar*: uint16
  usBreakChar*: uint16
  usMaxContext*: uint16
  usLowerOpticalPointSize*: uint16
  usUpperOpticalPointSize*: uint16
  Source   Edit
TableRecord = object
  tag*: string
  checksum*: uint32
  offset*: uint32
  length*: uint32
  Source   Edit

Procs

proc fullName(opentype: OpenType): string {....raises: [], tags: [].}
Returns full name of the font if available.   Source   Edit
proc getAdvance(opentype: OpenType; rune: Rune): float32 {....raises: [], tags: [].}
  Source   Edit
proc getGlyphPath(opentype: OpenType; rune: Rune): Path {....raises: [PixieError],
    tags: [RootEffect].}
  Source   Edit
proc getKerningAdjustment(opentype: OpenType; left, right: Rune): float32 {.
    ...raises: [], tags: [].}
  Source   Edit
proc getLeftSideBearing(opentype: OpenType; rune: Rune): float32 {....raises: [],
    tags: [].}
  Source   Edit
proc hasGlyph(opentype: OpenType; rune: Rune): bool {....raises: [], tags: [].}
  Source   Edit
proc isCCW(opentype: OpenType): bool {.inline, ...raises: [], tags: [].}
Returns the expected winding order of a font. Gyph - false - clockwise CFF - true - counterclockwise   Source   Edit
proc parseOpenType(buf: string; startLoc = 0): OpenType {....raises: [PixieError],
    tags: [].}
  Source   Edit
proc parseOpenTypeCollection(buf: string): seq[OpenType] {....raises: [PixieError],
    tags: [].}
Reads a true/open type collection and returns seq of OpenType files.   Source   Edit