package patoline

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

Patoline boxes

type box =
  1. | GlyphBox of Patoraw.RawContent.glyph
  2. | Kerning of box Patfonts.FTypes.kerningBox
  3. | Glue of drawingBox
  4. | Drawing of drawingBox
  5. | Hyphen of hyphenBox
  6. | Marker of marker
  7. | BeginFigure of int
  8. | FlushFigure of int
  9. | Parameters of parameters -> parameters
  10. | Layout of frame_zipper -> frame_zipper
  11. | Empty

Elementary box in a paragraph

and paragraph = box array

A paragraph is an array of elementary boxes. The line breaking algorithm produces lines (given by the type line) by selecting chunks in a paragraph array.

and drawingBox = {
  1. drawing_min_width : float;
  2. drawing_nominal_width : float;
  3. drawing_max_width : float;
  4. drawing_width_fixed : bool;
  5. drawing_adjust_before : bool;
  6. drawing_y0 : float;
  7. drawing_y1 : float;
  8. drawing_badness : float -> float;
  9. drawing_break_badness : float;
  10. drawing_states : int list;
  11. drawing_contents : float -> Patoraw.RawContent.raw list;
}
and hyphenBox = {
  1. hyphen_normal : box array;
  2. hyphenated : (box array * box array) array;
}
and kind =
  1. | Extern of string
  2. | Intern of string
  3. | Button of Patoraw.RawContent.button_kind * string
and marker =
  1. | Label of string
  2. | FigureRef of int
  3. | Pageref of string
  4. | Structure of int list
  5. | AlignmentMark
and line = {
  1. paragraph : int;
    (*

    Index of the paragraph containing this line in the array

    *)
  2. lastFigure : int;
    (*

    Last placed figure (initially -1)

    *)
  3. lineStart : int;
    (*

    Index of the first box of the line in the paragraph.

    *)
  4. lineEnd : int;
    (*

    Index of the box next to the last box of the line, or the box with the hyphenation if the line is hyphenated.

    *)
  5. hyphenStart : int;
  6. hyphenEnd : int;
  7. isFigure : bool;
  8. layout : frame_zipper;
  9. height : float;
  10. paragraph_height : int;
  11. page_line : int;
  12. min_width : float;
  13. nom_width : float;
  14. max_width : float;
  15. line_y0 : float;
  16. line_y1 : float;
}

Description of a line, which should be produced by the line breaking algorithm. A line is merely described as the index of its first box and the index of its last box inside the paragraph (which itself is an array of boxes).

and parameters = {
  1. measure : float;
  2. left_margin : float;
  3. local_optimization : int;
  4. min_height_before : float;
  5. min_height_after : float;
  6. min_page_before : int;
  7. min_page_after : int;
  8. not_last_line : bool;
  9. not_first_line : bool;
  10. min_lines_before : int;
  11. min_lines_after : int;
  12. absolute : bool;
}
and placed_line = {
  1. line_params : parameters;
  2. line : line;
}
and frame_content =
  1. | Placed_line of placed_line
  2. | Raw of Patoraw.RawContent.raw list
and frame = {
  1. frame_children : frame Patutil.Extra.IntMap.t;
  2. frame_tags : string list;
  3. frame_x0 : float;
  4. frame_y0 : float;
  5. frame_x1 : float;
  6. frame_y1 : float;
  7. frame_content : frame_content list;
}
and frame_zipper = frame * (int * frame) list
module MarkerMap : sig ... end
val is_glyph : box -> bool

Helpful test functions.

val is_glue : box -> bool
val is_hyphen : box -> bool

Build a box containing one glyph, with a cache.

Build a glyph id from a font and a unicode character.

val glyph_of_string : (Patfonts.FTypes.glyph_id list -> Patfonts.FTypes.glyph_id list) -> (Patfonts.FTypes.glyph_ids list -> Patfonts.FTypes.glyph_ids list) -> Patfonts.Fonts.font -> float -> Patoraw.Color.color -> string -> box list

