Module Graphv_gles2_native.Text
Module for text rendering. Text is rendered using a glyph bitmap. The default bitmap size is 2048x2048. It is possible to run out of space in this bitmap so try to be conservative with font sizes and number of fonts. Glyphs are grouped by font, size, and blur. A glyph will be rendered once per combination of properties.
type fonttype bounds={box : Bounds.t;advance : float;}
val text : t -> x:float -> y:float -> ?start:int -> ?end_:int -> string -> unitDraw a text substring with the current font at the specified location.
- parameter x
The x location to draw the font at. Depending on the current alignment this parameter may represent the center, bottom left, right, etc.
- parameter y
The y location to draw the font at. Depending on the current alignment this parameter may represent the center, bottom, top, etc.
- parameter start
The starting index of the string. Defaults to 0.
- parameter end_
The ending index. Defaults to the end of the string.
val text_w : t -> x:float -> y:float -> ?start:int -> ?end_:int -> string -> floatSame as
textexcept it returns the rendered length.
val find_font : t -> name:string -> font optionval set_size : t -> size:float -> unitSet the font size in pixel units. Warning: If this font size has not been used yet the glyphs will be generated on demand. This may cause a performance hit on the first rendering at this size. Try to avoid using many different sizes.
val set_blur : t -> blur:float -> unitSet the current blur, in pixel units
val set_line_height : t -> height:float -> unitSet the spacing between lines
val set_letter_spacing : t -> spacing:float -> unitSet the spacing between letters
val set_align : t -> align:Align.t -> unitSet the alignment for rendered text. This changes the x,y origin for the rendered text.
val set_font_face : t -> name:string -> unitChange the font by name
val set_font_face_id : t -> id:int -> unitChange the font by id
type text_row={start_index : int;end_index : int;width : float;minx : float;maxx : float;next : int;}
val break_lines : t -> break_width:float -> max_rows:int -> ?start:int -> ?end_:int -> lines:text_row array -> string -> intLayout lines of text in
break_widthsize rows.- parameter break_width
The maximum width of a row
- parameter max_rows
The maximum number of rows to layout. This allows the
linesparameter to be used accross different calls to save allocations.
- parameter start
The starting index of the string to layout, defaults to 0.
- parameter end_
The ending index of the string to layout, default to the end of the string.
- returns
The number of rows created.
val make_empty_rows : int -> text_row arrayHelper function to initialize an empty array of rows
type glyph_position={index : int;x : float;min_x : float;max_x : float;}Used to get glyph positions within a rendered string. Can be used for selections or other screen based picking.
val empty_glyph_position : glyph_positionA
glyph_positioninitialized to all zeros.
val glyph_positions : t -> x:float -> y:float -> ?start:int -> ?end_:int -> glyphs:glyph_position array -> string -> intval text_box : t -> x:float -> y:float -> break_width:float -> ?start:int -> ?end_:int -> string -> unitval box_bounds : t -> x:float -> y:float -> break_width:float -> ?start:int -> ?end_:int -> string -> Bounds.tval add_fallback_id : t -> font:font -> fallback:font -> unitval add_fallback : t -> name:string -> fallback:string -> unitval reset_fallback_id : t -> font:font -> unitval reset_fallback : t -> name:string -> unit