Custom Font - Generator by Name

Dear all, I try to set up a text (Polygon) with TextGenerator via Python scripting. For better processability during lithography I want to use the DEPLOF font (https://wieweb.com/site/downloads/). I installed this as ttf font in my system (MacOS) but I'm not able to get it working.

pya.TextGenerator.set_font_paths("/Users/user/Library/Fonts/")
text_generator = pya.TextGenerator.generator_by_name("DEPLOF.ttf")
text = text_generator.text("Test in DEPLOF", 0.001, 100, False, 0,0,0)
Cell_Name.shapes(layer5).insert(text)

I ever get the message: AttributeError: 'NoneType' object has no attribute 'text' (3. line of code)

I also do not find a proper solution using the API Reference, could anyone tell me a solution?

Thanks in advance

Comments

  • Hello @Rumtreiber,

    "Fonts" in KLayout are not TrueType fonts. Fonts are GDS (or other layout) files delivering a cell per character. For details please see the class description: https://www.klayout.de/doc-qt5/code/class_TextGenerator.html

    You may be able to convert TTF fonts to layout using QFont from the Qt binding, but I have no recipe for this right now.

    Matthias

  • Hi Matthias, thanks for your answer. I thought it is possible because there is a PCell in LTK Package (TextTOGDS) but honestly I don't understand how it works.

    BR
    Tobias

  • You basically need a way to convert TTF glyphs into polygons. Qt provides such a way via QFont and QRegion. Assuming the font is installed in your system this should be possible, but I have not tried myself yet. Maybe there are other ways (via fontconfig for example).

    Anyway ... TTF fonts are hardly usable for mask layout which is heavily constrained by design rules - not just in terms of single masks, but also in terms of a full layer stack if you need readability on the wafer. So the GDS way seems a natural path to me as we need "real layout" style glyphs.

    Matthias

Sign In or Register to comment.