Texts

There are two ways to generate text in device layouts. The first way is to generate polygons that look like fonts, which will ensure that the text can be fabricated. This is handled by functionality in the PolyText module.

The second way is to generate "text elements," which are more like annotations to save metadata into layout files. This is implemented in the Texts module.

PolyText

DeviceLayout.jl provides a few styles for rendering text as polygons. polytext! will render a string to a cell with options that depend on the style. The DotMatrix style provides more options than the styles derived from fonts, which only take a character width and Meta type.

Three functions characters_demo, scripted_demo, referenced_characters_demo are exported for demonstration but they also serve as a test of the functionality.

DeviceLayout.PolyText.DotMatrixType
DotMatrix(; pixelsize, pixelspacing=pixelsize,
            rounding=zero(pixelsize), meta::Meta=GDSMeta(0,0))

Keyword args

  • pixelsize: dimension for the width/height of each pixel.
  • pixelspacing: dimension for the spacing between adjacent pixels. Should be ≥ pixelsize. Defaults to pixelsize.
  • rounding: rounding radius for sharp corners of pixels. If pixelsize == pixelspacing, individual pixels are not rounded, but rather the pixels are unioned and the entire letter will be rounded.
  • meta: layer/datatype or similar info.
source
DeviceLayout.PolyText.polytextFunction
polytext(str::String, sty::PolyText.Style;
    scripting=false, linelimit=typemax(Int), verbose=false) where {T}

Renders the string str to a new coordinate system in a given style.

Keyword args

  • scripting: boolean parameter for allocating special characters ^, _, {, and } for superscripting and subscripting. Follows the same usage as LaTeX.
  • linelimit: sets the maximum number of characters per line and continues on a new line if str is longer than linelimit.
  • verbose: prints out information about the character dictionary.
source
DeviceLayout.PolyText.polytext!Function
polytext!(c::AbstractCoordinateSystem, str::String, sty::PolyText.Style;
    scripting=false, linelimit=typemax(Int), verbose=false)

Renders the string str to cell or coordinate system c in a given style.

Keyword args

  • scripting: boolean parameter for allocating special characters ^, _, {, and } for superscripting and subscripting. Follows the same usage as LaTeX.
  • linelimit: sets the maximum number of characters per line and continues on a new line if str is longer than linelimit.
  • verbose: prints out information about the character dictionary.
source
DeviceLayout.PolyText.characters_demoFunction
characters_demo(save_path = joinpath(homedir(),"Desktop","characters.gds"), flatten = false)

Demo script for demonstrating the available characters in polytext! and the linelimit parameter in use. flatten can flatten the cells before saving (for SVG output).

source
DeviceLayout.PolyText.scripted_demoFunction
scripted_demo(save_path = joinpath(homedir(),"Desktop","scripted.gds"), flatten = false)

Demo script for demonstrating the use of the scripting parameter in polytext!. flatten can flatten the cells before saving (for SVG output).

source
DeviceLayout.PolyText.referenced_characters_demoFunction
referenced_characters_demo(save_path = joinpath(homedir(),"Desktop","referenced_characters.gds");
    verbose_override = false)

Demo script for demonstrating the memory saving ability of keeping CellReferences for previously used characters in polytext!. Nothing is printed if verbose_override is true.

source

The fonts are generated by first converting characters from a TrueType font to a GDS file. This is done with the help of external layout tools. These characters are mono-spaced in 100µm x 200µm boxes, with cuts made to connect any interior islands within the characters to the outside. Following this, DeviceLayout.PolyText.format_gds is used to chop up the file into one character per Cell and then save the result for use by DeviceLayout.jl. All of these files are stored in deps/. To define a new font you need to make a new subtype and implement a few methods following the example in src/polytext/polytext.jl.

import DeviceLayout.Graphics: inch
cs = CoordinateSystem("cs", nm)
polytext!(cs, "AaBbCcDdEe", DotMatrix(; pixelsize=20μm, rounding=6μm))
save("dotmatrix_rounded_nosep.svg", flatten(Cell(cs, nm)), width=6inch, height=1inch);
cs = CoordinateSystem("cs", nm)
polytext!(cs, "AaBbCcDdEe", DotMatrix(; pixelsize=20μm, pixelspacing=30μm, rounding=6μm))
save("dotmatrix_rounded.svg", flatten(Cell(cs, nm)), width=6inch, height=1inch);
cs = CoordinateSystem("cs", nm)
polytext!(cs, "AaBbCcDdEe", DotMatrix(; pixelsize=20μm, meta=GDSMeta(1)))
save("dotmatrix.svg", flatten(Cell(cs, nm)), width=6inch, height=1inch);
cs = CoordinateSystem("cs", nm)
polytext!(cs, "AaBbCcDdEe", PolyTextSansMono(20μm, GDSMeta(0)))
save("sansmono.svg", flatten(Cell(cs, nm)), width=6inch, height=1inch);
cs = CoordinateSystem("cs", nm)
polytext!(cs, "AaBbCcDdEe", PolyTextComic(20μm, GDSMeta(0)))
save("comic.svg", flatten(Cell(cs, nm)), width=6inch, height=1inch);

Inline demonstrations

characters_demo(path_to_output_gds, true)
IOContext(IOStream(<file characters.svg>))
scripted_demo(path_to_output_gds, true);
IOContext(IOStream(<file scripted.svg>))

Texts

DeviceLayout.Texts.TextType
Text{S} <: GeometryEntity{S}

Text element in a layout. Distinct from rendering text as polygons (PolyText).

Arguments:

  • text: the text string.
  • origin: location of the text in parent coordinate system.
  • width: character width
  • can_scale: defaults to false, set to true if the text size should not be affected by scaling of parent coordinate system.
  • xalign: horizontal alignment of text with respect to origin. Can be any instance of abstract type Align.XAlignRule and defaults to LeftEdge().
  • yalign: vertical alignment of text with respect to origin. Can be any instance of abstract type Align.YAlignRule and defaults to TopEdge().
  • xrefl: Reflect across x-axis. Defaults to false.
  • mag: Magnification factor.
  • rot: Rotation in radians.
source
DeviceLayout.Cells.text!Function
text!(c::Cell{S}, str::String, origin::Point=zero(Point{S}), meta::Meta=GDSMeta(); kwargs...) where {S}

Annotate cell c with string str as a text element. See also polytext! for rendering strings as polygons.

source
text!(c::Cell, text::Texts.Text, meta)

Annotate cell c with Texts.Text object.

source