@connectedxm/zpl-generator 0.0.14 → 0.0.17

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.
@@ -4,6 +4,15 @@ export declare function generate(badge: Badge, data?: SourceData, overrides?: {
4
4
  [key: string]: string;
5
5
  }): string;
6
6
  export declare function getFieldValue(field: Field, data?: SourceData): string | undefined;
7
+ /**
8
+ * Counts how many lines the field data will occupy inside a ^FB field at
9
+ * a given font height. The field's own `fontHeight` is treated as the
10
+ * reference at which `measuredWidth` and `charsPerLine` were captured.
11
+ *
12
+ * Width scales linearly with height: at half the height, each glyph is
13
+ * roughly half as wide, so twice as many characters fit per line.
14
+ */
15
+ export declare function countLinesAtHeight(field: TextField, value: string, height: number): number;
7
16
  /**
8
17
  * Counts how many lines the field data will occupy inside a ^FB field.
9
18
  * Exported so consuming projects (e.g. React label previews) can reuse
@@ -15,3 +24,10 @@ export declare function getFieldValue(field: Field, data?: SourceData): string |
15
24
  * Otherwise falls back to a character-width heuristic using charsPerLine.
16
25
  */
17
26
  export declare function countLines(field: TextField, value: string): number;
27
+ /**
28
+ * Returns the largest font height ≤ `field.fontHeight` (and ≥
29
+ * `field.minFontHeight ?? 1`) at which the rendered text fits within
30
+ * `field.maxLines`. If even the minimum height cannot make the text fit,
31
+ * returns the minimum (text will overflow at the smallest allowed size).
32
+ */
33
+ export declare function calculateFittedFontHeight(field: TextField, value: string): number;
@@ -273,6 +273,7 @@ export declare const textFieldSchema: z.ZodObject<{
273
273
  }>;
274
274
  maxCharacters: z.ZodNumber;
275
275
  measuredWidth: z.ZodOptional<z.ZodNumber>;
276
+ minFontHeight: z.ZodOptional<z.ZodNumber>;
276
277
  }, z.core.$strip>;
277
278
  export type TextField = z.infer<typeof textFieldSchema>;
278
279
  export declare const barcodeFieldSchema: z.ZodObject<{
@@ -427,6 +428,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
427
428
  }>;
428
429
  maxCharacters: z.ZodNumber;
429
430
  measuredWidth: z.ZodOptional<z.ZodNumber>;
431
+ minFontHeight: z.ZodOptional<z.ZodNumber>;
430
432
  }, z.core.$strip>, z.ZodObject<{
431
433
  name: z.ZodString;
432
434
  x: z.ZodNumber;
@@ -682,6 +684,7 @@ export declare const badgeSchema: z.ZodObject<{
682
684
  }>;
683
685
  maxCharacters: z.ZodNumber;
684
686
  measuredWidth: z.ZodOptional<z.ZodNumber>;
687
+ minFontHeight: z.ZodOptional<z.ZodNumber>;
685
688
  }, z.core.$strip>, z.ZodObject<{
686
689
  name: z.ZodString;
687
690
  x: z.ZodNumber;
@@ -864,6 +867,7 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
864
867
  transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
865
868
  maxCharacters: number;
866
869
  measuredWidth?: number | undefined;
870
+ minFontHeight?: number | undefined;
867
871
  } | {
868
872
  name: string;
869
873
  x: number;
@@ -971,6 +975,7 @@ export declare function validateBadgeOrThrow(data: Badge): {
971
975
  transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
972
976
  maxCharacters: number;
973
977
  measuredWidth?: number | undefined;
978
+ minFontHeight?: number | undefined;
974
979
  } | {
975
980
  name: string;
976
981
  x: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/zpl-generator",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",