PageRenderTime 41ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Font/OpenType.mli

https://code.google.com/p/kompostilo/
OCaml | 193 lines | 126 code | 30 blank | 37 comment | 0 complexity | 6010c83db3a6b8a916e7a44b32720de7 MD5 | raw file
  1. (*
  2. Copyright (c) 2009 Barry Schwartz
  3. Permission is hereby granted, free of charge, to any person
  4. obtaining a copy of this software and associated documentation
  5. files (the "Software"), to deal in the Software without
  6. restriction, including without limitation the rights to use,
  7. copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the
  9. Software is furnished to do so, subject to the following
  10. conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. OTHER DEALINGS IN THE SOFTWARE.
  21. *)
  22. (*-----------------------------------------------------------------------*)
  23. open FontForge
  24. open Pycaml
  25. (*-----------------------------------------------------------------------*)
  26. module Tag :
  27. sig
  28. type t = int32 (* with sexp *) (* FIX: Do we still need to expose the type? *)
  29. val make_from_ints : int array -> t
  30. val make : string -> t
  31. val str : t -> string
  32. val compare : t -> t -> int
  33. end
  34. module TagMap : Nibbletrie.S with type key = Tag.t
  35. (*-----------------------------------------------------------------------*)
  36. (* Glyph indexes *)
  37. module GID :
  38. sig
  39. type t = int (* with sexp *)
  40. external of_int : int -> t = "%identity"
  41. external to_int : t -> int = "%identity"
  42. val compare : t -> t -> int
  43. val succ : t -> t
  44. val print : t -> unit
  45. val pythonize : t -> pyobject
  46. val unpythonize : pyobject -> t
  47. end
  48. module GIDMap : Nibbletrie.S with type key = GID.t
  49. module GIDSet : Nibbleset.S with type elt = GID.t
  50. type value_record = {
  51. (* Device-table fields are not supported. *)
  52. x_placement_adj : int;
  53. y_placement_adj : int;
  54. x_advance_adj : int;
  55. y_advance_adj : int;
  56. } (* with sexp *)
  57. type lookup_type =
  58. | DummyLookup
  59. (* GPOS *)
  60. | SingleAdjustmentLookup
  61. | PairAdjustmentLookup
  62. | CursiveAttachmentLookup
  63. | MarkToBaseAttachmentLookup
  64. | MarkToLigatureAttachmentLookup
  65. | MarkToMarkAttachmentLookup
  66. | ContextPositioningLookup
  67. | ChainedContextPositioningLookup
  68. | ExtensionPositioningLookup
  69. (* GSUB *)
  70. | SingleSubstitutionLookup
  71. | MultipleSubstitutionLookup
  72. | AlternateSubstitutionLookup
  73. | LigatureSubstitutionLookup
  74. | ContextSubstitutionLookup
  75. | ChainingContextSubstitutionLookup
  76. | ExtensionSubstitutionLookup
  77. | ReverseChainingContextSubstitutionLookup
  78. (* with sexp *)
  79. type chaining_context_subst_format3 = {
  80. backtrack_coverage : GIDSet.t list;
  81. input_coverage : GIDSet.t list;
  82. lookahead_coverage : GIDSet.t list;
  83. lookup_indexes : (int * int) list;
  84. }
  85. and subtable =
  86. | SingleSubstitutionSubtable of GID.t GIDMap.t
  87. | LigatureSubstitutionSubtable of (GID.t list * GID.t) list GIDMap.t
  88. | ChainingContextSubstitution3Subtable of chaining_context_subst_format3
  89. | SingleAdjustmentSubtable of value_record GIDMap.t
  90. | PairAdjustmentSubtable of (value_record option * value_record option) GIDMap.t GIDMap.t
  91. | ClassBasedKerningSubtable of (int * int GIDMap.t * int GIDMap.t * int array)
  92. and lookup_table = {
  93. lookupType : lookup_type;
  94. rightToLeft : bool;
  95. ignoreBaseGlyphs : bool;
  96. ignoreLigatures : bool;
  97. ignoreMarks : bool;
  98. useMarkFilteringSet : bool;
  99. markAttachmentType : int;
  100. subTables : subtable list;
  101. }
  102. (* with sexp *)
  103. (* FIX: Feature parameters are not yet implemented. *)
  104. type feature_parameters = NoFeatureParameters (* with sexp *)
  105. type feature_table = {
  106. featureTag : Tag.t;
  107. featureParams : feature_parameters;
  108. lookupListIndexes : int list;
  109. } (* with sexp *)
  110. (* FIX: Re-ordering tables are not yet implemented. *)
  111. type reordering_table = NoReorderingTable (* with sexp *)
  112. type langsys_table = {
  113. lookupOrder : reordering_table;
  114. reqFeature : feature_table option;
  115. features : feature_table list;
  116. } (* with sexp *)
  117. type gsub_or_gpos = {
  118. langSysTable : langsys_table;
  119. lookupListArray : lookup_table array;
  120. } (* with sexp *)
  121. val make_langsys_restricter :
  122. FFfont.t -> Tag.t -> Tag.t -> Tag.t * Tag.t
  123. module LookupMarks :
  124. sig
  125. type t (* with sexp *)
  126. val make_from_indexes : int -> int list -> t
  127. val indexes : t -> int list
  128. val union : t -> t -> t
  129. end
  130. module LookupMarker :
  131. sig
  132. type t (* with sexp *)
  133. val make_gsub : FFfont.t -> Tag.t -> Tag.t -> t
  134. val make_gpos : FFfont.t -> Tag.t -> Tag.t -> t
  135. val make_from_table : gsub_or_gpos option -> t
  136. val dummy : t
  137. val marks : t -> Tag.t list -> LookupMarks.t
  138. val lookups : t -> lookup_table array
  139. end
  140. module MarkerRepository :
  141. sig
  142. type t (* with sexp *)
  143. val create : unit -> t
  144. val put : t -> LookupMarker.t -> Tag.t -> Tag.t -> unit
  145. val put_gsub : t -> FFfont.t -> Tag.t -> Tag.t -> unit
  146. val put_gpos : t -> FFfont.t -> Tag.t -> Tag.t -> unit
  147. val get : t -> Tag.t -> Tag.t -> LookupMarker.t
  148. end
  149. (*-----------------------------------------------------------------------*)
  150. exception Bad_FeatureSet_spec of string
  151. module FeatureSet :
  152. sig
  153. type t (* with sexp *)
  154. val empty : t
  155. val default : t
  156. val change_one : t -> string -> t
  157. val change : t -> string list -> t
  158. val marks : t -> LookupMarker.t -> LookupMarks.t
  159. end
  160. (*-----------------------------------------------------------------------*)