Build a list of boxes from a string, using stuff from kerning.

val hyphenate : (string -> (string * string) array) -> (Patfonts.FTypes.glyph_id list -> Patfonts.FTypes.glyph_id list) -> (Patfonts.FTypes.glyph_ids list -> Patfonts.FTypes.glyph_ids list) -> Patfonts.Fonts.font -> float -> Patoraw.Color.color -> string -> box list

Build a list of boxes representing a word, while taking care of building an array of possible hyphenations for the word (if any).

Helper functions for layouts

val frame_up : (frame * (Patutil.Extra.IntMap.key * frame) list) -> frame * (Patutil.Extra.IntMap.key * frame) list
val frame_down_last : (frame * (Patutil.Extra.IntMap.key * frame) list) -> frame * (Patutil.Extra.IntMap.key * frame) list
val frame_top : (frame * (Patutil.Extra.IntMap.key * frame) list) -> frame * (Patutil.Extra.IntMap.key * frame) list
val empty_frame : frame
val frame : ?contents:frame_content list -> float -> float -> float -> float -> (frame * (int * frame) list) -> frame * (int * frame) list

Creates a new frame with the given top-left and bottom-right corners, appends this frame as a child of the current frame, and moves down to this new frame.

val make_page : (float * float) -> (frame * (int * frame) list) -> frame * (int * frame) list
val twocols : (frame * 'a) -> frame * 'a
val next_zipper : (frame * (Patutil.Extra.IntMap.key * frame) list) -> (frame * (Patutil.Extra.IntMap.key * frame) list) option
val doc_frame : frame
val frame_page : ('a * (Patutil.Extra.IntMap.key * frame) list) -> int
val layout_page : line -> int
val all_contents : frame -> frame_content list

Helper functions for lines

val uselessLine : line
val default_params : parameters
val lines_eq : line -> line -> bool
val empty_drawing_box : drawingBox
val drawing : ?adjust_before:bool -> ?vcenter:bool -> ?hcenter:bool -> ?offset:float -> ?width_fixed:bool -> ?states:int list -> Patoraw.RawContent.raw list -> drawingBox
val drawing_blit : drawingBox -> float -> float -> drawingBox -> drawingBox
val box_width : float -> box -> float
val box_size : box -> float
val box_interval : box -> float * float * float
val boxes_interval : box array -> float * float * float
val lower_y : box -> float
val upper_y : box -> float
val knuth_h_badness : float -> float -> float
val glue : float -> float -> float -> box
val resize_drawing : float -> drawingBox -> drawingBox
val resize : float -> box -> box
val translate : float -> float -> box -> box
val vkern_percent_under' : ('a -> 'b -> box list) -> float -> 'a -> 'b -> float * box list
val vkern_percent_under : ('a -> 'b -> box list) -> float -> 'a -> 'b -> box list
val vkern_center : ('a -> 'b -> box list) -> float -> 'a -> 'b -> box list
val vkern_translate : ('a -> 'b -> box list) -> float -> 'a -> 'b -> box list
val vkern_as : ('a -> 'b -> box list) -> ('a -> 'b -> box list) -> 'a -> 'b -> box list
val fold_left_line : box array array -> ('a -> box -> 'a) -> 'a -> line -> 'a

Calling fold_left_line paragraphs f x0 line computes f (... (f (f (f x0 box0) box1) box2) ...) boxn where box0, box1, box2, … boxn are the boxes which belong to line in its corresponding paragraph paragraphs.(line.paragraph).

val line_layout : box array array -> line -> frame_zipper -> frame_zipper
val fold_left : ('a -> box -> 'a) -> 'a -> box list -> 'a
val first_line : box array array -> line -> box
val last_line : box array array -> line -> box
val line_height : box array array -> drawingBox array -> line -> float * float
val comp : box array array -> float -> int -> int -> int -> int -> int -> float
val compression : box array array -> parameters -> line -> float
val box_to_string : box -> string
val text_line : box array array -> line -> string