Skip to content

Commit

Permalink
first public issue of fontforge-of-ocaml library under license LGPL 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pbaudin committed Apr 4, 2022
0 parents commit 764c120
Show file tree
Hide file tree
Showing 29 changed files with 6,600 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/_build/
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## v1.1.0

### First public release
15 changes: 15 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# License of fontforge-of-ocaml library #

The [fontforge-of-ocaml](https://github.com/pbaudin/[fontforge-of-ocaml) library is published under the license [LGPL v2.1](https://spdx.org/licenses/LGPL-2.1-only.html).

About this library,
you can redistribute it and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software
Foundation, version 2.1.

It is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.

See the GNU Lesser General Public License version 2.1
for more details (enclosed in the file [licenses/LGPLv2.1](licenses/LGPLv2.1))
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
##############################################################################
# #
# This file is part of fontforge-of-ocaml library #
# #
# Copyright (C) 2017-2022, Patrick BAUDIN #
# (https://github.com/pbaudin/fontforge-of-ocaml) #
# #
# you can redistribute it and/or modify it under the terms of the GNU #
# Lesser General Public License as published by the Free Software #
# Foundation, version 2.1. #
# #
# It is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. #
# #
# See the GNU Lesser General Public License version 2.1 #
# for more details (enclosed in the file licenses/LGPLv2.1) #
# #
##############################################################################

.PHONY: all build clean

PACKAGE=fontforge-of-ocaml

all: $(PACKAGE).opam build

build:
dune build @install

$(PACKAGE).opam: $(PACKAGE).opam.template dune-project
rm -f $@
dune build $@

PHONY: clean
clean:
rm -fr _build

##############################################################################

.PHONY: tests
tests:
dune build @runtest

##############################################################################

.PHONY: install uninstall

FFOO_INSTALLDIR?=""

install:
ifeq ($(FFOO_INSTALLDIR),"")
dune install
else
dune install --prefix ${FFOO_INSTALLDIR}
endif

uninstall:
ifeq ($(FFOO_INSTALLDIR),"")
dune uninstall
else
dune uninstall --prefix ${FFOO_INSTALLDIR}
endif

##############################################################################

.PHONY: headers

HEADER_FILES:=dune dune-project headers/headache_config.txt Makefile
HEADER_FILES+=src/dune $(wildcard src/*.ml) $(wildcard src/*.mli)
HEADER_FILES+=tests/dune tests/Makefile $(wildcard tests/*.ml) $(wildcard tests/*.mli)

HEADACHE=headache -c headers/headache_config.txt -h headers/license.txt

headers:
$(HEADACHE) $(HEADER_FILES)

##############################################################################
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<p>
<img src="images/fontforge-of-ocaml.png">
</p>

Copyright (C) 2017-2022, P. Baudin (https://github.com/pbaudin/fontforge-of-ocaml)

<p>
<img src="https://img.shields.io/badge/Tool_License-LGPL_2.1_only-green" /> </br>
<img src="https://img.shields.io/badge/Built_with-FontForge_and_OCaml_libraries-green" />
</br>

# OCaml binding to FontForge #

## Library usage ##

The `fontforge-of-ocaml` library is published under the [LGPL v2.1](LICENSE.md) license and its API is documented in the file [src/FontForge.mli](src/FontForge.mli).

### Example of use ###

Look at the included test file [tests/test_FontForgeLib.ml](tests/test_FontForgeLib.ml).

### Notice ###

The binding is incomplete, but don't forget that the library is able to load `.fea` ([OpenType Feature](https://opentypecookbook.com/putting-it-together)) files to design complex fonts.

### Installation ###

The library can easily be installed from source-based package manager [Opam](https://opam.ocaml.org/)
from a [pin](https://opam.ocaml.org/doc/Manual.html#Pinning) to this GitHub repository:
```bash
$ opam pin https://github.com/pbaudin/fontforge-of-ocaml
```

On Ubuntu, the library relies on `python3-fontforge` package that contains the `python3` binding to `FontForge`:
```bash
$ sudo apt-get install -y python3-fontforge
```

## Contributing ##

Since the library meets my needs, I won't complete the binding from myself.
Nevertheless, if you want to contribute you are welcome.
Don't hesitate to open an issue for that and why not propose a pull request.

## The story ##

### Preamble ###

This library was developed in 2017 and used for the design of several [Advanced Cross-Stitch Fonts](https://github.com/pbaudin/ACSF).
Five years later, it time to publish the `fontforge-of-ocaml` library even if the binding is incomplete.

### Development ###

The first version of that library was written in [`OCaml`](https://ocaml.org/) and
used the [`Lymp`](https://github.com/dbousque/lymp) library allowing you to use `Python` functions and objects of `FontForge` API from `OCaml` world.

The `FontForge` API imposes type constraints between the arguments of the functions managing the contextual font tables.
In order to offer an `OCaml` API as close as the `FontForge` API, the use of [Generalized Algebraic Data Type](https://caml.inria.fr/pub/docs/manual-ocaml/gadts.html) of `OCaml` was seen as an opportunity.
That has not been so much used due to some bugs in the `Lymp` library raised by the hudge number of calls from `OCaml` to `Python`.
A work around has been found in generating an intermediate file (specifying the [`OpenType Feature Data`](https://opentypecookbook.com/putting-it-together/) to use in a `.fea` file) to build the final fonts from `FontForge Python` API and the `OCaml` binding. That explains why the development of the `FontForge` binding was stopped earlier that expected.

In the meantime, `Fontforge` API migrated to `Python 3` and the `Lymp` library was no more able to perform the binding with newer versions of `OCaml` compiler and various libraries.
Nevertheless, with few effort the `Lymp` library was easily replaced by the [`PyMl`](https://github.com/thierry-martinez/pyml) library.

<p>
<img src="images/author.png">
</p>
21 changes: 21 additions & 0 deletions dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; This file is part of fontforge-of-ocaml library ;;
;; ;;
;; Copyright (C) 2017-2022, Patrick BAUDIN ;;
;; (https://github.com/pbaudin/fontforge-of-ocaml) ;;
;; ;;
;; you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software ;;
;; Foundation, version 2.1. ;;
;; ;;
;; It is distributed in the hope that it will be useful, but WITHOUT ANY ;;
;; WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;
;; FITNESS FOR A PARTICULAR PURPOSE. ;;
;; ;;
;; See the GNU Lesser General Public License version 2.1 ;;
;; for more details (enclosed in the file licenses/LGPLv2.1) ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(dirs src tests)
42 changes: 42 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(lang dune 2.8)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; This file is part of fontforge-of-ocaml library ;;
;; ;;
;; Copyright (C) 2017-2022, Patrick BAUDIN ;;
;; (https://github.com/pbaudin/fontforge-of-ocaml) ;;
;; ;;
;; you can redistribute it and/or modify it under the terms of the GNU ;;
;; Lesser General Public License as published by the Free Software ;;
;; Foundation, version 2.1. ;;
;; ;;
;; It is distributed in the hope that it will be useful, but WITHOUT ANY ;;
;; WARRANTY; without even the implied warranty of MERCHANTABILITY or ;;
;; FITNESS FOR A PARTICULAR PURPOSE. ;;
;; ;;
;; See the GNU Lesser General Public License version 2.1 ;;
;; for more details (enclosed in the file licenses/LGPLv2.1) ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(generate_opam_files true)

(name fontforge-of-ocaml)
(maintainers "https://github.com/pbaudin/fontforge-of-ocaml")

(package
(name fontforge-of-ocaml)
(depends
(ocaml (>= 4.09.0))
(base (>= v0.12.2))
(fmt (>= 0.8.9 ))
(pyml (>= 20200518 ))
(ppx_python (>= v0.12.0))
)
(depopts
(headache (>= 1.05))
)
; (conflict ...)
(tags ("font" "fontforge" "binding")
)
)
45 changes: 45 additions & 0 deletions fontforge-of-ocaml.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file is generated by dune, edit dune-project instead
tags: ["font" "fontforge" "binding"]
depends: [
"dune" {>= "2.8"}
"ocaml" {>= "4.09.0"}
"base" {>= "v0.12.2"}
"fmt" {>= "0.8.9"}
"pyml" {>= "20200518"}
"ppx_python" {>= "v0.12.0"}
"odoc" {with-doc}
]
depopts: [
"headache" {>= "1.05"}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
opam-version: "2.0"
name: "fontforge-of-ocaml"
version: "1.1.0"
synopsis: "OCaml binding of FontForge"
description: """
Library providing OCaml binding of FontForge Python API
"""
maintainer: "http://github.com/pbaudin"
authors: [
"Patrick Baudin"
]
license: "LGPL-2.1-only"
homepage: "http://github.com/pbaudin/fontforge-of-ocaml"
bug-reports: "https://github.com/pbaudin/fontforge-of-ocaml"
messages: [
]
dev-repo: "git+https://github.com/pbaudin/fontforge-of-ocaml"
17 changes: 17 additions & 0 deletions fontforge-of-ocaml.opam.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
opam-version: "2.0"
name: "fontforge-of-ocaml"
version: "1.1.0"
synopsis: "OCaml binding of FontForge"
description: """
Library providing OCaml binding of FontForge Python API
"""
maintainer: "http://github.com/pbaudin"
authors: [
"Patrick Baudin"
]
license: "LGPL-2.1-only"
homepage: "http://github.com/pbaudin/fontforge-of-ocaml"
bug-reports: "https://github.com/pbaudin/fontforge-of-ocaml"
messages: [
]
dev-repo: "git+https://github.com/pbaudin/fontforge-of-ocaml"
39 changes: 39 additions & 0 deletions headers/headache_config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##############################################################################
# #
# This file is part of fontforge-of-ocaml library #
# #
# Copyright (C) 2017-2022, Patrick BAUDIN #
# (https://github.com/pbaudin/fontforge-of-ocaml) #
# #
# you can redistribute it and/or modify it under the terms of the GNU #
# Lesser General Public License as published by the Free Software #
# Foundation, version 2.1. #
# #
# It is distributed in the hope that it will be useful, but WITHOUT ANY #
# WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. #
# #
# See the GNU Lesser General Public License version 2.1 #
# for more details (enclosed in the file licenses/LGPLv2.1) #
# #
##############################################################################

## Usage
# headache -c headache_config.txt -h license.txt ...

## Dune ##
# note: the skip directive requires a filename starting by ".*"
# since the skip directive looks at the full path-name
| "dune-project" -> frame open:";;" line:";" close:";;"
| ".*dune-project" -> skip match:"(lang.*"
| "dune" -> frame open:";;" line:";" close:";;"

## Makefile ##
| "Make.*" -> frame open:"#" line:"#" close:"#"

## Shell scripts ##
| ".*\.sh" -> frame open:"#" line:"#" close:"#"
| ".*\.sh" -> skip match:"#!.*"

## Headache config ##
| "headache_config.txt" -> frame open:"#" line:"#" close:"#"
17 changes: 17 additions & 0 deletions headers/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

This file is part of fontforge-of-ocaml library

Copyright (C) 2017-2022, Patrick BAUDIN
(https://github.com/pbaudin/fontforge-of-ocaml)

you can redistribute it and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software
Foundation, version 2.1.

It is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.

See the GNU Lesser General Public License version 2.1
for more details (enclosed in the file licenses/LGPLv2.1)

Binary file added images/author.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fontforge-of-ocaml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 764c120

Please sign in to comment.