@biolab/talk-to-figma 0.5.0 → 0.7.0

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.
@@ -743,6 +743,110 @@ server.tool(
743
743
  }
744
744
  }
745
745
  );
746
+ server.tool(
747
+ "set_font_family",
748
+ "Set the font family of an existing text node in Figma",
749
+ {
750
+ nodeId: z.string().describe("The ID of the text node to modify"),
751
+ fontFamily: z.string().describe("Font family name (e.g. 'Inter', 'Roboto', 'Arial')"),
752
+ fontStyle: z.string().optional().describe("Font style (e.g. 'Regular', 'Bold', 'Italic'). Defaults to 'Regular'")
753
+ },
754
+ async ({ nodeId, fontFamily, fontStyle }) => {
755
+ try {
756
+ const result = await sendCommandToFigma("set_font_family", {
757
+ nodeId,
758
+ fontFamily,
759
+ fontStyle: fontStyle || "Regular"
760
+ });
761
+ const typedResult = result;
762
+ return {
763
+ content: [
764
+ {
765
+ type: "text",
766
+ text: `Updated font family of node "${typedResult.name}" to "${typedResult.fontName.family} ${typedResult.fontName.style}"`
767
+ }
768
+ ]
769
+ };
770
+ } catch (error) {
771
+ return {
772
+ content: [
773
+ {
774
+ type: "text",
775
+ text: `Error setting font family: ${error instanceof Error ? error.message : String(error)}`
776
+ }
777
+ ]
778
+ };
779
+ }
780
+ }
781
+ );
782
+ server.tool(
783
+ "set_font_size",
784
+ "Set the font size of an existing text node in Figma",
785
+ {
786
+ nodeId: z.string().describe("The ID of the text node to modify"),
787
+ fontSize: z.number().min(1).describe("Font size in pixels")
788
+ },
789
+ async ({ nodeId, fontSize }) => {
790
+ try {
791
+ const result = await sendCommandToFigma("set_font_size", {
792
+ nodeId,
793
+ fontSize
794
+ });
795
+ const typedResult = result;
796
+ return {
797
+ content: [
798
+ {
799
+ type: "text",
800
+ text: `Updated font size of node "${typedResult.name}" to ${typedResult.fontSize}px`
801
+ }
802
+ ]
803
+ };
804
+ } catch (error) {
805
+ return {
806
+ content: [
807
+ {
808
+ type: "text",
809
+ text: `Error setting font size: ${error instanceof Error ? error.message : String(error)}`
810
+ }
811
+ ]
812
+ };
813
+ }
814
+ }
815
+ );
816
+ server.tool(
817
+ "set_font_weight",
818
+ "Set the font weight of an existing text node in Figma. Maps numeric weight to font style (100=Thin, 300=Light, 400=Regular, 500=Medium, 600=Semi Bold, 700=Bold, 800=Extra Bold, 900=Black)",
819
+ {
820
+ nodeId: z.string().describe("The ID of the text node to modify"),
821
+ fontWeight: z.number().min(100).max(900).describe("Font weight (100-900)")
822
+ },
823
+ async ({ nodeId, fontWeight }) => {
824
+ try {
825
+ const result = await sendCommandToFigma("set_font_weight", {
826
+ nodeId,
827
+ fontWeight
828
+ });
829
+ const typedResult = result;
830
+ return {
831
+ content: [
832
+ {
833
+ type: "text",
834
+ text: `Updated font weight of node "${typedResult.name}" to ${fontWeight} (${typedResult.fontName.style})`
835
+ }
836
+ ]
837
+ };
838
+ } catch (error) {
839
+ return {
840
+ content: [
841
+ {
842
+ type: "text",
843
+ text: `Error setting font weight: ${error instanceof Error ? error.message : String(error)}`
844
+ }
845
+ ]
846
+ };
847
+ }
848
+ }
849
+ );
746
850
  server.tool(
747
851
  "get_styles",
748
852
  "Get all styles from the current Figma document",