pixie/fonts

    Dark Mode
Search:
Group by:
  Source   Edit

Types

Arrangement = ref object
  lines*: seq[(int, int)]    ## The (start, stop) of the lines of text.
  spans*: seq[(int, int)]    ## The (start, stop) of the spans in the text.
  fonts*: seq[Font]          ## The font for each span.
  runes*: seq[Rune]          ## The runes of the text.
  positions*: seq[Vec2]      ## The positions of the glyphs for each rune.
  selectionRects*: seq[Rect] ## The selection rects for each glyph.
  
  Source   Edit
Font = ref object
  typeface*: Typeface
  size*: float32             ## Font size in pixels.
  lineHeight*: float32       ## The line height in pixels or autoLineHeight for the font's default line height.
  paints*: seq[Paint]
  textCase*: TextCase
  underline*: bool           ## Apply an underline.
  strikethrough*: bool       ## Apply a strikethrough.
  noKerningAdjustments*: bool ## Optionally disable kerning pair adjustments
  
  Source   Edit
HorizontalAlignment = enum
  LeftAlign, CenterAlign, RightAlign
  Source   Edit
Span = ref object
  text*: string
  font*: Font
  Source   Edit
TextCase = enum
  NormalCase, UpperCase, LowerCase, TitleCase
  Source   Edit
Typeface = ref object
  opentype: OpenType
  svgFont: SvgFont
  filePath*: string
  fallbacks*: seq[Typeface]
  Source   Edit
VerticalAlignment = enum
  TopAlign, MiddleAlign, BottomAlign
  Source   Edit

Consts

autoLineHeight: float32 = -1.0
Use default line height for the font size   Source   Edit

Procs

proc ascent(typeface: Typeface): float32 {....raises: [], tags: [].}
The font ascender value in font units.   Source   Edit
proc computeBounds(arrangement: Arrangement; transform = mat3()): Rect {.
    ...raises: [PixieError], tags: [RootEffect].}
  Source   Edit
proc copy(font: Font): Font {....raises: [], tags: [].}
  Source   Edit
proc defaultLineHeight(font: Font): float32 {.inline, ...raises: [], tags: [].}
The default line height in pixels for the current font size.   Source   Edit
proc descent(typeface: Typeface): float32 {....raises: [], tags: [].}
The font descender value in font units.   Source   Edit
proc fallbackTypeface(typeface: Typeface; rune: Rune): Typeface {....raises: [],
    tags: [].}
Looks through fallback typefaces to find one that has the glyph.   Source   Edit
proc fillText(target: Image; arrangement: Arrangement; transform = mat3()) {.
    inline, ...raises: [PixieError], tags: [RootEffect].}
Fills the text arrangement.   Source   Edit
proc fillText(target: Image; font: Font; text: string; transform = mat3();
              bounds = vec2(0, 0); hAlign = LeftAlign; vAlign = TopAlign) {.
    inline, ...raises: [PixieError], tags: [RootEffect].}
Typesets and fills the text. Optional parameters: transform: translation or matrix to apply bounds: width determines wrapping and hAlign, height for vAlign hAlign: horizontal alignment of the text vAlign: vertical alignment of the text   Source   Edit
proc getAdvance(typeface: Typeface; rune: Rune): float32 {.inline, ...raises: [],
    tags: [].}
The advance for the rune in pixels.   Source   Edit
proc getGlyphPath(typeface: Typeface; rune: Rune): Path {.inline,
    ...raises: [PixieError], tags: [RootEffect].}
The glyph path for the rune.   Source   Edit
proc getKerningAdjustment(typeface: Typeface; left, right: Rune): float32 {.
    inline, ...raises: [], tags: [].}
The kerning adjustment for the rune pair, in pixels.   Source   Edit
proc hasGlyph(typeface: Typeface; rune: Rune): bool {.inline, ...raises: [],
    tags: [].}
