It looks like you're new here. If you want to get involved, click one of these buttons!
Is the code for the "TEXT" PCell available somewhere?
This should be the code you are looking for, however this seems like not implemented by Py/Ruby API.
If you want to create text with different font you can use the "TrueType" library from ShapeLib directly.
TrueType text pCell example from ShapeLib:
@RawrRanger Yes, you're right. The implementation of the Basic Library is C++ and it's similar, but not exactly like the Python or Ruby implementation.
In order to generate Text from TrueType fonts, you can also use QPainterPath::addText and toSubpathPolygons to generate text polygons.
However, TrueType fonts are hardly useful for lithographic printing as they are likely to violate a number of design rules.
If it was me, I'd be taking those PCell texts and make a process-
rules-compliant set of every character / numeral / punctuation,
flatten each one & "make cell" with the character name, and
never touch them again except to place on layouts.
I like as few dependencies as possible and flat data is that.
I won't go to tapeout with parameterized cells.
I've added a new font type (gds file) in the fonts folder.
Now I would like to instantiate the "TEXT" pcell with this new font type via script.
This works well via the parameter "font", using 1 instead of 0.
But what about the parameter "font_name"? Is it the name that appears in the drop down box?
If I use that one, it doesn't work, I always get the default text (Non-manhattan).
For printable characters you really have to stay with "fat stick"
style or you'll violate groundrules on the little cutesy features of
(say) a Times New Roman font. In my experience you're lucky
to get "big and little". I have never seen anything remotely "pretty".
@tomas2004 The name of the font should be the name of the file sans extension (e.g. "myfont.gds") should become available as font with name "myfont".
Basically "font_name" should have priority if it is a valid name. If "font_name" is not valid, the index is taken and that allows little control over the font actually used. Which is not entirely true as the Basic:TEXT cell is based on "TextGenerator" (https://www.klayout.de/doc-qt5/code/class_TextGenerator.html) which has an API for font queries and it also provides a way to register fonts programmatically from arbitrary sources.
Got it! Works well, but I will use the TexGenerator from now on...
Very good The TextGenerator was created so that users do not necessarily have to use the PCell.
I noticed that a new line "\n" in the string "text" parameter results in a space making the "line_spacing" parameter kinda obsolete (at least in version 0.27.13). Can you verify?
the "\n" needs to be embedded into the string - so you need to use "LINE1\\nLINE2".
There reason is probably that I wanted that you can enter "\n" into the text edit box of the TEXT PCell which is not multi-line capable.