Skip to content

Commit

Permalink
Deploying to gh-pages from @ 5bc13cc 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
qpavsmi committed Aug 23, 2024
1 parent 60fb863 commit b182832
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
19 changes: 14 additions & 5 deletions _modules/kqcircuits/util/label_polygons.html
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ <h1>Source code for kqcircuits.util.label_polygons</h1><div class="highlight"><p
<span class="c1"># Please see our contribution agreements for individuals (meetiqm.com/iqm-individual-contributor-license-agreement)</span>
<span class="c1"># and organizations (meetiqm.com/iqm-organization-contributor-license-agreement).</span>

<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">lru_cache</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
<span class="kn">from</span> <span class="nn">kqcircuits.pya_resolver</span> <span class="kn">import</span> <span class="n">pya</span>
Expand All @@ -952,25 +953,33 @@ <h1>Source code for kqcircuits.util.label_polygons</h1><div class="highlight"><p

<div class="viewcode-block" id="get_text_polygon">
<a class="viewcode-back" href="../../../api/kqcircuits.util.label_polygons.html#kqcircuits.util.label_polygons.get_text_polygon">[docs]</a>
<span class="k">def</span> <span class="nf">get_text_polygon</span><span class="p">(</span><span class="n">label</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">size</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">OAS_TEXT_MAGNIFICATION</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">pya</span><span class="o">.</span><span class="n">Region</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">get_text_polygon</span><span class="p">(</span><span class="n">label</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">size</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">OAS_TEXT_MAGNIFICATION</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">pya</span><span class="o">.</span><span class="n">Region</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Returns the given label string as a region.</span>

<span class="sd"> If size argument is given as non-integer, will round it to nearest micron.</span>

<span class="sd"> Utilizes speed ups compared to generating text geometry with KLayout&#39;s TEXT PCells.</span>
<span class="sd"> Only supports characters layed out in the ``font_polygons.oas`` file.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="n">font_polygons</span> <span class="o">=</span> <span class="n">load_font_polygons</span><span class="p">()</span>
<span class="n">unsported_characters</span> <span class="o">=</span> <span class="nb">set</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">label</span><span class="p">)</span> <span class="o">-</span> <span class="nb">set</span><span class="p">(</span><span class="n">font_polygons</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
<span class="k">if</span> <span class="n">unsported_characters</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Unsupported characters for get_text_polygon: </span><span class="si">{</span><span class="n">unsported_characters</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
<span class="n">logging</span><span class="o">.</span><span class="n">warning</span><span class="p">(</span>
<span class="sa">f</span><span class="s2">&quot;Unsupported characters for get_text_polygon: </span><span class="si">{</span><span class="n">unsported_characters</span><span class="si">}</span><span class="s2">.&quot;</span>
<span class="sa">f</span><span class="s2">&quot; These characters will be skipped in label &#39;</span><span class="si">{</span><span class="n">label</span><span class="si">}</span><span class="s2">&#39;&quot;</span>
<span class="p">)</span>

<span class="n">norm_size</span> <span class="o">=</span> <span class="n">size</span> <span class="o">/</span> <span class="n">OAS_TEXT_MAGNIFICATION</span>
<span class="n">spacing</span> <span class="o">=</span> <span class="n">norm_size</span> <span class="o">*</span> <span class="n">OAS_TEXT_SPACING</span> <span class="o">/</span> <span class="n">OAS_DBU</span>
<span class="n">spacing</span> <span class="o">=</span> <span class="n">size</span> <span class="o">*</span> <span class="n">OAS_TEXT_SPACING</span> <span class="o">/</span> <span class="p">(</span><span class="n">OAS_DBU</span> <span class="o">*</span> <span class="n">OAS_TEXT_MAGNIFICATION</span><span class="p">)</span>
<span class="n">label_region</span> <span class="o">=</span> <span class="n">pya</span><span class="o">.</span><span class="n">Region</span><span class="p">()</span>
<span class="k">if</span> <span class="n">label</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">letter</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">label</span><span class="p">)):</span>
<span class="k">if</span> <span class="n">letter</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">font_polygons</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">label_region</span> <span class="o">+=</span> <span class="p">(</span>
<span class="n">font_polygons</span><span class="p">[</span><span class="n">letter</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span><span class="o">.</span><span class="n">scaled_and_snapped</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">norm_size</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">norm_size</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">moved</span><span class="p">(</span><span class="n">i</span> <span class="o">*</span> <span class="n">spacing</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">font_polygons</span><span class="p">[</span><span class="n">letter</span><span class="o">.</span><span class="n">upper</span><span class="p">()]</span>
<span class="o">.</span><span class="n">scaled_and_snapped</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">round</span><span class="p">(</span><span class="n">size</span><span class="p">),</span> <span class="n">OAS_TEXT_MAGNIFICATION</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="nb">round</span><span class="p">(</span><span class="n">size</span><span class="p">),</span> <span class="n">OAS_TEXT_MAGNIFICATION</span><span class="p">)</span>
<span class="o">.</span><span class="n">moved</span><span class="p">(</span><span class="n">i</span> <span class="o">*</span> <span class="n">spacing</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">label_region</span></div>

Expand Down
3 changes: 2 additions & 1 deletion api/kqcircuits.util.label_polygons.html
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,9 @@
<span id="kqcircuits-util-label-polygons"></span><h1>kqcircuits.util.label_polygons<a class="headerlink" href="#module-kqcircuits.util.label_polygons" title="Link to this heading"></a></h1>
<dl class="py function">
<dt class="sig sig-object py" id="kqcircuits.util.label_polygons.get_text_polygon">
<span class="sig-prename descclassname"><span class="pre">kqcircuits.util.label_polygons.</span></span><span class="sig-name descname"><span class="pre">get_text_polygon</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">500.0</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Region</span></span></span><a class="reference internal" href="../_modules/kqcircuits/util/label_polygons.html#get_text_polygon"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#kqcircuits.util.label_polygons.get_text_polygon" title="Link to this definition"></a></dt>
<span class="sig-prename descclassname"><span class="pre">kqcircuits.util.label_polygons.</span></span><span class="sig-name descname"><span class="pre">get_text_polygon</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">label</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">500.0</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Region</span></span></span><a class="reference internal" href="../_modules/kqcircuits/util/label_polygons.html#get_text_polygon"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#kqcircuits.util.label_polygons.get_text_polygon" title="Link to this definition"></a></dt>
<dd><p>Returns the given label string as a region.</p>
<p>If size argument is given as non-integer, will round it to nearest micron.</p>
<p>Utilizes speed ups compared to generating text geometry with KLayout’s TEXT PCells.
Only supports characters layed out in the <code class="docutils literal notranslate"><span class="pre">font_polygons.oas</span></code> file.</p>
</dd></dl>
Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit b182832

Please sign in to comment.