Skip to content

typerig.proxy.fl.objects.cjk · declarations 001

Back to typerig.proxy.fl.objects.cjk

GAUGE_KEYS module-attribute

GAUGE_KEYS

STD_STEMS_LIB_KEY module-attribute

STD_STEMS_LIB_KEY

capture_face_frames

capture_face_frames(pg, layers)

Snapshot per-master face (ink) bounds: {layer_name: (left,bottom,right,top)}. Call this BEFORE deleting parts — it is the pre-deletion latch the region paste places against. Returns None if no layer had ink.

compute_gauges

compute_gauges(geo, S=48, y_weight=1.05)

Normalized gauge vector for one Geometry via the Qt raster + pure math.

frame_for

frame_for(package, layer_name, advance, upm)

Em-square band in font units: x across the advance, y descender..ascender.

Reads the active layer's master vertical metrics via FontMetrics(package, layer_name) - no setMaster, so the edit is undisturbed, and correct when the active layer differs from the active master. Falls back to the package's current master, then UPM-derived defaults. Returns (left, bottom, right, top).

geometry_of

geometry_of(pg, layer)

Build a Geometry from a given pGlyph + flLayer. Shared by the panel, the batch runners and commands.

get_geometry

get_geometry()

Current glyph / active layer -> Geometry, or None when nothing to probe.

Goes through TypeRig's pGlyph proxy: fl6.CurrentGlyph() returns an fgGlyph (fontgate) which has no getContours(); pGlyph builds the real flGlyph and the active flLayer. The extraction itself is in geometry_of() so batch runners and commands can reuse it on arbitrary glyphs/layers.

layer_ink_bounds

layer_ink_bounds(pg, layer_name)

(left, bottom, right, top) of a layer's ink, or None if empty.

Reads geometry via flLayer.getContours() (resolves shapes/components across masters); pGlyph.contours(name) can come back empty for non-active, component-built masters — which would make those masters miss the face.

measure_part_stems

measure_part_stems(tr_glyph, pg, axis_layers, fallback_stems=None, tol_frac=0.2, snap=True)

Per-master (stx, sty) stems for a paste part, measured from its OWN contours.

tr_glyph : typerig.core Glyph (the part being pasted). pg : the target pGlyph (for per-master ps_stems). axis_layers : master/layer names of the delta axis. fallback_stems : {layer: (stx, sty)} used when detection finds nothing (e.g. the global Virtual-Axis lib values). snap : when True, each master's measurement is snapped to that master's own PostScript hinting stems (so an off-grid value lands on a real stem); False = raw medians.

Returns {layer: (stx, sty)} — only layers where a full pair could be formed.

measure_split

measure_split(pg, layer, idc, S=64)

Measured ⿰/⿱ split of one glyph/layer as a face fraction, or None. idc must be '⿰' or '⿱'. Thin wrapper: geometry -> raster -> boundary_ratio.

part_stem_candidates

part_stem_candidates(tr_glyph, layers)

Diagnostics: {layer: (v_widths, h_widths)} raw stem-candidate widths that the detector found per master — inspect these when auto-stems looks off.

rasterize

rasterize(path, frame, S)

Antialiased raster of a QPainterPath over the em-square frame.

path : QtGui.QPainterPath in font units (WindingFill). frame : (x0, y0, x1, y1) font-space band mapped onto the S x S image. S : raster edge length (32..64).

returns flat list[float] of length S*S, ink = 255 - gray, row-major with the TOP image row first — the identical contract as typerig.core.algo.cjk.rasterize_contours, so bands/zones stay portable between the two rasterizers. All-zeros for an empty path or degenerate frame.

read_std_stems_by_layer

read_std_stems_by_layer(pg, layers, lib_key=STD_STEMS_LIB_KEY)

Per-master standard hinting stems as {layer_name: [(value, 'V'|'H'), ...]}.

Source order: 1. a font-lib mirror under lib_key ({master: {'H':[..],'V':[..]}}) — clean, no master switching; 2. else per-master flPackage.ps_stemsV / ps_stemsH read via setMaster (the same per-master access TypeRig's metric getters use), restored afterwards. Layers with no stems are omitted; returns {} if nothing is available.

region_bounds

region_bounds(pg, layers, frac_for_layer, captured_faces=None, use_face=True, upm=None, default_face=None, margin=None)

Per-master target Bounds for an IDC-region paste — one entry per layer.

frac_for_layer : callable(layer_name) -> (fx0,fy0,fx1,fy1) y-UP slot fraction, or None to skip the layer. Lets the caller apply a per-master measured split. captured_faces : {layer_name: (l,b,r,t)} pre-deletion snapshot; a layer that is absent (or whose face is degenerate) falls back per the chain below. default_face : a face rect used for masters lacking their own (e.g. the active layer's face — "a wrong face beats no face"). margin : imaginary-face inset (0..1 of the em) when nothing is measured. use_face : when False, always use the em band.

Per master the reference frame is: own captured face -> default_face -> imaginary (em inset by margin) -> em band (cjk.reference_frame). NEVER a live face of the glyph under construction. Returns {layer_name: Bounds} (eNodesContainer bounds — the same type the node-selection paste path produces, so downstream fit/align/flip are untouched).

run_family_bands

run_family_bands(layer=None, names=None, S=48, max_outliers=20, progress_every=500)

Compute family mean/sd bands for the current font (was batch_stats.run).

layer - master/layer name (str) or None for each glyph's active layer. names - iterable of glyph names to restrict to, or None for all glyphs. Writes -balance-bands.json beside the font and returns its path.

run_idc_zones

run_idc_zones(idc_lookup, layer=None, names=None, S=64, progress_every=500)

Measure structural ⿰/⿱ split zones for the current font (was idc_zones.run).

idc_lookup(pglyph, glyph_name) -> top-level IDC char or None. This is the ONLY seam to the caller's IDS/CHISE database; this module stays free of it. Return any IDC in cjk.IDC_SET; only ⿰/⿱ are measured (others are counted for coverage).

layer - master/layer name (str) or None for each glyph's active layer. names - iterable of glyph names to restrict to, or None for all glyphs. Writes -idc-zones.json beside the font and returns its path.