text-shaper 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare const env: NodeJS.ProcessEnv | undefined;
@@ -15,6 +15,10 @@ export interface HintingEngine {
15
15
  ctx: ExecContext;
16
16
  /** Units per EM from font */
17
17
  unitsPerEM: number;
18
+ /** Original CVT values in font units */
19
+ cvtOriginal?: Int32Array;
20
+ /** Scaled CVT baseline after prep */
21
+ cvtBase?: Int32Array;
18
22
  /** Has fpgm been executed */
19
23
  fpgmExecuted: boolean;
20
24
  /** Current ppem (prep needs re-run if this changes) */
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Fixed-point scaling helpers (match FreeType rounding behavior).
3
+ */
4
+ export declare function mulFix(value: number, scaleFix: number): number;
5
+ export declare function divFix(value: number, divisor: number): number;
6
+ export declare function scaleFUnits(value: number, scaleFix: number): number;
@@ -42,9 +42,9 @@ export declare enum RoundMode {
42
42
  * Touch flags for points
43
43
  */
44
44
  export declare enum TouchFlag {
45
- X = 1,
46
- Y = 2,
47
- Both = 3
45
+ X = 16,
46
+ Y = 32,
47
+ Both = 48
48
48
  }
49
49
  /**
50
50
  * Glyph zone - holds glyph points
@@ -189,6 +189,7 @@ export interface ExecContext {
189
189
  ppem: number;
190
190
  pointSize: number;
191
191
  scale: number;
192
+ scaleFix: number;
192
193
  error: string | null;
193
194
  instructionCount: number;
194
195
  maxInstructions: number;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { processContextual, processInsertion, processLigature, processRearrangement, } from "./aat/state-machine.ts";
2
+ export { execute, runCVTProgram, runFontProgram, runGlyphProgram, runProgram, setCodeRange, createHintingEngine, executeFontProgram, type GlyphOutline, type HintedGlyph, type HintingEngine, hintedToPixels, hintGlyph, loadCVTProgram, loadFontProgram, setSize, compensate, parseSuperRound, round, roundDownToGrid, roundOff, roundSuper, roundSuper45, roundToDoubleGrid, roundToGrid, roundToHalfGrid, roundUpToGrid, type CallRecord, CodeRange, createDefaultGraphicsState, createExecContext, createGlyphZone, type ExecContext, type F2Dot14, type F26Dot6, type FunctionDef, type GlyphZone, type GraphicsState, type InstructionDef, Opcode, type Point as HintingPoint, RoundMode, TouchFlag, type UnitVector, } from "./hinting/index.ts";
2
3
  export { GlyphBuffer } from "./buffer/glyph-buffer.ts";
3
4
  export { UnicodeBuffer } from "./buffer/unicode-buffer.ts";
4
5
  export { adaptiveBlur as $adaptiveBlur, BitmapBuilder, bitmap, blur as $blur, boxBlur as $boxBlur, cascadeBlur as $cascadeBlur, char, clone as $clone, combine, combinePaths as $combinePaths, condensePath as $condensePath, convert as $convert, copy as $copy, embolden as $embolden, emboldenPath as $emboldenPath, fastBlur as $fastBlur, fromGlyph as $fromGlyph, glyph, glyphVar, italic as $italic, matrix as $matrix, obliquePath as $obliquePath, PathBuilder, pad as $pad, path, perspective as $perspective, pipe, rasterize as $rasterize, rasterizeAuto as $rasterizeAuto, rasterizeWithGradient as $rasterizeWithGradient, renderMsdf as $renderMsdf, renderSdf as $renderSdf, resize as $resize, resizeBilinear as $resizeBilinear, rotate as $rotate, rotateDeg as $rotateDeg, scale as $scale, shear as $shear, shift as $shift, strokeAsymmetric as $strokeAsymmetric, strokeAsymmetricCombined as $strokeAsymmetricCombined, strokePath as $strokePath, toGray as $toGray, toRGBA as $toRGBA, toSVG as $toSVG, translate as $translate, } from "./fluent/index.ts";
@@ -8,24 +9,34 @@ export { createFace, Face } from "./font/face.ts";
8
9
  export { Font, type FontLoadOptions } from "./font/font.ts";
9
10
  export type { AvarTable, AxisSegmentMap } from "./font/tables/avar.ts";
10
11
  export { applyAvar, applyAvarMapping } from "./font/tables/avar.ts";
12
+ export type { AxisTable as BaseAxisTable, BaselineValue, BaseScriptRecord, BaseTable, BaseValues, FeatMinMaxRecord, MinMax, MinMaxRecord, } from "./font/tables/base.ts";
13
+ export { BaselineTag, getBaselineForScript, getDefaultBaseline, getMinMaxExtent, parseBase, } from "./font/tables/base.ts";
11
14
  export type { BitmapGlyph, BitmapSize, CbdtTable, CblcTable, GlyphBitmapMetrics, IndexSubTable, SbitLineMetrics, } from "./font/tables/cbdt.ts";
12
15
  export { CbdtImageFormat, getBitmapGlyph, getColorBitmapSizes, hasColorBitmap, } from "./font/tables/cbdt.ts";
13
16
  export { executeCff2CharString, executeCffCharString, getCffGlyphWidth, } from "./font/tables/cff-charstring.ts";
17
+ export type { CffTable, FDDict, FDSelect, PrivateDict, TopDict, } from "./font/tables/cff.ts";
18
+ export { getCffString, parseCff } from "./font/tables/cff.ts";
19
+ export type { Cff2FDDict, Cff2FDSelect, Cff2PrivateDict, Cff2Table, Cff2TopDict, ItemVariationData as Cff2ItemVariationData, ItemVariationStore as Cff2ItemVariationStore, RegionAxisCoordinates as Cff2RegionAxisCoordinates, VariationRegion as Cff2VariationRegion, VariationRegionList, } from "./font/tables/cff2.ts";
20
+ export { calculateVariationDelta, parseCff2 } from "./font/tables/cff2.ts";
14
21
  export type { CmapTable } from "./font/tables/cmap.ts";
15
22
  export type { Affine2x3, BaseGlyphPaintRecord, BaseGlyphRecord, ClipBox, ClipRecord, ColorLine, ColorStop, ColrTable, ItemVariationData, ItemVariationStore, LayerRecord, Paint, PaintColrGlyph, PaintColrLayers, PaintComposite, PaintGlyph, PaintLinearGradient, PaintRadialGradient, PaintRotate, PaintScale, PaintSkew, PaintSolid, PaintSweepGradient, PaintTransform, PaintTranslate, RegionAxisCoordinates, VarColorLine, VarColorStop, VariationRegion, } from "./font/tables/colr.ts";
16
23
  export { CompositeMode, Extend, getClipBox, getColorLayers, getColorPaint, getColorVariationDelta, getLayerPaint, hasColorGlyph, isColrV1, PaintFormat, parseColr, } from "./font/tables/colr.ts";
17
24
  export type { Color, ColorPalette, CpalTable } from "./font/tables/cpal.ts";
18
25
  export { colorToHex, colorToRgba, getColor, PaletteType, parseCpal, } from "./font/tables/cpal.ts";
19
- export type { FeatTable, FeatureRecord, FeatureSetting, } from "./font/tables/feat.ts";
20
- export { aatToOpenTypeTag, CaseSensitiveLayoutSetting, CharacterShapeSetting, ContextualAlternativesSetting, DiacriticsSetting, FeatureFlags, FeatureType, FractionsSetting, getAllFeatures, getDefaultSetting, getFeature, getSettingByValue, hasSettingValue, isExclusiveFeature, LigatureSetting, LowerCaseSetting, NumberCaseSetting, NumberSpacingSetting, openTypeTagToAat, parseFeat, SmartSwashSetting, StylisticAlternativesSetting, UpperCaseSetting, VerticalPositionSetting, } from "./font/tables/feat.ts";
26
+ export type { FeatTable, FeatureRecord as AatFeatureRecord, FeatureSetting, } from "./font/tables/feat.ts";
27
+ export { aatToOpenTypeTag, CaseSensitiveLayoutSetting, CharacterShapeSetting, ContextualAlternativesSetting, DiacriticsSetting, FeatureFlags, FeatureType, FractionsSetting, getAllFeatures, getDefaultSetting, getFeature as getAatFeature, getSettingByValue, hasSettingValue, isExclusiveFeature, LigatureSetting, LowerCaseSetting, NumberCaseSetting, NumberSpacingSetting, openTypeTagToAat, parseFeat, SmartSwashSetting, StylisticAlternativesSetting, UpperCaseSetting, VerticalPositionSetting, } from "./font/tables/feat.ts";
21
28
  export type { FvarTable, NamedInstance, VariationAxis, } from "./font/tables/fvar.ts";
22
29
  export { normalizeAxisValue } from "./font/tables/fvar.ts";
30
+ export type { GaspRange, GaspTable } from "./font/tables/gasp.ts";
31
+ export { GaspFlag, getGaspBehavior, parseGasp, shouldDoGray, shouldGridFit, } from "./font/tables/gasp.ts";
23
32
  export type { GdefTable } from "./font/tables/gdef.ts";
24
33
  export type { CompositeGlyph, Contour, Glyph, GlyphPoint, SimpleGlyph, } from "./font/tables/glyf.ts";
25
34
  export type { GposTable } from "./font/tables/gpos.ts";
26
35
  export type { GsubTable } from "./font/tables/gsub.ts";
27
36
  export type { GlyphVariationData, GvarTable, TupleVariationHeader, } from "./font/tables/gvar.ts";
28
37
  export { calculateTupleScalar, getGlyphDelta } from "./font/tables/gvar.ts";
38
+ export type { CvtTable, FpgmTable, PrepTable, } from "./font/tables/hinting.ts";
39
+ export { parseCvt, parseFpgm, parsePrep } from "./font/tables/hinting.ts";
29
40
  export type { HeadTable } from "./font/tables/head.ts";
30
41
  export type { HheaTable } from "./font/tables/hhea.ts";
31
42
  export type { HmtxTable } from "./font/tables/hmtx.ts";
@@ -38,16 +49,28 @@ export { getKerxValue } from "./font/tables/kerx.ts";
38
49
  export type { LocaTable } from "./font/tables/loca.ts";
39
50
  export { getGlyphLocation, hasGlyphOutline } from "./font/tables/loca.ts";
40
51
  export type { MaxpTable } from "./font/tables/maxp.ts";
52
+ export type { ExtendedShapeCoverage, GlyphAssembly, GlyphPartRecord, MathConstants, MathGlyphConstruction, MathGlyphInfo, MathItalicsCorrection, MathKernInfo, MathKernInfoTable, MathKernRecord, MathTable, MathTopAccentAttachment, MathValueRecord, MathVariants, } from "./font/tables/math.ts";
53
+ export { getHorizontalAssembly, getHorizontalVariants, getItalicsCorrection, getTopAccentAttachment, getVerticalAssembly, getVerticalVariants, isExtendedShape, parseMath, } from "./font/tables/math.ts";
41
54
  export type { MorxChain, MorxSubtable, MorxTable } from "./font/tables/morx.ts";
42
55
  export { applyNonContextual, MorxSubtableType } from "./font/tables/morx.ts";
43
56
  export type { MvarTable, MvarValueRecord } from "./font/tables/mvar.ts";
44
57
  export { getCapHeightDelta, getHAscenderDelta, getHDescenderDelta, getMetricDelta, getXHeightDelta, MvarTags, } from "./font/tables/mvar.ts";
58
+ export type { NameRecord, NameTable } from "./font/tables/name.ts";
59
+ export { getFontFamily, getFontSubfamily, getFullName, getNameById, getPostScriptName, getVersion, NameId, parseName, PlatformId, WindowsEncodingId, } from "./font/tables/name.ts";
60
+ export type { Os2Table } from "./font/tables/os2.ts";
61
+ export { FsSelection, FsType, getEmbeddingPermission, isBold, isItalic, parseOs2, useTypoMetrics, WeightClass, WidthClass, } from "./font/tables/os2.ts";
62
+ export type { PostTable } from "./font/tables/post.ts";
63
+ export { getGlyphName, isMonospaced, parsePost } from "./font/tables/post.ts";
45
64
  export type { SbixGlyph, SbixStrike, SbixTable } from "./font/tables/sbix.ts";
46
65
  export { getAvailablePpemSizes, getGlyphBitmap as getSbixGlyphBitmap, getStrikeForPpem, hasGlyphBitmap, resolveDupeGlyph, SbixGraphicType, } from "./font/tables/sbix.ts";
47
66
  export type { AxisRecord, AxisValue, AxisValueFormat1, AxisValueFormat2, AxisValueFormat3, AxisValueFormat4, StatTable, } from "./font/tables/stat.ts";
48
67
  export { AxisValueFlags, findAxisValueByNameId, getAxisIndex, getAxisRecord, getAxisValueNumber, getAxisValuesForAxis, isElidableAxisValue, isOlderSiblingFont, matchAxisValue, } from "./font/tables/stat.ts";
49
68
  export type { SvgDocumentRecord, SvgTable } from "./font/tables/svg.ts";
50
69
  export { getSvgDocument, getSvgGlyphIds, hasSvgGlyph, } from "./font/tables/svg.ts";
70
+ export type { JstfLangSys, JstfMax, JstfModList, JstfPriorityRecord, JstfScriptRecord, JstfTable, } from "./font/tables/jstf.ts";
71
+ export { getExtenderGlyphs, getExtensionMods, getJstfPriorities, getShrinkageMods, JstfPriority, parseJstf, } from "./font/tables/jstf.ts";
72
+ export type { FontDirectory } from "./font/tables/sfnt.ts";
73
+ export { isCFF, isTrueType, parseFontDirectory, } from "./font/tables/sfnt.ts";
51
74
  export type { TrackData, TrakTable } from "./font/tables/trak.ts";
52
75
  export { applyTracking, getTrackingValue } from "./font/tables/trak.ts";
53
76
  export type { VheaTable } from "./font/tables/vhea.ts";
@@ -59,19 +82,28 @@ export type { VvarTable } from "./font/tables/vvar.ts";
59
82
  export { getAdvanceHeightDelta, getBsbDelta, getTsbDelta, getVorgDelta, } from "./font/tables/vvar.ts";
60
83
  export type { JustifyAdjustment, JustifyOptions, JustifyResult, LineBreakResult, } from "./layout/justify.ts";
61
84
  export { breakIntoLines, calculateLineWidth, JustifyMode, justify, justifyParagraph, } from "./layout/justify.ts";
62
- export type { ClassDef } from "./layout/structures/class-def.ts";
63
- export type { Coverage } from "./layout/structures/coverage.ts";
85
+ export { ClassDef } from "./layout/structures/class-def.ts";
86
+ export { EMPTY_CLASS_DEF, parseClassDef, parseClassDefAt, } from "./layout/structures/class-def.ts";
87
+ export { Coverage } from "./layout/structures/coverage.ts";
88
+ export { parseCoverage, parseCoverageAt } from "./layout/structures/coverage.ts";
64
89
  export type { DeviceOrVariationIndex, DeviceTable, VariationIndexTable, } from "./layout/structures/device.ts";
65
90
  export { applyDeviceAdjustment, getDeviceDelta, isVariationIndexTable, } from "./layout/structures/device.ts";
66
91
  export type { Condition, ConditionSet, FeatureVariationRecord, FeatureVariations, } from "./layout/structures/feature-variations.ts";
67
92
  export { applyFeatureVariations, evaluateConditionSet, findMatchingFeatureVariation, getSubstitutedLookups, } from "./layout/structures/feature-variations.ts";
93
+ export type { Feature, FeatureList, FeatureRecord, LangSys, LangSysRecord, LookupHeader, Script as LayoutScript, ScriptList, ScriptRecord, } from "./layout/structures/layout-common.ts";
94
+ export { findLangSys, findScript, getFeature, getMarkAttachmentType, LookupFlag, parseFeatureList, parseLookupHeaders, parseScriptList, } from "./layout/structures/layout-common.ts";
95
+ export { createLookupDigest, SetDigest } from "./layout/structures/set-digest.ts";
68
96
  export { type AsymmetricStrokeOptions, strokeAsymmetric, strokeAsymmetricCombined, strokeUniform, } from "./raster/asymmetric-stroke.ts";
69
97
  export { atlasToAlpha, atlasToRGBA, buildAsciiAtlas, buildAtlas, buildStringAtlas, getGlyphUV, } from "./raster/atlas.ts";
70
98
  export { getExactBounds } from "./raster/bbox.ts";
99
+ export { abs, ceilPixel, clamp, divFix, downscale, f26Dot6ToFloat, F16DOT16_ONE, F16DOT16_SHIFT, F26DOT6_ONE, F26DOT6_SHIFT, floatToF26Dot6, floatToPixel, floorPixel, fracPixel, hypot, mulDiv, mulFix, normalizeVector, ONE_PIXEL, PIXEL_BITS, PIXEL_MASK, roundPixel, sign, truncPixel, upscale, vectorLength, } from "./raster/fixed-point.ts";
100
+ export type { ValidationResult } from "./raster/outline-decompose.ts";
101
+ export { decomposePath, getFillRuleFromFlags, getPathBounds, OutlineError, validateOutline, } from "./raster/outline-decompose.ts";
71
102
  export { addBitmaps, blendBitmap, compositeBitmaps, convertBitmap, copyBitmap, emboldenBitmap, expandToFit, fixOutline, maxBitmaps, mulBitmaps, padBitmap, resizeBitmap, resizeBitmapBilinear, shiftBitmap, subBitmaps, } from "./raster/bitmap-utils.ts";
72
103
  export { blurBitmap, boxBlur, createGaussianKernel, gaussianBlur, } from "./raster/blur.ts";
73
104
  export { adaptiveBlur, cascadeBlur, fastGaussianBlur, } from "./raster/cascade-blur.ts";
74
105
  export { type ColorStop as GradientColorStop, createGradientBitmap, type Gradient, interpolateGradient, type LinearGradient, type RadialGradient, rasterizePathWithGradient, } from "./raster/gradient.ts";
106
+ export { LCD_FILTER_DEFAULT, LCD_FILTER_LEGACY, LCD_FILTER_LIGHT, lcdToRGBA, LcdMode, rasterizeLcd, } from "./raster/lcd-filter.ts";
75
107
  export { assignEdgeColors, buildMsdfAsciiAtlas, buildMsdfAtlas, buildMsdfStringAtlas, type MsdfEdge, type MsdfOptions, median, msdfAtlasToRGB, msdfAtlasToRGBA, type Point as MsdfPoint, renderMsdf, type SignedDistanceResult, signedDistanceToCubic, signedDistanceToLine, signedDistanceToQuadratic, } from "./raster/msdf.ts";
76
108
  export { bitmapToGray, bitmapToRGBA, rasterizeGlyph, rasterizePath, rasterizeText, } from "./raster/rasterize.ts";
77
109
  export { renderSdf, type SdfOptions } from "./raster/sdf.ts";