package adobe_font_metrics

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Parser for the Adobe Font Metrics (afm) format

The parser follows version 4.1 of the specification, as described in this document.

There is no attempt to rescue files that depart from this specification.

type header = {
  1. metrics_sets : int option;
  2. font_name : string;
  3. full_name : string option;
  4. family_name : string option;
  5. weight : string option;
  6. font_bbox : float * float * float * float;
  7. version : string option;
  8. notice : string option;
  9. encoding_scheme : string option;
  10. mapping_scheme : int option;
  11. esc_char : int option;
  12. character_set : string option;
  13. characters : int option;
  14. is_base_font : bool option;
  15. vvector : (float * float) option;
  16. is_fixed_v : bool option;
  17. cap_height : float option;
  18. xheight : float option;
  19. ascender : float option;
  20. descender : float option;
  21. stdhw : float option;
  22. stdvw : float option;
}
type writing_direction = {
  1. underline_position : float option;
  2. underline_thickness : float option;
  3. italic_angle : float option;
  4. char_width : (float * float) option;
  5. is_fixed_pitch : bool option;
}
type char_metrics = {
  1. code : [ `C of int | `CH of string ];
  2. wx : float option;
  3. w0x : float option;
  4. w1x : float option;
  5. wy : float option;
  6. w0y : float option;
  7. w1y : float option;
  8. w : (float * float) option;
  9. w0 : (float * float) option;
  10. w1 : (float * float) option;
  11. vv : (float * float) option;
  12. n : string option;
  13. b : (float * float * float * float) option;
  14. l : (string * string) list;
}
type track_kerning = {
  1. degree : int;
  2. min_pt_size : float;
  3. min_kern : float;
  4. max_pt_size : float;
  5. max_kern : float;
}
type kerning_pair_info = [
  1. | `KP of string * string * float * float
  2. | `KPH of string * string * float * float
  3. | `KPX of string * string * float
  4. | `KPY of string * string * float
]
type pairwise_kerning = kerning_pair_info array
type 'a with_direction = [
  1. | `Default of 'a
  2. | `Directed of 'a * 'a
]
type composite_character_data = {
  1. name : string;
  2. parts : (string * float * float) list;
}
type t = {
  1. version : string;
  2. header : header;
  3. writing_directions : writing_direction with_direction option;
  4. char_metrics : char_metrics array option;
  5. track_kerning : track_kerning array option;
  6. pairwise_kerning : pairwise_kerning with_direction option;
  7. composites : composite_character_data array option;
}
type error = [
  1. | `Syntax_error of string * int
]

Represents cause and line number of error

val from_file : string -> (t, [> error ]) Stdlib.result