pixie/fonts

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
  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: [], forbids: [].}
The font ascender value in font units. Source   Edit  
proc capHeight(typeface: Typeface): float32 {....raises: [], tags: [], forbids: [].}
The font cap height value in font units. Source   Edit  
proc computeBounds(arrangement: Arrangement; transform = mat3()): Rect {.
    ...raises: [PixieError], tags: [RootEffect], forbids: [].}
Source   Edit  
proc copy(font: Font): Font {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc defaultLineHeight(font: Font): float32 {.inline, ...raises: [], tags: [],
    forbids: [].}
The default line height in pixels for the current font size. Source   Edit  
proc descent(typeface: Typeface): float32 {....raises: [], tags: [], forbids: [].}
The font descender value in font units. Source   Edit  
proc fallbackTypeface(typeface: Typeface; rune: Rune): Typeface {....raises: [],
    tags: [], forbids: [].}
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], forbids: [].}
Fills the text arrangement. Source   Edit  
proc fillText(target: Image; font: Font; text: sink string; transform = mat3();
              bounds = vec2(0, 0); hAlign = LeftAlign; vAlign = TopAlign) {.
    inline, ...raises: [PixieError], tags: [RootEffect], forbids: [].}
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: [], forbids: [].}
The advance for the rune in pixels. Source   Edit  
proc getGlyphPath(typeface: Typeface; rune: Rune): Path {.inline,
    ...raises: [PixieError], tags: [RootEffect], forbids: [].}
The glyph path for the rune. Source   Edit  
proc getKerningAdjustment(typeface: Typeface; left, right: Rune): float32 {.
    inline, ...raises: [], tags: [], forbids: [].}
The kerning adjustment for the rune pair, in pixels. Source   Edit  
proc hasGlyph(typeface: Typeface; rune: Rune): bool {.inline, ...raises: [],
    tags: [], forbids: [].}
Returns if there is a glyph for this rune. Source   Edit  
proc layoutBounds(arrangement: Arrangement): Vec2 {....raises: [], tags: [],
    forbids: [].}
Computes the width and height of the arrangement in pixels. Source   Edit  
proc layoutBounds(font: Font; text: string): Vec2 {.inline, ...raises: [],
    tags: [], forbids: [].}
Computes the width and height of the text in pixels. Source   Edit  
proc layoutBounds(spans: seq[Span]): Vec2 {.inline, ...raises: [], tags: [],
    forbids: [].}
Computes the width and height of the spans in pixels. Source   Edit  
proc lineGap(typeface: Typeface): float32 {....raises: [], tags: [], forbids: [].}
The font line gap value in font units. Source   Edit  
proc lineHeight(typeface: Typeface): float32 {.inline, ...raises: [], tags: [],
    forbids: [].}
The default line height in font units. Source   Edit  
proc name(typeface: Typeface): string {....raises: [], tags: [], forbids: [].}
Returns the name of the font. Source   Edit  
proc newFont(typeface: Typeface): Font {....raises: [], tags: [], forbids: [].}
Source   Edit  
proc newSpan(text: sink string; font: Font): Span {....raises: [], tags: [],
    forbids: [].}
Creates a span, associating a font with the text. Source   Edit  
proc paint(font: Font): Paint {.inline, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc paint=(font: Font; paint: Paint) {.inline, ...raises: [], tags: [],
                                        forbids: [].}
Source   Edit  
proc parseOtf(buf: string): Typeface {....raises: [PixieError], tags: [],
                                       forbids: [].}
Source   Edit  
proc parseSvgFont(buf: string): Typeface {....raises: [PixieError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Source   Edit  
proc parseTtf(buf: string): Typeface {....raises: [PixieError], tags: [],
                                       forbids: [].}
Source   Edit  
proc readFont(filePath: string): Font {....raises: [PixieError], tags: [
    ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Loads a font from a file. Source   Edit  
proc readTypeface(filePath: string): Typeface {....raises: [PixieError],
    tags: [ReadIOEffect, RootEffect, WriteIOEffect], forbids: [].}
Loads a typeface from a file. Source   Edit  
proc readTypefaces(filePath: string): seq[Typeface] {....raises: [PixieError],
    tags: [ReadIOEffect], forbids: [].}
Loads a OpenType Collection (.ttc). Source   Edit  
proc scale(font: Font): float32 {.inline, ...raises: [], tags: [], forbids: [].}
The scale factor to transform font units into pixels. Source   Edit  
proc scale(typeface: Typeface): float32 {.inline, ...raises: [], tags: [],
    forbids: [].}
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], forbids: [].}
Strokes the text arrangement. Source   Edit  
proc strokeText(target: Image; font: Font; text: sink 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], forbids: [].}
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: sink string; bounds = vec2(0, 0);
             hAlign = LeftAlign; vAlign = TopAlign; wrap = true): Arrangement {.
    inline, ...raises: [], tags: [], forbids: [].}
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: openArray[Span]; bounds = vec2(0, 0); hAlign = LeftAlign;
             vAlign = TopAlign; wrap = true): Arrangement {....raises: [],
    tags: [], forbids: [].}
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