// Macros for composing labels // Last edited on 2019-04-17 18:44:05 by stolfilocal #macro mklab_concat(obj1,obj2) #local wd1 = max_extent(obj1).y; union{ object{ obj1 } object{ obj2 translate wd1*y } } #end #macro mklab_sub(obj,cht) // Modifies a text object to use as a subscript. // {cht} is the assumed height of a capital letter. #local csf = 0.5; // Scaling factor. #local cdp = 0.25*cht; // Assumed depth of capital letter. object{ obj scale < 1, csf, csf > translate (csf - 1.0)*cdp*z } #end #macro mklab_sup(obj,cht) // Modifies a text object to use as a superscript. // {cht} is the assumed height of a capital letter. #local csf = 0.5; // Scaling factor. #local cup = 0.15*cht; // Assumed accent space above capital letter. object{ obj scale < 1, csf, csf > translate (csf - 1.0)*(cht+cup)*z } #end #macro mklab_make(fnt,txt,rfnt,rtxt,sz) // Makes a text object {obj} which is string {txt} typeset // with font {fnt}. The object will have baseline on Y axis; up will be the Z axis. // Extends from 0 to +1 in X direction. // Also makes a reference text object {robj} that is {rtxt} typeset with font {rfnt} // Then scales {obj} in Y and Z by a factor that would make the height of {robj} // above the baseline be {sz}. #local obj = text{ ttf fnt txt 1.0 rotate 90*x rotate 90*z } #local robj = text{ ttf rfnt rtxt 1.0 rotate 90*x rotate 90*z } #local sc = sx/(max_extent(robj).z) object { obj scale < 1, sc, sc > } #end