Returns if there is a glyph for this rune.   Source   Edit
proc layoutBounds(arrangement: Arrangement): Vec2 {....raises: [], tags: [].}
Computes the width and height of the arrangement in pixels.   Source   Edit
proc layoutBounds(font: Font; text: string): Vec2 {.inline, ...raises: [], tags: [].}
Computes the width and height of the text in pixels.   Source   Edit
proc layoutBounds(spans: seq[Span]): Vec2 {.inline, ...raises: [], tags: [].}
Computes the width and height of the spans in pixels.   Source   Edit
proc lineGap(typeface: Typeface): float32 {....raises: [], tags: [].}
The font line gap value in font units.   Source   Edit
proc lineHeight(typeface: Typeface): float32 {.inline, ...raises: [], tags: [].}
The default line height in font units.   Source   Edit
proc name(typeface: Typeface): string {....raises: [], tags: [].}
Returns the name of the font.   Source   Edit
proc newFont(typeface: Typeface): Font {....raises: [], tags: [].}
  Source   Edit
proc newSpan(text: string; font: Font): Span {....raises: [], tags: [].}
Creates a span, associating a font with the text.   Source   Edit
proc paint(font: Font): Paint {.inline, ...raises: [], tags: [].}
  Source   Edit
proc paint=(font: Font; paint: Paint) {.inline, ...raises: [], tags: [].}
  Source   Edit
proc parseOtf(buf: string): Typeface {....raises: [PixieError], tags: [].}
  Source   Edit
proc parseSvgFont(buf: string): Typeface {....raises: [PixieError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect].}
  Source   Edit
proc parseTtf(buf: string): Typeface {....raises: [PixieError], tags: [].}
  Source   Edit
proc readFont(filePath: string): Font {....raises: [PixieError], tags: [
    ReadIOEffect, RootEffect, WriteIOEffect].}
Loads a font from a file.   Source   Edit
proc readTypeface(filePath: string): Typeface {....raises: [PixieError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect].}
Loads a typeface from a file.   Source   Edit
proc readTypefaces(filePath: string): seq[Typeface] {....raises: [PixieError],
    tags: [ReadIOEffect].}
Loads a OpenType Collection (.ttc).   Source   Edit
proc scale(font: Font): float32 {.inline, ...raises: [], tags: [].}
The scale factor to transform font units into pixels.   Source   Edit
proc scale(typeface: Typeface): float32 {.inline, ...raises: [], tags: [].}
The scale factor to transform font units into pixels.   Source   Edit
proc strokeText(target: Image; arrangement: Arrangement; transform = mat3();
                strokeWidth: float32 = 1.0; lineCap = ButtCap;
                lineJoin = MiterJoin; miterLimit = defaultMiterLimit;
                dashes: seq[float32] = @[]) {.inline, ...raises: [PixieError],
    tags: [RootEffect].}
Strokes the text arrangement.   Source   Edit
proc strokeText(target: Image; font: Font; text: string; transform = mat3();
                strokeWidth: float32 = 1.0; bounds = vec2(0, 0);
                hAlign = LeftAlign; vAlign = TopAlign; lineCap = ButtCap;
                lineJoin = MiterJoin; miterLimit = defaultMiterLimit;
                dashes: seq[float32] = @[]) {.inline, ...raises: [PixieError],
    tags: [RootEffect].}
Typesets and strokes the text. Optional parameters: transform: translation or matrix to apply bounds: width determines wrapping and hAlign, height for vAlign hAlign: horizontal alignment of the text vAlign: vertical alignment of the text lineCap: stroke line cap shape lineJoin: stroke line join shape   Source   Edit
proc typeset(font: Font; text: string; bounds = vec2(0, 0); hAlign = LeftAlign;
             vAlign = TopAlign; wrap = true): Arrangement {.inline, ...raises: [],
    tags: [].}
Lays out the character glyphs and returns the arrangement. Optional parameters: bounds: width determines wrapping and hAlign, height for vAlign hAlign: horizontal alignment of the text vAlign: vertical alignment of the text wrap: enable/disable text wrapping   Source   Edit
proc typeset(spans: seq[Span]; bounds = vec2(0, 0); hAlign = LeftAlign;
             vAlign = TopAlign; wrap = true): Arrangement {....raises: [], tags: [].}
Lays out the character glyphs and returns the arrangement. Optional parameters: bounds: width determines wrapping and hAlign, height for vAlign hAlign: horizontal alignment of the text vAlign: vertical alignment of the text wrap: enable/disable text wrapping   Source   Edit