<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[LogoNib Engineering]]></title><description><![CDATA[LogoNib Engineering]]></description><link>https://logonib.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Mon, 30 Nov 2026 23:45:20 GMT</lastBuildDate><atom:link href="https://logonib.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Why Converting a PNG or AI Logo to SVG Usually Fails at Print Shops (And a 6-Point SVG Pre-Flight Check)]]></title><description><![CDATA[Every week, founders generate a logo as a 1024×1024 PNG—from an AI image generator, a slide deck, or a quick web mockup—run it through the first "PNG to…]]></description><link>https://logonib.hashnode.dev/why-converting-a-png-or-ai-logo-to-svg-usually-fails-at-print-shops-and-a-6-point-svg-pre-flight-check</link><guid isPermaLink="true">https://logonib.hashnode.dev/why-converting-a-png-or-ai-logo-to-svg-usually-fails-at-print-shops-and-a-6-point-svg-pre-flight-check</guid><category><![CDATA[SVG]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Design]]></category><dc:creator><![CDATA[Hazel Fenwick]]></dc:creator><pubDate>Mon, 30 Nov 2026 16:44:59 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0c46f270015a9a7322119b/ec28482d-2a1d-4f24-ad4d-4e68f30b13ec.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every week, founders generate a logo as a <code>1024×1024</code> PNG—from an AI image generator, a slide deck, or a quick web mockup—run it through the first "PNG to SVG converter" they find on Google, and upload the result to a print shop for business cards, signage, or merch.</p>
<p><a class="embed-card" href="https://youtu.be/o1Vg5zk63RQ">https://youtu.be/o1Vg5zk63RQ</a></p>

<p>A day later, pre-press rejects the file.</p>
<p>Almost every rejection comes down to one of three hidden defects inside the <code>.svg</code> file. None of them are obvious when you preview the logo in Chrome on a laptop.</p>
<hr />
<h2>Defect 1: The "Fake SVG" (Base64 PNG Wrapped Inside <code>&lt;svg&gt;</code>)</h2>
<p>A surprising number of free "PNG to SVG" tools do not trace vectors at all. They base64-encode your raster PNG and wrap it inside a 4-line SVG container:</p>
<pre><code class="language-xml">&lt;svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"&gt;
  &lt;image width="512" height="512" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..." /&gt;
