MCPcopy Create free account
hub / github.com/KLayout/klayout / render_text

Method render_text

src/laybasic/laybasic/layBitmap.cc:795–902  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

793}
794
795void
796Bitmap::render_text (const lay::RenderText &text)
797{
798 if (text.font == db::DefaultFont) {
799
800 const lay::FixedFont &ff = lay::FixedFont::get_font (m_font_resolution);
801
802 // count the lines and max. characters per line
803
804 unsigned int lines = 1;
805 for (const char *cp = text.text.c_str (); *cp; ) {
806 if (tl::skip_newline (cp)) {
807 ++lines;
808 } else {
809 ++cp;
810 }
811 }
812
813 // compute the actual top left position
814 double y;
815 if (text.valign == db::VAlignBottom || text.valign == db::NoVAlign) {
816 y = text.b.bottom ();
817 y += double (ff.line_height () * (lines - 1) + ff.height ());
818 } else if (text.valign == db::VAlignCenter) {
819 y = text.b.center ().y ();
820 y += double ((ff.line_height () * (lines - 1) + ff.height ()) / 2);
821 } else {
822 y = text.b.top ();
823 }
824
825 // start generating the characters
826
827 const char *cp1 = text.text.c_str ();
828 while (*cp1) {
829
830 unsigned int length = 0;
831 const char *cp = cp1;
832 while (*cp && !tl::is_newline (*cp)) {
833 tl::utf32_from_utf8 (cp);
834 ++length;
835 }
836
837 double xx;
838 if (text.halign == db::HAlignRight) {
839 xx = text.b.right ();
840 xx -= double (ff.width () * length);
841 } else if (text.halign == db::HAlignCenter) {
842 xx = text.b.center ().x ();
843 xx -= double (ff.width () * length / 2);
844 } else {
845 xx = text.b.left ();
846 }
847 xx -= 0.5;
848
849 if (y > -0.5 && y < double (height () + ff.height () - 1) - 0.5) {
850
851 while (cp1 != cp) {
852

Callers 1

render_textsMethod · 0.80

Calls 15

get_fontFunction · 0.85
skip_newlineFunction · 0.85
is_newlineFunction · 0.85
utf32_from_utf8Function · 0.85
bottomMethod · 0.80
yMethod · 0.80
centerMethod · 0.80
topMethod · 0.80
rightMethod · 0.80
leftMethod · 0.80
reserve_edgesMethod · 0.80
count_edgesMethod · 0.80

Tested by

no test coverage detected