Paste: windows dpi
Author: | erg |
Mode: | factor |
Date: | Sun, 31 Jul 2022 03:08:47 |
Plain Text |
USING: accessors cache kernel math math.vectors namespaces
sequences ui.text ui.text.private windows.uniscribe ;
IN: ui.text.uniscribe
SINGLETON: uniscribe-renderer
: scale-dim ( dim -- dim' )
gl-scale-factor get-global [ [ gl-unscale ] map ] when ; inline
: scale-metrics ( metrics -- metrics' )
gl-scale-factor get-global [
clone
[ gl-unscale ] change-width
[ gl-unscale ] change-ascent
[ gl-unscale ] change-descent
[ gl-unscale ] change-height
[ gl-unscale ] change-leading
[ gl-unscale ] change-cap-height
[ gl-unscale ] change-x-height
] when ; inline
M: uniscribe-renderer string-dim
[ " " string-dim { 0 1 } v* ]
[ cached-script-string size>> scale-dim ] if-empty ;
M: uniscribe-renderer flush-layout-cache
cached-script-strings get-global purge-cache ;
M: uniscribe-renderer string>image
cached-script-string script-string>image { 0 0 } ;
M: uniscribe-renderer x>offset
[ 2drop 0 ] [
[ gl-scale ] 2dip
cached-script-string x>line-offset 0 = [ 1 + ] unless
] if-empty ;
M: uniscribe-renderer offset>x
[ 2drop 0 ] [ cached-script-string line-offset>x gl-unscale ] if-empty ;
M: uniscribe-renderer font-metrics
" " cached-script-string metrics>> clone f >>width ;
M: uniscribe-renderer line-metrics
[ " " line-metrics clone 0 >>width ]
[ cached-script-string metrics>> 50 >>width 10 >>cap-height 10 >>x-height scale-metrics ]
if-empty ;
uniscribe-renderer font-renderer set-global
New Annotation