&lt;/svg&gt;
</code></pre>
<p>Because the filename ends in <code>.svg</code>, it looks right on a screen. At 300 DPI print resolution, however, a <code>512px</code> embedded bitmap can only print <code>1.71 inches</code> wide (<code>512 ÷ 300 = 1.71"</code>). Stretch it across a <code>12"</code> tote bag or a <code>36"</code> trade-show banner and every edge turns blurry. Vinyl cutters and embroidery digitizers reject <code>&lt;image&gt;</code> tags outright because there are no vector cut paths to follow.</p>
<hr />
<h2>Defect 2: Live <code>&lt;text&gt;</code> Tags That Silently Swap Fonts</h2>
<p>When a browser tool or design app exports a logo with live <code>&lt;text font-family="Fraunces"&gt;</code> elements, the SVG does not carry the font file inside it. It relies on the recipient's computer having that exact font installed.</p>
<p>When a print shop opens the file in Illustrator or CorelDRAW without your font installed, the software silently substitutes Arial or Helvetica—wrecking letter spacing, line width, and emblem alignment.</p>
<p>Production vector logos convert every character into closed <code>&lt;path d="..."&gt;</code> outlines using font glyph geometry (for example via <code>opentype.js</code>) before export. Once outlined, <code>&lt;text&gt;</code> count is <code>0</code>, and the logo renders identically on every RIP, plotter, and browser forever.</p>
<hr />
<h2>Defect 3: Bitmap Auto-Tracing Destroys Thin Typography</h2>
<p>Even real bitmap tracers (Potrace, Image Trace, and ML vectorizers) struggle with small wordmarks and AI-generated logos:</p>
<ul>
<li>Anti-aliased gray pixels around small letters turn into wobbly multi-node curves instead of straight stems.</li>
<li>Counters inside <code>e</code>, <code>a</code>, and <code>o</code> pinch shut or produce self-intersecting subpaths.</li>
<li>Clean 12-point icons inflate into <code>400+</code> noisy anchor points that stall vinyl plotters and bloat web bundles.</li>
</ul>
<hr />
<h2>Inspecting Any SVG in the Browser (Zero Server Upload)</h2>
<p>When we built the pre-flight inspector for <a href="https://www.logonib.com">LogoNib</a>, we wrote a small pure-TypeScript DOM audit that runs locally in the browser via <code>DOMParser</code> (<code>image/svg+xml</code>). Here is the core check pattern:</p>
<pre><code class="language-ts">export function auditLogoSvg(rawSvg: string) {
  const doc = new DOMParser().parseFromString(rawSvg, 'image/svg+xml');
  const root = doc.documentElement;

  const liveTextNodes = root.querySelectorAll('text, tspan, textPath').length;
  const embeddedRasters = root.querySelectorAll('image').length;
  const vectorPrimitives = root.querySelectorAll(
    'path, circle, rect, ellipse, polygon, polyline'
  ).length;
  const hasViewBox = Boolean(root.getAttribute('viewBox')?.trim());
  const hasNaNPaths = Array.from(root.querySelectorAll('path')).some((p) =&gt;
    /\bNaN\b/i.test(p.getAttribute('d') ?? '')
  );

  return {
    liveTextNodes,      // Must be 0 for print-ready outlined SVG
    embeddedRasters,    // Must be 0 (catches fake wrapped-PNG SVGs)
    vectorPrimitives,   // Should be &gt; 0 real geometry elements
    hasViewBox,         // Required for predictable scaling
    hasNaNPaths         // Catches malformed path coordinates
  };
}
</code></pre>
<p>One important browser security detail if you build your own SVG tool: <strong>never</strong> render untrusted user SVGs via <code>innerHTML</code>, <code>{@html}</code>, or a same-origin <code>image/svg+xml</code> Blob URL (inline <code>&lt;script&gt;</code> tags and <code>onload</code> handlers execute inside SVG documents). Instead, strip scripts/event handlers first and rasterize the preview onto an offscreen <code>&lt;canvas&gt;</code> before emitting a safe <code>image/png</code> Blob URL.</p>
<hr />
<h2>The 6-Point Pre-Flight Checklist Before Sending a Logo to Print</h2>
<p>Before uploading your logo to a printer, merch vendor, or sign shop, check all six items:</p>
<ol>
<li><strong>Zero <code>&lt;text&gt;</code> tags</strong> — confirm every letter is an outlined <code>&lt;path&gt;</code>.</li>
<li><strong>Zero <code>&lt;image&gt;</code> embeds</strong> — confirm the SVG is not a wrapped PNG.</li>
<li><strong>Explicit <code>viewBox</code> attribute</strong> — ensures crisp proportional scaling across web, PDF, and print RIPs.</li>
<li><strong>Pure monochrome variants</strong> — export <code>#111111</code> pure-black (for invoices, stamps, and laser engraving) and <code>#FFFFFF</code> pure-white (for dark headers and packaging).</li>
<li><strong>High-resolution transparent PNG backup</strong> — export at <code>2048px–4000px</code> wide for Stripe Checkout, slide decks, and social headers.</li>
<li><strong>CMYK Total Area Coverage <code>&lt;= 300%</code> + WCAG 2.1 contrast</strong> — avoids wet-ink smudging on coated paper stocks and unreadable web badges.</li>
</ol>
<hr />
<h2>Free No-Signup Browser Tools to Run These Checks Today</h2>
<p>If you already have a logo SVG and want to audit or recolor it right now without installing Illustrator or creating an account, all of our pre-press utilities run 100% locally in your browser:</p>
<ul>
<li><strong><a href="https://www.logonib.com/tools/svg-font-outline-checker">SVG Font Outline &amp; Pre-Press Checker</a></strong> — detects live <code>&lt;text&gt;</code> tags, fake wrapped-PNG <code>&lt;image&gt;</code> embeds, missing <code>viewBox</code>, and <code>NaN</code> path bugs in one click.</li>
<li><strong><a href="https://www.logonib.com/tools/svg-color-recolor">SVG Logo Color Changer &amp; Monochrome Generator</a></strong> — converts any SVG into pure black, pure white, or custom brand colors with live CMYK/WCAG contrast and a 3-variant ZIP export.</li>
<li><strong><a href="https://www.logonib.com/tools/svg-to-png">SVG to 4K Transparent PNG Converter</a></strong> — exports crisp <code>2048px</code> or <code>4000px</code> transparent PNGs locally.</li>
<li><strong><a href="https://www.logonib.com/tools/hex-to-cmyk-wcag">HEX to CMYK &amp; WCAG 2.1 Print Checker</a></strong> — calculates print CMYK formulas and flags ink coverage above <code>300%</code>.</li>
</ul>
<p>For the full engineering breakdown—including DPI print-size tables and a side-by-side comparison of bitmap tracing vs manual redraw vs native OpenType outlining—read the complete guide: <strong><a href="https://www.logonib.com/guides/convert-png-to-vector-svg">How to Convert a PNG or AI Logo to Print-Ready Vector SVG</a></strong> (and if you are rebuilding an AI raster logo from scratch, see our <strong><a href="https://www.logonib.com/alternatives/chatgpt-logo-maker">ChatGPT / AI Logo vs Outlined Vector SVG guide</a></strong>).</p>
<p>Need a brand-new outlined vector logo and full brand kit without a subscription? You can test <strong><a href="https://www.logonib.com">LogoNib Studio</a></strong> free on your own company name—and even download a <strong><a href="https://www.logonib.com/#specs">free 8-file Alder &amp; Pine sample ZIP</a></strong> first to inspect the outlined SVGs, 300-DPI bleed PDF, and 4-page brand guide yourself. One-time packs start at <code>$29</code> with zero recurring fees and a 30-day refund guarantee.</p>
]]></content:encoded></item><item><title><![CDATA[Why opentype.js 2.0's toPathData() Silently Emits NaN (and How We Fixed Outlined SVG + PDF Exports in the Browser)]]></title><description><![CDATA[How opentype.js@2.0.0 double-exponent rounding writes NaN into outlined SVG paths, and our 20-line fix in LogoNib.]]></description><link>https://logonib.hashnode.dev/why-opentype-js-2-0-s-topathdata-silently-emits-nan-and-how-we-fixed-outlined-svg-pdf-exports-in-the-browser</link><guid isPermaLink="true">https://logonib.hashnode.dev/why-opentype-js-2-0-s-topathdata-silently-emits-nan-and-how-we-fixed-outlined-svg-pdf-exports-in-the-browser</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[SVG]]></category><category><![CDATA[TypeScript]]></category><dc:creator><![CDATA[Hazel Fenwick]]></dc:creator><pubDate>Mon, 30 Nov 2026 14:15:08 GMT</pubDate><content:encoded><![CDATA[<p>If you use <code>opentype.js@2.0.0</code> to convert TrueType/OpenType text into outlined SVG <code>&lt;path&gt;</code> elements, run this four-line snippet in Node or your browser console:</p>
<pre><code class="language-js">const f = 524.0000001;
const intPart = Math.floor(f);
const decPart = f - intPart;
console.log(decPart + "e+" + 2, "-&gt;", Math.round(decPart + "e+" + 2));
// 9.999996564147295e-8e+2 -&gt; NaN
</code></pre>
<p>That exact string-concatenation rounding trick lives inside <code>opentype.js@2.0.0</code>'s <code>Path.prototype.toPathData()</code> helper (<code>src/path.mjs</code>), and it silently writes literal <code>NaN</code> coordinates into SVG <code>d="..."</code> attributes whenever a glyph vertex lands within <code>1e-6</code> above an integer.</p>
<p>We hit this bug in production while building <strong><a href="https://www.logonib.com">LogoNib</a></strong> — a browser-native vector logo and print-ready brand kit studio that compiles outlined SVGs, 4K PNGs, and pure-vector 300-DPI print PDFs entirely on the client. Here is the exact root cause, the 20-line fix we shipped, and how we regression-test every bundled <code>.ttf</code> font before export.</p>
<hr />
<h2>How We Caught It: <code>fraunces-600.ttf</code> Crashing <code>pdf-lib</code></h2>
<p>Most online logo makers either hand you raster PNGs or export SVGs containing raw <code>&lt;text font-family="..."&gt;</code> tags. The moment a founder sends that SVG to a print shop or opens it in Illustrator without the font installed, the wordmark silently falls back to Arial or Times New Roman.</p>
<p>In <a href="https://www.logonib.com">LogoNib</a>, we eliminate missing-font bugs completely by running deterministic glyph outlining in the browser:</p>
<ol>
<li>Fetch the exact <code>.ttf</code> font binary (<code>Inter</code>, <code>Syne</code>, <code>Fraunces</code>, <code>Playfair Display</code>, <code>Space Grotesk</code>, etc.)</li>
<li>Measure kerning, tracking, and bounding boxes with <code>opentype.js</code></li>
<li>Convert every letterform directly to vector Bezier <code>&lt;path&gt;</code> commands (zero <code>&lt;text&gt;</code> tags, zero external font links)</li>
<li>Compile those exact same <code>&lt;path&gt;</code> primitives straight into PDF vector drawing operators via <code>pdf-lib</code> (generating infinite-resolution vector logo PDFs, a 4-page CMYK/WCAG brand style guide, and <code>3.75" x 2.25"</code> full-bleed <code>0.125"</code> business card PDFs with crop marks)</li>
</ol>
<p>Everything worked on <code>Inter</code>, <code>Syne</code>, and <code>Space Grotesk</code> — until we generated a live specimen ZIP for <strong>"Alder &amp; Pine"</strong> set in <strong><code>Fraunces</code></strong> (<code>fraunces-600.ttf</code>).</p>
<p>The exported SVG silently contained <code>NaN</code> inside a curve command. Browsers quietly skipped the malformed segment, making it nearly invisible at a glance — until <code>pdf-lib</code> tried to parse the SVG path into PDF operators and threw immediately.</p>
<hr />
<h2>The Exact Root Cause in <code>opentype.js@2.0.0</code></h2>
<p>Digging into <code>node_modules/opentype.js/dist/opentype.js</code> (<code>src/path.mjs</code>), <code>Path.prototype.toPathData()</code> delegates every coordinate to <code>roundDecimal()</code>:</p>
<pre><code class="language-js">var decimalRoundingCache = {};
function roundDecimal(float, places) {
  const integerPart = Math.floor(float);
  const decimalPart = float - integerPart;
  if (!decimalRoundingCache[places]) {
    decimalRoundingCache[places] = {};
  }
  if (decimalRoundingCache[places][decimalPart] !== void 0) {
    const roundedDecimalPart2 = decimalRoundingCache[places][decimalPart];
    return integerPart + roundedDecimalPart2;
  }
  const roundedDecimalPart = +(Math.round(decimalPart + "e+" + places) + "e-" + places);
  decimalRoundingCache[places][decimalPart] = roundedDecimalPart;
  return integerPart + roundedDecimalPart;
}
</code></pre>
<p>Here is the failure chain when floating-point glyph scaling lands just above an integer (for example <code>524.0000001</code>):</p>
<ol>
<li><code>integerPart = Math.floor(524.0000001)</code> -&gt; <code>524</code></li>
<li><code>decimalPart = 524.0000001 - 524</code> -&gt; <code>9.999996564147295e-8</code></li>
<li>Because <code>decimalPart &lt; 1e-6</code>, JavaScript serializes it in <strong>scientific notation</strong> with an existing <code>e-8</code> exponent.</li>
<li><code>decimalPart + "e+" + 2</code> produces <strong><code>"9.999996564147295e-8e+2"</code></strong> — a string with <strong>two exponents</strong>.</li>
<li><code>Math.round("9.999996564147295e-8e+2")</code> returns <strong><code>NaN</code></strong>.</li>
<li><code>decimalRoundingCache[2][decimalPart] = NaN</code> <strong>caches the <code>NaN</code> permanently</strong> for the lifetime of the runtime.</li>
</ol>
<p>Any scaled glyph coordinate whose fractional part falls in <code>(0, 1e-6)</code> corrupts the entire SVG path string — and because font scaling (<code>fontSize / unitsPerEm</code>) produces arbitrary IEEE-754 floats, hitting that window is purely a matter of font size and glyph offsets.</p>
<hr />
<h2>The Fix: Serialize <code>path.commands</code> Directly with Finite Guards</h2>
<p>The raw geometric commands on <code>path.commands</code> (<code>M</code>, <code>L</code>, <code>Q</code>, <code>C</code>, <code>Z</code>) are still clean, finite IEEE-754 numbers. Bypassing <code>toPathData()</code> and serializing <code>path.commands</code> directly with numeric rounding (<code>Math.round(n * 100) / 100</code>) and <code>Number.isFinite()</code> checks eliminates both the double-exponent <code>NaN</code> bug and any surprise <code>optimizeCommands</code> mutations:</p>
<pre><code class="language-ts">function fmt(n: number): string {
  const r = Math.round(n * 100) / 100;
  return Object.is(r, -0) ? '0' : String(r);
}

function serializeOpenTypePath(path: OpenTypePath): string {
  const commands = path.commands;
  if (!Array.isArray(commands) || commands.length === 0) {
    return path.toPathData(2);
  }
  const parts: string[] = [];
  for (const cmd of commands) {
    if (cmd.type === 'M' || cmd.type === 'L') {
      if (Number.isFinite(cmd.x) &amp;&amp; Number.isFinite(cmd.y)) {
        parts.push(`${cmd.type}${fmt(cmd.x!)} ${fmt(cmd.y!)}`);
      }
    } else if (cmd.type === 'Q') {
      if (
        Number.isFinite(cmd.x1) &amp;&amp;
        Number.isFinite(cmd.y1) &amp;&amp;
        Number.isFinite(cmd.x) &amp;&amp;
        Number.isFinite(cmd.y)
      ) {
        parts.push(`Q${fmt(cmd.x1!)} ${fmt(cmd.y1!)} ${fmt(cmd.x!)} ${fmt(cmd.y!)}`);
      }
    } else if (cmd.type === 'C') {
      if (
        Number.isFinite(cmd.x1) &amp;&amp;
        Number.isFinite(cmd.y1) &amp;&amp;
        Number.isFinite(cmd.x2) &amp;&amp;
        Number.isFinite(cmd.y2) &amp;&amp;
        Number.isFinite(cmd.x) &amp;&amp;
        Number.isFinite(cmd.y)
      ) {
        parts.push(
          `C${fmt(cmd.x1!)} ${fmt(cmd.y1!)} ${fmt(cmd.x2!)} ${fmt(cmd.y2!)} ${fmt(cmd.x!)} ${fmt(cmd.y!)}`
        );
      }
    } else if (cmd.type === 'Z') {
      parts.push('Z');
    }
  }
  return parts.join('');
}
</code></pre>
<p>Then we added a Vitest regression suite that loops through <strong>every bundled <code>.ttf</code> font</strong> in LogoNib, compiles both the outlined SVG and the pure-vector PDF with <code>pdf-lib</code>, and asserts:</p>
<pre><code class="language-ts">expect(outlined.brandPathD).not.toContain('NaN');
expect(outlined.taglinePathD).not.toContain('NaN');
expect(outlined.svg).not.toContain('NaN');
expect(outlined.svg).not.toContain('&lt;text');

const pdfBytes = await buildVectorLogoPdf(outlined, concept, 'color');
expect(new TextDecoder().decode(pdfBytes.subarray(0, 5))).toBe('%PDF-');
</code></pre>
<p>All 35 unit tests pass cleanly across every font weight and layout variant.</p>
<hr />
<h2>Inspect the Output Yourself (Zero Sign-Up)</h2>
<p>If you want to verify the actual outlined SVGs and vector PDFs produced by this pipeline in Illustrator, Inkscape, Figma, or Ghostscript:</p>
<ul>
<li><strong>Download a real 8-file production ZIP (<code>alder-and-pine-sample.zip</code>)</strong> — click <strong>"Download Sample ZIP (Alder &amp; Pine)"</strong> at <strong><a href="https://www.logonib.com/#specs">logonib.com/#specs</a></strong> (generated client-side on demand with zero email or account required — includes the exact <code>Fraunces</code> outlined SVGs, 4000px transparent PNG, 300-DPI vector logo PDF, 4-page brand guidelines PDF, and <code>3.5" x 2"</code> bleed business card PDF).</li>
<li><strong>Try the live Wireframe path inspector</strong> — enter any project name at <strong><a href="https://www.logonib.com">logonib.com</a></strong> with no signup, open the studio, and toggle <strong>Wireframe</strong> to inspect every SVG primitive directly on the drafting canvas.</li>
<li><strong>4 free standalone client-side utilities (<a href="https://www.logonib.com/tools">logonib.com/tools</a>)</strong> — while building the studio export engine, we also broke out four zero-upload browser tools free for everyone:<ul>
<li><a href="https://www.logonib.com/tools/hex-to-cmyk-wcag">HEX to CMYK &amp; WCAG 2.1 Contrast Lab</a> (with &gt;300% total ink coverage pre-press alerts)</li>
<li><a href="https://www.logonib.com/tools/favicon-generator">Binary Multi-Size Favicon (<code>.ICO</code> + PWA) Generator</a></li>
<li><a href="https://www.logonib.com/tools/svg-to-png">4K SVG-to-PNG Converter &amp; Path Inspector</a></li>
<li><a href="https://www.logonib.com/tools/social-media-logo-resizer">12-Preset Social Media Logo Resizer</a></li>
</ul>
</li>
</ul>
<p>Designing, inspecting wireframes, downloading the sample ZIP, and using all four utilities are completely free; if you want to export a commercial vector kit for a brand, LogoNib uses strictly one-time pricing (<code>$29-$89</code>, no subscriptions, 30-day money-back guarantee).</p>
<p>If you spot any edge cases in the outlined SVG paths or vector PDF output — or have hit other surprising floating-point bugs in <code>opentype.js</code> — let me know in the comments!</p>
]]></content:encoded></item><item><title><![CDATA[Packing Multi-Size .ICO Files, CMYK Ink Separations, and 4K SVG Rasterizers Purely in the Browser]]></title><description><![CDATA[Three zero-upload TypeScript patterns from building LogoNib's browser-based vector brand studio.]]></description><link>https://logonib.hashnode.dev/packing-multi-size-ico-files-cmyk-ink-separations-and-4k-svg-rasterizers-purely-in-the-browser</link><guid isPermaLink="true">https://logonib.hashnode.dev/packing-multi-size-ico-files-cmyk-ink-separations-and-4k-svg-rasterizers-purely-in-the-browser</guid><category><![CDATA[TypeScript]]></category><category><![CDATA[SVG]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Design]]></category><dc:creator><![CDATA[Hazel Fenwick]]></dc:creator><pubDate>Sun, 29 Nov 2026 15:42:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6b0c46f270015a9a7322119b/0acb4316-7110-4e77-b569-2345c44c685c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Most online brand and design utilities upload your logo to a server just to resize a PNG, pack a <code>favicon.ico</code>, or inspect SVG dimensions. When we built <a href="https://www.logonib.com">LogoNib</a>, we wanted every single file-utility workflow — from generating multi-size favicons to checking print CMYK ink coverage and converting SVGs to 4000px transparent PNGs — to run <strong>100% locally in the browser</strong> with zero file uploads and zero server round-trips.</p>
<p>Here are the three concrete TypeScript patterns powering our free browser tools, including the subtle binary and browser-security edge cases that tend to break naive implementations.</p>
<hr />
<h2>1. Packing a Valid Multi-Size <code>favicon.ico</code> with <code>DataView</code> (Zero Dependencies)</h2>
<p>Modern browsers expect a <code>favicon.ico</code> that bundles multiple crisp icon frames (<code>16×16</code>, <code>32×32</code>, <code>48×48</code>) into one binary container. You do not need ImageMagick or a backend service to build one. Since Windows Vista, the ICO container format natively supports raw PNG payloads inside each directory entry — meaning any browser Canvas export (<code>canvas.toBlob(..., 'image/png')</code>) can be packed directly into an <code>ArrayBuffer</code>.</p>
<p>The binary layout consists of:</p>
<ol>
<li>A <strong>6-byte <code>ICONDIR</code> header</strong> (little-endian): <code>reserved (0)</code>, <code>type (1 = ICO)</code>, <code>count</code>.</li>
<li><strong>16 bytes per <code>ICONDIRENTRY</code></strong> describing each frame's width, height, color planes, bits-per-pixel, payload byte length, and absolute byte offset from the start of the file.</li>
<li>The concatenated raw PNG bytes.</li>
</ol>
<p>One subtle detail: dimensions of <code>256px</code> must be encoded as <code>0</code> in the 1-byte width/height fields.</p>
<pre><code class="language-ts">export function buildMultiSizeIco(
  pngBuffers: Array&lt;{ size: number; data: Uint8Array }&gt;
): Uint8Array {
  const count = pngBuffers.length;
  const headerSize = 6;
  const dirEntrySize = 16;
  const dirTotal = dirEntrySize * count;

  let dataTotal = 0;
  for (const frame of pngBuffers) {
    dataTotal += frame.data.byteLength;
  }

  const out = new Uint8Array(headerSize + dirTotal + dataTotal);
  const view = new DataView(out.buffer);

  // ICONDIR header (little-endian)
  view.setUint16(0, 0, true);     // reserved
  view.setUint16(2, 1, true);     // type = 1 (ICO)
  view.setUint16(4, count, true); // image count

  let offset = headerSize + dirTotal;
  for (let i = 0; i &lt; count; i++) {
    const { size, data } = pngBuffers[i];
    const entryOffset = headerSize + i * dirEntrySize;
    const dim = size &gt;= 256 ? 0 : size;

    view.setUint8(entryOffset + 0, dim);               // width
    view.setUint8(entryOffset + 1, dim);               // height
    view.setUint8(entryOffset + 2, 0);                 // palette count
    view.setUint8(entryOffset + 3, 0);                 // reserved
    view.setUint16(entryOffset + 4, 1, true);          // color planes
    view.setUint16(entryOffset + 6, 32, true);         // bits per pixel
    view.setUint32(entryOffset + 8, data.byteLength, true);
    view.setUint32(entryOffset + 12, offset, true);    // offset from file start

    out.set(data, offset);
    offset += data.byteLength;
  }

  return out;
}
</code></pre>
<p>Pair that with <code>180×180</code> (<code>apple-touch-icon.png</code>), <code>192×192</code>, <code>512×512</code>, and a <code>site.webmanifest</code>, and you have a complete production favicon bundle assembled client-side in milliseconds. You can test the live tool at <a href="https://www.logonib.com/tools/favicon-generator">LogoNib Favicon (.ICO) Generator</a>.</p>
<hr />
<h2>2. Device-Independent HEX → CMYK &amp; WCAG 2.1 Contrast Math</h2>
<p>When founders take a brand palette from Figma or CSS straight to a commercial printer, two failures show up immediately:</p>
<ul>
<li><strong>Over-saturated total ink coverage</strong> (CMYK <code>C + M + Y + K</code> exceeding 300% smudges on uncoated stock).</li>
<li><strong>Inaccessible contrast pairs</strong> (e.g., vibrant brand accents placed on light paper or dark slate headers failing WCAG AA <code>4.5:1</code>).</li>
</ul>
<p>Both checks reduce cleanly to deterministic pure functions:</p>
<pre><code class="language-ts">export function rgbToCmyk(r: number, g: number, b: number) {
  const rn = Math.max(0, Math.min(255, r)) / 255;
  const gn = Math.max(0, Math.min(255, g)) / 255;
  const bn = Math.max(0, Math.min(255, b)) / 255;

  const k = 1 - Math.max(rn, gn, bn);
  if (k &gt;= 1 - 1e-9) return { c: 0, m: 0, y: 0, k: 100 };

  const c = (1 - rn - k) / (1 - k);
  const m = (1 - gn - k) / (1 - k);
  const y = (1 - bn - k) / (1 - k);

  return {
    c: Math.round(c * 100),
    m: Math.round(m * 100),
    y: Math.round(y * 100),
    k: Math.round(k * 100),
  };
}

function linearizeChannel(channel255: number): number {
  const s = channel255 / 255;
  return s &lt;= 0.04045 ? s / 12.92 : Math.pow((s + 0.055) / 1.055, 2.4);
}

export function contrastRatio(hex1: string, hex2: string): number {
  const lum = (hex: string) =&gt; {
    const n = parseInt(hex.replace('#', ''), 16);
    return (
      0.2126 * linearizeChannel((n &gt;&gt; 16) &amp; 255) +
      0.7152 * linearizeChannel((n &gt;&gt; 8) &amp; 255) +
      0.0722 * linearizeChannel(n &amp; 255)
    );
  };
  const l1 = lum(hex1);
  const l2 = lum(hex2);
  const lighter = Math.max(l1, l2);
  const darker = Math.min(l1, l2);
  return Math.round(((lighter + 0.05) / (darker + 0.05)) * 100) / 100;
}
</code></pre>
<p>Note the exact sRGB linearization threshold (<code>0.04045</code> per WCAG 2.1, rather than the older <code>0.03928</code> draft value). You can inspect live CMYK separations, total ink coverage percentages, and an 8-pair WCAG matrix interactively in our <a href="https://www.logonib.com/tools/hex-to-cmyk-wcag">HEX to CMYK &amp; WCAG Contrast Lab</a>.</p>
<hr />
<h2>3. Rasterizing Untrusted User SVGs Safely at 4000px Without XSS</h2>
<p>Accepting arbitrary <code>.svg</code> uploads in a browser converter introduces a real security footgun: <strong>never inject user-uploaded SVG markup into the DOM via <code>innerHTML</code></strong>, and <strong>never open a same-origin <code>image/svg+xml</code> Blob URL in a navigable link or iframe</strong> — SVG files can carry inline <code>&lt;script&gt;</code>, <code>onload</code> handlers, or <code>&lt;foreignObject&gt;</code> payloads.</p>
<p>To inspect and rasterize untrusted SVGs safely:</p>
<ol>
<li>Parse the SVG string with <code>DOMParser.parseFromString(raw, 'image/svg+xml')</code> — parsed XML documents do not execute scripts.</li>
<li>Audit and strip active nodes (<code>&lt;script&gt;</code>, <code>&lt;foreignObject&gt;</code>, <code>on*</code> event attributes, external <code>javascript:</code> / remote <code>href</code> references), while reading <code>viewBox</code>, <code>&lt;path&gt;</code> counts, and detecting sneaky embedded <code>&lt;image&gt;</code> rasters disguised as SVGs.</li>
<li>Re-serialize the sanitized SVG into a <code>data:image/svg+xml;charset=utf-8,...</code> source loaded exclusively inside an <code>HTMLImageElement</code> (<code>img.src = ...</code>). Browsers enforce strict isolation on <code>&lt;img&gt;</code>-loaded SVGs (zero script execution, zero external subresource loading).</li>
<li>Draw to an offscreen <code>&lt;canvas&gt;</code> scaled up to <code>4000px</code> wide (preserving exact <code>viewBox</code> aspect ratio) and export via <code>canvas.toBlob('image/png')</code>.</li>
</ol>
<p>We shipped this exact pipeline in our <a href="https://www.logonib.com/tools/svg-to-png">4K SVG to Transparent PNG Converter &amp; Vector Path Inspector</a> alongside a <a href="https://www.logonib.com/tools/social-media-logo-resizer">12-Platform Social Media Logo Resizer &amp; Safe-Zone Cropper</a> and a <a href="https://www.logonib.com/guides/vector-logo-print-spec">Pre-Press Vector Logo Print Spec Guide</a>.</p>
<hr />
<h2>Why We Built These Alongside LogoNib</h2>
<p>All four utilities are free and require no sign-up. They grew directly out of the client-side vector geometry, OpenType outlining, and print-PDF export engine behind <a href="https://www.logonib.com">LogoNib</a> — our browser-based vector logo and brand kit studio for founders and small businesses who want real outlined SVGs, 300-DPI print PDFs, and full commercial rights for a one-time fee instead of recurring design subscriptions.</p>
<p>If you run into edge cases with Canvas DPI scaling, multi-frame <code>.ICO</code> validation in Safari/Edge, or sRGB-to-CMYK print proofing, drop a comment below — happy to compare notes.</p>
]]></content:encoded></item></channel></rss>