Skip to content

Fix build in papchanges branch #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: papchanges
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 102 additions & 111 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ license = "Apache-2.0"
clap = { git = "https://github.com/MFEK/clap.rlib", branch = "master" }

# parses .glif files
#glifparser = { git = "https://github.com/MFEK/glifparser.rlib", branch = "master", features=["mfek"] }
glifparser = { path = "../glifparser.rlib", features=["mfek"] } # for development
#MFEKmath = { git = "https://github.com/MFEK/math.rlib", branch = "nibstroking" }
MFEKmath = { path = "../math.rlib", features = ["skia"]} # for development
#mfek-ipc = { git = "https://github.com/MFEK/ipc.rlib" }
mfek-ipc = { path = "../ipc.rlib" } # for development
glifparser = { git = "https://github.com/MFEK/glifparser.rlib", branch = "master", features=["mfek"] }
#glifparser = { path = "../glifparser.rlib", features=["mfek"] } # for development
MFEKmath = { git = "https://github.com/MFEK/math.rlib", features=["skia"], branch = "main" }
#MFEKmath = { path = "../math.rlib" } # for development
mfek-ipc = { git = "https://github.com/MFEK/ipc.rlib" }
#mfek-ipc = { path = "../ipc.rlib" } # for development

# For reading and writing glifs
xmltree = "0.10"
log = "0.4.11"
env_logger = "0.9"
serde_json = "1.0" # for glifjson
float-cmp = { version = "0.9.0", features = ["std"] }

# Can link FontForge as a dylib, if you have it installed. For nib stroking

#[features]
#fontforge = ["MFEKmath/fontforge"]
[features]
fontforge = ["MFEKmath/fontforge"]

