Class: Ucode::Audit::Browser::MissingGlyphPage

Inherits:
Object
  • Object
show all
Includes:
Repo::AtomicWrites
Defined in:
lib/ucode/audit/browser/missing_glyph_page.rb

Overview

Renders one standalone per-block HTML gallery of missing glyphs at <face_dir>/missing/<BLOCK>.html (TODO 26).

Every touched block with at least one missing codepoint gets one page. The gallery is fully static — inlined CSS, no client-side fetch — so it works via file:// and is what fontist.org can iframe or screenshot for the "what's missing" widget.

SVGs are inlined from the co-located universal-set build (when GlyphPanel#available?). When the universal set is absent, the page renders codepoint IDs only — no errors, no broken-image placeholders.

For very large missing-codepoint sets (CJK can be thousands), the page emits at most page_size thumbnails inline; an overflow notice replaces the rest.

Constant Summary collapse

DEFAULT_PAGE_SIZE =
500

Instance Method Summary collapse

Methods included from Repo::AtomicWrites

#same_content?, #to_pretty_json, #write_atomic

Constructor Details

#initialize(block_name:, missing_codepoints:, glyph_panel:, page_size: DEFAULT_PAGE_SIZE) ⇒ MissingGlyphPage

Returns a new instance of MissingGlyphPage.

Parameters:

  • block_name (String)

    Unicode block name (verbatim)

  • missing_codepoints (Array<Integer>)

    codepoints the font does not cover for this block

  • glyph_panel (GlyphPanel)

    service that reads the universal-set manifest + glyphs dir

  • page_size (Integer) (defaults to: DEFAULT_PAGE_SIZE)

    max thumbnails emitted inline



42
43
44
45
46
47
48
# File 'lib/ucode/audit/browser/missing_glyph_page.rb', line 42

def initialize(block_name:, missing_codepoints:, glyph_panel:,
               page_size: DEFAULT_PAGE_SIZE)
  @block_name = block_name
  @missing_codepoints = missing_codepoints
  @glyph_panel = glyph_panel
  @page_size = page_size
end

Instance Method Details

#renderString

Returns rendered HTML.

Returns:

  • (String)

    rendered HTML



58
59
60
61
62
63
64
65
66
67
# File 'lib/ucode/audit/browser/missing_glyph_page.rb', line 58

def render
  Template.new(:missing_glyph_page).render(
    block_name: @block_name,
    panels: panel_data,
    visible_count: visible.size,
    total_count: @missing_codepoints.size,
    overflow_count: overflow_count,
    universal_set_available: @glyph_panel.available?,
  )
end

#write(face_dir) ⇒ Boolean

Returns true if written, false if skipped (identical).

Parameters:

  • face_dir (String, Pathname)

Returns:

  • (Boolean)

    true if written, false if skipped (identical)



52
53
54
55
# File 'lib/ucode/audit/browser/missing_glyph_page.rb', line 52

def write(face_dir)
  path = Ucode::Audit::Emitter::Paths.missing_glyph_page_under(face_dir, @block_name)
  write_atomic(path, render)
end