Text sizing, rotating and aligning with Ruby

Hi,

I want to adjust all text size, rotation and alignment with a Ruby script.

The documentation indicates that size= , halign= , valign= should set the size and alignment of a text, so my script is :

include RBA

app = RBA::Application.instance
mw = app.main_window
view = mw.current_view
cv = view.cellview(view.active_cellview_index)
ly = view.active_cellview.layout
cl = view.active_cellview.cell
dbu = ly.dbu

layer_info = LayerInfo.new(127,0)
layer_index = ly.layer(layer_info)

cl.each_shape(layer_index) do |shape|
    if shape.is_text?
        text = shape.text
        text.size= 100*dbu
        text.halign= 1
        text.valign= 1
        text.trans= RBA::Trans::R90
        print( text.string,",")
    end
end

view.update_content
view.add_missing_layers
#view.zoom_fit

But it does not set the size, alignment nor the rotation of the texts of the cell, although they are properly listed with the print command.

Please, can you tell me where is my mistake ?

Thank you, Best regards,

Laurent

Comments

  • I wonder whether this has to do with the Default font not
    being scalable, while the ones in the list are. Can you change
    the font property to (say) "Stick" and see if that helps?

    I note that the font is not an accessible Property, has to be
    set in File>Setup>Display>Texts and this affects all texts
    regardless of when they were placed.

  • Thanks .. this was my question too :)

    Font is actually not used so far - it's just a property that needs to be preserved because some tools want it. So if you read and write GDS, the font is transferred to the output, but not further used by KLayout.

    IMHO there is no global definition what font ID maps to which kind of font. GDS seems to have the option to include a font table, but I have no sample for such a case. So I did not try to map it. And frankly, no one has asked so far for font representation. And once you use OASIS or other formats, fonts play no or a different role anyway.

    Best regards,

    Matthias

  • I finally used search and replace. It works like a charm for the size :

        with texts from instances of nd288.. where shape.text_string ~ "D<*>" do shape.text_size =  1 um
    

    But is does not work for the rotation :

        with texts from instances of nd288.. where shape.text_string ~ "D<*>" do shape.text_rot = Trans.R90
    

    BRgds,
    Laurent

Sign In or Register to comment.