The Shulchan Aruch · Orach Chayim
אורח חיים ל״וOrach Chayim 36
Siman 36 of 697 in Orach Chayim — 3 se'ifim
הלכות תפיליןLaws of Tefillin· siman 36
Se’if 1א׳
צָרִיךְ לְדַקְדֵּק בִּכְתִיבַת הָאוֹתִיּוֹת שֶׁלֹּא תִּשְׁתַּנֶּה צוּרַת שׁוּם אַחַת מֵהֶן וְלֹא תִּדְמֶה לְאַחֶרֶת. הַגָּה: וּלְכַתְּחִלָּה יִכְתֹּב בִּכְתִיבָה תַּמָּה כַּמְבֹאָר בַּטּוּר וּבִשְׁאָר פּוֹסְקִים, וְהוּא יָדוּעַ אֵצֶל הַסּוֹפְרִים מִיהוּ אִם שִׁנָּה בְּצוּרַת הַכְּתָב אֵינוֹ פָּסוּל.
One must be precise in the writing of the letters such that no letter's shape should change and no letter should resemble another. Rema: "And in the first place, [the scribe] should write in [a style known as] "ketivah tamah" as elaborated in the Tur and other halachic authorities and it [this style] is known amongst the scribes. In any case, if he changed the style of lettering he did not invalidate the tefillin."
Se’if 2ב׳
כָּל אוֹת צְרִיכָה לִהְיוֹת גֹּלֶם אֶחָד, לְכָךְ צָרִיךְ לִזָּהֵר בַּנְּקֻדָּה שֶׁעַל הָאֶלֶף שֶׁהִיא כְּמִין יוֹד, וּבַנְּקֻדָּה שֶׁתַּחְתֶּיהָ וּבְיוֹדֵ"י הַשִּׁי"ן וְעַיִ"ן וַאֲחוֹרֵי צַדִּ"י שֶׁיְּהוּ נוֹגְעוֹת בָּאוֹת, וּבְאַחַת שֶׁאֵינָהּ נוֹגַעַת פְּסוּלִין. וְכֵן בִּשְׁאָר אוֹתִיּוֹת, חוּץ מֵהֵ " א וְקוֹ"ף שֶׁאֵין לִגֹּעַ הָרֶגֶל בַּגַּג, וְאִם נָגַע פָּסוּל.
Every letter needs to be a unified entity; therefore one must be cautious with the dot that is upon the Alef, which is shaped as a Yud, and the dot underneath the Alef, and with the Yuds of the Shin and Ayin and back of the Tzadi that they [the dots shaped as Yuds] should touch [the rest of] the letter. In a case where the Yud doesn't touch [the rest of the letter] the tefillin are void. And likewise for the other letters [- they must be unified without disconnected parts], other than Hea and Kof where the leg [of the letter] shouldn't touch the roof. If it did touch, that is void.
Se’if 3ג׳
צָרִיךְ לְתַיֵּג שַׁעַטְנֵ"ז גֵּ"ץ וְהַסוֹפְרִים נָהֲגוּ לְתַיֵּג אוֹתִיּוֹת אֲחֵרוֹת, וְאִם לֹא תִּיֵּג אֲפִלּוּ שַׁעַטְנֵ"ז גֵּ"ץ לֹא פָּסַל:
One must add the appropriate tags [lines ending with round dots] upon the letters that make the acronym SHATNEZ GETZ [Shin, Ayin, Tet, Nun, Zayin, Gimmel, Tzadi]. And the scribes customarily tagged other letters [as well]. If the scribe did not tag even SHATNEZ GETZ, he did not void the tefillin.
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0