[profile.release]
opt-level = 'z'
Expand Down
135 changes: 99 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,47 +93,110 @@ cargo run -- --out Untitled2.ufo/glyphs/k.low.glif --path FRBStandardCursive-Reg
### Pattern Along Path
```
MFEKstroke-PAP 0.2.1
Matthew Blanchard <[email protected]>; Fredrick R. Brennan <copypasteⒶkittens.ph>; MFEK Authors
Matthew Blanchard <[email protected]>; Fredrick R. Brennan <copypasteⒶkittens.ph>; MFEK
Authors
Maps a pattern glyph along a path glyph.

USAGE:
MFEKstroke PAP [OPTIONS] --path <path> --pattern <pattern>
MFEKstroke PAP [OPTIONS] --path <path>

OPTIONS:
-p, --pattern <pattern> The path to the input pattern file. You may also provide either --dot-pattern or
--dash-pattern to use built-in patterns.
-=, --dash-pattern Use a simple dash pattern
-., --dot-pattern Use a simple dot pattern
-P, --path <path> The path to the input path file.
-o, --output <output> The path where the output will be saved. If omitted, or `-`, stdout.


-c, --contour <contour> <isize> if this is a positive number we stroke only that specific contour in the
outline by index. [default: -1]
-m, --mode <mode> Repeat mode. [default: single] [possible values: single, repeated]
-s, --subdivide <subdivide> <usize> how many times to subdivide the patterns at their midpoint. [default: 0]


-X, --sx <sx> <f64> how much we scale our input pattern on the x-axis. [default: 1]
-Y, --sy <sy> <f64> how much we scale our input pattern on the y-axis. [default: 1]
-n, --noffset <normal-offset> <f64> how much to offset the pattern along the normal of the path. [default: 0]
-t, --toffset <tangent-offset> <f64> how much to offset the pattern along the tangent of the path. [default: 0]


-W, --spacing <spacing> <f64> how much padding to trail each copy with. [default: 0]
-!, --stretch <stretch> <stretch> false if not given, true if given, spacing mode if value of spacing
given [possible values: spacing]
-S, --simplify <boolean> if we should run the result through Skia's (buggy) simplify routine.
-O, --overdraw <overdraw> <f64> pattern copies overlapping more than arg% are removed. [default: 100%]
-Q, --one-pass <boolean> whether we should not reflow the path after culling during overdraw
(faster but worse).
-C, --no-center-pattern <boolean> supply if you wish to center the pattern
-r, --reverse <boolean> true will reverse the path.
-R, --reverse-culling <boolean> true will reverse the order we check for overlaps during overlap
culling.

-h, --help Prints help information
-V, --version Prints version information
-p, --pattern <pattern>
The path to the input pattern file. You may also provide either --dot-pattern or --dash-
pattern to use built-in patterns.

-=, --dash-pattern
Use a simple dash pattern

-w, --warp
Warp the pattern to fit the path.

-., --dot-pattern
Use a simple dot pattern

-P, --path <path>
The path to the input path file.

-o, --output <output>
The path where the output will be saved. If omitted, or `-`, stdout.



-c, --contour <contour>
<isize> if this is a positive number we stroke only that specific contour in the outline
by index. [default: -1]

-m, --mode <mode>
Repeat mode. [default: single] [possible values: single, repeated]

-s, --subdivide <subdivide>
<usize> how many times to subdivide the patterns at their midpoint. [default: 0]



-°, --subdivide-angle <subdivide_angle>
<f64> how many degrees of change in direction to subdivide the patterns at. [default: 0]


-X, --sx <sx>
<f64> how much we scale our input pattern on the x-axis. [default: 1]

-Y, --sy <sy>
<f64> how much we scale our input pattern on the y-axis. [default: 1]

-|, --split-at-discontinuity
Handle discontinuities by splitting the path.

-n, --noffset <normal-offset>
<f64> how much to offset the pattern along the normal of the path. [default: 0]

-t, --toffset <tangent-offset>
<f64> how much to offset the pattern along the tangent of the path. [default: 0]



-W, --spacing <spacing>
<f64> how much padding to trail each copy with. [default: 0]

-!, --stretch <stretch>
<stretch> false if not given, true if given, spacing mode if value of spacing given
[possible values: spacing]

-S, --simplify
<boolean> if we should run the result through Skia's (buggy) simplify routine.

-O, --remove-overlapping
Remove patterns that would overlap.

-Z, --erase-overlapping
Erase the area underneath patterns that would overlap.

-z, --erase-overlapping-stroke <erase_overlapping_stroke_width>
<float> how much we should expand the pattern when erasing overlapping patterns.

-%, --erase-overlapping-area-percent <erase_overlapping_area_percent>
<float> how much we should expand the pattern when erasing overlapping patterns.

-Q, --one-pass
<boolean> whether we should not reflow the path after culling during overdraw (faster
but worse).

-C, --no-center-pattern
<boolean> supply if you wish to center the pattern

-r, --reverse
<boolean> true will reverse the path.

-R, --reverse-culling
<boolean> true will reverse the order we check for overlaps during overlap culling.



-h, --help
Print help information

-V, --version
Print version information
```
### Variable Width Stroking
(Note: In VWS mode, it is expected that you are using MFEKglif to generate the input files. Therefore, not many helpful command line options are provided. If you wish to use VWS programatically, play with MFEKglif's VWS tool, get some output, and study it; then generate conformant XML.)
Expand Down
3 changes: 2 additions & 1 deletion src/constant_width_stroke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use glifparser::glif::contour_operations::vws::{InterpolationType, VWSHandle};

use glifparser::glif::mfek::{MFEKGlif};
use MFEKmath::variable_width_stroking::VWSSettings;

use glifparser::{Glif, Outline, PointData};

use clap::{App, AppSettings, Arg};
Expand Down Expand Up @@ -151,7 +152,7 @@ fn make_vws_contours(path: &Glif<()>, settings: &CWSSettings<()>) -> Vec<VWSCont
interpolation: InterpolationType::Linear,
};

