! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel arrays sequences math math.order opengl opengl.gl strings fonts colors ; IN: ui.text HOOK: x>offset font-renderer ( x font string -- n ) HOOK: offset>x font-renderer ( n font string -- x ) GENERIC: text-dim ( font text -- dim ) M: string text-dim string-dim ; M: sequence text-dim [ { 0 0 } ] 2dip [ string-dim combine-text-dim ] with each ; : text-width ( font text -- w ) text-dim first ; : text-height ( font text -- h ) text-dim second ; HOOK: line-metrics font-renderer ( font string -- metrics ) GENERIC# draw-text 1 ( font text loc -- ) M: string draw-text draw-string ; M: sequence draw-text [ [ 2dup { 0 0 } draw-string 0.0 swap string-height 0.0 glTranslated ] with each ] with-translation ;