This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{multicol} | |
\usepackage[bidi = basic]{babel} | |
\babelprovide[ | |
main, | |
import, | |
mapdigits, | |
justification=kashida, | |
transforms=kashida.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from fontParts.world import * | |
import argparse | |
""" | |
Command Line Python Script | |
- Type: Mastering | |
- Purpose: To determine the OpenType OS/2 Weight Class value for a font based on its styleName. | |
- Specifications: | |
- Parse the styleName of the font | |
- Use a predefined mapping of style names to weight classes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
RoboFont Script | |
based on: | |
https://gist.github.com/ryanbugden/a4ddf19cab034f837a51fb9d4f0db015 | |
- Type: Mastering | |
- Purpose: To fix contour direction for postscript curves (CFF/Cubic/OTF) in selected glyphs. | |
- Specifications: | |
- Sorts contours by area and clusters them into contours that contain other contours | |
- Reverses the direction of contours in clusters where the largest contour is not clockwise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fontgadgets.extensions.groups.kerning_groups import isKerningGroup | |
from ufo2ft.featureWriters import KernFeatureWriter | |
from ufo2ft.featureWriters.kernFeatureWriter import COMMON_SCRIPTS_SET, DFLT_SCRIPTS, script_direction | |
from ufo2ft.featureCompiler import parseLayoutFeatures | |
""" | |
RoboFont Script | |
- Type: Mastering | |
- Purpose: To fix the issue where fontmake skips kerning pairs: "Skipping kerning pair with mixed direction (LTR, RTL)" by splitting mixed RTL/Neutral kerning groups in a font and adding new kerning if necessary. | |
- Specifications: | |
- Parse the open type features of a font to determine the direction of each glyph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
import time | |
""" | |
based on: | |
https://pomax.github.io/bezierinfo/#tracing | |
Tracing a curve at fixed distance intervals from "A Primer on Bézier Curves" by Pomax | |
""" | |
logger = logging.getLogger('my_timer') | |
handler = logging.StreamHandler(sys.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
""" | |
based on | |
https://pomax.github.io/bezierinfo/#arclength | |
we can determine the approximate length of a Bézier curve by computing the Legendre-Gauss sum. | |
""" | |
# Gaussian quadrature coefficients | |
T = [-0.9061798459, -0.5384693101, 0, 0.5384693101, 0.9061798459] | |
C = [0.2369268850, 0.4786286705, 0.5688888889, 0.4786286705, 0.2369268850] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
from typing import Tuple | |
EPSILON = .1 | |
def forward_transform(points: Tuple[Tuple[float, float], ...], scale: float = 1) -> Tuple[float, float]: | |
p1, p2, p3, p4 = points | |
dy = p2[1] - p1[1] | |
if abs(dy) < EPSILON: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import sys | |
import time | |
logger = logging.getLogger('my_timer') | |
handler = logging.StreamHandler(sys.stdout) | |
logger.addHandler(handler) | |
def timeit(method): | |
""" | |
A decorator that makes it possible to time functions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def bezier_curve(p0, p1, p2, p3, t): | |
x = (1-t)**3 * p0[0] + 3*(1-t)**2 * t * p1[0] + 3*(1-t) * t**2 * p2[0] + t**3 * p3[0] | |
y = (1-t)**3 * p0[1] + 3*(1-t)**2 * t * p1[1] + 3*(1-t) * t**2 * p2[1] + t**3 * p3[1] | |
return (x, y) | |
def bezier_curve_derivative(p0, p1, p2, p3, t): | |
x = 3*(1-t)**2 * (p1[0] - p0[0]) + 6*(1-t) * t * (p2[0] - p1[0]) + 3*t**2 * (p3[0] - p2[0]) | |
y = 3*(1-t)**2 * (p1[1] - p0[1]) + 6*(1-t) * t * (p2[1] - p1[1]) + 3*t**2 * (p3[1] - p2[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import cmath | |
import random | |
def distance(p1: tuple, p2: tuple): | |
""" | |
Calculate the Euclidean distance between two points. | |
Args: | |
p1 (tuple): The first point as a tuple of (x, y) coordinates. |
NewerOlder