for outline in path.outline.as_ref() {
if let Some(outline) = path.outline.as_ref() {
for (cidx, contour) in outline.iter().enumerate() {
let pointiter = contour.iter().enumerate();

Expand Down
2 changes: 1 addition & 1 deletion src/dash_along_path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use clap::{App, AppSettings, Arg, ArgMatches};
use glifparser::glif::contour_operations::{DashContour, dash::DashCull};
use glifparser::glif::contour_operations::dash::{DashContour, DashCull};
use glifparser::outline::RefigurePointTypes as _;
use MFEKmath::skia_safe::{PaintCap, PaintJoin};

Expand Down
17 changes: 12 additions & 5 deletions src/pattern_along_path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::fs;

use float_cmp::ApproxEq as _;
use float_cmp::F64Margin;
use MFEKmath::pattern_along_glif;
use glifparser::glif::contour_operations::pap::{PatternCopies, PatternStretch, PatternSubdivide};
use MFEKmath::vec2;
Expand Down Expand Up @@ -79,6 +81,7 @@ pub fn clap_app() -> clap::App<'static> {
.validator(super::arg_validator_usize)
.help("<usize> how many times to subdivide the patterns at their midpoint. [default: 0]\n\n\n"))
.arg(Arg::new("subdivide_angle")
.short('°')
.long("subdivide-angle")
.takes_value(true)
.default_value("1")
Expand All @@ -100,6 +103,7 @@ pub fn clap_app() -> clap::App<'static> {
.validator(super::arg_validator_positive_f64)
.help("<f64> how much we scale our input pattern on the y-axis."))
.arg(Arg::new("split_at_discontinuity")
.short('|')
.long("split-at-discontinuity")
.help("Handle discontinuities by splitting the path.")
)
Expand Down Expand Up @@ -146,12 +150,14 @@ pub fn clap_app() -> clap::App<'static> {
.help("Erase the area underneath patterns that would overlap."))
.arg(Arg::new("erase_overlapping_stroke_width")
.long("erase-overlapping-stroke")
.short('z')
.takes_value(true)
.default_value("5")
.hide_default_value(true)
.validator(super::arg_validator_f64)
.help("<float> how much we should expand the pattern when erasing overlapping patterns."))
.arg(Arg::new("erase_overlapping_area_percent")
.short('%')
.long("erase-overlapping-area-percent")
.takes_value(true)
.default_value("5")
Expand Down Expand Up @@ -256,10 +262,11 @@ pub fn pap_cli(matches: &clap::ArgMatches) {

if let Some(sub_angle_string) = matches.value_of("subdivide_angle") {
let n = sub_angle_string.parse::<f64>().unwrap();
settings.subdivide = match n {
0. => PatternSubdivide::Off,
_ => PatternSubdivide::Angle(n),
};
if 0.0f64.approx_eq(n, F64Margin { ulps: 2, epsilon: 0.01 }) {
settings.subdivide = PatternSubdivide::Off;
} else {
settings.subdivide = PatternSubdivide::Angle(n);
}
}

if let Some(spacing_string) = matches.value_of("spacing") {
Expand All @@ -278,7 +285,7 @@ pub fn pap_cli(matches: &clap::ArgMatches) {
settings.center_pattern = !matches.is_present("no-center-pattern");
settings.simplify = matches.is_present("simplify");

if let Some(s) = matches.value_of("remove_overlapping") {
if matches.value_of("remove_overlapping").is_some() {
settings.cull_overlap = glifparser::glif::contour_operations::pap::PatternCulling::RemoveOverlapping;
}

Expand Down
8 changes: 0 additions & 8 deletions src/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,3 @@ pub fn arg_validator_usize(v: &str) -> Result<(), String> {
Err(_) => Err(String::from("Value must be a positive integer")),
}
}

pub fn arg_validator_suffix(f: &impl Fn(&str) -> Result<(), String>, suffix: char) -> impl Fn(&str) -> Result<(), String> + '_ {
move |v| {
let len = if v.ends_with(suffix) { 1 } else { 0 };
let vlen = v.len();
f(&v[0..vlen - len - 1])
}
}
2 changes: 1 addition & 1 deletion src/variable_width_stroke.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs;

use clap::{App, Arg};
use MFEKmath::{variable_width_stroke_glif, VWSSettings};
use MFEKmath::{variable_width_stroking::{variable_width_stroke_glif, VWSSettings}};

pub fn clap_app() -> clap::App<'static> {
App::new("VWS")
Expand Down