1 /* 
    2  * ctx.h is free software; you can redistribute it and/or
    3  * modify it under the terms of the GNU Lesser General Public
    4  * License as published by the Free Software Foundation; either
    5  * version 3 of the License, or (at your option) any later version.
    6  *
    7  * ctx.h is distributed in the hope that it will be useful,
    8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10  * Lesser General Public License for more details.
   11  *
   12  * You should have received a copy of the GNU Lesser General Public
   13  * License along with ctx; if not, see <https://www.gnu.org/licenses/>.
   14  *
   15  * 2012, 2015, 2019, 2020 Øyvind Kolås <pippin@gimp.org>
   16  *
   17  * ctx is a single header 2d vector graphics processing framework.
   18  *
   19  * To use ctx in a project, do the following:
   20  *
   21  * #define CTX_IMPLEMENTATION
   22  * #include "ctx.h"
   23  *
   24  * Ctx does not - yet - contain a minimal default fallback font, so
   25  * you probably want to also include a font, and perhaps enable
   26  * the cairo or SDL2 optional renderers, a more complete example
   27  * could be:
   28  *
   29  * #include <cairo.h>
   30  * #include <SDL.h>
   31  * #include "ctx-font-regular.h"
   32  * #define CTX_IMPLEMENTATION
   33  * #include "ctx.h"
   34  *
   35  * The behavior of ctx can be tweaked, and additional features can
   36  * be enabled with other includes, see further down in the start
   37  * of this file for details.
   38  */
   39 
   40 #ifndef CTX_H
   41 #define CTX_H
   42 
   43 #ifdef __cplusplus
   44 extern "C" {
   45 #endif
   46 
   47 #include <stdint.h>
   48 #include <string.h>
   49 #include <stdio.h>
   50 
   51 typedef struct _Ctx            Ctx;
   52 
   53 /* The pixel formats supported as render targets
   54  */
   55 enum _CtxPixelFormat
   56 {
   57   CTX_FORMAT_GRAY8,
   58   CTX_FORMAT_GRAYA8,
   59   CTX_FORMAT_RGB8,
   60   CTX_FORMAT_RGBA8,
   61   CTX_FORMAT_BGRA8,
   62   CTX_FORMAT_RGB565,
   63   CTX_FORMAT_RGB565_BYTESWAPPED,
   64   CTX_FORMAT_RGB332,
   65   CTX_FORMAT_RGBAF,
   66   CTX_FORMAT_GRAYF,
   67   CTX_FORMAT_GRAYAF,
   68   CTX_FORMAT_GRAY1,
   69   CTX_FORMAT_GRAY2,
   70   CTX_FORMAT_GRAY4,
   71   CTX_FORMAT_CMYK8,
   72   CTX_FORMAT_CMYKA8,
   73   CTX_FORMAT_CMYKAF,
   74   CTX_FORMAT_DEVICEN1,
   75   CTX_FORMAT_DEVICEN2,
   76   CTX_FORMAT_DEVICEN3,
   77   CTX_FORMAT_DEVICEN4,
   78   CTX_FORMAT_DEVICEN5,
   79   CTX_FORMAT_DEVICEN6,
   80   CTX_FORMAT_DEVICEN7,
   81   CTX_FORMAT_DEVICEN8,
   82   CTX_FORMAT_DEVICEN9,
   83   CTX_FORMAT_DEVICEN10,
   84   CTX_FORMAT_DEVICEN11,
   85   CTX_FORMAT_DEVICEN12,
   86   CTX_FORMAT_DEVICEN13,
   87   CTX_FORMAT_DEVICEN14,
   88   CTX_FORMAT_DEVICEN15,
   89   CTX_FORMAT_DEVICEN16
   90 };
   91 typedef enum   _CtxPixelFormat CtxPixelFormat;
   92 
   93 typedef struct _CtxGlyph       CtxGlyph;
   94 
   95 /**
   96  * ctx_new:
   97  *
   98  * Create a new drawing context, this context has no pixels but
   99  * accumulates commands and can be played back on other ctx
  100  * render contexts.
  101  */
  102 Ctx *ctx_new (void);
  103 
  104 /**
  105  * ctx_new_for_framebuffer:
  106  *
  107  * Create a new drawing context for a framebuffer, rendering happens
  108  * immediately.
  109  */
  110 Ctx *ctx_new_for_framebuffer (void *data,
  111                               int   width,
  112                               int   height,
  113                               int   stride,
  114                               CtxPixelFormat pixel_format);
  115 /**
  116  * ctx_new_ui:
  117  *
  118  * Create a new interactive ctx context, might depend on additional
  119  * integration.
  120  */
  121 Ctx *ctx_new_ui (int width, int height);
  122 
  123 /**
  124  * ctx_new_for_renderstream:
  125  *
  126  * Create a new drawing context for a pre-existing renderstream.
  127  */
  128 Ctx *ctx_new_for_renderstream (void *data, size_t length);
  129 
  130 
  131 /**
  132  * ctx_dirty_rect:
  133  *
  134  * Query the dirtied bounding box of drawing commands thus far.
  135  */
  136 void  ctx_dirty_rect      (Ctx *ctx, int *x, int *y, int *width, int 
  137                            *height);
  138 
  139 /**
  140  * ctx_free:
  141  * @ctx: a ctx context
  142  */
  143 void ctx_free (Ctx *ctx);
  144 
  145 
  146 /* clears and resets a context */
  147 void ctx_reset          (Ctx *ctx);
  148 void ctx_begin_path     (Ctx *ctx);
  149 void ctx_save           (Ctx *ctx);
  150 void ctx_restore        (Ctx *ctx);
  151 void ctx_start_group    (Ctx *ctx);
  152 void ctx_end_group      (Ctx *ctx);
  153 void ctx_clip           (Ctx *ctx);
  154 void ctx_identity       (Ctx *ctx);
  155 void ctx_rotate         (Ctx *ctx, float x);
  156 
  157 #define CTX_LINE_WIDTH_HAIRLINE -1000.0
  158 #define CTX_LINE_WIDTH_ALIASED  -1.0
  159 #define CTX_LINE_WIDTH_FAST     -1.0  /* aliased 1px wide line */
  160 void ctx_miter_limit (Ctx *ctx, float limit);
  161 void ctx_line_width       (Ctx *ctx, float x);
  162 void ctx_apply_transform  (Ctx *ctx, float a,  float b,  // hscale, hskew
  163                            float c,  float d,  // vskew,  vscale
  164                            float e,  float f); // htran,  vtran
  165 
  166 void  ctx_font_size       (Ctx *ctx, float x);
  167 void  ctx_font            (Ctx *ctx, const char *font);
  168 void  ctx_scale           (Ctx *ctx, float x, float y);
  169 void  ctx_translate       (Ctx *ctx, float x, float y);
  170 void  ctx_line_to         (Ctx *ctx, float x, float y);
  171 void  ctx_move_to         (Ctx *ctx, float x, float y);
  172 void  ctx_curve_to        (Ctx *ctx, float cx0, float cy0,
  173                            float cx1, float cy1,
  174                            float x, float y);
  175 void  ctx_quad_to         (Ctx *ctx, float cx, float cy,
  176                            float x, float y);
  177 void  ctx_arc             (Ctx  *ctx,
  178                            float x, float y,
  179                            float radius,
  180                            float angle1, float angle2,
  181                            int   direction);
  182 void  ctx_arc_to          (Ctx *ctx, float x1, float y1,
  183                            float x2, float y2, float radius);
  184 void  ctx_rel_arc_to      (Ctx *ctx, float x1, float y1,
  185                            float x2, float y2, float radius);
  186 void  ctx_rectangle       (Ctx *ctx,
  187                            float x0, float y0,
  188                            float w, float h);
  189 void  ctx_round_rectangle (Ctx *ctx,
  190                            float x0, float y0,
  191                            float w, float h,
  192                            float radius);
  193 void  ctx_rel_line_to     (Ctx *ctx,
  194                            float x, float y);
  195 void  ctx_rel_move_to     (Ctx *ctx,
  196                            float x, float y);
  197 void  ctx_rel_curve_to    (Ctx *ctx,
  198                            float x0, float y0,
  199                            float x1, float y1,
  200                            float x2, float y2);
  201 void  ctx_rel_quad_to     (Ctx *ctx,
  202                            float cx, float cy,
  203                            float x, float y);
  204 void  ctx_close_path      (Ctx *ctx);
  205 float ctx_get_font_size   (Ctx *ctx);
  206 float ctx_get_line_width  (Ctx *ctx);
  207 int   ctx_width           (Ctx *ctx);
  208 int   ctx_height          (Ctx *ctx);
  209 int   ctx_rev             (Ctx *ctx);
  210 float ctx_x               (Ctx *ctx);
  211 float ctx_y               (Ctx *ctx);
  212 void  ctx_current_point   (Ctx *ctx, float *x, float *y);
  213 void  ctx_get_transform   (Ctx *ctx, float *a, float *b,
  214                            float *c, float *d,
  215                            float *e, float *f);
  216 
  217 CtxGlyph *ctx_glyph_allocate (int n_glyphs);
  218 
  219 void gtx_glyph_free       (CtxGlyph *glyphs);
  220 
  221 int  ctx_glyph            (Ctx *ctx, uint32_t unichar, int stroke);
  222 
  223 void ctx_arc              (Ctx  *ctx,
  224                            float x, float y,
  225                            float radius,
  226                            float angle1, float angle2,
  227                            int   direction);
  228 
  229 void ctx_arc_to           (Ctx *ctx, float x1, float y1,
  230                            float x2, float y2, float radius);
  231 
  232 void ctx_quad_to          (Ctx *ctx, float cx, float cy,
  233                            float x, float y);
  234 
  235 void ctx_arc              (Ctx  *ctx,
  236                            float x, float y,
  237                            float radius,
  238                            float angle1, float angle2,
  239                            int   direction);
  240 
  241 void ctx_arc_to           (Ctx *ctx, float x1, float y1,
  242                            float x2, float y2, float radius);
  243 
  244 void ctx_preserve         (Ctx *ctx);
  245 void ctx_fill             (Ctx *ctx);
  246 void ctx_stroke           (Ctx *ctx);
  247 void ctx_paint            (Ctx *ctx);
  248 void ctx_parse            (Ctx *ctx, const char *string);
  249 
  250 void ctx_shadow_rgba      (Ctx *ctx, float r, float g, float b, float a);
  251 void ctx_shadow_blur      (Ctx *ctx, float x);
  252 void ctx_shadow_offset_x  (Ctx *ctx, float x);
  253 void ctx_shadow_offset_y  (Ctx *ctx, float y);
  254 void ctx_view_box         (Ctx *ctx,
  255                            float x0, float y0,
  256                            float w, float h);
  257 void
  258 ctx_set_pixel_u8          (Ctx *ctx, uint16_t x, uint16_t y, uint8_t r, 
  259                            uint8_t g, uint8_t b, uint8_t a);
  260 
  261 void  ctx_global_alpha     (Ctx *ctx, float global_alpha);
  262 float ctx_get_global_alpha (Ctx *ctx);
  263 
  264 void ctx_named_source (Ctx *ctx, const char *name);
  265 // followed by a color, gradient or pattern definition
  266 
  267 void ctx_rgba   (Ctx *ctx, float r, float g, float b, float a);
  268 void ctx_rgb    (Ctx *ctx, float r, float g, float b);
  269 void ctx_gray   (Ctx *ctx, float gray);
  270 void ctx_rgba8  (Ctx *ctx, uint8_t r, uint8_t g, uint8_t b, uint8_t a);
  271 void ctx_drgba  (Ctx *ctx, float r, float g, float b, float a);
  272 void ctx_cmyka  (Ctx *ctx, float c, float m, float y, float k, float a);
  273 void ctx_cmyk   (Ctx *ctx, float c, float m, float y, float k);
  274 void ctx_dcmyka (Ctx *ctx, float c, float m, float y, float k, float a);
  275 void ctx_dcmyk  (Ctx *ctx, float c, float m, float y, float k);
  276 
  277 /* there is also getters for colors, by first setting a color in one format 
  278 and getting
  279  * it with another color conversions can be done
  280  */
  281 
  282 void ctx_get_rgba   (Ctx *ctx, float *rgba);
  283 void ctx_get_graya  (Ctx *ctx, float *ya);
  284 void ctx_get_drgba  (Ctx *ctx, float *drgba);
  285 void ctx_get_cmyka  (Ctx *ctx, float *cmyka);
  286 void ctx_get_dcmyka (Ctx *ctx, float *dcmyka);
  287 int  ctx_in_fill    (Ctx *ctx, float x, float y);
  288 int  ctx_in_stroke  (Ctx *ctx, float x, float y);
  289 
  290 void ctx_linear_gradient (Ctx *ctx, float x0, float y0, float x1, float y1);
  291 void ctx_radial_gradient (Ctx *ctx, float x0, float y0, float r0,
  292                           float x1, float y1, float r1);
  293 /* XXX should be ctx_gradient_add_stop_rgba */
  294 void ctx_gradient_add_stop (Ctx *ctx, float pos, float r, float g, float b, 
  295                             float a);
  296 
  297 void ctx_gradient_add_stop_u8 (Ctx *ctx, float pos, uint8_t r, uint8_t g, 
  298                                uint8_t b, uint8_t a);
  299 
  300 /*ctx_texture_init:
  301  *
  302  * return value: the actual id assigned, if id is out of range - or later
  303  * when -1 as id will mean auto-assign.
  304  */
  305 int ctx_texture_init (Ctx *ctx, int id, int width, int height, int bpp,
  306                       uint8_t *pixels,
  307                       void (*freefunc) (void *pixels, void *user_data),
  308                       void *user_data);
  309 int ctx_texture_load        (Ctx *ctx, int id, const char *path);
  310 int ctx_texture_load_memory (Ctx *ctx, int id, const char *data, int length)
  311                              ;
  312 void ctx_texture_release    (Ctx *ctx, int id);
  313 void ctx_texture            (Ctx *ctx, int id, float x, float y);
  314 
  315 void ctx_image_path (Ctx *ctx, const char *path, float x, float y);
  316 
  317 typedef struct _CtxRenderstream CtxRenderstream;
  318 typedef void (*CtxFullCb) (CtxRenderstream *renderstream, void *data);
  319 
  320 void _ctx_set_store_clear (Ctx *ctx);
  321 void _ctx_set_transformation (Ctx *ctx, int transformation);
  322 
  323 Ctx *ctx_hasher_new (int width, int height, int cols, int rows);
  324 uint8_t *ctx_hasher_get_hash (Ctx *ctx, int col, int row);
  325 
  326 int ctx_utf8_strlen (const char *s);
  327 
  328 #ifdef _BABL_H
  329 #define CTX_BABL 1
  330 #else
  331 #define CTX_BABL 0
  332 #endif
  333 
  334 /* If cairo.h is included before ctx.h add cairo integration code
  335  */
  336 #ifdef CAIRO_H
  337 #define CTX_CAIRO 1
  338 #else
  339 #define CTX_CAIRO 0
  340 #endif
  341 
  342 #ifdef SDL_h_
  343 #define CTX_SDL 1
  344 #else
  345 #define CTX_SDL 0
  346 #endif
  347 
  348 #ifndef CTX_FB
  349 #if CTX_SDL
  350 #define CTX_FB 1
  351 #else
  352 #define CTX_FB 0
  353 #endif
  354 #endif
  355 
  356 #if CTX_SDL
  357 #define ctx_mutex_t            SDL_mutex
  358 #define ctx_create_mutex()     SDL_CreateMutex()
  359 #define ctx_lock_mutex(a)      SDL_LockMutex(a)
  360 #define ctx_unlock_mutex(a)    SDL_UnlockMutex(a)
  361 #else
  362 #define ctx_mutex_t           int
  363 #define ctx_create_mutex()    NULL
  364 #define ctx_lock_mutex(a)   
  365 #define ctx_unlock_mutex(a)  
  366 #endif
  367 
  368 #if CTX_CAIRO
  369 
  370 /* render the deferred commands of a ctx context to a cairo
  371  * context
  372  */
  373 void  ctx_render_cairo  (Ctx *ctx, cairo_t *cr);
  374 
  375 /* create a ctx context that directly renders to the specified
  376  * cairo context
  377  */
  378 Ctx * ctx_new_for_cairo (cairo_t *cr);
  379 #endif
  380 
  381 void ctx_render_stream  (Ctx *ctx, FILE *stream, int formatter);
  382 
  383 void ctx_render_ctx     (Ctx *ctx, Ctx *d_ctx);
  384 
  385 void ctx_start_move     (Ctx *ctx);
  386 
  387 
  388 int ctx_add_single      (Ctx *ctx, void *entry);
  389 
  390 uint32_t ctx_utf8_to_unichar (const char *input);
  391 int      ctx_unichar_to_utf8 (uint32_t  ch, uint8_t  *dest);
  392 
  393 
  394 typedef enum
  395 {
  396   CTX_FILL_RULE_EVEN_ODD,
  397   CTX_FILL_RULE_WINDING
  398 } CtxFillRule;
  399 
  400 typedef enum
  401 {
  402   CTX_COMPOSITE_SOURCE_OVER,
  403   CTX_COMPOSITE_COPY,
  404   CTX_COMPOSITE_SOURCE_IN,
  405   CTX_COMPOSITE_SOURCE_OUT,
  406   CTX_COMPOSITE_SOURCE_ATOP,
  407   CTX_COMPOSITE_CLEAR,
  408 
  409   CTX_COMPOSITE_DESTINATION_OVER,
  410   CTX_COMPOSITE_DESTINATION,
  411   CTX_COMPOSITE_DESTINATION_IN,
  412   CTX_COMPOSITE_DESTINATION_OUT,
  413   CTX_COMPOSITE_DESTINATION_ATOP,
  414   CTX_COMPOSITE_XOR,
  415 } CtxCompositingMode;
  416 
  417 typedef enum
  418 {
  419   CTX_BLEND_NORMAL,
  420   CTX_BLEND_MULTIPLY,
  421   CTX_BLEND_SCREEN,
  422   CTX_BLEND_OVERLAY,
  423   CTX_BLEND_DARKEN,
  424   CTX_BLEND_LIGHTEN,
  425   CTX_BLEND_COLOR_DODGE,
  426   CTX_BLEND_COLOR_BURN,
  427   CTX_BLEND_HARD_LIGHT,
  428   CTX_BLEND_SOFT_LIGHT,
  429   CTX_BLEND_DIFFERENCE,
  430   CTX_BLEND_EXCLUSION,
  431   CTX_BLEND_HUE, 
  432   CTX_BLEND_SATURATION, 
  433   CTX_BLEND_COLOR, 
  434   CTX_BLEND_LUMINOSITY,  // 15
  435   CTX_BLEND_DIVIDE,
  436   CTX_BLEND_ADDITION,
  437   CTX_BLEND_SUBTRACT,    // 18
  438 } CtxBlend;
  439 
  440 void ctx_blend_mode (Ctx *ctx, CtxBlend mode);
  441 
  442 typedef enum
  443 {
  444   CTX_JOIN_BEVEL = 0,
  445   CTX_JOIN_ROUND = 1,
  446   CTX_JOIN_MITER = 2
  447 } CtxLineJoin;
  448 
  449 typedef enum
  450 {
  451   CTX_CAP_NONE   = 0,
  452   CTX_CAP_ROUND  = 1,
  453   CTX_CAP_SQUARE = 2
  454 } CtxLineCap;
  455 
  456 typedef enum
  457 {
  458   CTX_TEXT_BASELINE_ALPHABETIC = 0,
  459   CTX_TEXT_BASELINE_TOP,
  460   CTX_TEXT_BASELINE_HANGING,
  461   CTX_TEXT_BASELINE_MIDDLE,
  462   CTX_TEXT_BASELINE_IDEOGRAPHIC,
  463   CTX_TEXT_BASELINE_BOTTOM
  464 } CtxTextBaseline;
  465 
  466 typedef enum
  467 {
  468   CTX_TEXT_ALIGN_START = 0,
  469   CTX_TEXT_ALIGN_END,
  470   CTX_TEXT_ALIGN_CENTER,
  471   CTX_TEXT_ALIGN_LEFT,
  472   CTX_TEXT_ALIGN_RIGHT
  473 } CtxTextAlign;
  474 
  475 typedef enum
  476 {
  477   CTX_TEXT_DIRECTION_INHERIT = 0,
  478   CTX_TEXT_DIRECTION_LTR,
  479   CTX_TEXT_DIRECTION_RTL
  480 } CtxTextDirection;
  481 
  482 struct
  483 _CtxGlyph
  484 {
  485   uint32_t index;
  486   float    x;
  487   float    y;
  488 };
  489 
  490 void ctx_text_align           (Ctx *ctx, CtxTextAlign      align);
  491 void ctx_text_baseline        (Ctx *ctx, CtxTextBaseline   baseline);
  492 void ctx_text_direction       (Ctx *ctx, CtxTextDirection  direction);
  493 void ctx_fill_rule            (Ctx *ctx, CtxFillRule       fill_rule);
  494 void ctx_line_cap             (Ctx *ctx, CtxLineCap        cap);
  495 void ctx_line_join            (Ctx *ctx, CtxLineJoin       join);
  496 void ctx_compositing_mode     (Ctx *ctx, CtxCompositingMode mode);
  497 int  ctx_set_renderstream     (Ctx *ctx, void *data, int length);
  498 typedef struct _CtxEntry CtxEntry;
  499 /* we only care about the tight packing for this specific
  500  * structx as we do indexing across members in arrays of it,
  501  * to make sure its size becomes 9bytes -
  502  * the pack pragma is also sufficient on recent gcc versions
  503  */
  504 #pragma pack(push,1)
  505 struct
  506   _CtxEntry
  507 {
  508   uint8_t code;
  509   union
  510   {
  511     float    f[2];
  512     uint8_t  u8[8];
  513     int8_t   s8[8];
  514     uint16_t u16[4];
  515     int16_t  s16[4];
  516     uint32_t u32[2];
  517     int32_t  s32[2];
  518     uint64_t u64[1]; // unused
  519   } data; // 9bytes long, we're favoring compactness and correctness
  520   // over performance. By sacrificing float precision, zeroing
  521   // first 8bit of f[0] would permit 8bytes long and better
  522   // aglinment and cacheline behavior.
  523 };
  524 #pragma pack(pop)
  525 const CtxEntry *ctx_get_renderstream (Ctx *ctx);
  526 int  ctx_append_renderstream  (Ctx *ctx, void *data, int length);
  527 
  528 /* these are only needed for clients rendering text, as all text gets
  529  * converted to paths.
  530  */
  531 void  ctx_glyphs        (Ctx        *ctx,
  532                          CtxGlyph   *glyphs,
  533                          int         n_glyphs);
  534 
  535 void  ctx_glyphs_stroke (Ctx       *ctx,
  536                          CtxGlyph   *glyphs,
  537                          int         n_glyphs);
  538 
  539 void  ctx_text          (Ctx        *ctx,
  540                          const char *string);
  541 
  542 void  ctx_text_stroke   (Ctx        *ctx,
  543                          const char *string);
  544 
  545 /* returns the total horizontal advance if string had been rendered */
  546 float ctx_text_width    (Ctx        *ctx,
  547                          const char *string);
  548 
  549 float ctx_glyph_width   (Ctx *ctx, int unichar);
  550 
  551 int   ctx_load_font_ttf (const char *name, const void *ttf_contents, int 
  552                          length);
  553 
  554 
  555 enum _CtxModifierState
  556 {
  557   CTX_MODIFIER_STATE_SHIFT   = (1<<0),
  558   CTX_MODIFIER_STATE_CONTROL = (1<<1),
  559   CTX_MODIFIER_STATE_ALT     = (1<<2),
  560   CTX_MODIFIER_STATE_BUTTON1 = (1<<3),
  561   CTX_MODIFIER_STATE_BUTTON2 = (1<<4),
  562   CTX_MODIFIER_STATE_BUTTON3 = (1<<5),
  563   CTX_MODIFIER_STATE_DRAG    = (1<<6), // pointer button is down (0 or any)
  564 };
  565 typedef enum _CtxModifierState CtxModifierState;
  566 
  567 enum _CtxScrollDirection
  568 {
  569   CTX_SCROLL_DIRECTION_UP,
  570   CTX_SCROLL_DIRECTION_DOWN,
  571   CTX_SCROLL_DIRECTION_LEFT,
  572   CTX_SCROLL_DIRECTION_RIGHT
  573 };
  574 typedef enum _CtxScrollDirection CtxScrollDirection;
  575 
  576 typedef struct _CtxEvent CtxEvent;
  577 
  578 void ctx_set_renderer (Ctx *ctx,
  579                        void *renderer);
  580 void *ctx_get_renderer (Ctx *ctx);
  581 
  582 /* the following API is only available when CTX_EVENTS is defined to 1
  583  *
  584  * it provides the ability to register callbacks with the current path
  585  * that get delivered with transformed coordinates.
  586  */
  587 float ctx_get_float (Ctx *ctx, uint32_t hash);
  588 void ctx_set_float (Ctx *ctx, uint32_t hash, float value);
  589 
  590 unsigned long ctx_ticks (void);
  591 void ctx_flush (Ctx *ctx);
  592 
  593 void _ctx_events_init     (Ctx *ctx);
  594 typedef struct _CtxRectangle CtxRectangle;
  595 struct _CtxRectangle {
  596   int x;
  597   int y;
  598   int width;
  599   int height;
  600 };
  601 
  602 
  603 typedef void (*CtxCb) (CtxEvent *event,
  604                        void     *data,
  605                        void     *data2);
  606 typedef void (*CtxDestroyNotify) (void *data);
  607 
  608 enum _CtxEventType {
  609   CTX_PRESS          = 1 << 0,
  610   CTX_MOTION         = 1 << 1,
  611   CTX_RELEASE        = 1 << 2,
  612   CTX_ENTER          = 1 << 3,
  613   CTX_LEAVE          = 1 << 4,
  614   CTX_TAP            = 1 << 5,
  615   CTX_TAP_AND_HOLD   = 1 << 6,
  616 
  617   /* NYI: SWIPE, ZOOM ROT_ZOOM, */
  618 
  619   CTX_DRAG_PRESS     = 1 << 7,
  620   CTX_DRAG_MOTION    = 1 << 8,
  621   CTX_DRAG_RELEASE   = 1 << 9,
  622   CTX_KEY_DOWN       = 1 << 10,
  623   CTX_KEY_UP         = 1 << 11,
  624   CTX_SCROLL         = 1 << 12,
  625   CTX_MESSAGE        = 1 << 13,
  626   CTX_DROP           = 1 << 14,
  627 
  628   /* client should store state - preparing
  629                                  * for restart
  630                                  */
  631   CTX_POINTER  = (CTX_PRESS | CTX_MOTION | CTX_RELEASE | CTX_DROP),
  632   CTX_TAPS     = (CTX_TAP | CTX_TAP_AND_HOLD),
  633   CTX_CROSSING = (CTX_ENTER | CTX_LEAVE),
  634   CTX_DRAG     = (CTX_DRAG_PRESS | CTX_DRAG_MOTION | CTX_DRAG_RELEASE),
  635   CTX_KEY      = (CTX_KEY_DOWN | CTX_KEY_UP),
  636   CTX_MISC     = (CTX_MESSAGE),
  637   CTX_ANY      = (CTX_POINTER | CTX_DRAG | CTX_CROSSING | CTX_KEY | 
  638                  CTX_MISC | CTX_TAPS),
  639 };
  640 typedef enum _CtxEventType CtxEventType;
  641 
  642 #define CTX_CLICK   CTX_PRESS   // SHOULD HAVE MORE LOGIC
  643 
  644 struct _CtxEvent {
  645   CtxEventType  type;
  646   uint32_t time;
  647   Ctx     *ctx;
  648   int stop_propagate; /* when set - propagation is stopped */
  649 
  650   CtxModifierState state;
  651 
  652   int      device_no; /* 0 = left mouse button / virtual focus */
  653                       /* 1 = middle mouse button */
  654                       /* 2 = right mouse button */
  655                       /* 3 = first multi-touch .. (NYI) */
  656 
  657   float   device_x; /* untransformed (device) coordinates  */
  658   float   device_y;
  659 
  660   /* coordinates; and deltas for motion/drag events in user-coordinates: */
  661   float   x;
  662   float   y;
  663   float   start_x; /* start-coordinates (press) event for drag, */
  664   float   start_y; /*    untransformed coordinates */
  665   float   prev_x;  /* previous events coordinates */
  666   float   prev_y;
  667   float   delta_x; /* x - prev_x, redundant - but often useful */
  668   float   delta_y; /* y - prev_y, redundant - ..  */
  669 
  670 
  671   unsigned int unicode; /* only valid for key-events */
  672   const char *string;   /* as key can be "up" "down" "space" "backspace" 
  673   "a" "b" "ø" etc .. */
  674                         /* this is also where the message is delivered for
  675                          * MESSAGE events
  676                          *
  677                          * and the data for drop events are delivered
  678                          */
  679   CtxScrollDirection scroll_direction;
  680 
  681 
  682   // would be nice to add the bounding box of the hit-area causing
  683   // the event, making for instance scissored enter/leave repaint easier.
  684 };
  685 
  686 // layer-event "layer"  motion x y device_no 
  687 
  688 void ctx_add_key_binding_full (Ctx *ctx,
  689                                const char *key,
  690                                const char *action,
  691                                const char *label,
  692                                CtxCb       cb,
  693                                void       *cb_data,
  694                                CtxDestroyNotify destroy_notify,
  695                                void       *destroy_data);
  696 void ctx_add_key_binding (Ctx *ctx,
  697                           const char *key,
  698                           const char *action,
  699                           const char *label,
  700                           CtxCb cb,
  701                           void  *cb_data);
  702 typedef struct CtxBinding {
  703   char *nick;
  704   char *command;
  705   char *label;
  706   CtxCb cb;
  707   void *cb_data;
  708   CtxDestroyNotify destroy_notify;
  709   void  *destroy_data;
  710 } CtxBinding;
  711 CtxBinding *ctx_get_bindings (Ctx *ctx);
  712 void  ctx_clear_bindings     (Ctx *ctx);
  713 void  ctx_remove_idle        (Ctx *ctx, int handle);
  714 int   ctx_add_timeout_full   (Ctx *ctx, int ms, int (*idle_cb)(Ctx *ctx, 
  715                               void *idle_data), void *idle_data,
  716                               void (*destroy_notify)(void *destroy_data), 
  717                                     void *destroy_data);
  718 int   ctx_add_timeout        (Ctx *ctx, int ms, int (*idle_cb)(Ctx *ctx, 
  719                               void *idle_data), void *idle_data);
  720 int   ctx_add_idle_full      (Ctx *ctx, int (*idle_cb)(Ctx *ctx, void 
  721                               *idle_data), void *idle_data,
  722                               void (*destroy_notify)(void *destroy_data), 
  723                                     void *destroy_data);
  724 int   ctx_add_idle           (Ctx *ctx, int (*idle_cb)(Ctx *ctx, void 
  725                               *idle_data), void *idle_data);
  726 
  727 
  728 void ctx_add_hit_region (Ctx *ctx, const char *id);
  729 
  730 void ctx_listen_full (Ctx     *ctx,
  731                       float    x,
  732                       float    y,
  733                       float    width,
  734                       float    height,
  735                       CtxEventType  types,
  736                       CtxCb    cb,
  737                       void    *data1,
  738                       void    *data2,
  739                       void   (*finalize)(void *listen_data, void 
  740                               *listen_data2,
  741                                          void *finalize_data),
  742                       void    *finalize_data);
  743 void  ctx_event_stop_propagate (CtxEvent *event);
  744 void  ctx_listen               (Ctx          *ctx,
  745                                 CtxEventType  types,
  746                                 CtxCb         cb,
  747                                 void*         data1,
  748                                 void*         data2);
  749 void  ctx_listen_with_finalize (Ctx          *ctx,
  750                                 CtxEventType  types,
  751                                 CtxCb         cb,
  752                                 void*         data1,
  753                                 void*         data2,
  754                       void   (*finalize)(void *listen_data, void 
  755                               *listen_data2,
  756                                          void *finalize_data),
  757                       void    *finalize_data);
  758 
  759 void ctx_init (int *argc, char ***argv); // is a no-op but could launch
  760                                          // terminal
  761 CtxEvent *ctx_get_event (Ctx *ctx);
  762 
  763 int   ctx_pointer_is_down (Ctx *ctx, int no);
  764 float ctx_pointer_x (Ctx *ctx);
  765 float ctx_pointer_y (Ctx *ctx);
  766 void  ctx_freeze (Ctx *ctx);
  767 void  ctx_thaw   (Ctx *ctx);
  768 int   ctx_events_frozen (Ctx *ctx);
  769 void  ctx_events_clear_items (Ctx *ctx);
  770 int   ctx_events_width (Ctx *ctx);
  771 int   ctx_events_height (Ctx *ctx);
  772 
  773 /* The following functions drive the event delivery, registered callbacks
  774  * are called in response to these being called.
  775  */
  776 
  777 int ctx_key_press (Ctx *ctx, unsigned int keyval,
  778                    const char *string, uint32_t time);
  779 int ctx_scrolled  (Ctx *ctx, float x, float y, CtxScrollDirection 
  780                    scroll_direction, uint32_t time);
  781 void ctx_incoming_message (Ctx *ctx, const char *message, long time);
  782 int ctx_pointer_motion    (Ctx *ctx, float x, float y, int device_no, 
  783                            uint32_t time);
  784 int ctx_pointer_release   (Ctx *ctx, float x, float y, int device_no, 
  785                            uint32_t time);
  786 int ctx_pointer_press     (Ctx *ctx, float x, float y, int device_no, 
  787                            uint32_t time);
  788 int ctx_pointer_drop      (Ctx *ctx, float x, float y, int device_no, 
  789                            uint32_t time,
  790                            char *string);
  791 
  792 
  793 ////////////////////
  794 
  795 typedef enum
  796 {
  797   // items marked with % are currently only for the parser
  798   // for instance for svg compatibility or simulated/converted color spaces
  799   // not the serialization/internal render stream
  800   //
  801   // unless specified, the arguments expected are 32bit float numbers.
  802   //
  803   CTX_FLUSH            = ';',
  804   CTX_ARC_TO           = 'A', // x1 y1 x2 y2 radius
  805   CTX_ARC              = 'B', // x y radius angle1 angle2 direction
  806   CTX_CURVE_TO         = 'C', // cx1 cy1 cx2 cy2 x y
  807 
  808   CTX_STROKE           = 'E', //
  809   CTX_FILL             = 'F', //
  810   CTX_RESTORE          = 'G', //
  811   CTX_HOR_LINE_TO      = 'H', // x
  812 
  813   CTX_ROTATE           = 'J', // radians
  814   CTX_COLOR            = 'K', // model, c1 c2 c3 ca - has a variable set of
  815   // arguments.
  816   CTX_LINE_TO          = 'L', // x y
  817   CTX_MOVE_TO          = 'M', // x y
  818   CTX_BEGIN_PATH       = 'N',
  819   CTX_SCALE            = 'O', // xscale yscale
  820   CTX_NEW_PAGE         = 'P', // - NYI
  821   CTX_QUAD_TO          = 'Q', // cx cy x y
  822   CTX_VIEW_BOX         = 'R', // x y width height
  823   CTX_SMOOTH_TO        = 'S', // cx cy x y
  824   CTX_SMOOTHQ_TO       = 'T', // x y
  825   CTX_RESET            = 'U', //
  826   CTX_VER_LINE_TO      = 'V', // y
  827   CTX_APPLY_TRANSFORM  = 'W', // a b c d e f - for set_transform combine 
  828                          with identity
  829   CTX_EXIT             = 'X', //
  830 
  831   CTX_CLOSE_PATH2      = 'Z', //
  832   CTX_REL_ARC_TO       = 'a', // x1 y1 x2 y2 radius
  833   CTX_CLIP             = 'b',
  834   CTX_REL_CURVE_TO     = 'c', // cx1 cy1 cx2 cy2 x y
  835 
  836   CTX_TRANSLATE        = 'e', // x y
  837   CTX_LINEAR_GRADIENT  = 'f', // x1 y1 x2 y2
  838   CTX_SAVE             = 'g',
  839   CTX_REL_HOR_LINE_TO  = 'h', // x
  840   CTX_TEXTURE          = 'i',
  841   CTX_PRESERVE         = 'j', // - make the following fill, stroke or clip 
  842                          leave the path
  843 
  844   CTX_SET_KEY          = 'k', // - used together with another char to 
  845                          identify a key to set
  846   CTX_REL_LINE_TO      = 'l', // x y
  847   CTX_REL_MOVE_TO      = 'm', // x y
  848   CTX_FONT         = 'n', // as used by text parser
  849   CTX_RADIAL_GRADIENT  = 'o', // x1 y1 radius1 x2 y2 radius2
  850   CTX_GRADIENT_STOP    = 'p', //   , count depends on current color model
  851   CTX_REL_QUAD_TO      = 'q', // cx cy x y
  852   CTX_RECTANGLE        = 'r', // x y width height
  853   CTX_REL_SMOOTH_TO    = 's', // cx cy x y
  854   CTX_REL_SMOOTHQ_TO   = 't', // x y
  855   CTX_TEXT_STROKE      = 'u', // string - utf8 string
  856   CTX_REL_VER_LINE_TO  = 'v', // y
  857   CTX_GLYPH            = 'w', // unichar fontsize
  858   CTX_TEXT             = 'x', // string | kern - utf8 data to shape or 
  859                          horizontal kerning amount
  860   CTX_IDENTITY         = 'y', //
  861   CTX_CLOSE_PATH       = 'z', //
  862 
  863   CTX_ROUND_RECTANGLE  = 'Y', // x y width height radius
  864   CTX_SET              = 'D', // key value - will take over k/K spots?
  865   CTX_GET              = 'd', // key -
  866   /* these commands have single byte binary representations,
  867    * but are two chars in text, values below 9 are used for
  868    * low integers of enum values. and can thus not be used here
  869    */
  870   CTX_SET_DRGB_SPACE       = 21, // hacks integer for now
  871   CTX_SET_RGB_SPACE        = 22, //
  872   CTX_SET_CMYK_SPACE       = 23, //
  873   CTX_SET_DCMYK_SPACE      = 24, //
  874 
  875   /* though expressed as two chars in serialization we have
  876    * dedicated byte commands for these setters
  877    */
  878   CTX_TEXT_ALIGN           = 17, // kt align - u8, default = 
  879                              CTX_TEXT_ALIGN_START
  880   CTX_TEXT_BASELINE        = 18, // kb baseline - u8, default = 
  881                              CTX_TEXT_ALIGN_ALPHABETIC
  882   CTX_TEXT_DIRECTION       = 19, // kd
  883   CTX_MITER_LIMIT          = 20, // km limit - float, default = 0.0
  884   CTX_GLOBAL_ALPHA         = 26, // ka alpha - default=1.0
  885   CTX_COMPOSITING_MODE     = 27, // kc mode - u8 , default=0
  886   CTX_BLEND_MODE           = '$',// kB mode - u8 , default=0
  887                                  // kb - text baseline
  888   CTX_FONT_SIZE            = 28, // kf size - float, default=?
  889   CTX_LINE_JOIN            = 29, // kj join - u8 , default=0
  890   CTX_LINE_CAP             = 30, // kc cap - u8, default = 0
  891   CTX_LINE_WIDTH           = 31, // kw width, default = 2.0
  892   CTX_FILL_RULE            = '!', // kr rule - u8, default = 
  893                              CTX_FILLE_RULE_EVEN_ODD
  894   CTX_SHADOW_BLUR          = '<', // ks
  895   CTX_SHADOW_COLOR         = '>', // kC
  896   CTX_SHADOW_OFFSET_X      = '?', // kx
  897   CTX_SHADOW_OFFSET_Y      = '&', // ky
  898   CTX_START_GROUP          = '{',
  899   CTX_END_GROUP            = '}',
  900 
  901   CTX_FUNCTION             = 25,
  902   //CTX_ENDFUN = 26,
  903 
  904   // non-alphabetic chars that get filtered out when parsing
  905   // are used for internal purposes
  906   //
  907   // unused:  . , : backslash  #  % ^ { } < > ? & /
  908   //           i 
  909   //
  910   CTX_CONT             = '\0', // - contains args from preceding entry
  911   CTX_SET_RGBA_U8      = '*', // r g b a - u8
  912   // NYI
  913   CTX_BITPIX           = 'I', // x, y, width, height, scale
  914   CTX_BITPIX_DATA      = 'j', //
  915 
  916   CTX_NOP              = ' ', //
  917   CTX_NEW_EDGE         = '+', // x0 y0 x1 y1 - s16
  918   CTX_EDGE             = '|', // x0 y0 x1 y1 - s16
  919   CTX_EDGE_FLIPPED     = '`', // x0 y0 x1 y1 - s16
  920 
  921   CTX_REPEAT_HISTORY   = ']', //
  922   CTX_DATA             = '(', // size size-in-entries - u32
  923   CTX_DATA_REV         = ')', // reverse traversal data marker
  924   // needed to be able to do backwards
  925   // traversal
  926   CTX_DEFINE_GLYPH     = '@', // unichar width - u32
  927   CTX_KERNING_PAIR     = '[', // glA glB kerning, glA and glB in u16 
  928                          kerning in s32
  929   CTX_SET_PIXEL        = '-', // r g b a x y - u8 for rgba, and u16 for x,y
  930 
  931   /* optimizations that reduce the number of entries used,
  932    * not visible outside the draw-stream compression -
  933    * these are using values that would mean numbers in an
  934    * SVG path.
  935    */
  936   CTX_REL_LINE_TO_X4            = '0', // x1 y1 x2 y2 x3 y3 x4 y4   -- s8
  937   CTX_REL_LINE_TO_REL_CURVE_TO  = '1', // x1 y1 cx1 cy1 cx2 cy2 x y -- s8
  938   CTX_REL_CURVE_TO_REL_LINE_TO  = '2', // cx1 cy1 cx2 cy2 x y x1 y1 -- s8
  939   CTX_REL_CURVE_TO_REL_MOVE_TO  = '3', // cx1 cy1 cx2 cy2 x y x1 y1 -- s8
  940   CTX_REL_LINE_TO_X2            = '4', // x1 y1 x2 y2 -- s16
  941   CTX_MOVE_TO_REL_LINE_TO       = '5', // x1 y1 x2 y2 -- s16
  942   CTX_REL_LINE_TO_REL_MOVE_TO   = '6', // x1 y1 x2 y2 -- s16
  943   CTX_FILL_MOVE_TO              = '7', // x y
  944   CTX_REL_QUAD_TO_REL_QUAD_TO   = '8', // cx1 x1 cy1 y1 cx1 x2 cy1 y1 -- s8
  945   CTX_REL_QUAD_TO_S16           = '9', // cx1 cy1 x y                 - s16
  946 } CtxCode;
  947 
  948 
  949 #pragma pack(push,1)
  950 
  951 typedef struct _CtxCommand CtxCommand;
  952 typedef struct _CtxIterator CtxIterator;
  953 
  954 CtxIterator *
  955 ctx_current_path (Ctx *ctx);
  956 void
  957 ctx_path_extents (Ctx *ctx, float *ex1, float *ey1, float *ex2, float *ey2);
  958 
  959 
  960 
  961 
  962 #define CTX_ASSERT               0
  963 
  964 #if CTX_ASSERT==1
  965 #define ctx_assert(a)  if(!(a)){fprintf(stderr,"%s:%i assertion failed\n", 
  966                    __FUNCTION__, __LINE__);  }
  967 #else
  968 #define ctx_assert(a)
  969 #endif
  970 
  971 int ctx_get_renderstream_count (Ctx *ctx);
  972 
  973 struct
  974   _CtxCommand
  975 {
  976   union
  977   {
  978     uint8_t  code;
  979     CtxEntry entry;
  980     struct
  981     {
  982       uint8_t code;
  983       float scalex;
  984       float scaley;
  985     } scale;
  986     struct
  987     {
  988       uint8_t code;
  989       uint32_t stringlen;
  990       uint32_t blocklen;
  991       uint8_t cont;
  992       uint8_t data[8]; /* ... and continues */
  993     } data;
  994     struct
  995     {
  996       uint8_t code;
  997       uint32_t stringlen;
  998       uint32_t blocklen;
  999     } data_rev;
 1000     struct
 1001     {
 1002       uint8_t code;
 1003       float pad;
 1004       float pad2;
 1005       uint8_t code_data;
 1006       uint32_t stringlen;
 1007       uint32_t blocklen;
 1008       uint8_t code_cont;
 1009       uint8_t utf8[8]; /* .. and continues */
 1010     } text;
 1011     struct
 1012     {
 1013       uint8_t  code;
 1014       uint32_t key_hash;
 1015       float    pad;
 1016       uint8_t  code_data;
 1017       uint32_t stringlen;
 1018       uint32_t blocklen;
 1019       uint8_t  code_cont;
 1020       uint8_t  utf8[8]; /* .. and continues */
 1021     } set;
 1022     struct
 1023     {
 1024       uint8_t  code;
 1025       uint32_t pad0;
 1026       float    pad1;
 1027       uint8_t  code_data;
 1028       uint32_t stringlen;
 1029       uint32_t blocklen;
 1030       uint8_t  code_cont;
 1031       uint8_t  utf8[8]; /* .. and continues */
 1032     } get;
 1033     struct
 1034     {
 1035       uint8_t  code;
 1036       float    pad;
 1037       float    pad2;
 1038       uint8_t  code_data;
 1039       uint32_t stringlen;
 1040       uint32_t blocklen;
 1041       uint8_t  code_cont;
 1042       uint8_t  utf8[8]; /* .. and continues */
 1043     } text_stroke;
 1044     struct
 1045     {
 1046       uint8_t  code;
 1047       float    pad;
 1048       float    pad2;
 1049       uint8_t  code_data;
 1050       uint32_t stringlen;
 1051       uint32_t blocklen;
 1052       uint8_t  code_cont;
 1053       uint8_t  utf8[8]; /* .. and continues */
 1054     } set_font;
 1055     struct
 1056     {
 1057       uint8_t code;
 1058       float model;
 1059       float r;
 1060       uint8_t pad1;
 1061       float g;
 1062       float b;
 1063       uint8_t pad2;
 1064       float a;
 1065     } rgba;
 1066     struct
 1067     {
 1068       uint8_t code;
 1069       float model;
 1070       float c;
 1071       uint8_t pad1;
 1072       float m;
 1073       float y;
 1074       uint8_t pad2;
 1075       float k;
 1076       float a;
 1077     } cmyka;
 1078     struct
 1079     {
 1080       uint8_t code;
 1081       float model;
 1082       float g;
 1083       uint8_t pad1;
 1084       float a;
 1085     } graya;
 1086     struct
 1087     {
 1088       uint8_t code;
 1089       float model;
 1090       float c0;
 1091       uint8_t pad1;
 1092       float c1;
 1093       float c2;
 1094       uint8_t pad2;
 1095       float c3;
 1096       float c4;
 1097       uint8_t pad3;
 1098       float c5;
 1099       float c6;
 1100       uint8_t pad4;
 1101       float c7;
 1102       float c8;
 1103       uint8_t pad5;
 1104       float c9;
 1105       float c10;
 1106     } set_color;
 1107     struct
 1108     {
 1109       uint8_t code;
 1110       float x;
 1111       float y;
 1112     } rel_move_to;
 1113     struct
 1114     {
 1115       uint8_t code;
 1116       float x;
 1117       float y;
 1118     } rel_line_to;
 1119     struct
 1120     {
 1121       uint8_t code;
 1122       float x;
 1123       float y;
 1124     } line_to;
 1125     struct
 1126     {
 1127       uint8_t code;
 1128       float cx1;
 1129       float cy1;
 1130       uint8_t pad0;
 1131       float cx2;
 1132       float cy2;
 1133       uint8_t pad1;
 1134       float x;
 1135       float y;
 1136     } rel_curve_to;
 1137     struct
 1138     {
 1139       uint8_t code;
 1140       float x;
 1141       float y;
 1142     } move_to;
 1143     struct
 1144     {
 1145       uint8_t code;
 1146       float cx1;
 1147       float cy1;
 1148       uint8_t pad0;
 1149       float cx2;
 1150       float cy2;
 1151       uint8_t pad1;
 1152       float x;
 1153       float y;
 1154     } curve_to;
 1155     struct
 1156     {
 1157       uint8_t code;
 1158       float x1;
 1159       float y1;
 1160       uint8_t pad0;
 1161       float r1;
 1162       float x2;
 1163       uint8_t pad1;
 1164       float y2;
 1165       float r2;
 1166     } radial_gradient;
 1167     struct
 1168     {
 1169       uint8_t code;
 1170       float x1;
 1171       float y1;
 1172       uint8_t pad0;
 1173       float x2;
 1174       float y2;
 1175     } linear_gradient;
 1176     struct
 1177     {
 1178       uint8_t code;
 1179       float x;
 1180       float y;
 1181       uint8_t pad0;
 1182       float width;
 1183       float height;
 1184       uint8_t pad1;
 1185       float radius;
 1186     } rectangle;
 1187     struct
 1188     {
 1189       uint8_t code;
 1190       uint8_t rgba[4];
 1191       uint16_t x;
 1192       uint16_t y;
 1193     } set_pixel;
 1194     struct
 1195     {
 1196       uint8_t code;
 1197       float cx;
 1198       float cy;
 1199       uint8_t pad0;
 1200       float x;
 1201       float y;
 1202     } quad_to;
 1203     struct
 1204     {
 1205       uint8_t code;
 1206       float cx;
 1207       float cy;
 1208       uint8_t pad0;
 1209       float x;
 1210       float y;
 1211     } rel_quad_to;
 1212     struct
 1213     {
 1214       uint8_t code;
 1215       float x;
 1216       float y;
 1217       uint8_t pad0;
 1218       float radius;
 1219       float angle1;
 1220       uint8_t pad1;
 1221       float angle2;
 1222       float direction;
 1223     }
 1224     arc;
 1225     struct
 1226     {
 1227       uint8_t code;
 1228       float x1;
 1229       float y1;
 1230       uint8_t pad0;
 1231       float x2;
 1232       float y2;
 1233       uint8_t pad1;
 1234       float radius;
 1235     }
 1236     arc_to;
 1237     /* some format specific generic accesors:  */
 1238     struct
 1239     {
 1240       uint8_t code;
 1241       float x0;
 1242       float y0;
 1243       uint8_t pad0;
 1244       float x1;
 1245       float y1;
 1246       uint8_t pad1;
 1247       float x2;
 1248       float y2;
 1249       uint8_t pad2;
 1250       float x3;
 1251       float y3;
 1252       uint8_t pad3;
 1253       float x4;
 1254       float y4;
 1255     } c;
 1256     struct
 1257     {
 1258       uint8_t code;
 1259       float a0;
 1260       float a1;
 1261       uint8_t pad0;
 1262       float a2;
 1263       float a3;
 1264       uint8_t pad1;
 1265       float a4;
 1266       float a5;
 1267       uint8_t pad2;
 1268       float a6;
 1269       float a7;
 1270       uint8_t pad3;
 1271       float a8;
 1272       float a9;
 1273     } f;
 1274     struct
 1275     {
 1276       uint8_t code;
 1277       uint32_t a0;
 1278       uint32_t a1;
 1279       uint8_t pad0;
 1280       uint32_t a2;
 1281       uint32_t a3;
 1282       uint8_t pad1;
 1283       uint32_t a4;
 1284       uint32_t a5;
 1285       uint8_t pad2;
 1286       uint32_t a6;
 1287       uint32_t a7;
 1288       uint8_t pad3;
 1289       uint32_t a8;
 1290       uint32_t a9;
 1291     } u32;
 1292     struct
 1293     {
 1294       uint8_t code;
 1295       uint64_t a0;
 1296       uint8_t pad0;
 1297       uint64_t a1;
 1298       uint8_t pad1;
 1299       uint64_t a2;
 1300       uint8_t pad2;
 1301       uint64_t a3;
 1302       uint8_t pad3;
 1303       uint64_t a4;
 1304     } u64;
 1305     struct
 1306     {
 1307       uint8_t code;
 1308       int32_t a0;
 1309       int32_t a1;
 1310       uint8_t pad0;
 1311       int32_t a2;
 1312       int32_t a3;
 1313       uint8_t pad1;
 1314       int32_t a4;
 1315       int32_t a5;
 1316       uint8_t pad2;
 1317       int32_t a6;
 1318       int32_t a7;
 1319       uint8_t pad3;
 1320       int32_t a8;
 1321       int32_t a9;
 1322     } s32;
 1323     struct
 1324     {
 1325       uint8_t code;
 1326       int16_t a0;
 1327       int16_t a1;
 1328       int16_t a2;
 1329       int16_t a3;
 1330       uint8_t pad0;
 1331       int16_t a4;
 1332       int16_t a5;
 1333       int16_t a6;
 1334       int16_t a7;
 1335       uint8_t pad1;
 1336       int16_t a8;
 1337       int16_t a9;
 1338       int16_t a10;
 1339       int16_t a11;
 1340       uint8_t pad2;
 1341       int16_t a12;
 1342       int16_t a13;
 1343       int16_t a14;
 1344       int16_t a15;
 1345       uint8_t pad3;
 1346       int16_t a16;
 1347       int16_t a17;
 1348       int16_t a18;
 1349       int16_t a19;
 1350     } s16;
 1351     struct
 1352     {
 1353       uint8_t code;
 1354       uint16_t a0;
 1355       uint16_t a1;
 1356       uint16_t a2;
 1357       uint16_t a3;
 1358       uint8_t pad0;
 1359       uint16_t a4;
 1360       uint16_t a5;
 1361       uint16_t a6;
 1362       uint16_t a7;
 1363       uint8_t pad1;
 1364       uint16_t a8;
 1365       uint16_t a9;
 1366       uint16_t a10;
 1367       uint16_t a11;
 1368       uint8_t pad2;
 1369       uint16_t a12;
 1370       uint16_t a13;
 1371       uint16_t a14;
 1372       uint16_t a15;
 1373       uint8_t pad3;
 1374       uint16_t a16;
 1375       uint16_t a17;
 1376       uint16_t a18;
 1377       uint16_t a19;
 1378     } u16;
 1379     struct
 1380     {
 1381       uint8_t code;
 1382       uint8_t a0;
 1383       uint8_t a1;
 1384       uint8_t a2;
 1385       uint8_t a3;
 1386       uint8_t a4;
 1387       uint8_t a5;
 1388       uint8_t a6;
 1389       uint8_t a7;
 1390       uint8_t pad0;
 1391       uint8_t a8;
 1392       uint8_t a9;
 1393       uint8_t a10;
 1394       uint8_t a11;
 1395       uint8_t a12;
 1396       uint8_t a13;
 1397       uint8_t a14;
 1398       uint8_t a15;
 1399       uint8_t pad1;
 1400       uint8_t a16;
 1401       uint8_t a17;
 1402       uint8_t a18;
 1403       uint8_t a19;
 1404       uint8_t a20;
 1405       uint8_t a21;
 1406       uint8_t a22;
 1407       uint8_t a23;
 1408     } u8;
 1409     struct
 1410     {
 1411       uint8_t code;
 1412       int8_t a0;
 1413       int8_t a1;
 1414       int8_t a2;
 1415       int8_t a3;
 1416       int8_t a4;
 1417       int8_t a5;
 1418       int8_t a6;
 1419       int8_t a7;
 1420       uint8_t pad0;
 1421       int8_t a8;
 1422       int8_t a9;
 1423       int8_t a10;
 1424       int8_t a11;
 1425       int8_t a12;
 1426       int8_t a13;
 1427       int8_t a14;
 1428       int8_t a15;
 1429       uint8_t pad1;
 1430       int8_t a16;
 1431       int8_t a17;
 1432       int8_t a18;
 1433       int8_t a19;
 1434       int8_t a20;
 1435       int8_t a21;
 1436       int8_t a22;
 1437       int8_t a23;
 1438     } s8;
 1439   };
 1440   CtxEntry next_entry; // also pads size of CtxCommand slightly.
 1441 };
 1442 
 1443 typedef struct _CtxImplementation CtxImplementation;
 1444 struct _CtxImplementation
 1445 {
 1446   void (*process) (void *renderer, CtxCommand *entry);
 1447   void (*flush)   (void *renderer);
 1448   void (*free)    (void *renderer);
 1449 };
 1450 
 1451 CtxCommand *ctx_iterator_next (CtxIterator *iterator);
 1452 
 1453 #define ctx_arg_string()  ((char*)&entry[2].data.u8[0])
 1454 
 1455 
 1456 /* The above should be public API
 1457  */
 1458 
 1459 #pragma pack(pop)
 1460 
 1461 /* access macros for nth argument of a given type when packed into
 1462  * an CtxEntry pointer in current code context
 1463  */
 1464 #define ctx_arg_float(no) entry[(no)>>1].data.f[(no)&1]
 1465 #define ctx_arg_u64(no)   entry[(no)].data.u64[0]
 1466 #define ctx_arg_u32(no)   entry[(no)>>1].data.u32[(no)&1]
 1467 #define ctx_arg_s32(no)   entry[(no)>>1].data.s32[(no)&1]
 1468 #define ctx_arg_u16(no)   entry[(no)>>2].data.u16[(no)&3]
 1469 #define ctx_arg_s16(no)   entry[(no)>>2].data.s16[(no)&3]
 1470 #define ctx_arg_u8(no)    entry[(no)>>3].data.u8[(no)&7]
 1471 #define ctx_arg_s8(no)    entry[(no)>>3].data.s8[(no)&7]
 1472 #define ctx_arg_string()  ((char*)&entry[2].data.u8[0])
 1473 
 1474 typedef enum
 1475 {
 1476   CTX_GRAY           = 1,
 1477   CTX_RGB            = 3,
 1478   CTX_DRGB           = 4,
 1479   CTX_CMYK           = 5,
 1480   CTX_DCMYK          = 6,
 1481   CTX_LAB            = 7,
 1482   CTX_LCH            = 8,
 1483   CTX_GRAYA          = 101,
 1484   CTX_RGBA           = 103,
 1485   CTX_DRGBA          = 104,
 1486   CTX_CMYKA          = 105,
 1487   CTX_DCMYKA         = 106,
 1488   CTX_LABA           = 107,
 1489   CTX_LCHA           = 108,
 1490   CTX_GRAYA_A        = 201,
 1491   CTX_RGBA_A         = 203,
 1492   CTX_RGBA_A_DEVICE  = 204,
 1493   CTX_CMYKA_A        = 205,
 1494   CTX_DCMYKA_A       = 206,
 1495   // RGB  device and  RGB  ?
 1496 } CtxColorModel;
 1497 
 1498 enum _CtxAntialias
 1499 {
 1500   CTX_ANTIALIAS_DEFAULT,
 1501   CTX_ANTIALIAS_NONE, //
 1502   CTX_ANTIALIAS_FAST, // aa 3
 1503   CTX_ANTIALIAS_GOOD, // aa 5
 1504   CTX_ANTIALIAS_BEST  // aa 17
 1505 };
 1506 typedef enum _CtxAntialias CtxAntialias;
 1507 
 1508 void         ctx_set_antialias (Ctx *ctx, CtxAntialias antialias);
 1509 CtxAntialias ctx_get_antialias (Ctx *ctx);
 1510 void         ctx_set_render_threads   (Ctx *ctx, int n_threads);
 1511 int          ctx_get_render_threads   (Ctx *ctx);
 1512 
 1513 void         ctx_set_hash_cache (Ctx *ctx, int enable_hash_cache);
 1514 int          ctx_get_hash_cache (Ctx *ctx);
 1515 
 1516 
 1517 
 1518 
 1519 
 1520 
 1521 
 1522 
 1523 
 1524 
 1525 
 1526 typedef struct _CtxParser CtxParser;
 1527   CtxParser *ctx_parser_new (
 1528   Ctx       *ctx,
 1529   int        width,
 1530   int        height,
 1531   float      cell_width,
 1532   float      cell_height,
 1533   int        cursor_x,
 1534   int        cursor_y,
 1535   int   (*set_prop)(void *prop_data, uint32_t key, const char *data,  int 
 1536          len),
 1537   int   (*get_prop)(void *prop_Data, const char *key, char **data, int *len)
 1538          ,
 1539   void  *prop_data,
 1540   void (*exit) (void *exit_data),
 1541   void *exit_data);
 1542 
 1543 void
 1544 ctx_parser_set_size (CtxParser *parser,
 1545                      int        width,
 1546                      int        height,
 1547                      float      cell_width,
 1548                      float      cell_height);
 1549 
 1550 void ctx_parser_feed_byte (CtxParser *parser, int byte);
 1551 
 1552 void ctx_parser_free (CtxParser *parser);
 1553 
 1554 #ifndef assert
 1555 #define assert(a)
 1556 #endif
 1557 
 1558 #ifdef __cplusplus
 1559 }
 1560 #endif
 1561 #endif
 1562 /* this is a ctx encoded font based on DejaVuSans.ttf */
 1563 /* CTX_SUBDIV:4  CTX_BAKE_FONT_SIZE:160 */
 1564 /* glyphs covered: 
 1565 
 1566  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi
 1567   jklmnopqrstuvwxyz{|}~  */
 1568 static const struct __attribute__ ((packed)) {uint8_t code; uint32_t a; 
 1569                                    uint32_t b;}
 1570 ctx_font_ascii[]={
 1571 {'@', 0x00000020, 0x00002bb0},/*                 x-advance: 43.687500 */
 1572 {'@', 0x00000021, 0x00003719},/*        !        x-advance: 55.097656 */
 1573 {'m', 0x41a5e7f2, 0xc1886037},
 1574 {'0', 0x44000036, 0xbc0000ca},
 1575 {'m', 0x00000000, 0xc2a64f08},
 1576 {'l', 0x4159fc90, 0x00000000},
 1577 {'l', 0x00000000, 0x422fd6c4},
 1578 {'l', 0xbfabcfe0, 0x41bfad86},
 1579 {'l', 0xc12df5b2, 0x00000000},
 1580 {'l', 0xbfb46710, 0xc1bfad86},
 1581 {'l', 0x00000000, 0xc22fd6c4},
 1582 {'@', 0x00000022, 0x00003f38},/*        "        x-advance: 63.218750 */
 1583 {'m', 0x41c50c07, 0xc2c86716},
 1584 {'l', 0x00000000, 0x4214fe48},
 1585 {'4', 0x0000ffd3, 0xff6c0000},
 1586 {'6', 0x0000002d, 0x00000065},
 1587 {'l', 0x00000000, 0x4214fe48},
 1588 {'l', 0xc1368ce4, 0x00000000},
 1589 {'l', 0x00000000, 0xc214fe48},
 1590 {'l', 0x41368ce4, 0x00000000},
 1591 {'@', 0x00000023, 0x0000732a},/*        #        x-advance: 115.164062 */
 1592 {'m', 0x428c8973, 0xc271e113},
 1593 {'0', 0x59ea00b2, 0xa716004e},
 1594 {'m', 0xc12112e8, 0xc218c06d},
 1595 {'0', 0x004e6fe5, 0x002a911c},
 1596 {'0', 0x00536fe5, 0x00a22900},
 1597 {'0', 0x005559ea, 0x00a12900},
 1598 {'0', 0x00d66fe5, 0x00b2911b},
 1599 {'0', 0x00d56fe5, 0x00ac911b},
 1600 {'0', 0x005ed700, 0x00aaa716},
 1601 {'0', 0x0060d700, 0x002b911b},
 1602 {'@', 0x00000024, 0x00005773},/*        $        x-advance: 87.449219 */
 1603 {'m', 0x4239c595, 0x41a19c59},
 1604 {'4', 0x0000ffe6, 0xffb00000},
 1605 {'8', 0xfac800e4, 0xeec8fae4},
 1606 {'l', 0x00000000, 0xc14149e1},
 1607 {'8', 0x1a37111b, 0x0839081c},
 1608 {'l', 0x00000000, 0xc1f4d50c},
 1609 {'8', 0xe0aaf7c5, 0xc1e6e9e6},
 1610 {'8', 0xbc1dd500, 0xe454e71d},
 1611 {'4', 0xffc10000, 0x0000001a},
 1612 {'l', 0x00000000, 0x417920a8},
 1613 {'8', 0x05300118, 0x0b2d0417},
 1614 {'l', 0x00000000, 0x413beb60},
 1615 {'8', 0xefd3f5ea, 0xf9d0fae9},
 1616 {'l', 0x00000000, 0x41e54302},
 1617 {'8', 0x2159093c, 0x421c181c},
 1618 {'8', 0x47e22d00, 0x1ea91ae2},
 1619 {'6', 0x00510000, 0xfee1ffe6},
 1620 {'l', 0x00000000, 0xc1dc2258},
 1621 {'8', 0x11d103e1, 0x25f00ef0},
 1622 {'8', 0x230f1700, 0x12300c0f},
 1623 {'m', 0x40d6c3d8, 0x414e2cac},
 1624 {'l', 0x00000000, 0x41e87bb4},
 1625 {'8', 0xed33fc22, 0xda11f211},
 1626 {'8', 0xdbf0e900, 0xecccf3f0},
 1627 {'@', 0x00000025, 0x0000829a},/*        %        x-advance: 130.601562 */
 1628 {'m', 0x42c7dda3, 0xc2306037},
 1629 {'8', 0x13dc00e9, 0x37f313f3},
 1630 {'8', 0x370d2200, 0x1324130d},
 1631 {'8', 0xed230016, 0xc90dec0d},
 1632 {'8', 0xc9f3dd00, 0xecddecf3},
 1633 {'m', 0x00000000, 0xc1086034},
 1634 {'8', 0x1d43002a, 0x4f181d18},
 1635 {'8', 0x4fe73200, 0x1dbd1de8},
 1636 {'8', 0xe3bd00d6, 0xb1e8e3e8},
 1637 {'8', 0xb118ce00, 0xe343e319},
 1638 {'m', 0xc28a8603, 0xc2237d6c},
 1639 {'8', 0x14dc00e9, 0x36f313f3},
 1640 {'8', 0x370d2300, 0x1324130d},
 1641 {'8', 0xed240017, 0xc90ded0d},
 1642 {'8', 0xcaf3de00, 0xecdcecf3},
 1643 {'m', 0x42726a86, 0xc1086038},
 1644 {'l', 0x412bcfe0, 0x00000000},
 1645 {'4', 0x019fff06, 0x0000ffd6},
 1646 {'6', 0xfe6100fa, 0x0000ff0e},
 1647 {'8', 0x1d43002a, 0x4f191d19},
 1648 {'8', 0x50e73200, 0x1dbd1de8},
 1649 {'8', 0xe3bd00d6, 0xb0e8e3e8},
 1650 {'8', 0xb118cf00, 0xe343e318},
 1651 {'@', 0x00000026, 0x00006b2e},/*        &        x-advance: 107.179688 */
 1652 {'m', 0x4205b0f7, 0xc257920a},
 1653 {'8', 0x2bdd15e8, 0x2df515f5},
 1654 {'8', 0x411c2700, 0x1a471a1c},
 1655 {'8', 0xf82f0019, 0xe729f816},
 1656 {'6', 0xff6fff72, 0xffe20025},
 1657 {'l', 0x42086037, 0x420b98e9},
 1658 {'8', 0xcd18e90f, 0xc70ae508},
 1659 {'l', 0x4147bb40, 0x00000000},
 1660 {'8', 0x46ef23fd, 0x44da22f3},
 1661 {'4', 0x004c004a, 0x0000ffbd},
 1662 {'l', 0xc1198e98, 0xc11dda33},
 1663 {'8', 0x23c617e5, 0x0bbf0be2},
 1664 {'8', 0xdc9700c0, 0xa2d7dbd7},
 1665 {'8', 0xc011de00, 0xc835e211},
 1666 {'8', 0xdfedf0f4, 0xdffaf0fa},
 1667 {'8', 0xbb1dd500, 0xe64fe61d},
 1668 {'8', 0x042c0016, 0x0e2d0416},
 1669 {'l', 0x00000000, 0x41436fb0},
 1670 {'8', 0xedd4f4e9, 0xfad9faeb},
 1671 {'8', 0x0fd300e4, 0x26ef0eef},
 1672 {'8', 0x1b070d00, 0x26200d08},
 1673 {'@', 0x00000027, 0x000025c9},/*        '        x-advance: 37.785156 */
 1674 {'m', 0x41c50c07, 0xc2c86716},
 1675 {'l', 0x00000000, 0x4214fe48},
 1676 {'l', 0xc1368ce3, 0x00000000},
 1677 {'l', 0x00000000, 0xc214fe48},
 1678 {'l', 0x41368ce3, 0x00000000},
 1679 {'@', 0x00000028, 0x0000359f},/*        (        x-advance: 53.621094 */
 1680 {'m', 0x422a7844, 0xc2d09732},
 1681 {'q', 0xc10fe480, 0x4176fae0},
 1682 {0, 0xc155b0f6, 0x41f44b9c},
 1683 {'q', 0xc08b98e8, 0x41719c54},
 1684 {0, 0xc08b98e8, 0x41f4d50a},
 1685 {'q', 0x00000000, 0x41780dbe},
 1686 {0, 0x408b98e8, 0x41f5e7f2},
 1687 {'9', 0x003c0011, 0x007a0035},
 1688 {'l', 0xc12bcfe2, 0x00000000},
 1689 {'q', 0xc12112e6, 0xc17c5958},
 1690 {0, 0xc1719c5a, 0xc1f80dbf},
 1691 {'q', 0xc09eed18, 0xc173c224},
 1692 {0, 0xc09eed18, 0xc1f225cc},
 1693 {'q', 0x00000000, 0xc16f768c},
 1694 {0, 0x409eed18, 0xc1f112e6},
 1695 {'q', 0x409eed1c, 0xc172af40},
 1696 {0, 0x41719c5a, 0xc1f80dc0},
 1697 {'l', 0x412bcfe2, 0x00000000},
 1698 {'@', 0x00000029, 0x0000359f},/*        )        x-advance: 53.621094 */
 1699 {'m', 0x41301b7d, 0xc2d09732},
 1700 {'l', 0x412bcfe5, 0x00000000},
 1701 {'q', 0x412112e6, 0x417d6c40},
 1702 {0, 0x41708972, 0x41f80dc0},
 1703 {'q', 0x40a112e8, 0x4172af40},
 1704 {0, 0x40a112e8, 0x41f112e6},
 1705 {'q', 0x00000000, 0x41708974},
 1706 {0, 0xc0a112e8, 0x41f225cc},
 1707 {'9', 0x003cffed, 0x007cffc4},
 1708 {'l', 0xc12bcfe5, 0x00000000},
 1709 {'q', 0x410ed19d, 0xc175e7f3},
 1710 {0, 0x41549e11, 0xc1f44b99},
 1711 {'q', 0x408dbeb4, 0xc173c226},
 1712 {0, 0x408dbeb4, 0xc1f5e7f2},
 1713 {'q', 0x00000000, 0xc1780dc0},
 1714 {0, 0xc08dbeb4, 0xc1f4d50a},
 1715 {'q', 0xc08b98e8, 0xc1719c58},
 1716 {0, 0xc1549e11, 0xc1f44b9c},
 1717 {'@', 0x0000002a, 0x000044b9},/*        *        x-advance: 68.722656 */
 1718 {'m', 0x42814302, 0xc2a761ef},
 1719 {'0', 0x346034a0, 0xcaa61af1},
 1720 {'0', 0x00e26500, 0x36a69b00},
 1721 {'0', 0xcc60e6f1, 0xe60fcca0},
 1722 {'0', 0x9b00365a, 0x6500001e},
 1723 {'l', 0x41b46716, 0xc159fc90},
 1724 {'l', 0x407920b0, 0x40d49e10},
 1725 {'@', 0x0000002b, 0x0000732a},/*        +        x-advance: 115.164062 */
 1726 {'m', 0x427ce2ca, 0xc2ac5957},
 1727 {'l', 0x00000000, 0x421587ba},
 1728 {'l', 0x421587bc, 0x00000000},
 1729 {'l', 0x00000000, 0x41368ce4},
 1730 {'l', 0xc21587bc, 0x00000000},
 1731 {'l', 0x00000000, 0x421587bb},
 1732 {'l', 0xc1346714, 0x00000000},
 1733 {'l', 0x00000000, 0xc21587bb},
 1734 {'l', 0xc21587bb, 0x00000000},
 1735 {'l', 0xb5800000, 0xc1368ce4},
 1736 {'l', 0x421587bb, 0x00000000},
 1737 {'l', 0x00000000, 0xc21587ba},
 1738 {'l', 0x41346714, 0x00000000},
 1739 {'@', 0x0000002c, 0x00002bb0},/*        ,        x-advance: 43.687500 */
 1740 {'m', 0x4180dbeb, 0xc1886037},
 1741 {'0', 0x2e000038, 0x00de55d4},
 1742 {'l', 0x40b01b7c, 0xc1abcfe4},
 1743 {'l', 0x00000000, 0xc138b2b0},
 1744 {'@', 0x0000002d, 0x00003198},/*        -        x-advance: 49.593750 */
 1745 {'m', 0x40d6c3dd, 0xc22c9e11},
 1746 {'l', 0x4210b2af, 0x00000000},
 1747 {'l', 0x00000000, 0x41301b7c},
 1748 {'l', 0xc210b2af, 0x00000000},
 1749 {'l', 0xb5c00000, 0xc1301b7c},
 1750 {'@', 0x0000002e, 0x00002bb0},/*        .        x-advance: 43.687500 */
 1751 {'m', 0x416b2af4, 0xc1886037},
 1752 {'0', 0x44000038, 0xbc0000c8},
 1753 {'@', 0x0000002f, 0x00002e4f},/*        /        x-advance: 46.308594 */
 1754 {'m', 0x420b98e9, 0xc2c86716},
 1755 {'l', 0x41368ce4, 0x00000000},
 1756 {'l', 0xc20b98e9, 0x42e1e7f2},
 1757 {'l', 0xc1368ce4, 0xb5800000},
 1758 {'l', 0x420b98e9, 0xc2e1e7f2},
 1759 {'@', 0x00000030, 0x00005773},/*        0        x-advance: 87.449219 */
 1760 {'m', 0x422ec3dd, 0xc2b68ce3},
 1761 {'q', 0xc1278448, 0x00000000},
 1762 {0, 0xc17c5956, 0x41255e80},
 1763 {'q', 0xc0a7844c, 0x41244b98},
 1764 {0, 0xc0a7844c, 0x41f7844c},
 1765 {'q', 0x00000000, 0x41a4d50c},
 1766 {0, 0x40a7844c, 0x41f7844c},
 1767 {'8', 0x293f2915, 0xd73f002a},
 1768 {'q', 0x40a9aa18, 0xc1255e80},
 1769 {0, 0x40a9aa18, 0xc1f7844c},
 1770 {'q', 0x00000000, 0xc1a55e80},
 1771 {0, 0xc0a9aa18, 0xc1f7844c},
 1772 {'9', 0xffd7ffec, 0xffd7ffc1},
 1773 {'m', 0x00000000, 0xc12bcfe0},
 1774 {'q', 0x4186c3de, 0x00000000},
 1775 {0, 0x41cda33a, 0x4155b0f8},
 1776 {'q', 0x410ed198, 0x41549e10},
 1777 {0, 0x410ed198, 0x421aa180},
 1778 {'q', 0x00000000, 0x41ca6a86},
 1779 {0, 0xc10ed198, 0x421aa181},
 1780 {'8', 0x359a35dd, 0xcb9900bd},
 1781 {'q', 0xc10dbeb5, 0xc155b0f8},
 1782 {0, 0xc10dbeb5, 0xc21aa181},
 1783 {'q', 0x00000000, 0xc1caf3f8},
 1784 {0, 0x410dbeb5, 0xc21aa180},
 1785 {'q', 0x410ed19c, 0xc155b0f8},
 1786 {0, 0x41ce2cab, 0xc155b0f8},
 1787 {'@', 0x00000031, 0x00005773},/*        1        x-advance: 87.449219 */
 1788 {'m', 0x41886037, 0xc1368ce3},
 1789 {'l', 0x41b12e63, 0x00000000},
 1790 {'l', 0x00000000, 0xc298e2cb},
 1791 {'0', 0xcf0013a0, 0x0036ed5f},
 1792 {'l', 0x00000000, 0x42b1957a},
 1793 {'l', 0x41b12e64, 0xb6400000},
 1794 {'l', 0x00000000, 0x41368ce3},
 1795 {'l', 0xc266df5a, 0x00000000},
 1796 {'l', 0xb6000000, 0xc1368ce3},
 1797 {'@', 0x00000032, 0x00005773},/*        2        x-advance: 87.449219 */
 1798 {'m', 0x41d301b8, 0xc1368ce3},
 1799 {'l', 0x423d4302, 0x00000000},
 1800 {'4', 0x002d0000, 0x0000ff02},
 1801 {'l', 0xb6000000, 0xc1368ce3},
 1802 {'8', 0xab54e11e, 0xbb43cb35},
 1803 {'8', 0xcf24e31a, 0xd90aec0a},
 1804 {'8', 0xcceae100, 0xecc6ecea},
 1805 {'8', 0x08cb00e7, 0x1ac408e4},
 1806 {'l', 0x00000000, 0xc15b0f78},
 1807 {'8', 0xed3df320, 0xfa34fa1c},
 1808 {'8', 0x1f63003e, 0x53251f25},
 1809 {'8', 0x2ef71800, 0x34df16f7},
 1810 {'8', 0x2dd607fa, 0x679b25dd},
 1811 {'@', 0x00000033, 0x00005773},/*        3        x-advance: 87.449219 */
 1812 {'m', 0x425f1656, 0xc2581b7d},
 1813 {'8', 0x223c0826, 0x40161a16},
 1814 {'q', 0x00000000, 0x416d50c0},
 1815 {0, 0xc12338b8, 0x41b79fc8},
 1816 {'q', 0xc12338b0, 0x4101eed3},
 1817 {0, 0xc1e7f240, 0x4101eed3},
 1818 {'8', 0xfccc00e7, 0xf1c9fbe6},
 1819 {'l', 0x00000000, 0xc151655e},
 1820 {'8', 0x13310d16, 0x0638061a},
 1821 {'8', 0xec4d0033, 0xc61aec1a},
 1822 {'8', 0xc9e8dd00, 0xecbcece8},
 1823 {'4', 0x0000ffd2, 0xffd40000},
 1824 {'l', 0x41436fae, 0x00000000},
 1825 {'8', 0xf13d0028, 0xd215f015},
 1826 {'8', 0xd1eae200, 0xf0c2f0eb},
 1827 {'8', 0x04d100ea, 0x0fc804e7},
 1828 {'l', 0x00000000, 0xc14149e0},
 1829 {'8', 0xf439f81e, 0xfc33fc1b},
 1830 {'8', 0x1c61003d, 0x4b231b23},
 1831 {'8', 0x38ed2100, 0x1fca16ed},
 1832 {'@', 0x00000034, 0x00005773},/*        4        x-advance: 87.449219 */
 1833 {'m', 0x424fc905, 0xc2b0c74d},
 1834 {'4', 0x00d5ff78, 0x00000088},
 1835 {'6', 0xff2b0000, 0xffd1fff2},
 1836 {'l', 0x41886038, 0x00000000},
 1837 {'l', 0x00000000, 0x42829aa2},
 1838 {'0', 0x2d000039, 0x5e0000c7},
 1839 {'l', 0xc157d6c4, 0x00000000},
 1840 {'l', 0x00000000, 0xc1bcfe48},
 1841 {'l', 0xc234f089, 0x00000000},
 1842 {'l', 0xb5c00000, 0xc151655c},
 1843 {'l', 0x4226b61e, 0xc27df5b1},
 1844 {'@', 0x00000035, 0x00005773},/*        5        x-advance: 87.449219 */
 1845 {'m', 0x416d50c0, 0xc2c86716},
 1846 {'l', 0x4254e2ca, 0x00000000},
 1847 {'4', 0x002d0000, 0x0000ff5d},
 1848 {'l', 0x00000000, 0x41c48294},
 1849 {'8', 0xfb17fc0b, 0xfe17fe0b},
 1850 {'8', 0x246a0043, 0x63272427},
 1851 {'q', 0x00000000, 0x4181655f},
 1852 {0, 0xc12112e8, 0x41c957a0},
 1853 {'q', 0xc12112e4, 0x410ed19d},
 1854 {0, 0xc1e31d34, 0x410ed19d},
 1855 {'8', 0xfccd00e7, 0xf4cbfce6},
 1856 {'l', 0x00000000, 0xc159fc90},
 1857 {'8', 0x13310d18, 0x06360619},
 1858 {'8', 0xe849002e, 0xbe1be81b},
 1859 {'8', 0xbee5d700, 0xe8b7e8e5},
 1860 {'8', 0x04d500eb, 0x0fd404eb},
 1861 {'l', 0x00000000, 0xc249579f},
 1862 {'@', 0x00000036, 0x00005773},/*        6        x-advance: 87.449219 */
 1863 {'m', 0x423579fc, 0xc25e036f},
 1864 {'8', 0x18c700dc, 0x44eb18eb},
 1865 {'8', 0x44152b00, 0x18391815},
 1866 {'8', 0xe8390024, 0xbc15e715},
 1867 {'8', 0xbcebd500, 0xe8c7e8eb},
 1868 {'m', 0x41d74d50, 0xc229eed1},
 1869 {'l', 0x00000000, 0x41459578},
 1870 {'8', 0xf2d7f7ec, 0xfbd7fbec},
 1871 {'8', 0x24ae00cb, 0x6de024e4},
 1872 {'8', 0xdd27e90f, 0xf434f417},
 1873 {'8', 0x245f003c, 0x63232423},
 1874 {'8', 0x63dc3d00, 0x259f25dc},
 1875 {'q', 0xc18b0f76, 0xb4c00000},
 1876 {0, 0xc1d49e10, 0xc1549e11},
 1877 {'q', 0xc1131d36, 0xc155b0f8},
 1878 {0, 0xc1131d36, 0xc21aa181},
 1879 {'q', 0x00000000, 0xc1be112c},
 1880 {0, 0x41346716, 0xc21768ce},
 1881 {'q', 0x41346718, 0xc16293c0},
 1882 {0, 0x41f225cc, 0xc16293c0},
 1883 {'8', 0x04290014, 0x0c2b0414},
 1884 {'@', 0x00000037, 0x00005773},/*        7        x-advance: 87.449219 */
 1885 {'m', 0x41346716, 0xc2c86716},
 1886 {'l', 0x4280dbeb, 0x00000000},
 1887 {'l', 0x00000000, 0x40b8b2b0},
 1888 {'l', 0xc21180dc, 0x42bcdbeb},
 1889 {'l', 0xc16293c2, 0x00000000},
 1890 {'l', 0x4208e9aa, 0xc2b1957a},
 1891 {'l', 0xc2407bb4, 0x00000000},
 1892 {'l', 0xb6000000, 0xc1368ce0},
 1893 {'@', 0x00000038, 0x00005773},/*        8        x-advance: 87.449219 */
 1894 {'m', 0x422ec3dd, 0xc23e55e8},
 1895 {'8', 0x14c400da, 0x38ea14ea},
 1896 {'8', 0x38162400, 0x143c1416},
 1897 {'8', 0xec3c0026, 0xc816ec16},
 1898 {'8', 0xc8eadc00, 0xecc4ecea},
 1899 {'m', 0xc158e9a8, 0xc0b8b2b0},
 1900 {'8', 0xe0caf8de, 0xc6ede9ed},
 1901 {'8', 0xb522d000, 0xe55de522},
 1902 {'8', 0x1b5d003b, 0x4b221b22},
 1903 {'8', 0x3aed2200, 0x20cb17ed},
 1904 {'8', 0x233c0927, 0x40161a16},
 1905 {'8', 0x59dd3a00, 0x1f9b1fdd},
 1906 {'8', 0xe19a00be, 0xa7dde1dd},
 1907 {'8', 0xc016da00, 0xdd3de616},
 1908 {'m', 0xc09eed1c, 0xc1ab4670},
 1909 {'8', 0x30131f00, 0x11361113},
 1910 {'8', 0xef360022, 0xd013ef13},
 1911 {'8', 0xd0ede100, 0xefcaefed},
 1912 {'8', 0x11ca00dd, 0x30ed11ed},
 1913 {'@', 0x00000039, 0x00005773},/*        9        x-advance: 87.449219 */
 1914 {'m', 0x41719c59, 0xc0052784},
 1915 {'l', 0x00000000, 0xc145957a},
 1916 {'8', 0x0e290914, 0x05290514},
 1917 {'8', 0xdd510035, 0x9320dc1c},
 1918 {'8', 0x23d917f1, 0x0ccc0ce9},
 1919 {'8', 0xdca100c4, 0x9ddedcde},
 1920 {'8', 0x9d24c300, 0xdb61db24},
 1921 {'q', 0x418b0f76, 0x00000000},
 1922 {0, 0x41d4149c, 0x4155b0f8},
 1923 {'q', 0x41131d38, 0x41549e10},
 1924 {0, 0x41131d38, 0x421aa180},
 1925 {'q', 0x00000000, 0x41bd87bc},
 1926 {0, 0xc1346718, 0x421768ce},
 1927 {'q', 0xc133542c, 0x416180dd},
 1928 {0, 0xc1f19c58, 0x416180dd},
 1929 {'8', 0xfcd700ec, 0xf4d5fcec},
 1930 {'m', 0x41d7d6c4, 0xc229eed2},
 1931 {'8', 0xe8390024, 0xbc15e815},
 1932 {'8', 0xbcebd500, 0xe7c7e7eb},
 1933 {'8', 0x19c700dc, 0x44eb18eb},
 1934 {'8', 0x44152b00, 0x18391815},
 1935 {'@', 0x0000003a, 0x00002e4f},/*        :        x-advance: 46.308594 */
 1936 {'m', 0x4180dbeb, 0xc1886037},
 1937 {'0', 0x44000038, 0xbc0000c8},
 1938 {'m', 0x00000000, 0xc2581b7c},
 1939 {'0', 0x44000038, 0xbc0000c8},
 1940 {'@', 0x0000003b, 0x00002e4f},/*        ;        x-advance: 46.308594 */
 1941 {'m', 0x4180dbeb, 0xc28e25cc},
 1942 {'0', 0x44000038, 0xbc0000c8},
 1943 {'m', 0x00000000, 0x42581b7c},
 1944 {'0', 0x2e000038, 0x00de55d4},
 1945 {'l', 0x40b01b7c, 0xc1abcfe4},
 1946 {'l', 0x00000000, 0xc138b2b0},
 1947 {'@', 0x0000003c, 0x0000732a},/*        <        x-advance: 115.164062 */
 1948 {'m', 0x42c93543, 0xc2874d51},
 1949 {'l', 0xc28a8604, 0x41c50c08},
 1950 {'l', 0x428a8604, 0x41c3f921},
 1951 {'l', 0x00000000, 0x41436fac},
 1952 {'l', 0xc2ac149e, 0xc1f9aa17},
 1953 {'l', 0xb5800000, 0xc132414c},
 1954 {'l', 0x42ac149e, 0xc1f9aa16},
 1955 {'l', 0x00000000, 0x41436fa8},
 1956 {'@', 0x0000003d, 0x0000732a},/*        =        x-advance: 115.164062 */
 1957 {'m', 0x41690527, 0xc279aa18},
 1958 {'l', 0x42ac149e, 0x00000000},
 1959 {'4', 0x002d0000, 0x0000fea8},
 1960 {'6', 0xffd30000, 0x006d0000},
 1961 {'l', 0x42ac149e, 0x00000000},
 1962 {'l', 0x00000000, 0x41368ce4},
 1963 {'l', 0xc2ac149e, 0x00000000},
 1964 {'l', 0xb5800000, 0xc1368ce4},
 1965 {'@', 0x0000003e, 0x0000732a},/*        >        x-advance: 115.164062 */
 1966 {'m', 0x41690527, 0xc2874d51},
 1967 {'l', 0x00000000, 0xc1436fa8},
 1968 {'l', 0x42ac149e, 0x41f9aa16},
 1969 {'l', 0x00000000, 0x4132414c},
 1970 {'l', 0xc2ac149e, 0x41f9aa17},
 1971 {'l', 0xb5800000, 0xc1436fac},
 1972 {'l', 0x428a414a, 0xc1c3f921},
 1973 {'l', 0xc28a414a, 0xc1c50c08},
 1974 {'@', 0x0000003f, 0x000048f3},/*        ?        x-advance: 72.949219 */
 1975 {'m', 0x41d1eed1, 0xc1886037},
 1976 {'0', 0x44000036, 0xbc0000ca},
 1977 {'m', 0x41538b2a, 0xc11dda32},
 1978 {'4', 0x0000ffcd, 0xffd70000},
 1979 {'8', 0xd407e500, 0xd81fef07},
 1980 {'l', 0x40c149e0, 0xc0bf2418},
 1981 {'8', 0xe616f20f, 0xe706f406},
 1982 {'8', 0xdaefe900, 0xf2d2f2ef},
 1983 {'8', 0x09d300eb, 0x1bcf09e9},
 1984 {'l', 0x00000000, 0xc149e110},
 1985 {'8', 0xea33f119, 0xf935f91a},
 1986 {'8', 0x1a4f0031, 0x441e1a1e},
 1987 {'8', 0x26f71400, 0x29df12f7},
 1988 {'l', 0xc0bcfe48, 0x40b8b2b0},
 1989 {'8', 0x13ef0cf4, 0x0df906fb},
 1990 {'8', 0x0dfe05ff, 0x16000800},
 1991 {'l', 0x00000000, 0x410414a0},
 1992 {'@', 0x00000040, 0x00008973},/*        @        x-advance: 137.449219 */
 1993 {'m', 0x424c9052, 0xc210293c},
 1994 {'8', 0x3c132600, 0x15341513},
 1995 {'8', 0xea330021, 0xc413ea13},
 1996 {'8', 0xc5eddb00, 0xeacceaed},
 1997 {'8', 0x16cd00e0, 0x3bed16ed},
 1998 {'m', 0x42124f08, 0x41a08973},
 1999 {'8', 0x1edb14f0, 0x09d009ec},
 2000 {'8', 0xdfb500d2, 0xa9e4dfe4},
 2001 {'8', 0xa91ccb00, 0xdf4adf1c},
 2002 {'8', 0x0a30001b, 0x1e240914},
 2003 {'4', 0xffdd0000, 0x00000026},
 2004 {'l', 0x00000000, 0x4245957a},
 2005 {'8', 0xdd3dfb27, 0xb316e216},
 2006 {'8', 0xcbf8e400, 0xd2e7e7f8},
 2007 {'8', 0xcbbcdde5, 0xeea9eed8},
 2008 {'8', 0x08c100df, 0x19c808e2},
 2009 {'8', 0x47be1bd6, 0x60e92ce9},
 2010 {'8', 0x4f0f2a00, 0x412c250f},
 2011 {'8', 0x2a411b1c, 0x0e4f0e25},
 2012 {'8', 0xf5430022, 0xdf3df521},
 2013 {'l', 0x40c149e0, 0x40ee63a6},
 2014 {'8', 0x28b71adf, 0x0db00dd9},
 2015 {'8', 0xefa300cf, 0xcdb2efd4},
 2016 {'8', 0xb3ccdfde, 0xa1efd4ef},
 2017 {'8', 0xa312d000, 0xb334d412},
 2018 {'8', 0xcc50de22, 0xee60ee2d},
 2019 {'8', 0x17690038, 0x42511730},
 2020 {'8', 0x391e1a14, 0x3f0a1e0a},
 2021 {'q', 0x00000000, 0x418d3543},
 2022 {0, 0xc12abd00, 0x41ded19d},
 2023 {'q', 0xc12abd00, 0x412338b2},
 2024 {0, 0xc1ebb468, 0x4129aa17},
 2025 {'l', 0x00000000, 0xc1255e7f},
 2026 {'@', 0x00000041, 0x00005e06},/*        A        x-advance: 94.023438 */
 2027 {'m', 0x423beb62, 0xc2adb0f7},
 2028 {'4', 0x00c7ffb7, 0x00000093},
 2029 {'6', 0xff39ffb7, 0xffcbffe2},
 2030 {'l', 0x4175e7f4, 0x00000000},
 2031 {'l', 0x4218c06d, 0x42c86716},
 2032 {'l', 0xc16180d8, 0x00000000},
 2033 {'l', 0xc1120a50, 0xc1cda338},
 2034 {'l', 0xc234abd0, 0x00000000},
 2035 {'l', 0xc1120a4e, 0x41cda338},
 2036 {'l', 0xc164b98e, 0x00000000},
 2037 {'l', 0x42190527, 0xc2c86716},
 2038 {'@', 0x00000042, 0x00005e4b},/*        B        x-advance: 94.292969 */
 2039 {'m', 0x41d86037, 0xc23f68ce},
 2040 {'4', 0x00920000, 0x00000056},
 2041 {'8', 0xef40002b, 0xc915ee15},
 2042 {'8', 0xc9ebdb00, 0xefc0efec},
 2043 {'6', 0x0000ffaa, 0xff5c0000},
 2044 {'4', 0x00780000, 0x00000050},
 2045 {'8', 0xf23b0027, 0xd313f113},
 2046 {'8', 0xd3ede200, 0xf1c5f1ed},
 2047 {'6', 0x0000ffb0, 0xffd4ffca},
 2048 {'l', 0x420a8603, 0x00000000},
 2049 {'8', 0x195f003e, 0x49211921},
 2050 {'8', 0x3aef2400, 0x1bce15ef},
 2051 {'8', 0x233e0827, 0x43161b16},
 2052 {'8', 0x52dc3500, 0x1d991ddc},
 2053 {'l', 0xc20fe482, 0x00000000},
 2054 {'l', 0x00000000, 0xc2c86716},
 2055 {'@', 0x00000043, 0x00005ff9},/*        C        x-advance: 95.972656 */
 2056 {'m', 0x42b10c07, 0xc2b8f769},
 2057 {'l', 0x00000000, 0x4164b990},
 2058 {'8', 0xdac6e7e5, 0xf4bff4e2},
 2059 {'q', 0xc189731c, 0x00000000},
 2060 {0, 0xc1d27843, 0x41289730},
 2061 {'q', 0xc1120a50, 0x41278450},
 2062 {0, 0xc1120a50, 0x41f2af40},
 2063 {'q', 0x00000000, 0x419e63a7},
 2064 {0, 0x41120a50, 0x41f2af40},
 2065 {'8', 0x29692924, 0xf4410022},
 2066 {'9', 0xfff4001f, 0xffda003a},
 2067 {'l', 0x00000000, 0x416293c2},
 2068 {'8', 0x1cc413e4, 0x09bd09e1},
 2069 {'q', 0xc1b60370, 0x34000000},
 2070 {0, 0xc20f5b10, 0xc15e4828},
 2071 {'q', 0xc151655c, 0xc15f5b10},
 2072 {0, 0xc151655c, 0xc21836fb},
 2073 {'q', 0x00000000, 0xc1c149e0},
 2074 {0, 0x4151655e, 0xc21836fa},
 2075 {'q', 0x4151655e, 0xc15f5b10},
 2076 {0, 0x420f5b10, 0xc15f5b10},
 2077 {'8', 0x09430023, 0x1c3b091f},
 2078 {'@', 0x00000044, 0x000069d6},/*        D        x-advance: 105.835938 */
 2079 {'m', 0x41d86037, 0xc2b21eed},
 2080 {'4', 0x01370000, 0x00000041},
 2081 {'q', 0x41a5e7f2, 0x00000000},
 2082 {0, 0x41f2af3e, 0xc11655e8},
 2083 {'q', 0x411aa180, 0xc11655e8},
 2084 {0, 0x411aa180, 0xc1ed50bf},
 2085 {'q', 0x00000000, 0xc1a112e8},
 2086 {0, 0xc11aa180, 0xc1ebb468},
 2087 {'9', 0xffdbffda, 0xffdbff87},
 2088 {'6', 0x0000ffbf, 0xffd4ffca},
 2089 {'l', 0x41ded19c, 0x00000000},
 2090 {'q', 0x41e90526, 0x00000000},
 2091 {0, 0x422b01b7, 0x41425cc8},
 2092 {'q', 0x4159fc90, 0x414149e0},
 2093 {0, 0x4159fc90, 0x421768ce},
 2094 {'q', 0x00000000, 0x41cf3f91},
 2095 {0, 0xc15b0f78, 0x421836fa},
 2096 {'9', 0x0030ffca, 0x0030ff56},
 2097 {'l', 0xc1ded19c, 0x00000000},
 2098 {'l', 0x00000000, 0xc2c86716},
 2099 {'@', 0x00000045, 0x000056d8},/*        E        x-advance: 86.843750 */
 2100 {'m', 0x4157d6c4, 0xc2c86716},
 2101 {'l', 0x427d6c3d, 0x00000000},
 2102 {'l', 0x00000000, 0x41368ce0},
 2103 {'l', 0xc24731d2, 0x00000000},
 2104 {'l', 0xb6000000, 0x41ed50c2},
 2105 {'l', 0x423edf5a, 0x00000000},
 2106 {'l', 0x00000000, 0x41368ce0},
 2107 {'l', 0xc23edf5a, 0x00000000},
 2108 {'l', 0xb6000000, 0x42113c22},
 2109 {'l', 0x424c06de, 0x35800000},
 2110 {'l', 0x00000000, 0x41368ce3},
 2111 {'l', 0xc28120a4, 0x00000000},
 2112 {'l', 0xb6800000, 0xc2c86716},
 2113 {'@', 0x00000046, 0x00004f0f},/*        F        x-advance: 79.058594 */
 2114 {'m', 0x4157d6c4, 0xc2c86716},
 2115 {'l', 0x426655e7, 0x00000000},
 2116 {'l', 0x00000000, 0x41368ce0},
 2117 {'l', 0xc2301b7c, 0x00000000},
 2118 {'l', 0xb6000000, 0x41ec3dda},
 2119 {'l', 0x421eed18, 0x00000000},
 2120 {'l', 0x00000000, 0x41368ce4},
 2121 {'l', 0xc21eed18, 0x00000000},
 2122 {'l', 0xb6000000, 0x423f68ce},
 2123 {'l', 0xc158e9aa, 0x00000000},
 2124 {'l', 0x00000000, 0xc2c86716},
 2125 {'@', 0x00000047, 0x00006a82},/*        G        x-advance: 106.507812 */
 2126 {'m', 0x42a39fc9, 0xc164b98e},
 2127 {'l', 0x00000000, 0xc1d74d51},
 2128 {'l', 0xc1b12e64, 0x00000000},
 2129 {'4', 0xffd40000, 0x0000008e},
 2130 {'l', 0x00000000, 0x422c149e},
 2131 {'8', 0x21bb16e1, 0x0bb00bdb},
 2132 {'q', 0xc1bbeb62, 0x34000000},
 2133 {0, 0xc2131d36, 0xc15b0f76},
 2134 {'q', 0xc1538b28, 0xc15c225c},
 2135 {0, 0xc1538b28, 0xc2190528},
 2136 {'q', 0x00000000, 0xc1c48294},
 2137 {0, 0x41538b2a, 0xc2190526},
 2138 {'q', 0x41549e12, 0xc15c2260},
 2139 {0, 0x42131d36, 0xc15c2260},
 2140 {'8', 0x094a0027, 0x1c410923},
 2141 {'l', 0x00000000, 0x4166df60},
 2142 {'8', 0xdac1e7e2, 0xf4b9f4df},
 2143 {'q', 0xc1931d34, 0x00000000},
 2144 {0, 0xc1dd3542, 0x41244b98},
 2145 {'q', 0xc1131d36, 0x41244b98},
 2146 {0, 0xc1131d36, 0x41f4d50c},
 2147 {'q', 0x00000000, 0x41a225cd},
 2148 {0, 0x41131d36, 0x41f44b99},
 2149 {'8', 0x296e2925, 0xfc33001c},
 2150 {'q', 0x40b46720, 0xbfa338b0},
 2151 {0, 0x412225d0, 0xc07920a4},
 2152 {'@', 0x00000048, 0x0000675b},/*        H        x-advance: 103.355469 */
 2153 {'m', 0x4157d6c4, 0xc2c86716},
 2154 {'l', 0x4158e9aa, 0x00000000},
 2155 {'l', 0x00000000, 0x42244b99},
 2156 {'l', 0x42450c06, 0x00000000},
 2157 {'l', 0x00000000, 0xc2244b99},
 2158 {'l', 0x4158e9a8, 0x00000000},
 2159 {'l', 0x00000000, 0x42c86716},
 2160 {'l', 0xc158e9a8, 0x00000000},
 2161 {'l', 0x00000000, 0xc23edf5b},
 2162 {'l', 0xc2450c06, 0x00000000},
 2163 {'l', 0xb6000000, 0x423edf5b},
 2164 {'l', 0xc158e9aa, 0x00000000},
 2165 {'l', 0x00000000, 0xc2c86716},
 2166 {'@', 0x00000049, 0x00002889},/*        I        x-advance: 40.535156 */
 2167 {'m', 0x4157d6c4, 0xc2c86716},
 2168 {'l', 0x4158e9aa, 0x00000000},
 2169 {'l', 0x00000000, 0x42c86716},
 2170 {'l', 0xc158e9aa, 0x00000000},
 2171 {'l', 0x00000000, 0xc2c86716},
 2172 {'@', 0x0000004a, 0x00002889},/*        J        x-advance: 40.535156 */
 2173 {'m', 0x4157d6c4, 0xc2c86716},
 2174 {'4', 0x00000036, 0x01740000},
 2175 {'8', 0x69e54800, 0x20a820e5},
 2176 {'4', 0x0000ffec, 0xffd30000},
 2177 {'l', 0x40874d50, 0x00000000},
 2178 {'8', 0xec320023, 0xb80eec0e},
 2179 {'l', 0x00000000, 0xc2ba7165},
 2180 {'@', 0x0000004b, 0x00005a22},/*        K        x-advance: 90.132812 */
 2181 {'m', 0x4157d6c4, 0xc2c86716},
 2182 {'l', 0x4158e9aa, 0x00000000},
 2183 {'l', 0x00000000, 0x4229655e},
 2184 {'l', 0x4233dda2, 0xc229655e},
 2185 {'l', 0x418b98ec, 0x00000000},
 2186 {'l', 0xc246ed1a, 0x423ad87b},
 2187 {'l', 0x42552784, 0x4255f5b1},
 2188 {'l', 0xc18ed19c, 0x00000000},
 2189 {'l', 0xc2407bb4, 0xc2410527},
 2190 {'l', 0xb6000000, 0x42410527},
 2191 {'l', 0xc158e9aa, 0x00000000},
 2192 {'l', 0x00000000, 0xc2c86716},
 2193 {'@', 0x0000004c, 0x00004c93},/*        L        x-advance: 76.574219 */
 2194 {'m', 0x4157d6c4, 0xc2c86716},
 2195 {'l', 0x4158e9aa, 0x00000000},
 2196 {'l', 0x00000000, 0x42b1957a},
 2197 {'l', 0x42432af4, 0xb6400000},
 2198 {'l', 0x00000000, 0x41368ce3},
 2199 {'l', 0xc279655f, 0x00000000},
 2200 {'l', 0x00000000, 0xc2c86716},
 2201 {'@', 0x0000004d, 0x00007697},/*        M        x-advance: 118.589844 */
 2202 {'m', 0x4157d6c4, 0xc2c86716},
 2203 {'l', 0x41a19c58, 0x00000000},
 2204 {'l', 0x41cc9054, 0x42886036},
 2205 {'l', 0x41cda336, 0xc2886036},
 2206 {'l', 0x41a19c5c, 0x00000000},
 2207 {'l', 0x00000000, 0x42c86716},
 2208 {'l', 0xc1538b30, 0x00000000},
 2209 {'l', 0x00000000, 0xc2aff920},
 2210 {'l', 0xc1ceb61c, 0x4289731c},
 2211 {'l', 0xc159fc94, 0x36800000},
 2212 {'l', 0xc1ceb61e, 0xc289731c},
 2213 {'l', 0x00000000, 0x42aff920},
 2214 {'l', 0xc1527844, 0x00000000},
 2215 {'l', 0x00000000, 0xc2c86716},
 2216 {'@', 0x0000004e, 0x000066d1},/*        N        x-advance: 102.816406 */
 2217 {'m', 0x4157d6c4, 0xc2c86716},
 2218 {'l', 0x41920a4f, 0x00000000},
 2219 {'l', 0x4231b7d6, 0x42a7a6a8},
 2220 {'l', 0x00000000, 0xc2a7a6a8},
 2221 {'l', 0x41527848, 0x00000000},
 2222 {'l', 0x00000000, 0x42c86716},
 2223 {'l', 0xc1920a50, 0x00000000},
 2224 {'l', 0xc231b7d6, 0xc2a7a6a8},
 2225 {'l', 0x00000000, 0x42a7a6a8},
 2226 {'l', 0xc1527844, 0x00000000},
 2227 {'l', 0x00000000, 0xc2c86716},
 2228 {'@', 0x0000004f, 0x00006c30},/*        O        x-advance: 108.187500 */
 2229 {'m', 0x4258a4f0, 0xc2b6036f},
 2230 {'q', 0xc16c3dd8, 0x00000000},
 2231 {0, 0xc1bbeb61, 0x41301b78},
 2232 {'q', 0xc10a8604, 0x41301b80},
 2233 {0, 0xc10a8604, 0x41f00000},
 2234 {'q', 0x00000000, 0x419768cf},
 2235 {0, 0x410a8604, 0x41ef768d},
 2236 {'8', 0x2c5d2c22, 0xd45d003b},
 2237 {'q', 0x410a8600, 0xc1301b7c},
 2238 {0, 0x410a8600, 0xc1ef768d},
 2239 {'q', 0x00000000, 0xc197f240},
 2240 {0, 0xc10a8600, 0xc1f00000},
 2241 {'9', 0xffd4ffde, 0xffd4ffa3},
 2242 {'m', 0x00000000, 0xc1301b80},
 2243 {'q', 0x41a89730, 0x00000000},
 2244 {0, 0x4206c3de, 0x416293c0},
 2245 {'q', 0x4149e110, 0x416180e0},
 2246 {0, 0x4149e110, 0x421768ce},
 2247 {'q', 0x00000000, 0x41bd87bc},
 2248 {0, 0xc149e110, 0x421768ce},
 2249 {'q', 0xc149e118, 0x416180dd},
 2250 {0, 0xc206c3de, 0x416180dd},
 2251 {'q', 0xc1a920a4, 0xb4c00000},
 2252 {0, 0xc2074d50, 0xc16180dc},
 2253 {'q', 0xc149e114, 0xc16180db},
 2254 {0, 0xc149e114, 0xc21768ce},
 2255 {'q', 0x00000000, 0xc1be112c},
 2256 {0, 0x4149e112, 0xc21768ce},
 2257 {'q', 0x414af3fa, 0xc16293c0},
 2258 {0, 0x42074d50, 0xc16293c0},
 2259 {'@', 0x00000050, 0x000052e2},/*        P        x-advance: 82.882812 */
 2260 {'m', 0x41d86037, 0xc2b21eed},
 2261 {'4', 0x00960000, 0x00000044},
 2262 {'8', 0xed3a0025, 0xc914ed14},
 2263 {'8', 0xc9ecdd00, 0xedc6edec},
 2264 {'6', 0x0000ffbc, 0xffd4ffca},
 2265 {'l', 0x41f4d50c, 0x00000000},
 2266 {'8', 0x1e650043, 0x59221e22},
 2267 {'8', 0x59de3b00, 0x1e9b1ede},
 2268 {'l', 0xc1886037, 0x00000000},
 2269 {'l', 0x00000000, 0x422112e6},
 2270 {'l', 0xc158e9aa, 0x00000000},
 2271 {'l', 0x00000000, 0xc2c86716},
 2272 {'@', 0x00000051, 0x00006c30},/*        Q        x-advance: 108.187500 */
 2273 {'m', 0x4258a4f0, 0xc2b6036f},
 2274 {'q', 0xc16c3dd8, 0x00000000},
 2275 {0, 0xc1bbeb61, 0x41301b78},
 2276 {'q', 0xc10a8604, 0x41301b80},
 2277 {0, 0xc10a8604, 0x41f00000},
 2278 {'q', 0x00000000, 0x419768cf},
 2279 {0, 0x410a8604, 0x41ef768d},
 2280 {'8', 0x2c5d2c22, 0xd45d003b},
 2281 {'q', 0x410a8600, 0xc1301b7c},
 2282 {0, 0x410a8600, 0xc1ef768d},
 2283 {'q', 0x00000000, 0xc197f240},
 2284 {0, 0xc10a8600, 0xc1f00000},
 2285 {'9', 0xffd4ffde, 0xffd4ffa3},
 2286 {'m', 0x4197f240, 0x42b263a6},
 2287 {'4', 0x004e0047, 0x0000ffbf},
 2288 {'l', 0xc16d50bc, 0xc1805278},
 2289 {'8', 0x00f300f8, 0x00f800fc},
 2290 {'q', 0xc1a920a4, 0x00000000},
 2291 {0, 0xc2074d50, 0xc16180dc},
 2292 {'q', 0xc149e114, 0xc16293c1},
 2293 {0, 0xc149e114, 0xc21768ce},
 2294 {'q', 0x00000000, 0xc1be112c},
 2295 {0, 0x4149e112, 0xc21768ce},
 2296 {'q', 0x414af3fa, 0xc16293c0},
 2297 {0, 0x42074d50, 0xc16293c0},
 2298 {'q', 0x41a89730, 0x00000000},
 2299 {0, 0x4206c3de, 0x416293c0},
 2300 {'q', 0x4149e110, 0x416180e0},
 2301 {0, 0x4149e110, 0x421768ce},
 2302 {'q', 0x00000000, 0x418b98ea},
 2303 {0, 0xc0e180e0, 0x41eeed1a},
 2304 {'q', 0xc0df5b10, 0x4146a860},
 2305 {0, 0xc1a225cc, 0x419293c2},
 2306 {'@', 0x00000052, 0x00005f80},/*        R        x-advance: 95.500000 */
 2307 {'m', 0x427406df, 0xc23beb62},
 2308 {'8', 0x19210511, 0x35211310},
 2309 {'4', 0x006d0037, 0x0000ffc6},
 2310 {'l', 0xc14d19c8, 0xc1cda338},
 2311 {'8', 0xcbdad8ed, 0xf3cef3ee},
 2312 {'l', 0xc16c3dda, 0x00000000},
 2313 {'l', 0x00000000, 0x4229655e},
 2314 {'4', 0x0000ffca, 0xfe700000},
 2315 {'l', 0x41f4d50c, 0x00000000},
 2316 {'8', 0x1c660044, 0x56211c21},
 2317 {'8', 0x3eef2500, 0x22cd18ef},
 2318 {'m', 0xc207d6c4, 0xc2285278},
 2319 {'4', 0x008e0000, 0x00000044},
 2320 {'8', 0xef3b0027, 0xcb14ee14},
 2321 {'8', 0xccecdd00, 0xefc5efed},
 2322 {'l', 0xc1886037, 0x00000000},
 2323 {'@', 0x00000053, 0x0000573f},/*        S        x-advance: 87.246094 */
 2324 {'m', 0x42931d35, 0xc2c1d354},
 2325 {'l', 0x00000000, 0x41538b28},
 2326 {'8', 0xeac6f2e2, 0xf9ccf9e5},
 2327 {'8', 0x11bc00d4, 0x30e911e9},
 2328 {'8', 0x280f1a00, 0x153c0d10},
 2329 {'l', 0x410301b8, 0x3fd6c3e0},
 2330 {'8', 0x28590b3c, 0x4d1c1c1c},
 2331 {'q', 0x00000000, 0x41690528},
 2332 {0, 0xc11cc750, 0x41b0a4f0},
 2333 {'q', 0xc11bb464, 0x40f08975},
 2334 {0, 0xc1e4b98c, 0x40f08975},
 2335 {'8', 0xfac400e4, 0xedbefae1},
 2336 {'l', 0x00000000, 0xc15f5b0f},
 2337 {'8', 0x1b401221, 0x093e091f},
 2338 {'8', 0xee47002e, 0xcc19ee19},
 2339 {'8', 0xd2eee300, 0xe8c5f0ef},
 2340 {'l', 0xc10414a0, 0xbfce2cc0},
 2341 {'8', 0xdba9f4c4, 0xb9e5e7e5},
 2342 {'8', 0xad25cb00, 0xe267e225},
 2343 {'8', 0x0539001c, 0x0f3b051d},
 2344 {'@', 0x00000054, 0x000053f5},/*        T        x-advance: 83.957031 */
 2345 {'m', 0xbece2cac, 0xc2c86716},
 2346 {'l', 0x42a987bb, 0x00000000},
 2347 {'l', 0x00000000, 0x41368ce0},
 2348 {'l', 0xc20e4828, 0x00000000},
 2349 {'l', 0x00000000, 0x42b1957a},
 2350 {'l', 0xc159fc90, 0x00000000},
 2351 {'l', 0x00000000, 0xc2b1957a},
 2352 {'l', 0xc20e4829, 0x00000000},
 2353 {'l', 0xb5b00000, 0xc1368ce0},
 2354 {'@', 0x00000055, 0x0000649a},/*        U        x-advance: 100.601562 */
 2355 {'m', 0x413f2414, 0xc2c86716},
 2356 {'4', 0x00000036, 0x00f30000},
 2357 {'8', 0x5c174000, 0x1c4b1c17},
 2358 {'8', 0xe44b0034, 0xa417e417},
 2359 {'4', 0xff0d0000, 0x00000036},
 2360 {'l', 0x00000000, 0x427a338b},
 2361 {'q', 0x00000000, 0x419cc74d},
 2362 {0, 0xc11bb468, 0x41ecc74c},
 2363 {'q', 0xc11aa180, 0x41200001},
 2364 {0, 0xc1e4b98e, 0x41200001},
 2365 {'q', 0xc197f240, 0xb4c00000},
 2366 {0, 0xc1e5cc74, 0xc1200000},
 2367 {'q', 0xc11aa180, 0xc11fffff},
 2368 {0, 0xc11aa180, 0xc1ecc74c},
 2369 {'l', 0x00000000, 0xc27a338b},
 2370 {'@', 0x00000056, 0x00005e06},/*        V        x-advance: 94.023438 */
 2371 {'m', 0x421d50c0, 0x00000000},
 2372 {'l', 0xc2190527, 0xc2c86716},
 2373 {'l', 0x416293c1, 0x00000000},
 2374 {'l', 0x41fdf5b2, 0x42a8b98e},
 2375 {'l', 0x41fe7f24, 0xc2a8b98e},
 2376 {'l', 0x416180d8, 0x00000000},
 2377 {'l', 0xc218c06d, 0x42c86716},
 2378 {'l', 0xc175e7f4, 0x00000000},
 2379 {'@', 0x00000057, 0x000087e7},/*        W        x-advance: 135.902344 */
 2380 {'m', 0x40920a4f, 0xc2c86716},
 2381 {'l', 0x415b0f76, 0x00000000},
 2382 {'l', 0x41a89731, 0x42a9655e},
 2383 {'l', 0x41a80dbe, 0xc2a9655e},
 2384 {'l', 0x4173c224, 0x00000000},
 2385 {'l', 0x41a89734, 0x42a9655e},
 2386 {'l', 0x41a80dbc, 0xc2a9655e},
 2387 {'l', 0x415c2260, 0x00000000},
 2388 {'l', 0xc1c957a0, 0x42c86716},
 2389 {'l', 0xc1886038, 0x00000000},
 2390 {'l', 0xc1a920a4, 0xc2adf5b1},
 2391 {'l', 0xc1aabcfe, 0x42adf5b1},
 2392 {'l', 0xc1886036, 0x00000000},
 2393 {'l', 0xc1c8ce2c, 0xc2c86716},
 2394 {'@', 0x00000058, 0x00005e29},/*        X        x-advance: 94.160156 */
 2395 {'m', 0x410a8603, 0xc2c86716},
 2396 {'l', 0x41690527, 0x00000000},
 2397 {'l', 0x41c731d3, 0x4214fe48},
 2398 {'l', 0x41c844b8, 0xc214fe48},
 2399 {'l', 0x41690528, 0x00000000},
 2400 {'l', 0xc200dbeb, 0x42407bb4},
 2401 {'l', 0x4209731d, 0x42505278},
 2402 {'l', 0xc1690528, 0x00000000},
 2403 {'l', 0xc1e180da, 0xc22a7844},
 2404 {'l', 0xc1e31d35, 0x422a7844},
 2405 {'l', 0xc16a180e, 0x00000000},
 2406 {'l', 0x420f1656, 0xc255f5b1},
 2407 {'l', 0xc1f9aa18, 0xc23ad87b},
 2408 {'@', 0x00000059, 0x000053f5},/*        Y        x-advance: 83.957031 */
 2409 {'m', 0xbe89731d, 0xc2c86716},
 2410 {'l', 0x41690527, 0x00000000},
 2411 {'l', 0x41de4829, 0x4224d50c},
 2412 {'l', 0x41dcabd0, 0xc224d50c},
 2413 {'l', 0x41690528, 0x00000000},
 2414 {'l', 0xc20dbeb6, 0x4251eed1},
 2415 {'l', 0x00000000, 0x423edf5b},
 2416 {'l', 0xc159fc90, 0x00000000},
 2417 {'l', 0x00000000, 0xc23edf5b},
 2418 {'l', 0xc20dbeb6, 0xc251eed1},
 2419 {'@', 0x0000005a, 0x00005e29},/*        Z        x-advance: 94.160156 */
 2420 {'m', 0x40f6fad8, 0xc2c86716},
 2421 {'l', 0x429d731c, 0x00000000},
 2422 {'l', 0x00000000, 0x41255e80},
 2423 {'l', 0xc27d6c3c, 0x429ce9aa},
 2424 {'l', 0x4281cc74, 0xb6400000},
 2425 {'l', 0x00000000, 0x41368ce3},
 2426 {'l', 0xc2a39fc8, 0x00000000},
 2427 {'l', 0xb6400000, 0xc1255e7f},
 2428 {'l', 0x427d6c3d, 0xc29ce9aa},
 2429 {'l', 0xc2773f91, 0x00000000},
 2430 {'l', 0x00000000, 0xc1368ce0},
 2431 {'@', 0x0000005b, 0x0000359f},/*        [        x-advance: 53.621094 */
 2432 {'m', 0x413cfe48, 0xc2d0dbeb},
 2433 {'l', 0x41e3a6a8, 0x00000000},
 2434 {'l', 0x00000000, 0x41198e98},
 2435 {'l', 0xc180dbeb, 0x00000000},
 2436 {'l', 0x00000000, 0x42ceb61f},
 2437 {'l', 0x4180dbeb, 0xb5800000},
 2438 {'l', 0x00000000, 0x41198e9b},
 2439 {'l', 0xc1e3a6a8, 0x00000000},
 2440 {'l', 0x00000000, 0xc2f519c5},
 2441 {'@', 0x0000005c, 0x00002e4f},/*       \         x-advance: 46.308594 */
 2442 {'m', 0x41368ce3, 0xc2c86716},
 2443 {'l', 0x420b98e9, 0x42e1e7f2},
 2444 {'l', 0xc1368ce4, 0xb5800000},
 2445 {'l', 0xc20b98e9, 0xc2e1e7f2},
 2446 {'l', 0x41368ce3, 0x00000000},
 2447 {'@', 0x0000005d, 0x0000359f},/*        ]        x-advance: 53.621094 */
 2448 {'m', 0x42273f92, 0xc2d0dbeb},
 2449 {'l', 0x00000000, 0x42f519c5},
 2450 {'l', 0xc1e3a6a8, 0x36000000},
 2451 {'l', 0xb5800000, 0xc1198e9b},
 2452 {'l', 0x41805278, 0x00000000},
 2453 {'l', 0x00000000, 0xc2ceb61f},
 2454 {'l', 0xc1805278, 0x00000000},
 2455 {'l', 0xb5800000, 0xc1198e98},
 2456 {'l', 0x41e3a6a8, 0x00000000},
 2457 {'@', 0x0000005e, 0x0000732a},/*        ^        x-advance: 115.164062 */
 2458 {'m', 0x42805278, 0xc2c86716},
 2459 {'l', 0x4211c596, 0x421587bb},
 2460 {'l', 0xc157d6c8, 0x00000000},
 2461 {'l', 0xc1ec3dd8, 0xc1d4149e},
 2462 {'l', 0xc1ec3ddb, 0x41d4149e},
 2463 {'l', 0xc157d6c3, 0x00000000},
 2464 {'l', 0x4211c595, 0xc21587bb},
 2465 {'l', 0x41527844, 0x00000000},
 2466 {'@', 0x0000005f, 0x000044b9},/*        _        x-advance: 68.722656 */
 2467 {'m', 0x428c225d, 0x41b68ce3},
 2468 {'l', 0x00000000, 0x41198e9a},
 2469 {'l', 0xc28ed19d, 0x00000000},
 2470 {'l', 0x36600000, 0xc1198e9a},
 2471 {'l', 0x428ed19d, 0x00000000},
 2472 {'@', 0x00000060, 0x000044b9},/*        `        x-advance: 68.722656 */
 2473 {'m', 0x41c50c07, 0xc2dbdda3},
 2474 {'0', 0x00d7644b, 0x00349ca9},
 2475 {'@', 0x00000061, 0x0000543a},/*        a        x-advance: 84.226562 */
 2476 {'m', 0x423c74d5, 0xc2172414},
 2477 {'8', 0x0dae00c5, 0x2ee90de9},
 2478 {'8', 0x29111a00, 0x0f2f0f11},
 2479 {'8', 0xe4410029, 0xb318e318},
 2480 {'4', 0xfff50000, 0x0000ffcf},
 2481 {'m', 0x41c50c06, 0xc0a338b8},
 2482 {'4', 0x00ab0000, 0x0000ffcf},
 2483 {'l', 0x00000000, 0xc1368ce3},
 2484 {'8', 0x28d61bf0, 0x0cc30ce7},
 2485 {'8', 0xe7b700d2, 0xbbe5e6e5},
 2486 {'8', 0xb421ce00, 0xe765e722},
 2487 {'4', 0x00000045, 0xfffc0000},
 2488 {'8', 0xcceade00, 0xeec2eeea},
 2489 {'8', 0x06ce00e7, 0x12d206e8},
 2490 {'l', 0x00000000, 0xc1368ce4},
 2491 {'8', 0xf134f61b, 0xfb31fb19},
 2492 {'8', 0x21610041, 0x66202120},
 2493 {'@', 0x00000062, 0x0000573f},/*        b        x-advance: 87.246094 */
 2494 {'m', 0x4285d354, 0xc216112e},
 2495 {'8', 0xabeaca00, 0xe1c3e1ea},
 2496 {'8', 0x1fc300d9, 0x55ea1eea},
 2497 {'8', 0x55163600, 0x1e3d1e16},
 2498 {'8', 0xe23d0027, 0xab16e116},
 2499 {'m', 0xc2280dbe, 0xc1d1eed2},
 2500 {'8', 0xd927e60f, 0xf338f317},
 2501 {'q', 0x415b0f74, 0x00000000},
 2502 {0, 0x41b1b7d6, 0x412df5b0},
 2503 {'q', 0x41097320, 0x412df5b4},
 2504 {0, 0x41097320, 0x41e4b990},
 2505 {'q', 0x00000000, 0x418dbeb6},
 2506 {0, 0xc1097320, 0x41e4b98e},
 2507 {'8', 0x2ba82bde, 0xf4c800df},
 2508 {'9', 0xfff3ffe9, 0xffd8ffd9},
 2509 {'l', 0x00000000, 0x41346716},
 2510 {'l', 0xc146a860, 0x00000000},
 2511 {'l', 0x00000000, 0xc2d0dbeb},
 2512 {'l', 0x4146a860, 0x00000000},
 2513 {'l', 0x00000000, 0x4222af3f},
 2514 {'@', 0x00000063, 0x00004b92},/*        c        x-advance: 75.570312 */
 2515 {'m', 0x4286180e, 0xc2909052},
 2516 {'l', 0x00000000, 0x4138b2ac},
 2517 {'8', 0xefd6f5ec, 0xfbd6fbec},
 2518 {'8', 0x1eb600d0, 0x55e61ee6},
 2519 {'8', 0x551a3700, 0x1e4a1e1a},
 2520 {'8', 0xfb2a0015, 0xef2afb15},
 2521 {'l', 0x00000000, 0x41368ce2},
 2522 {'8', 0x0ed609ec, 0x04d204ea},
 2523 {'q', 0xc187d6c4, 0x00000000},
 2524 {0, 0xc1d7d6c4, 0xc12abcfe},
 2525 {'q', 0xc1200000, 0xc12abcff},
 2526 {0, 0xc1200000, 0xc1e655e8},
 2527 {'q', 0xb5000000, 0xc1931d36},
 2528 {0, 0x412112e6, 0xc1e768d0},
 2529 {'8', 0xd66ed628, 0x042c0016},
 2530 {'q', 0x40adf5b0, 0x3f920a80},
 2531 {0, 0x41289734, 0x405f5b20},
 2532 {'@', 0x00000064, 0x0000573f},/*        d        x-advance: 87.246094 */
 2533 {'m', 0x4279aa18, 0xc27f0897},
 2534 {'l', 0x00000000, 0xc222af3f},
 2535 {'l', 0x41459578, 0x00000000},
 2536 {'4', 0x01a10000, 0x0000ffcf},
 2537 {'l', 0x00000000, 0xc1346716},
 2538 {'8', 0x28d91af1, 0x0cc80ce9},
 2539 {'q', 0xc159fc90, 0x34000000},
 2540 {0, 0xc1b1b7d7, 0xc12df5b0},
 2541 {'q', 0xc1086036, 0xc12df5b0},
 2542 {0, 0xc1086036, 0xc1e4b98e},
 2543 {'q', 0xb5000000, 0xc18dbeb6},
 2544 {0, 0x41086036, 0xc1e4b990},
 2545 {'8', 0xd558d522, 0x0d380021},
 2546 {'9', 0x000c0017, 0x00270027},
 2547 {'m', 0xc2285278, 0x41d1eed2},
 2548 {'8', 0x55163600, 0x1e3d1e16},
 2549 {'8', 0xe23d0027, 0xab16e116},
 2550 {'8', 0xabeaca00, 0xe1c3e1ea},
 2551 {'8', 0x1fc300d9, 0x55ea1eea},
 2552 {'@', 0x00000065, 0x00005490},/*        e        x-advance: 84.562500 */
 2553 {'m', 0x429a7f24, 0xc222af3f},
 2554 {'4', 0x00180000, 0x0000ff1d},
 2555 {'8', 0x4d1e3303, 0x1a4c1a1b},
 2556 {'8', 0xfa37001c, 0xec35fa1a},
 2557 {'l', 0x00000000, 0x413ad87b},
 2558 {'8', 0x11ca0be6, 0x05c805e5},
 2559 {'q', 0xc18fe482, 0x00000000},
 2560 {0, 0xc1e4301b, 0xc127844c},
 2561 {'q', 0xc127844a, 0xc127844b},
 2562 {0, 0xc127844a, 0xc1e293c2},
 2563 {'q', 0xb5000000, 0xc193a6a8},
 2564 {0, 0x411eed1a, 0xc1ea180e},
 2565 {'8', 0xd56bd527, 0x275f003c},
 2566 {'9', 0x00260023, 0x006a0023},
 2567 {'m', 0xc1459578, 0xc067f240},
 2568 {'8', 0xc0ead800, 0xe8c6e8ea},
 2569 {'8', 0x17be00d7, 0x41e417e8},
 2570 {'l', 0x42301b7e, 0xbd897200},
 2571 {'@', 0x00000066, 0x00003063},/*        f        x-advance: 48.386719 */
 2572 {'m', 0x424c06df, 0xc2d0dbeb},
 2573 {'4', 0x00290000, 0x0000ffd1},
 2574 {'8', 0x0adb00e6, 0x26f60af6},
 2575 {'0', 0x00511a00, 0x00af2600},
 2576 {'l', 0x00000000, 0x42832414},
 2577 {'l', 0xc146a85f, 0x00000000},
 2578 {'l', 0x00000000, 0xc2832414},
 2579 {'0', 0xda0000d1, 0xec00002f},
 2580 {'8', 0xb717ce00, 0xe94ae917},
 2581 {'l', 0x413ad87c, 0x00000000},
 2582 {'@', 0x00000067, 0x0000573f},/*        g        x-advance: 87.246094 */
 2583 {'m', 0x4279aa18, 0xc219d354},
 2584 {'8', 0xadeacb00, 0xe3c2e3ea},
 2585 {'8', 0x1dc200d9, 0x53ea1dea},
 2586 {'8', 0x52163500, 0x1d3e1d16},
 2587 {'8', 0xe33e0028, 0xae16e316},
 2588 {'m', 0x41459578, 0x41e90528},
 2589 {'q', 0x00000000, 0x41998e9a},
 2590 {0, 0xc1086038, 0x41e4b98e},
 2591 {'8', 0x259825de, 0xfdcf00e6},
 2592 {'9', 0xfffcffe9, 0xfff4ffd4},
 2593 {'l', 0x00000000, 0xc14036fb},
 2594 {'8', 0x112a0b15, 0x052b0515},
 2595 {'8', 0xe7480030, 0xb418e718},
 2596 {'l', 0x00000000, 0xc0c36fb0},
 2597 {'8', 0x27d91af1, 0x0dc70de9},
 2598 {'8', 0xd6a700c9, 0x91dfd6df},
 2599 {'8', 0x9121bb00, 0xd659d621},
 2600 {'8', 0x0d390021, 0x27270d17},
 2601 {'l', 0x00000000, 0xc1368ce4},
 2602 {'l', 0x41459578, 0x00000000},
 2603 {'l', 0x00000000, 0x4283ad88},
 2604 {'@', 0x00000068, 0x0000571d},/*        h        x-advance: 87.113281 */
 2605 {'m', 0x4296df5b, 0xc23579fc},
 2606 {'4', 0x00b50000, 0x0000ffcf},
 2607 {'l', 0x00000000, 0xc233dda3},
 2608 {'8', 0xc1f0d600, 0xebcfebf0},
 2609 {'8', 0x19c100d8, 0x45e919e9},
 2610 {'l', 0x00000000, 0x4229eed1},
 2611 {'l', 0xc146a860, 0x00000000},
 2612 {'4', 0xfe5f0000, 0x00000031},
 2613 {'l', 0x00000000, 0x4223c225},
 2614 {'8', 0xd829e511, 0xf337f318},
 2615 {'8', 0x204e0033, 0x5e1a1f1a},
 2616 {'@', 0x00000069, 0x00002630},/*        i        x-advance: 38.187500 */
 2617 {'m', 0x414f3f92, 0xc29655e8},
 2618 {'l', 0x4145957a, 0x00000000},
 2619 {'4', 0x012c0000, 0x0000ffcf},
 2620 {'6', 0xfed40000, 0xff8b0000},
 2621 {'0', 0x3e000031, 0xc20000cf},
 2622 {'@', 0x0000006a, 0x00002630},/*        j        x-advance: 38.187500 */
 2623 {'m', 0x414f3f92, 0xc29655e8},
 2624 {'4', 0x00000031, 0x01320000},
 2625 {'8', 0x53ea3900, 0x19ba19eb},
 2626 {'4', 0x0000ffee, 0xffd70000},
 2627 {'l', 0x40527845, 0x00000000},
 2628 {'8', 0xf426001c, 0xca0af30a},
 2629 {'6', 0xfece0000, 0xff8b0000},
 2630 {'0', 0x3e000031, 0xc20000cf},
 2631 {'@', 0x0000006b, 0x00004f98},/*        k        x-advance: 79.593750 */
 2632 {'m', 0x4147bb46, 0xc2d0dbeb},
 2633 {'l', 0x4146a860, 0x00000000},
 2634 {'l', 0x00000000, 0x4276b61e},
 2635 {'l', 0x421361ee, 0xc201aa18},
 2636 {'l', 0x417c5958, 0x00000000},
 2637 {'l', 0xc21f768d, 0x420cabd0},
 2638 {'l', 0x42262cab, 0x42200000},
 2639 {'l', 0xc180dbea, 0x00000000},
 2640 {'l', 0xc218c06e, 0xc212d87b},
 2641 {'l', 0x36000000, 0x4212d87b},
 2642 {'l', 0xc146a860, 0x00000000},
 2643 {'l', 0x00000000, 0xc2d0dbeb},
 2644 {'@', 0x0000006c, 0x00002630},/*        l        x-advance: 38.187500 */
 2645 {'m', 0x414f3f92, 0xc2d0dbeb},
 2646 {'l', 0x4145957a, 0x00000000},
 2647 {'l', 0x00000000, 0x42d0dbeb},
 2648 {'l', 0xc145957a, 0x00000000},
 2649 {'l', 0x00000000, 0xc2d0dbeb},
 2650 {'@', 0x0000006d, 0x000085e4},/*        m        x-advance: 133.890625 */
 2651 {'m', 0x428ef3f9, 0xc272f3f9},
 2652 {'8', 0xcf2cdf12, 0xf13cf119},
 2653 {'8', 0x2148002e, 0x5d192019},
 2654 {'4', 0x00b50000, 0x0000ffcf},
 2655 {'l', 0x00000000, 0xc233dda3},
 2656 {'8', 0xc0f1d500, 0xecd2ecf1},
 2657 {'8', 0x19c400da, 0x45ea19ea},
 2658 {'4', 0x00a90000, 0x0000ffcf},
 2659 {'l', 0x00000000, 0xc233dda3},
 2660 {'8', 0xc0f1d500, 0xecd1ecf1},
 2661 {'8', 0x19c400db, 0x45ea19ea},
 2662 {'l', 0x00000000, 0x4229eed1},
 2663 {'l', 0xc146a860, 0x00000000},
 2664 {'4', 0xfed40000, 0x00000031},
 2665 {'l', 0x00000000, 0x413ad87c},
 2666 {'8', 0xd828e510, 0xf338f317},
 2667 {'8', 0x10370020, 0x30221017},
 2668 {'@', 0x0000006e, 0x0000571d},/*        n        x-advance: 87.113281 */
 2669 {'m', 0x4296df5b, 0xc23579fc},
 2670 {'4', 0x00b50000, 0x0000ffcf},
 2671 {'l', 0x00000000, 0xc233dda3},
 2672 {'8', 0xc1f0d600, 0xebcfebf0},
 2673 {'8', 0x19c100d8, 0x45e919e9},
 2674 {'l', 0x00000000, 0x4229eed1},
 2675 {'l', 0xc146a860, 0x00000000},
 2676 {'4', 0xfed40000, 0x00000031},
 2677 {'l', 0x00000000, 0x413ad87c},
 2678 {'8', 0xd829e511, 0xf337f318},
 2679 {'8', 0x204e0033, 0x5e1a1f1a},
 2680 {'@', 0x0000006f, 0x00005418},/*        o        x-advance: 84.093750 */
 2681 {'m', 0x42285278, 0xc2850527},
 2682 {'8', 0x1fc200d9, 0x54e91ee9},
 2683 {'8', 0x55163500, 0x1e3f1e17},
 2684 {'8', 0xe13e0027, 0xac17e117},
 2685 {'8', 0xace9cb00, 0xe1c2e1e9},
 2686 {'m', 0x00000000, 0xc1278450},
 2687 {'q', 0x4180dbec, 0x00000000},
 2688 {0, 0x41ca6a84, 0x41278450},
 2689 {'q', 0x41131d38, 0x41278448},
 2690 {0, 0x41131d38, 0x41e7f240},
 2691 {'q', 0x00000000, 0x4193a6a8},
 2692 {0, 0xc1131d38, 0x41e7f240},
 2693 {'8', 0x299b29dc, 0xd79b00c0},
 2694 {'q', 0xc1120a4e, 0xc1289731},
 2695 {0, 0xc1120a4e, 0xc1e7f240},
 2696 {'q', 0xb5000000, 0xc194301c},
 2697 {0, 0x41120a4e, 0xc1e7f240},
 2698 {'q', 0x41131d36, 0xc1278450},
 2699 {0, 0x41caf3f9, 0xc1278450},
 2700 {'@', 0x00000070, 0x0000573f},/*        p        x-advance: 87.246094 */
 2701 {'m', 0x41c731d3, 0xc1346716},
 2702 {'l', 0x00000000, 0x421f768c},
 2703 {'l', 0xc146a860, 0x36000000},
 2704 {'4', 0xfe610000, 0x00000031},
 2705 {'l', 0x00000000, 0x41368ce4},
 2706 {'8', 0xd927e60f, 0xf338f317},
 2707 {'q', 0x415b0f74, 0x00000000},
 2708 {0, 0x41b1b7d6, 0x412df5b0},
 2709 {'q', 0x41097320, 0x412df5b4},
 2710 {0, 0x41097320, 0x41e4b990},
 2711 {'q', 0x00000000, 0x418dbeb6},
 2712 {0, 0xc1097320, 0x41e4b98e},
 2713 {'8', 0x2ba82bde, 0xf4c800df},
 2714 {'9', 0xfff3ffe9, 0xffd8ffd9},
 2715 {'m', 0x42280dbe, 0xc1d1eed1},
 2716 {'8', 0xabeaca00, 0xe1c3e1ea},
 2717 {'8', 0x1fc300d9, 0x55ea1eea},
 2718 {'8', 0x55163600, 0x1e3d1e16},
 2719 {'8', 0xe23d0027, 0xab16e116},
 2720 {'@', 0x00000071, 0x0000573f},/*        q        x-advance: 87.246094 */
 2721 {'m', 0x41a2af3f, 0xc216112e},
 2722 {'8', 0x55163600, 0x1e3d1e16},
 2723 {'8', 0xe23d0027, 0xab16e116},
 2724 {'8', 0xabeaca00, 0xe1c3e1ea},
 2725 {'8', 0x1fc300d9, 0x55ea1eea},
 2726 {'m', 0x42285278, 0x41d1eed1},
 2727 {'8', 0x28d91af1, 0x0cc80ce9},
 2728 {'q', 0xc159fc90, 0x34000000},
 2729 {0, 0xc1b1b7d7, 0xc12df5b0},
 2730 {'q', 0xc1086036, 0xc12df5b0},
 2731 {0, 0xc1086036, 0xc1e4b98e},
 2732 {'q', 0xb5000000, 0xc18dbeb6},
 2733 {0, 0x41086036, 0xc1e4b990},
 2734 {'8', 0xd558d522, 0x0d380021},
 2735 {'9', 0x000c0017, 0x00270027},
 2736 {'l', 0x00000000, 0xc1368ce4},
 2737 {'l', 0x41459578, 0x00000000},
 2738 {'l', 0x00000000, 0x42cf844c},
 2739 {'l', 0xc1459578, 0xb6800000},
 2740 {'l', 0x00000000, 0xc21f768c},
 2741 {'@', 0x00000072, 0x00003882},/*        r        x-advance: 56.507812 */
 2742 {'m', 0x42620a4f, 0xc27e7f24},
 2743 {'8', 0xfaeefcf8, 0xfeebfef7},
 2744 {'8', 0x1bc000d7, 0x4eea1bea},
 2745 {'l', 0x00000000, 0x421e63a6},
 2746 {'l', 0xc146a860, 0x00000000},
 2747 {'4', 0xfed40000, 0x00000031},
 2748 {'l', 0x00000000, 0x413ad87c},
 2749 {'8', 0xd828e50f, 0xf33cf318},
 2750 {'8', 0x000b0005, 0x010d0006},
 2751 {'l', 0x3d897400, 0x414af3f8},
 2752 {'@', 0x00000073, 0x0000479c},/*        s        x-advance: 71.609375 */
 2753 {'m', 0x42737d6c, 0xc291e7f2},
 2754 {'l', 0x00000000, 0x413ad87c},
 2755 {'8', 0xf0d5f6ec, 0xfbd2fbea},
 2756 {'8', 0x0bc900dc, 0x21ee0bee},
 2757 {'8', 0x1b0d1100, 0x1234090d},
 2758 {'l', 0x40874d50, 0x3f708980},
 2759 {'8', 0x1f4a0b34, 0x39161416},
 2760 {'8', 0x42df2900, 0x18a518df},
 2761 {'8', 0xfcce00e8, 0xf2c9fce6},
 2762 {'l', 0x00000000, 0xc14c06df},
 2763 {'8', 0x15350e1b, 0x0634061a},
 2764 {'8', 0xf5350022, 0xdf12f412},
 2765 {'8', 0xe2f3ec00, 0xecc5f6f3},
 2766 {'l', 0xc0897320, 0xbf80dbe0},
 2767 {'8', 0xe3bef7d3, 0xc9ececec},
 2768 {'8', 0xbf1ed600, 0xe955e91e},
 2769 {'8', 0x0433001b, 0x0c2c0418},
 2770 {'@', 0x00000074, 0x000035e4},/*        t        x-advance: 53.890625 */
 2771 {'m', 0x41c9579f, 0xc2c10527},
 2772 {'0', 0x00655500, 0x009b2600},
 2773 {'l', 0x00000000, 0x422338b2},
 2774 {'8', 0x2f092400, 0x0a290a0a},
 2775 {'4', 0x00000032, 0x00290000},
 2776 {'l', 0xc14af3f8, 0x00000000},
 2777 {'8', 0xebb200c7, 0xb3ebebeb},
 2778 {'l', 0x00000000, 0xc22338b2},
 2779 {'0', 0xda0000dc, 0xab000024},
 2780 {'l', 0x4146a85f, 0x00000000},
 2781 {'@', 0x00000075, 0x0000571d},/*        u        x-advance: 87.113281 */
 2782 {'m', 0x413ad87b, 0xc1ed50c0},
 2783 {'4', 0xff4a0000, 0x00000031},
 2784 {'l', 0x00000000, 0x4234225d},
 2785 {'8', 0x40102a00, 0x15311510},
 2786 {'8', 0xe73f0028, 0xbb17e717},
 2787 {'l', 0x00000000, 0xc22a7845},
 2788 {'l', 0x41459574, 0x00000000},
 2789 {'4', 0x012c0000, 0x0000ffcf},
 2790 {'l', 0x00000000, 0xc138b2af},
 2791 {'8', 0x28d71bef, 0x0dc90de9},
 2792 {'8', 0xe0b200cd, 0xa2e6e0e6},
 2793 {'m', 0x41f89732, 0xc23d4302},
 2794 {'l', 0x00000000, 0x00000000},
 2795 {'@', 0x00000076, 0x00005157},/*        v        x-advance: 81.339844 */
 2796 {'m', 0x408301b8, 0xc29655e8},
 2797 {'l', 0x4151655e, 0x00000000},
 2798 {'l', 0x41bbeb61, 0x427c5958},
 2799 {'l', 0x41bbeb62, 0xc27c5958},
 2800 {'l', 0x41516560, 0x00000000},
 2801 {'l', 0xc1e180dc, 0x429655e8},
 2802 {'l', 0xc1863a6a, 0x00000000},
 2803 {'l', 0xc1e180dc, 0xc29655e8},
 2804 {'@', 0x00000077, 0x0000706a},/*        w        x-advance: 112.414062 */
 2805 {'m', 0x40b8b2af, 0xc29655e8},
 2806 {'l', 0x4145957a, 0x00000000},
 2807 {'l', 0x4176fad6, 0x426aa181},
 2808 {'l', 0x4175e7f4, 0xc26aa181},
 2809 {'l', 0x41690528, 0x00000000},
 2810 {'l', 0x4176fad4, 0x426aa181},
 2811 {'l', 0x4175e7f8, 0xc26aa181},
 2812 {'l', 0x41459578, 0x00000000},
 2813 {'l', 0xc19d50c0, 0x429655e8},
 2814 {'l', 0xc1690528, 0x00000000},
 2815 {'l', 0xc1816560, 0xc2767165},
 2816 {'l', 0xc181eed0, 0x42767165},
 2817 {'l', 0xc1690528, 0x00000000},
 2818 {'l', 0xc19d50c0, 0xc29655e8},
 2819 {'@', 0x00000078, 0x00005157},/*        x        x-advance: 81.339844 */
 2820 {'m', 0x4296df5b, 0xc29655e8},
 2821 {'l', 0xc1d9731e, 0x42124f09},
 2822 {'l', 0x41e4b98e, 0x421a5cc7},
 2823 {'l', 0xc1690524, 0x00000000},
 2824 {'l', 0xc1af0898, 0xc1ec3dda},
 2825 {'l', 0xc1af0897, 0x41ec3dda},
 2826 {'l', 0xc1690527, 0x00000000},
 2827 {'l', 0x41e98e9a, 0xc21d50c0},
 2828 {'l', 0xc1d5b0f7, 0xc20f5b10},
 2829 {'0', 0x6b4f003a, 0x003a954f},
 2830 {'@', 0x00000079, 0x00005157},/*        y        x-advance: 81.339844 */
 2831 {'m', 0x4230e9aa, 0x40df5b0f},
 2832 {'8', 0x46d835ec, 0x10cb10ed},
 2833 {'4', 0x0000ffd9, 0xffd70000},
 2834 {'l', 0x40e7f242, 0x00000000},
 2835 {'8', 0xf71f0014, 0xd318f70b},
 2836 {'l', 0x400dbeb0, 0xc0b46716},
 2837 {'l', 0xc1f338b2, 0xc293eb62},
 2838 {'l', 0x4151655e, 0x00000000},
 2839 {'l', 0x41bbeb61, 0x426b2af4},
 2840 {'l', 0x41bbeb62, 0xc26b2af4},
 2841 {'l', 0x41516560, 0x00000000},
 2842 {'l', 0xc204149e, 0x42a44b99},
 2843 {'@', 0x0000007a, 0x00004825},/*        z        x-advance: 72.144531 */
 2844 {'m', 0x40f2af3f, 0xc29655e8},
 2845 {'l', 0x426aa180, 0x00000000},
 2846 {'l', 0x00000000, 0x41346718},
 2847 {'l', 0xc239c595, 0x42581b7d},
 2848 {'l', 0x4239c595, 0x35800000},
 2849 {'l', 0x00000000, 0x411dda33},
 2850 {'l', 0xc271579f, 0x00000000},
 2851 {'l', 0x00000000, 0xc1346716},
 2852 {'l', 0x4239c595, 0xc2581b7c},
 2853 {'l', 0xc2330f76, 0x00000000},
 2854 {'l', 0xb5000000, 0xc11dda38},
 2855 {'@', 0x0000007b, 0x00005773},/*        {        x-advance: 87.449219 */
 2856 {'m', 0x428c8973, 0x414c06df},
 2857 {'4', 0x00260000, 0x0000fff0},
 2858 {'8', 0xeda700be, 0xb1eaedea},
 2859 {'l', 0x00000000, 0xc1805278},
 2860 {'8', 0xc8f2d800, 0xf1ccf1f2},
 2861 {'4', 0x0000fff0, 0xffda0000},
 2862 {'l', 0x408301b8, 0x00000000},
 2863 {'8', 0xf1340026, 0xc90ef10e},
 2864 {'l', 0x00000000, 0xc180dbec},
 2865 {'8', 0xb216c500, 0xed59ed16},
 2866 {'4', 0x00000010, 0x00260000},
 2867 {'l', 0xc0920a50, 0x00000000},
 2868 {'8', 0x0bcf00db, 0x31f50bf5},
 2869 {'l', 0x00000000, 0x41852786},
 2870 {'8', 0x3df42a00, 0x19d713f4},
 2871 {'8', 0x1a29071d, 0x3c0c130c},
 2872 {'l', 0x00000000, 0x41852785},
 2873 {'8', 0x310b2500, 0x0b310b0b},
 2874 {'l', 0x40920a50, 0x00000000},
 2875 {'@', 0x0000007c, 0x00002e4f},/*        |        x-advance: 46.308594 */
 2876 {'m', 0x41e6df5b, 0xc2d2112e},
 2877 {'l', 0x00000000, 0x4309731d},
 2878 {'l', 0xc1368ce4, 0x00000000},
 2879 {'l', 0x00000000, 0xc309731d},
 2880 {'l', 0x41368ce4, 0x00000000},
 2881 {'@', 0x0000007d, 0x00005773},/*        }        x-advance: 87.449219 */
 2882 {'m', 0x4189731d, 0x414c06df},
 2883 {'l', 0x409655e8, 0x00000000},
 2884 {'8', 0xf5300025, 0xcf0bf50b},
 2885 {'l', 0x00000000, 0xc1852784},
 2886 {'8', 0xc40cd700, 0xe629ed0c},
 2887 {'8', 0xe7d7fae3, 0xc3f4edf4},
 2888 {'l', 0x00000000, 0xc1852786},
 2889 {'8', 0xcff5da00, 0xf5d0f5f5},
 2890 {'4', 0x0000ffee, 0xffda0000},
 2891 {'l', 0x40874d50, 0x00000000},
 2892 {'8', 0x13590042, 0x4e161316},
 2893 {'l', 0x00000000, 0x4180dbec},
 2894 {'8', 0x370e2800, 0x0f340f0e},
 2895 {'4', 0x00000010, 0x00260000},
 2896 {'l', 0xc0852780, 0x00000000},
 2897 {'8', 0x0fcc00da, 0x38f20ff2},
 2898 {'l', 0x00000000, 0x41805278},
 2899 {'8', 0x4fea3b00, 0x13a713ea},
 2900 {'l', 0xc0874d50, 0x00000000},
 2901 {'l', 0x00000000, 0xc11aa181},
 2902 {'@', 0x0000007e, 0x0000732a},/*        ~        x-advance: 115.164062 */
 2903 {'m', 0x42c93543, 0xc25b5430},
 2904 {'l', 0x00000000, 0x413f2414},
 2905 {'8', 0x1ecc15e4, 0x09cf09e9},
 2906 {'8', 0xf1bc00e3, 0xfffcfffe},
 2907 {'8', 0xfefb00ff, 0xf0bef0d7},
 2908 {'8', 0x0ad200e9, 0x20cf0ae9},
 2909 {'l', 0x00000000, 0xc13f2414},
 2910 {'8', 0xe234eb1c, 0xf732f718},
 2911 {'8', 0x1044001d, 0x01040102},
 2912 {'8', 0x02050002, 0x10421029},
 2913 {'8', 0xf62d0017, 0xe032f616},
 2914 {'[', 0x0047002d, 0x00000508},
 2915 {'[', 0x004a002d, 0x000007a6},
 2916 {'[', 0x004f002d, 0x000003d3},
 2917 {'[', 0x0051002d, 0x00000508},
 2918 {'[', 0x006f002d, 0x0000028c},
 2919 {'[', 0x00410041, 0x000003d3},
 2920 {'[', 0x0041004c, 0x00000327},
 2921 {'[', 0x002d004f, 0x000003d3},
 2922 {'[', 0x002d0051, 0x000003d3},
 2923 {'[', 0x00410053, 0x0000028c},
 2924 {'[', 0x002d006f, 0x0000028c},
 2925 };
 2926 #define CTX_FONT_ascii 1
 2927 #ifndef __CTX_LIST__
 2928 #define __CTX_LIST__
 2929 
 2930 #include <stdlib.h>
 2931 
 2932 /* The whole ctx_list implementation is in the header and will be inlined
 2933  * wherever it is used.
 2934  */
 2935 
 2936 typedef struct _CtxList CtxList;
 2937 struct _CtxList {
 2938   void *data;
 2939   CtxList *next;
 2940   void (*freefunc)(void *data, void *freefunc_data);
 2941   void *freefunc_data;
 2942 };
 2943 
 2944 static inline void ctx_list_prepend_full (CtxList **list, void *data,
 2945     void (*freefunc)(void *data, void *freefunc_data),
 2946     void *freefunc_data)
 2947 {
 2948   CtxList *new_= (CtxList*)calloc (sizeof (CtxList), 1);
 2949   new_->next = *list;
 2950   new_->data=data;
 2951   new_->freefunc=freefunc;
 2952   new_->freefunc_data = freefunc_data;
 2953   *list = new_;
 2954 }
 2955 
 2956 static inline int ctx_list_length (CtxList *list)
 2957 {
 2958   int length = 0;
 2959   CtxList *l;
 2960   for (l = list; l; l = l->next, length++);
 2961   return length;
 2962 }
 2963 
 2964 static inline void ctx_list_prepend (CtxList **list, void *data)
 2965 {
 2966   CtxList *new_ = (CtxList*) calloc (sizeof (CtxList), 1);
 2967   new_->next= *list;
 2968   new_->data=data;
 2969   *list = new_;
 2970 }
 2971 
 2972 static inline CtxList *ctx_list_nth (CtxList *list, int no)
 2973 {
 2974   while (no-- && list)
 2975     { list = list->next; }
 2976   return list;
 2977 }
 2978 
 2979 
 2980 static inline void
 2981 ctx_list_insert_before (CtxList **list, CtxList *sibling,
 2982                        void *data)
 2983 {
 2984   if (*list == NULL || *list == sibling)
 2985     {
 2986       ctx_list_prepend (list, data);
 2987     }
 2988   else
 2989     {
 2990       CtxList *prev = NULL;
 2991       for (CtxList *l = *list; l; l=l->next)
 2992         {
 2993           if (l == sibling)
 2994             { break; }
 2995           prev = l;
 2996         }
 2997       if (prev)
 2998         {
 2999           CtxList *new_ = (CtxList*)calloc (sizeof (CtxList), 1);
 3000           new_->next = sibling;
 3001           new_->data = data;
 3002           prev->next=new_;
 3003         }
 3004     }
 3005 }
 3006 
 3007 static inline void ctx_list_remove (CtxList **list, void *data)
 3008 {
 3009   CtxList *iter, *prev = NULL;
 3010   if ((*list)->data == data)
 3011     {
 3012       if ((*list)->freefunc)
 3013         (*list)->freefunc ((*list)->data, (*list)->freefunc_data);
 3014       prev = (*list)->next;
 3015       free (*list);
 3016       *list = prev;
 3017       return;
 3018     }
 3019   for (iter = *list; iter; iter = iter->next)
 3020     if (iter->data == data)
 3021       {
 3022         if (iter->freefunc)
 3023           iter->freefunc (iter->data, iter->freefunc_data);
 3024         prev->next = iter->next;
 3025         free (iter);
 3026         break;
 3027       }
 3028     else
 3029       prev = iter;
 3030 }
 3031 
 3032 static inline void ctx_list_free (CtxList **list)
 3033 {
 3034   while (*list)
 3035     ctx_list_remove (list, (*list)->data);
 3036 }
 3037 
 3038 static inline void
 3039 ctx_list_reverse (CtxList **list)
 3040 {
 3041   CtxList *new_ = NULL;
 3042   CtxList *l;
 3043   for (l = *list; l; l=l->next)
 3044     ctx_list_prepend (&new_, l->data);
 3045   ctx_list_free (list);
 3046   *list = new_;
 3047 }
 3048 
 3049 static inline void *ctx_list_last (CtxList *list)
 3050 {
 3051   if (list)
 3052     {
 3053       CtxList *last;
 3054       for (last = list; last->next; last=last->next);
 3055       return last->data;
 3056     }
 3057   return NULL;
 3058 }
 3059 
 3060 static inline void ctx_list_append_full (CtxList **list, void *data,
 3061     void (*freefunc)(void *data, void *freefunc_data),
 3062     void *freefunc_data)
 3063 {
 3064   CtxList *new_ = (CtxList*) calloc (sizeof (CtxList), 1);
 3065   new_->data=data;
 3066   new_->freefunc = freefunc;
 3067   new_->freefunc_data = freefunc_data;
 3068   if (*list)
 3069     {
 3070       CtxList *last;
 3071       for (last = *list; last->next; last=last->next);
 3072       last->next = new_;
 3073       return;
 3074     }
 3075   *list = new_;
 3076   return;
 3077 }
 3078 
 3079 static inline void ctx_list_append (CtxList **list, void *data)
 3080 {
 3081   ctx_list_append_full (list, data, NULL, NULL);
 3082 }
 3083 
 3084 static inline void
 3085 ctx_list_insert_at (CtxList **list,
 3086                     int       no,
 3087                     void     *data)
 3088 {
 3089   if (*list == NULL || no == 0)
 3090     {
 3091       ctx_list_prepend (list, data);
 3092     }
 3093   else
 3094     {
 3095       int pos = 0;
 3096       CtxList *prev = NULL;
 3097       CtxList *sibling = NULL;
 3098       for (CtxList *l = *list; l && pos < no; l=l->next)
 3099         {
 3100           prev = sibling;
 3101           sibling = l;
 3102           pos ++;
 3103         }
 3104       if (prev)
 3105         {
 3106           CtxList *new_ = (CtxList*)calloc (sizeof (CtxList), 1);
 3107           new_->next = sibling;
 3108           new_->data = data;
 3109           prev->next=new_;
 3110           return;
 3111         }
 3112       ctx_list_append (list, data);
 3113     }
 3114 }
 3115 
 3116 static CtxList*
 3117 ctx_list_merge_sorted (CtxList* list1,
 3118                        CtxList* list2,
 3119     int(*compare)(const void *a, const void *b, void *userdata), void 
 3120         *userdata
 3121 )
 3122 {
 3123   if (list1 == NULL)
 3124      return(list2);
 3125   else if (list2==NULL)
 3126      return(list1);
 3127 
 3128   if (compare (list1->data, list2->data, userdata) >= 0)
 3129   {
 3130     list1->next = ctx_list_merge_sorted (list1->next,list2, compare, 
 3131                   userdata);
 3132     /*list1->next->prev = list1;
 3133       list1->prev = NULL;*/
 3134     return list1;
 3135   }
 3136   else
 3137   {
 3138     list2->next = ctx_list_merge_sorted (list1,list2->next, compare, 
 3139                   userdata);
 3140     /*list2->next->prev = list2;
 3141       list2->prev = NULL;*/
 3142     return list2;
 3143   }
 3144 }
 3145 
 3146 static void
 3147 ctx_list_split_half (CtxList*  head,
 3148                      CtxList** list1,
 3149                      CtxList** list2)
 3150 {
 3151   CtxList* fast;
 3152   CtxList* slow;
 3153   if (head==NULL || head->next==NULL)
 3154   {
 3155     *list1 = head;
 3156     *list2 = NULL;
 3157   }
 3158   else
 3159   {
 3160     slow = head;
 3161     fast = head->next;
 3162 
 3163     while (fast != NULL)
 3164     {
 3165       fast = fast->next;
 3166       if (fast != NULL)
 3167       {
 3168         slow = slow->next;
 3169         fast = fast->next;
 3170       }
 3171     }
 3172 
 3173     *list1 = head;
 3174     *list2 = slow->next;
 3175     slow->next = NULL;
 3176   }
 3177 }
 3178 
 3179 static inline void ctx_list_sort (CtxList **head,
 3180     int(*compare)(const void *a, const void *b, void *userdata),
 3181     void *userdata)
 3182 {
 3183   CtxList* list1;
 3184   CtxList* list2;
 3185 
 3186   /* Base case -- length 0 or 1 */
 3187   if ((*head == NULL) || ((*head)->next == NULL))
 3188   {
 3189     return;
 3190   }
 3191 
 3192   ctx_list_split_half (*head, &list1, &list2);
 3193   ctx_list_sort (&list1, compare, userdata);
 3194   ctx_list_sort (&list2, compare, userdata);
 3195   *head = ctx_list_merge_sorted (list1, list2, compare, userdata);
 3196 }
 3197 
 3198 #endif
 3199 
 3200 /* definitions that determine which features are included and their 
 3201 settings,
 3202  * for particular platforms - in particular microcontrollers ctx might need
 3203  * tuning for different quality/performance/resource constraints.
 3204  *
 3205  * the way to configure ctx is to set these defines, before both including 
 3206  it
 3207  * as a header and in the file where CTX_IMPLEMENTATION is set to include 
 3208  the
 3209  * implementation for different featureset and runtime settings.
 3210  *
 3211  */
 3212 
 3213 #ifndef CTX_RASTERIZER  // set to 0 before to disable rasterizer code, 
 3214 useful for clients that only
 3215 // build journals.
 3216 #define CTX_RASTERIZER   1
 3217 #endif
 3218 
 3219 /* whether the font rendering happens in backend or front-end of API,
 3220  * the option is used by the tool that converts ttf fonts to ctx internal
 3221  * representation.
 3222  */
 3223 #ifndef CTX_BACKEND_TEXT
 3224 #define CTX_BACKEND_TEXT 1
 3225 #endif
 3226 
 3227 
 3228 
 3229 /* force full antialising */
 3230 #ifndef CTX_RASTERIZER_FORCE_AA
 3231 #define CTX_RASTERIZER_FORCE_AA  0
 3232 #endif
 3233 
 3234 /* when AA is not forced, the slope below which full AA get enabled.
 3235  */
 3236 
 3237 #define CTX_RASTERIZER_AA_SLOPE_LIMIT    (2125/CTX_SUBDIV/rasterizer->aa)
 3238 
 3239 #ifndef CTX_RASTERIZER_AA_SLOPE_DEBUG
 3240 #define CTX_RASTERIZER_AA_SLOPE_DEBUG 0
 3241 #endif
 3242 
 3243 
 3244 /* subpixel-aa coordinates used in BITPACKing of renderstream
 3245  */
 3246 #define CTX_SUBDIV   4 // higher gives higher quality, but 4096wide 
 3247 rendering
 3248                        // stops working
 3249 
 3250 // 8    12 68 40 24
 3251 // 16   12 68 40 24
 3252 /* scale-factor for font outlines prior to bit quantization by CTX_SUBDIV
 3253  *
 3254  * changing this also changes font file format
 3255  */
 3256 #define CTX_BAKE_FONT_SIZE    160
 3257 
 3258 /* pack some linetos/curvetos/movetos into denser renderstream 
 3259 indstructions,
 3260  * permitting more vectors to be stored in the same space.
 3261  */
 3262 #ifndef CTX_BITPACK
 3263 #define CTX_BITPACK           1
 3264 #endif
 3265 
 3266 /* whether we have a shape-cache where we keep pre-rasterized bitmaps of
 3267  * commonly occuring small shapes, disabled by default since it has some
 3268  * glitches (and potential hangs with multi threading).
 3269  */
 3270 #ifndef CTX_SHAPE_CACHE
 3271 #define CTX_SHAPE_CACHE        0
 3272 #endif
 3273 
 3274 /* size (in pixels, w*h) that we cache rasterization for
 3275  */
 3276 #ifndef CTX_SHAPE_CACHE_DIM
 3277 #define CTX_SHAPE_CACHE_DIM      (16*16)
 3278 #endif
 3279 
 3280 #ifndef CTX_SHAPE_CACHE_MAX_DIM
 3281 #define CTX_SHAPE_CACHE_MAX_DIM  32
 3282 #endif
 3283 
 3284 #ifndef CTX_PARSER_MAXLEN
 3285 #define CTX_PARSER_MAXLEN  1024 // this is the largest text string we 
 3286 support
 3287 #endif
 3288 
 3289 #ifndef CTX_COMPOSITING_GROUPS
 3290 #define CTX_COMPOSITING_GROUPS   1
 3291 #endif
 3292 
 3293 /* maximum nesting level of compositing groups
 3294  */
 3295 #ifndef CTX_GROUP_MAX
 3296 #define CTX_GROUP_MAX     8
 3297 #endif
 3298 
 3299 #ifndef CTX_ENABLE_CLIP
 3300 #define CTX_ENABLE_CLIP   1
 3301 #endif
 3302 
 3303 /* use a 1bit clip buffer, saving RAM on microcontrollers, other rendering
 3304  * will still be antialiased.
 3305  */
 3306 #ifndef CTX_1BIT_CLIP
 3307 #define CTX_1BIT_CLIP 0
 3308 #endif
 3309 
 3310 /* maximum number of entries in shape cache
 3311  */
 3312 #ifndef CTX_SHAPE_CACHE_ENTRIES
 3313 #define CTX_SHAPE_CACHE_ENTRIES  160
 3314 #endif
 3315 
 3316 #ifndef CTX_ENABLE_SHADOW_BLUR
 3317 #define CTX_ENABLE_SHADOW_BLUR    1
 3318 #endif
 3319 
 3320 #ifndef CTX_GRADIENTS
 3321 #define CTX_GRADIENTS      1
 3322 #endif
 3323 
 3324 /* some optinal micro-optimizations that are known to increase code size
 3325  */
 3326 #ifndef CTX_BLOATY_FAST_PATHS
 3327 #define CTX_BLOATY_FAST_PATHS 1
 3328 #endif
 3329 
 3330 #ifndef CTX_GRADIENT_CACHE
 3331 #define CTX_GRADIENT_CACHE 1
 3332 #endif
 3333 
 3334 #ifndef CTX_FONTS_FROM_FILE
 3335 #define CTX_FONTS_FROM_FILE 1
 3336 #endif
 3337 
 3338 #ifndef CTX_FORMATTER
 3339 #define CTX_FORMATTER       1
 3340 #endif
 3341 
 3342 #ifndef CTX_PARSER
 3343 #define CTX_PARSER          1
 3344 #endif
 3345 
 3346 #ifndef CTX_CURRENT_PATH
 3347 #define CTX_CURRENT_PATH    1
 3348 #endif
 3349 
 3350 #ifndef CTX_XML
 3351 #define CTX_XML             1
 3352 #endif
 3353 
 3354 /* when ctx_math is defined, which it is by default, we use ctx' own
 3355  * implementations of math functions, instead of relying on math.h
 3356  * the possible inlining gives us a slight speed-gain, and on
 3357  * embedded platforms guarantees that we do not do double precision
 3358  * math.
 3359  */
 3360 #ifndef CTX_MATH
 3361 #define CTX_MATH           1  // use internal fast math for sqrt,sin,cos,
 3362 atan2f etc.
 3363 #endif
 3364 
 3365 #define ctx_log(fmt, ...)
 3366 //#define ctx_log(str, a...) fprintf(stderr, str, ##a)
 3367 
 3368 /* the initial journal size - for both rasterizer
 3369  * edgelist and renderstram.
 3370  */
 3371 #ifndef CTX_MIN_JOURNAL_SIZE
 3372 #define CTX_MIN_JOURNAL_SIZE   1024*128
 3373 #endif
 3374 
 3375 /* The maximum size we permit the renderstream to grow to,
 3376  * the memory used is this number * 9, where 9 is sizeof(CtxEntry)
 3377  */
 3378 #ifndef CTX_MAX_JOURNAL_SIZE
 3379 #define CTX_MAX_JOURNAL_SIZE   CTX_MIN_JOURNAL_SIZE
 3380 #endif
 3381 
 3382 #ifndef CTX_RENDERSTREAM_STATIC
 3383 #define CTX_RENDERSTREAM_STATIC  0
 3384 #endif
 3385 
 3386 #ifndef CTX_MIN_EDGE_LIST_SIZE
 3387 #define CTX_MIN_EDGE_LIST_SIZE   1024
 3388 #endif
 3389 
 3390 /* The maximum complexity of a single path
 3391  */
 3392 #ifndef CTX_MAX_EDGE_LIST_SIZE
 3393 #define CTX_MAX_EDGE_LIST_SIZE  CTX_MIN_EDGE_LIST_SIZE
 3394 #endif
 3395 
 3396 #ifndef CTX_STRINGPOOL_SIZE
 3397   // XXX should be possible to make zero and disappear when codepaths not 
 3398   in use
 3399   //     to save size
 3400 #define CTX_STRINGPOOL_SIZE     4000 // needed for tiger
 3401 #endif
 3402 
 3403 /* whether we dither or not for gradients
 3404  */
 3405 #ifndef CTX_DITHER
 3406 #define CTX_DITHER 1
 3407 #endif
 3408 
 3409 /*  only source-over clear and copy will work, the API still
 3410  *  through - but the renderer is limited, for use to measure
 3411  *  size and possibly in severely constrained ROMs.
 3412  */
 3413 #ifndef CTX_BLENDING_AND_COMPOSITING
 3414 #define CTX_BLENDING_AND_COMPOSITING 1
 3415 #endif
 3416 
 3417 /*  this forces the inlining of some performance
 3418  *  critical paths.
 3419  */
 3420 #ifndef CTX_FORCE_INLINES
 3421 #define CTX_FORCE_INLINES               1
 3422 #endif
 3423 
 3424 /* create one-off inlined inner loop for normal blend mode
 3425  */
 3426 #ifndef CTX_INLINED_NORMAL     
 3427 #define CTX_INLINED_NORMAL      1
 3428 #endif
 3429 
 3430 #ifndef CTX_INLINED_GRADIENTS
 3431 #define CTX_INLINED_GRADIENTS   1
 3432 #endif
 3433 
 3434 #ifndef CTX_BRAILLE_TEXT
 3435 #define CTX_BRAILLE_TEXT        0
 3436 #endif
 3437 
 3438 /* including immintrin.h triggers building of AVX2 code paths, if - like
 3439  * sometimes when including SDL one does want it at all do a
 3440  * #define CTX_AVX2 0  before including ctx.h for implementation.
 3441  */
 3442 #ifndef CTX_AVX2
 3443 #ifdef _IMMINTRIN_H_INCLUDED
 3444 #define CTX_AVX2         1
 3445 #else
 3446 #define CTX_AVX2         0
 3447 #endif
 3448 #endif
 3449 
 3450 /* Build code paths for grayscale rasterization, normally this is handled
 3451  * by the RGBA8 codepaths; on microcontrollers with eink this might be
 3452  * a better option.
 3453  */
 3454 #ifndef CTX_NATIVE_GRAYA8
 3455 #define CTX_NATIVE_GRAYA8       0
 3456 #endif
 3457 
 3458 /* enable CMYK rasterization targets
 3459  */
 3460 #ifndef CTX_ENABLE_CMYK
 3461 #define CTX_ENABLE_CMYK         1
 3462 #endif
 3463 
 3464 /* enable color management, slightly increases CtxColor struct size, can
 3465  * be disabled for microcontrollers.
 3466  */
 3467 #ifndef CTX_ENABLE_CM
 3468 #define CTX_ENABLE_CM           1
 3469 #endif
 3470 
 3471 #ifndef CTX_EVENTS
 3472 #define CTX_EVENTS              1
 3473 #endif
 3474 
 3475 #ifndef CTX_LIMIT_FORMATS
 3476 #define CTX_LIMIT_FORMATS       0
 3477 #endif
 3478 
 3479 /* by default ctx includes all pixel formats, on microcontrollers
 3480  * it can be useful to slim down code and runtime size by only
 3481  * defining the used formats, set CTX_LIMIT_FORMATS to 1, and
 3482  * manually add CTX_ENABLE_ flags for each of them.
 3483  */
 3484 #if CTX_LIMIT_FORMATS
 3485 #else
 3486 
 3487 #define CTX_ENABLE_GRAY1                1
 3488 #define CTX_ENABLE_GRAY2                1
 3489 #define CTX_ENABLE_GRAY4                1
 3490 #define CTX_ENABLE_GRAY8                1
 3491 #define CTX_ENABLE_GRAYA8               1
 3492 #define CTX_ENABLE_GRAYF                1
 3493 #define CTX_ENABLE_GRAYAF               1
 3494 
 3495 #define CTX_ENABLE_RGB8                 1
 3496 #define CTX_ENABLE_RGBA8                1
 3497 #define CTX_ENABLE_BGRA8                1
 3498 
 3499 #define CTX_ENABLE_RGB332               1
 3500 #define CTX_ENABLE_RGB565               1
 3501 #define CTX_ENABLE_RGB565_BYTESWAPPED   1
 3502 #define CTX_ENABLE_RGBAF                1
 3503 
 3504 #if CTX_ENABLE_CMYK
 3505 #define CTX_ENABLE_CMYK8                1
 3506 #define CTX_ENABLE_CMYKA8               1
 3507 #define CTX_ENABLE_CMYKAF               1
 3508 #endif
 3509 
 3510 #endif
 3511 
 3512 /* by including ctx-font-regular.h, or ctx-font-mono.h the
 3513  * built-in fonts using ctx renderstream encoding is enabled
 3514  */
 3515 #if CTX_FONT_regular || CTX_FONT_mono || CTX_FONT_bold \
 3516   || CTX_FONT_italic || CTX_FONT_sans || CTX_FONT_serif \
 3517   || CTX_FONT_ascii
 3518 #ifndef CTX_FONT_ENGINE_CTX
 3519 #define CTX_FONT_ENGINE_CTX        1
 3520 #endif
 3521 #endif
 3522 
 3523 
 3524 /* If stb_strutype.h is included before ctx.h add integration code for 
 3525 runtime loading
 3526  * of opentype fonts.
 3527  */
 3528 #ifdef __STB_INCLUDE_STB_TRUETYPE_H__
 3529 #ifndef CTX_FONT_ENGINE_STB
 3530 #define CTX_FONT_ENGINE_STB        1
 3531 #endif
 3532 #else
 3533 #define CTX_FONT_ENGINE_STB        0
 3534 #endif
 3535 
 3536 /* force add format if we have shape cache */
 3537 #if CTX_SHAPE_CACHE
 3538 #ifdef CTX_ENABLE_GRAY8
 3539 #undef CTX_ENABLE_GRAY8
 3540 #endif
 3541 #define CTX_ENABLE_GRAY8  1
 3542 #endif
 3543 
 3544 /* include the bitpack packer, can be opted out of to decrease code size
 3545  */
 3546 #ifndef CTX_BITPACK_PACKER
 3547 #define CTX_BITPACK_PACKER 1
 3548 #endif
 3549 
 3550 /* enable RGBA8 intermediate format for
 3551  *the indirectly implemented pixel-formats.
 3552  */
 3553 #if CTX_ENABLE_GRAY1 | CTX_ENABLE_GRAY2 | CTX_ENABLE_GRAY4 | 
 3554 CTX_ENABLE_RGB565 | CTX_ENABLE_RGB565_BYTESWAPPED | CTX_ENABLE_RGB8 | 
 3555 CTX_ENABLE_RGB332
 3556 
 3557   #ifdef CTX_ENABLE_RGBA8
 3558     #undef CTX_ENABLE_RGBA8
 3559   #endif
 3560   #define CTX_ENABLE_RGBA8  1
 3561 #endif
 3562 
 3563 /* enable cmykf which is cmyk intermediate format
 3564  */
 3565 #ifdef CTX_ENABLE_CMYK8
 3566 #ifdef CTX_ENABLE_CMYKF
 3567 #undef CTX_ENABLE_CMYKF
 3568 #endif
 3569 #define CTX_ENABLE_CMYKF  1
 3570 #endif
 3571 #ifdef CTX_ENABLE_CMYKA8
 3572 #ifdef CTX_ENABLE_CMYKF
 3573 #undef CTX_ENABLE_CMYKF
 3574 #endif
 3575 #define CTX_ENABLE_CMYKF  1
 3576 #endif
 3577 
 3578 #ifdef CTX_ENABLE_CMYKF8
 3579 #ifdef CTX_ENABLE_CMYK
 3580 #undef CTX_ENABLE_CMYK
 3581 #endif
 3582 #define CTX_ENABLE_CMYK   1
 3583 #endif
 3584 
 3585 #define CTX_PI                              3.141592653589793f
 3586 #ifndef CTX_RASTERIZER_MAX_CIRCLE_SEGMENTS
 3587 #define CTX_RASTERIZER_MAX_CIRCLE_SEGMENTS  100
 3588 #endif
 3589 
 3590 #ifndef CTX_MAX_FONTS
 3591 #define CTX_MAX_FONTS            3
 3592 #endif
 3593 
 3594 #ifndef CTX_MAX_STATES
 3595 #define CTX_MAX_STATES           10
 3596 #endif
 3597 
 3598 #ifndef CTX_MAX_EDGES
 3599 #define CTX_MAX_EDGES            257
 3600 #endif
 3601 
 3602 #ifndef CTX_MAX_LINGERING_EDGES
 3603 #define CTX_MAX_LINGERING_EDGES  32
 3604 #endif
 3605 
 3606 #ifndef CTX_MAX_TEXTURES
 3607 #define CTX_MAX_TEXTURES         16
 3608 #endif
 3609 
 3610 #ifndef CTX_MAX_PENDING
 3611 #define CTX_MAX_PENDING          128
 3612 #endif
 3613 
 3614 #ifndef CTX_HASH_ROWS
 3615 #define CTX_HASH_ROWS            8
 3616 #endif
 3617 #ifndef CTX_HASH_COLS
 3618 #define CTX_HASH_COLS            4
 3619 #endif
 3620 
 3621 #ifndef CTX_MAX_THREADS
 3622 #define CTX_MAX_THREADS          8
 3623 #endif
 3624 
 3625 
 3626 #define CTX_RASTERIZER_EDGE_MULTIPLIER  1024
 3627 
 3628 
 3629 #ifndef __CTX_EXTRA_H
 3630 #define __CTX_EXTRA_H
 3631 
 3632 
 3633 #define CTX_CLAMP(val,min,max) ((val)<(min)?(min):(val)>(max)?(max):(val))
 3634 static inline int   ctx_mini (int a, int b)     { if (a < b) return a; 
 3635                               return b; }
 3636 static inline float ctx_minf (float a, float b) { if (a < b) return a; 
 3637                               return b; }
 3638 static inline int   ctx_maxi (int a, int b)     { if (a > b) return a; 
 3639                               return b; }
 3640 static inline float ctx_maxf (float a, float b) { if (a > b) return a; 
 3641                               return b; }
 3642 
 3643 
 3644 typedef enum CtxOutputmode
 3645 {
 3646   CTX_OUTPUT_MODE_QUARTER,
 3647   CTX_OUTPUT_MODE_BRAILLE,
 3648   CTX_OUTPUT_MODE_SIXELS,
 3649   CTX_OUTPUT_MODE_GRAYS,
 3650   CTX_OUTPUT_MODE_CTX,
 3651   CTX_OUTPUT_MODE_CTX_COMPACT,
 3652   CTX_OUTPUT_MODE_UI
 3653 } CtxOutputmode;
 3654 
 3655 #define CTX_NORMALIZE(a)            (((a)=='-')?'_':(a))
 3656 #define CTX_NORMALIZE_CASEFOLDED(a) (((a)=='-')?'_':((((a)>='A')&&((a)<='Z')
 3657                                  )?(a)+32:(a)))
 3658 
 3659 
 3660 /* We use the preprocessor to compute case invariant hashes
 3661  * of strings directly, if there is collisions in our vocabulary
 3662  * the compiler tells us.
 3663  */
 3664 
 3665 #define CTX_STRHash(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a27,a12,a13) (\
 3666           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a0))+ \
 3667           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a1))*27)+ \
 3668           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a2))*27*27)+ \
 3669           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a3))*27*27*27)+ \
 3670           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a4))*27*27*27*27) + \
 3671           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a5))*27*27*27*27*27) + \
 3672           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a6))*27*27*27*27*27*27) + \
 3673           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a7))*27*27*27*27*27*27*27) + 
 3674            \
 3675           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a8))*27*27*27*27*27*27*27*27)
 3676            + \
 3677           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a9))
 3678            *27*27*27*27*27*27*27*27*27) + \
 3679           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a10))
 3680            *27*27*27*27*27*27*27*27*27*27) + \
 3681           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a27))
 3682            *27*27*27*27*27*27*27*27*27*27*27) + \
 3683           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a12))
 3684            *27*27*27*27*27*27*27*27*27*27*27*27) + \
 3685           (((uint32_t)CTX_NORMALIZE_CASEFOLDED(a13))
 3686            *27*27*27*27*27*27*27*27*27*27*27*27*27)))
 3687 
 3688 #define CTX_STRH(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a27,a12,a13) (\
 3689           (((uint32_t)CTX_NORMALIZE(a0))+ \
 3690           (((uint32_t)CTX_NORMALIZE(a1))*27)+ \
 3691           (((uint32_t)CTX_NORMALIZE(a2))*27*27)+ \
 3692           (((uint32_t)CTX_NORMALIZE(a3))*27*27*27)+ \
 3693           (((uint32_t)CTX_NORMALIZE(a4))*27*27*27*27) + \
 3694           (((uint32_t)CTX_NORMALIZE(a5))*27*27*27*27*27) + \
 3695           (((uint32_t)CTX_NORMALIZE(a6))*27*27*27*27*27*27) + \
 3696           (((uint32_t)CTX_NORMALIZE(a7))*27*27*27*27*27*27*27) + \
 3697           (((uint32_t)CTX_NORMALIZE(a8))*27*27*27*27*27*27*27*27) + \
 3698           (((uint32_t)CTX_NORMALIZE(a9))*27*27*27*27*27*27*27*27*27) + \
 3699           (((uint32_t)CTX_NORMALIZE(a10))*27*27*27*27*27*27*27*27*27*27) + 
 3700            \
 3701           (((uint32_t)CTX_NORMALIZE(a27))*27*27*27*27*27*27*27*27*27*27*27) 
 3702            + \
 3703           (((uint32_t)CTX_NORMALIZE(a12))
 3704            *27*27*27*27*27*27*27*27*27*27*27*27) + \
 3705           (((uint32_t)CTX_NORMALIZE(a13))
 3706            *27*27*27*27*27*27*27*27*27*27*27*27*27)))
 3707 
 3708 static inline uint32_t ctx_strhash (const char *str, int case_insensitive)
 3709 {
 3710   uint32_t ret;
 3711   if (!str) return 0;
 3712   int len = strlen (str);
 3713   if (case_insensitive)
 3714     ret =CTX_STRHash(len>=0?str[0]:0,
 3715                        len>=1?str[1]:0,
 3716                        len>=2?str[2]:0,
 3717                        len>=3?str[3]:0,
 3718                        len>=4?str[4]:0,
 3719                        len>=5?str[5]:0,
 3720                        len>=6?str[6]:0,
 3721                        len>=7?str[7]:0,
 3722                        len>=8?str[8]:0,
 3723                        len>=9?str[9]:0,
 3724                        len>=10?str[10]:0,
 3725                        len>=11?str[11]:0,
 3726                        len>=12?str[12]:0,
 3727                        len>=13?str[13]:0);
 3728   else
 3729     ret =CTX_STRH(len>=0?str[0]:0,
 3730                     len>=1?str[1]:0,
 3731                     len>=2?str[2]:0,
 3732                     len>=3?str[3]:0,
 3733                     len>=4?str[4]:0,
 3734                     len>=5?str[5]:0,
 3735                     len>=6?str[6]:0,
 3736                     len>=7?str[7]:0,
 3737                     len>=8?str[8]:0,
 3738                     len>=9?str[9]:0,
 3739                     len>=10?str[10]:0,
 3740                     len>=11?str[11]:0,
 3741                     len>=12?str[12]:0,
 3742                     len>=13?str[13]:0);
 3743                   return ret;
 3744 }
 3745 
 3746 #if CTX_FORCE_INLINES
 3747 #define CTX_INLINE inline __attribute__((always_inline))
 3748 #else
 3749 #define CTX_INLINE inline
 3750 #endif
 3751 
 3752 static inline float ctx_pow2 (float a) { return a * a; }
 3753 #if CTX_MATH
 3754 
 3755 static inline float
 3756 ctx_fabsf (float x)
 3757 {
 3758   union
 3759   {
 3760     float f;
 3761     uint32_t i;
 3762   } u = { x };
 3763   u.i &= 0x7fffffff;
 3764   return u.f;
 3765 }
 3766 
 3767 static inline float
 3768 ctx_invsqrtf (float x)
 3769 {
 3770   void *foo = &x;
 3771   float xhalf = 0.5f * x;
 3772   int i=* (int *) foo;
 3773   void *bar = &i;
 3774   i = 0x5f3759df - (i >> 1);
 3775   x = * (float *) bar;
 3776   x *= (1.5f - xhalf * x * x);
 3777   x *= (1.5f - xhalf * x * x); //repeating Newton-Raphson step for higher 
 3778        precision
 3779   return x;
 3780 }
 3781 
 3782 CTX_INLINE static float
 3783 ctx_sinf (float x)
 3784 {
 3785   /* source : http://mooooo.ooo/chebyshev-sine-approximation/ */
 3786   while (x < -CTX_PI)
 3787     { x += CTX_PI * 2; }
 3788   while (x > CTX_PI)
 3789     { x -= CTX_PI * 2; }
 3790   float coeffs[]=
 3791   {
 3792     -0.10132118f,           // x
 3793       0.0066208798f,         // x^3
 3794       -0.00017350505f,        // x^5
 3795       0.0000025222919f,      // x^7
 3796       -0.000000023317787f,    // x^9
 3797       0.00000000013291342f
 3798     }; // x^11
 3799   float x2 = x*x;
 3800   float p11 = coeffs[5];
 3801   float p9  = p11*x2 + coeffs[4];
 3802   float p7  = p9*x2  + coeffs[3];
 3803   float p5  = p7*x2  + coeffs[2];
 3804   float p3  = p5*x2  + coeffs[1];
 3805   float p1  = p3*x2  + coeffs[0];
 3806   return (x - CTX_PI + 0.00000008742278f) *
 3807          (x + CTX_PI - 0.00000008742278f) * p1 * x;
 3808 }
 3809 
 3810 static inline float ctx_atan2f (float y, float x)
 3811 {
 3812   float atan, z;
 3813   if ( x == 0.0f )
 3814     {
 3815       if ( y > 0.0f )
 3816         { return CTX_PI/2; }
 3817       if ( y == 0.0f )
 3818         { return 0.0f; }
 3819       return -CTX_PI/2;
 3820     }
 3821   z = y/x;
 3822   if ( ctx_fabsf ( z ) < 1.0f )
 3823     {
 3824       atan = z/ (1.0f + 0.28f*z*z);
 3825       if (x < 0.0f)
 3826         {
 3827           if ( y < 0.0f )
 3828             { return atan - CTX_PI; }
 3829           return atan + CTX_PI;
 3830         }
 3831     }
 3832   else
 3833     {
 3834       atan = CTX_PI/2 - z/ (z*z + 0.28f);
 3835       if ( y < 0.0f ) { return atan - CTX_PI; }
 3836     }
 3837   return atan;
 3838 }
 3839 
 3840 CTX_INLINE static float ctx_sqrtf (float a)
 3841 {
 3842   return 1.0f/ctx_invsqrtf (a);
 3843 }
 3844 
 3845 CTX_INLINE static float ctx_hypotf (float a, float b)
 3846 {
 3847   return ctx_sqrtf (ctx_pow2 (a)+ctx_pow2 (b) );
 3848 }
 3849 
 3850 static inline float ctx_atanf (float a)
 3851 {
 3852   return ctx_atan2f ( (a), 1.0f);
 3853 }
 3854 
 3855 static inline float ctx_asinf (float x)
 3856 {
 3857   return ctx_atanf ( (x) * (ctx_invsqrtf (1.0f-ctx_pow2 (x) ) ) );
 3858 }
 3859 
 3860 static inline float ctx_acosf (float x)
 3861 {
 3862   return ctx_atanf ( (ctx_sqrtf (1.0f-ctx_pow2 (x) ) / (x) ) );
 3863 }
 3864 
 3865 CTX_INLINE static float ctx_cosf (float a)
 3866 {
 3867   return ctx_sinf ( (a) + CTX_PI/2.0f);
 3868 }
 3869 
 3870 static inline float ctx_tanf (float a)
 3871 {
 3872   return (ctx_cosf (a) /ctx_sinf (a) );
 3873 }
 3874 static inline float
 3875 ctx_floorf (float x)
 3876 {
 3877   return (int)x; // XXX
 3878 }
 3879 static inline float
 3880 ctx_expf (float x)
 3881 {
 3882   union { uint32_t i; float f; } v =
 3883     { (1 << 23) * (x + 183.1395965) };
 3884   return v.f;
 3885 }
 3886 
 3887 /* define more trig based on having sqrt, sin and atan2 */
 3888 
 3889 #else
 3890 #include <math.h>
 3891 static inline float ctx_fabsf (float x)           { return fabsf (x); }
 3892 static inline float ctx_floorf (float x)          { return floorf (x); }
 3893 static inline float ctx_sinf (float x)            { return sinf (x); }
 3894 static inline float ctx_atan2f (float y, float x) { return atan2f (y, x); }
 3895 static inline float ctx_hypotf (float a, float b) { return hypotf (a, b); }
 3896 static inline float ctx_acosf (float a)           { return acosf (a); }
 3897 static inline float ctx_cosf (float a)            { return cosf (a); }
 3898 static inline float ctx_tanf (float a)            { return tanf (a); }
 3899 static inline float ctx_expf (float p)            { return expf (p); }
 3900 static inline float ctx_sqrtf (float a)           { return sqrtf (a); }
 3901 #endif
 3902 
 3903 static inline float _ctx_parse_float (const char *str, char **endptr)
 3904 {
 3905   return strtod (str, endptr); /* XXX: , vs . problem in some locales */
 3906 }
 3907 
 3908 const char *ctx_get_string (Ctx *ctx, uint32_t hash);
 3909 void ctx_set_string (Ctx *ctx, uint32_t hash, const char *value);
 3910 typedef struct _CtxColor CtxColor;
 3911 typedef struct _CtxBuffer CtxBuffer;
 3912 
 3913 typedef struct _CtxMatrix     CtxMatrix;
 3914 struct
 3915   _CtxMatrix
 3916 {
 3917   float m[3][2];
 3918 };
 3919 void ctx_get_matrix (Ctx *ctx, CtxMatrix *matrix);
 3920 
 3921 int ctx_color (Ctx *ctx, const char *string);
 3922 typedef struct _CtxState CtxState;
 3923 CtxColor *ctx_color_new ();
 3924 CtxState *ctx_get_state (Ctx *ctx);
 3925 void ctx_color_get_rgba (CtxState *state, CtxColor *color, float *out);
 3926 void ctx_color_set_rgba (CtxState *state, CtxColor *color, float r, float g,
 3927                          float b, float a);
 3928 void ctx_color_free (CtxColor *color);
 3929 void ctx_set_color (Ctx *ctx, uint32_t hash, CtxColor *color);
 3930 int  ctx_get_color (Ctx *ctx, uint32_t hash, CtxColor *color);
 3931 int ctx_color_set_from_string (Ctx *ctx, CtxColor *color, const char 
 3932                                *string);
 3933 
 3934 int ctx_color_is_transparent (CtxColor *color);
 3935 int ctx_utf8_len (const unsigned char first_byte);
 3936 
 3937 void ctx_user_to_device          (Ctx *ctx, float *x, float *y);
 3938 void ctx_user_to_device_distance (Ctx *ctx, float *x, float *y);
 3939 const char *ctx_utf8_skip (const char *s, int utf8_length);
 3940 void ctx_apply_matrix (Ctx *ctx, CtxMatrix *matrix);
 3941 void ctx_matrix_apply_transform (const CtxMatrix *m, float *x, float *y);
 3942 void ctx_matrix_invert (CtxMatrix *m);
 3943 void ctx_matrix_identity (CtxMatrix *matrix);
 3944 void ctx_matrix_scale (CtxMatrix *matrix, float x, float y);
 3945 void ctx_matrix_rotate (CtxMatrix *matrix, float angle);
 3946 void ctx_matrix_multiply (CtxMatrix       *result,
 3947                           const CtxMatrix *t,
 3948                           const CtxMatrix *s);
 3949 void
 3950 ctx_matrix_translate (CtxMatrix *matrix, float x, float y);
 3951 int ctx_is_set_now (Ctx *ctx, uint32_t hash);
 3952 void ctx_set_size (Ctx *ctx, int width, int height);
 3953 
 3954 #if CTX_FONTS_FROM_FILE
 3955 int   ctx_load_font_ttf_file (const char *name, const char *path);
 3956 int
 3957 _ctx_file_get_contents (const char     *path,
 3958                         unsigned char **contents,
 3959                         long           *length);
 3960 #endif
 3961 
 3962 #endif
 3963 #ifndef __CTX_CONSTANTS
 3964 #define __CTX_CONSTANTS
 3965 
 3966 #define CTX_add_stop       CTX_STRH('a','d','d','_','s','t','o','p',0,0,0,0,
 3967                                     0,0)
 3968 #define CTX_addStop        CTX_STRH('a','d','d','S','t','o','p',0,0,0,0,0,0,
 3969                                     0)
 3970 #define CTX_alphabetic     CTX_STRH('a','l','p','h','a','b','e','t','i','c',
 3971                                     0,0,0,0)
 3972 #define CTX_arc            CTX_STRH('a','r','c',0,0,0,0,0,0,0,0,0,0,0)
 3973 #define CTX_arc_to         CTX_STRH('a','r','c','_','t','o',0,0,0,0,0,0,0,0)
 3974 #define CTX_arcTo          CTX_STRH('a','r','c','T','o',0,0,0,0,0,0,0,0,0)
 3975 #define CTX_begin_path     CTX_STRH('b','e','g','i','n','_','p','a','t','h',
 3976                                     0,0,0,0)
 3977 #define CTX_beginPath      CTX_STRH('b','e','g','i','n','P','a','t','h',0,0,
 3978                                     0,0,0)
 3979 #define CTX_bevel          CTX_STRH('b','e','v','e','l',0, 0, 0, 0, 0, 0, 0,
 3980                                     0,0)
 3981 #define CTX_bottom         CTX_STRH('b','o','t','t','o','m',0,0,0,0,0,0,0,0)
 3982 #define CTX_cap            CTX_STRH('c','a','p',0,0,0,0,0,0,0,0,0,0,0)
 3983 #define CTX_center         CTX_STRH('c','e','n','t','e','r', 0, 0, 0, 0, 0, 
 3984                                     0,0,0)
 3985 #define CTX_clear          CTX_STRH('c','l','e','a','r',0,0,0,0,0,0,0,0,0)
 3986 #define CTX_color          CTX_STRH('c','o','l','o','r',0,0,0,0,0,0,0,0,0)
 3987 #define CTX_copy           CTX_STRH('c','o','p','y',0,0,0,0,0,0,0,0,0,0)
 3988 #define CTX_clip           CTX_STRH('c','l','i','p',0,0,0,0,0,0,0,0,0,0)
 3989 #define CTX_close_path     CTX_STRH('c','l','o','s','e','_','p','a','t','h',
 3990                                     0,0,0,0)
 3991 #define CTX_closePath      CTX_STRH('c','l','o','s','e','P','a','t','h',0,0,
 3992                                     0,0,0)
 3993 #define CTX_cmyka          CTX_STRH('c','m','y','k','a',0,0,0,0,0,0,0,0,0)
 3994 #define CTX_cmyk           CTX_STRH('c','m','y','k',0,0,0,0,0,0,0,0,0,0)
 3995 #define CTX_cmyk_space     CTX_STRH('c','m','y','k','_','s','p','a','c','e',
 3996                                     0,0,0,0)
 3997 #define CTX_cmykSpace      CTX_STRH('c','m','y','k','S','p','a','c','e',0,0,
 3998                                     0,0,0)
 3999 #define CTX_color          CTX_STRH('c','o','l','o','r',0,0,0,0,0,0,0,0,0)
 4000 
 4001 #define CTX_blending       CTX_STRH('b','l','e','n','d','i','n','g',0,0,0,0,
 4002                                     0,0)
 4003 #define CTX_blend          CTX_STRH('b','l','e','n','d',0,0,0,0,0,0,0,0,0)
 4004 #define CTX_blending_mode  CTX_STRH('b','l','e','n','d','i','n','g','_','m',
 4005                                     'o','d','e',0)
 4006 #define CTX_blendingMode   CTX_STRH('b','l','e','n','d','i','n','g','M','o',
 4007                                     'd','e',0,0)
 4008 #define CTX_blend_mode     CTX_STRH('b','l','e','n','d','_','m','o','d','e',
 4009                                     0,0,0,0)
 4010 #define CTX_blendMode      CTX_STRH('b','l','e','n','d','M','o','d','e',0,0,
 4011                                     0,0,0)
 4012 
 4013 #define CTX_composite      CTX_STRH('c','o','m','p','o','s','i','t','i','e',
 4014                                     0,0,0,0)
 4015 #define CTX_compositing_mode CTX_STRH('c','o','m','p','o','s','i','t','i',
 4016                                       'n','g','_','m','o')
 4017 #define CTX_compositingMode CTX_STRH('c','o','m','p','o','s','i','t','i',
 4018                                      'n','g','M','o','d')
 4019 #define CTX_curve_to       CTX_STRH('c','u','r','v','e','_','t','o',0,0,0,0,
 4020                                     0,0)
 4021 #define CTX_curveTo        CTX_STRH('c','u','r','v','e','T','o',0,0,0,0,0,0,
 4022                                     0)
 4023 #define CTX_darken         CTX_STRH('d','a','r','k','e','n',0,0,0,0,0,0,0,0)
 4024 #define CTX_dcmyk_space    CTX_STRH('d','c','m','y','k','_','s','p','a','c',
 4025                                     'e',0,0,0)
 4026 #define CTX_dcmykSpace     CTX_STRH('d','c','m','y','k','S','p','a','c','e',
 4027                                     0,0,0,0)
 4028 #define CTX_destinationIn  CTX_STRH('d','e','s','t','i','n','a','t','i','o',
 4029                                     'n','I','n',0)
 4030 #define CTX_destination_in CTX_STRH('d','e','s','t','i','n','a','t','i','o',
 4031                                     'n','_','i','n')
 4032 #define CTX_destinationAtop CTX_STRH('d','e','s','t','i','n','a','t','i',
 4033                                      'o','n','A','t','o')
 4034 #define CTX_destination_atop CTX_STRH('d','e','s','t','i','n','a','t','i',
 4035                                       'o','n','_','a','t')
 4036 #define CTX_destinationOver CTX_STRH('d','e','s','t','i','n','a','t','i',
 4037                                      'o','n','O','v','e')
 4038 #define CTX_destination_over CTX_STRH('d','e','s','t','i','n','a','t','i',
 4039                                       'o','n','-','o','v')
 4040 #define CTX_destinationOut CTX_STRH('d','e','s','t','i','n','a','t','i','o',
 4041                                     'n','O','u','t')
 4042 #define CTX_destination_out CTX_STRH('d','e','s','t','i','n','a','t','i',
 4043                                      'o','n','_','o','u')
 4044 #define CTX_difference     CTX_STRH('d','i','f','f','e','r','e','n','c','e',
 4045                                     0,0,0,0)
 4046 #define CTX_done           CTX_STRH('d','o','n','e',0,0,0,0,0,0,0,0,0,0)
 4047 #define CTX_drgba          CTX_STRH('d','r','g','b','a',0,0,0,0,0,0,0,0,0)
 4048 #define CTX_drgb           CTX_STRH('d','r','g','b',0,0,0,0,0,0,0,0,0,0)
 4049 #define CTX_drgb_space     CTX_STRH('d','r','g','b','_','s','p','a','c','e',
 4050                                     0,0,0,0)
 4051 #define CTX_drgbSpace      CTX_STRH('d','r','g','b','S','p','a','c','e',0,0,
 4052                                     0,0,0)
 4053 #define CTX_end            CTX_STRH('e','n','d',0,0,0, 0, 0, 0, 0, 0, 0,0,0)
 4054 #define CTX_endfun         CTX_STRH('e','n','d','f','u','n',0,0,0,0,0,0,0,0)
 4055 
 4056 #define CTX_end_group      CTX_STRH('e','n','d','_','G','r','o','u','p',0,0,
 4057                                     0,0,0)
 4058 #define CTX_endGroup       CTX_STRH('e','n','d','G','r','o','u','p',0,0,0,0,
 4059                                     0,0)
 4060 
 4061 #define CTX_even_odd       CTX_STRH('e','v','e','n','_','o','d', 'd', 0, 0, 
 4062                                     0, 0,0,0)
 4063 #define CTX_evenOdd        CTX_STRH('e','v','e','n','O','d', 'd', 0, 0, 0, 
 4064                                     0, 0,0,0)
 4065 #define CTX_exit           CTX_STRH('e','x','i','t',0,0,0,0,0,0,0,0,0,0)
 4066 #define CTX_fill           CTX_STRH('f','i','l','l',0,0,0,0,0,0,0,0,0,0)
 4067 #define CTX_fill_rule      CTX_STRH('f','i','l','l','_','r','u','l','e',0,0,
 4068                                     0,0,0)
 4069 #define CTX_fillRule       CTX_STRH('f','i','l','l','R','u','l','e',0,0,0,0,
 4070                                     0,0)
 4071 #define CTX_flush          CTX_STRH('f','l','u','s','h',0,0,0,0,0,0,0,0,0)
 4072 #define CTX_font           CTX_STRH('f','o','n','t',0,0,0,0,0,0,0,0,0,0)
 4073 #define CTX_font_size      CTX_STRH('f','o','n','t','_','s','i','z','e',0,0,
 4074                                     0,0,0)
 4075 #define CTX_setFontSize       CTX_STRH('s','e','t','F','o','n','t','S','i',
 4076                                        'z','e',0,0,0)
 4077 #define CTX_fontSize       CTX_STRH('f','o','n','t','S','i','z','e',0,0,0,0,
 4078                                     0,0)
 4079 #define CTX_function       CTX_STRH('f','u','n','c','t','i','o','n',0,0,0,0,
 4080                                     0,0)
 4081 #define CTX_getkey         CTX_STRH('g','e','t','k','e','y',0,0,0,0,0,0,0,0)
 4082 #define CTX_global_alpha   CTX_STRH('g','l','o','b','a','l','_','a','l','p',
 4083                                     'h','a',0,0)
 4084 #define CTX_globalAlpha    CTX_STRH('g','l','o','b','a','l','A','l','p','h',
 4085                                     'a',0,0,0)
 4086 #define CTX_glyph          CTX_STRH('g','l','y','p','h',0,0,0,0,0,0,0,0,0)
 4087 #define CTX_gradient_add_stop CTX_STRH('g','r','a','d','i','e','n','t','_',
 4088                                        'a','d','d','_','s')
 4089 #define CTX_gradientAddStop CTX_STRH('g','r','a','d','i','e','n','t','A',
 4090                                      'd','d','S','t','o')
 4091 #define CTX_graya          CTX_STRH('g','r','a','y','a',0,0,0,0,0,0,0,0,0)
 4092 #define CTX_gray           CTX_STRH('g','r','a','y',0,0,0,0,0,0,0,0,0,0)
 4093 #define CTX_H
 4094 #define CTX_hanging        CTX_STRH('h','a','n','g','i','n','g',0,0,0,0,0,0,
 4095                                     0)
 4096 #define CTX_height         CTX_STRH('h','e','i','g','h','t',0,0,0,0,0,0,0,0)
 4097 #define CTX_hor_line_to    CTX_STRH('h','o','r','_','l','i','n','e','_','t',
 4098                                     'o',0,0,0)
 4099 #define CTX_horLineTo      CTX_STRH('h','o','r','L','i','n','e','T','o',0,0,
 4100                                     0,0,0)
 4101 #define CTX_hue            CTX_STRH('h','u','e',0,0,0,0,0,0,0,0,0,0,0)
 4102 #define CTX_identity       CTX_STRH('i','d','e','n','t','i','t','y',0,0,0,0,
 4103                                     0,0)
 4104 #define CTX_ideographic    CTX_STRH('i','d','e','o','g','r','a','p','h','i',
 4105                                     'c',0,0,0)
 4106 #define CTX_join           CTX_STRH('j','o','i','n',0,0,0,0,0,0,0,0,0,0)
 4107 #define CTX_laba           CTX_STRH('l','a','b','a',0,0,0,0,0,0,0,0,0,0)
 4108 #define CTX_lab            CTX_STRH('l','a','b',0,0,0,0,0,0,0,0,0,0,0)
 4109 #define CTX_lcha           CTX_STRH('l','c','h','a',0,0,0,0,0,0,0,0,0,0)
 4110 #define CTX_lch            CTX_STRH('l','c','h',0,0,0,0,0,0,0,0,0,0,0)
 4111 #define CTX_left           CTX_STRH('l','e','f','t',0,0, 0, 0, 0, 0, 0, 0,0,
 4112                                     0)
 4113 #define CTX_lighter        CTX_STRH('l','i','g','h','t','e','r',0,0,0,0,0,0,
 4114                                     0)
 4115 #define CTX_lighten        CTX_STRH('l','i','g','h','t','e','n',0,0,0,0,0,0,
 4116                                     0)
 4117 #define CTX_linear_gradient CTX_STRH('l','i','n','e','a','r','_','g','r',
 4118                                      'a','d','i','e','n')
 4119 #define CTX_linearGradient CTX_STRH('l','i','n','e','a','r','G','r','a','d',
 4120                                     'i','e','n','t')
 4121 #define CTX_line_cap       CTX_STRH('l','i','n','e','_','c','a','p',0,0,0,0,
 4122                                     0,0)
 4123 #define CTX_lineCap        CTX_STRH('l','i','n','e','C','a','p',0,0,0,0,0,0,
 4124                                     0)
 4125 #define CTX_setLineCap     CTX_STRH('s','e','t','L','i','n','e','C','a','p',
 4126                                     0,0,0,0)
 4127 #define CTX_line_height    CTX_STRH('l','i','n','e','_','h','e','i','h','t',
 4128                                     0,0,0,0)
 4129 #define CTX_line_join      CTX_STRH('l','i','n','e','_','j','o','i','n',0,0,
 4130                                     0,0,0)
 4131 #define CTX_lineJoin       CTX_STRH('l','i','n','e','J','o','i','n',0,0,0,0,
 4132                                     0,0)
 4133 #define CTX_setLineJoin    CTX_STRH('s','e','t','L','i','n','e','J','o','i',
 4134                                     'n',0,0,0)
 4135 #define CTX_line_spacing   CTX_STRH('l','i','n','e','_','s','p','a','c','i',
 4136                                     'n','g',0,0)
 4137 #define CTX_line_to        CTX_STRH('l','i','n','e','_','t','o',0,0,0,0,0,0,
 4138                                     0)
 4139 #define CTX_lineTo         CTX_STRH('l','i','n','e','T','o',0,0,0,0,0,0,0,0)
 4140 #define CTX_line_width     CTX_STRH('l','i','n','e','_','w','i','d','t','h',
 4141                                     0,0,0,0)
 4142 #define CTX_lineWidth      CTX_STRH('l','i','n','e','W','i','d','t','h',0,0,
 4143                                     0,0,0)
 4144 #define CTX_setLineWidth   CTX_STRH('s','e','t','L','i','n','e','W','i','d',
 4145                                     't','h',0,0)
 4146 #define CTX_view_box       CTX_STRH('v','i','e','w','_','b','o','x',0,0,0,0,
 4147                                     0,0)
 4148 #define CTX_viewBox        CTX_STRH('v','i','e','w','B','o','x',0,0,0,0,0,0,
 4149                                     0)
 4150 #define CTX_middle         CTX_STRH('m','i','d','d','l','e',0, 0, 0, 0, 0, 
 4151                                     0,0,0)
 4152 #define CTX_miter          CTX_STRH('m','i','t','e','r',0, 0, 0, 0, 0, 0, 0,
 4153                                     0,0)
 4154 #define CTX_miter_limit    CTX_STRH('m','i','t','e','r','_','l','i','m','i',
 4155                                     't',0,0,0)
 4156 #define CTX_miterLimit     CTX_STRH('m','i','t','e','r','L','i','m','i','t',
 4157                                     0,0,0,0)
 4158 #define CTX_move_to        CTX_STRH('m','o','v','e','_','t','o',0,0,0,0,0,0,
 4159                                     0)
 4160 #define CTX_moveTo         CTX_STRH('m','o','v','e','T','o',0,0,0,0,0,0,0,0)
 4161 #define CTX_multiply       CTX_STRH('m','u','l','t','i','p','l','y',0,0,0,0,
 4162                                     0,0)
 4163 #define CTX_new_page       CTX_STRH('n','e','w','_','p','a','g','e',0,0,0,0,
 4164                                     0,0)
 4165 #define CTX_newPage        CTX_STRH('n','e','w','P','a','g','e',0,0,0,0,0,0,
 4166                                     0)
 4167 #define CTX_new_path       CTX_STRH('n','e','w','_','p','a','t','h',0,0,0,0,
 4168                                     0,0)
 4169 #define CTX_newPath        CTX_STRH('n','e','w','P','a','t','h',0,0,0,0,0,0,
 4170                                     0)
 4171 #define CTX_new_state      CTX_STRH('n','e','w','_','s','t','a','t','e',0,0,
 4172                                     0,0,0)
 4173 #define CTX_none           CTX_STRH('n','o','n','e', 0 ,0, 0, 0, 0, 0, 0, 0,
 4174                                     0,0)
 4175 #define CTX_normal         CTX_STRH('n','o','r','m','a','l',0,0,0,0,0,0,0,0)
 4176 #define CTX_quad_to        CTX_STRH('q','u','a','d','_','t','o',0,0,0,0,0,0,
 4177                                     0)
 4178 #define CTX_quadTo         CTX_STRH('q','u','a','d','T','o',0,0,0,0,0,0,0,0)
 4179 #define CTX_radial_gradient CTX_STRH('r','a','d','i','a','l','_','g','r',
 4180                                      'a','d','i','e','n')
 4181 #define CTX_radialGradient  CTX_STRH('r','a','d','i','a','l','G','r','a',
 4182                                      'd','i','e','n','t')
 4183 #define CTX_rectangle      CTX_STRH('r','e','c','t','a','n','g','l','e',0,0,
 4184                                     0,0,0)
 4185 #define CTX_rect           CTX_STRH('r','e','c','t',0,0,0,0,0,0,0,0,0,0)
 4186 #define CTX_rel_arc_to     CTX_STRH('r','e','l','_','a','r','c','_','t','o',
 4187                                     0,0,0,0)
 4188 #define CTX_relArcTo       CTX_STRH('r','e','l','A','r','c','T','o',0,0,0,0,
 4189                                     0,0)
 4190 #define CTX_rel_curve_to   CTX_STRH('r','e','l','_','c','u','r','v','e','_',
 4191                                     't','o',0,0)
 4192 #define CTX_relCurveTo     CTX_STRH('r','e','l','C','u','r','v','e','T','o',
 4193                                     0,0,0,0)
 4194 #define CTX_rel_hor_line_to CTX_STRH('r','e','l','_','h','o','r','_','l',
 4195                                      'i','n','e',0,0)
 4196 #define CTX_relHorLineTo   CTX_STRH('r','e','l','H','o','r','L','i','n','e',
 4197                                     'T','o',0,0)
 4198 #define CTX_rel_line_to    CTX_STRH('r','e','l','_','l','i','n','e','_','t',
 4199                                     'o',0,0,0)
 4200 #define CTX_relLineTo      CTX_STRH('r','e','l','L','i','n','e','T','o',0,0,
 4201                                     0,0,0)
 4202 #define CTX_rel_move_to    CTX_STRH('r','e','l','_','m','o','v','e','_','t',
 4203                                     'o',0,0,0)
 4204 #define CTX_relMoveTo      CTX_STRH('r','e','l','M','o','v','e','T','o',0,0,
 4205                                     0,0,0)
 4206 #define CTX_rel_quad_to    CTX_STRH('r','e','l','_','q','u','a','d','_','t',
 4207                                     'o',0,0,0)
 4208 #define CTX_relQuadTo      CTX_STRH('r','e','l','Q','u','a','d','T','o',0,0,
 4209                                     0,0,0)
 4210 #define CTX_rel_smoothq_to CTX_STRH('r','e','l','_','s','m','o','o','t','h',
 4211                                     'q','_','t','o')
 4212 #define CTX_relSmoothqTo   CTX_STRH('r','e','l','S','m','o','o','t','h','q',
 4213                                     'T','o',0,0)
 4214 #define CTX_rel_smooth_to  CTX_STRH('r','e','l','_','s','m','o','o','t','h',
 4215                                     '_','t','o',0)
 4216 #define CTX_relSmoothTo    CTX_STRH('r','e','l','S','m','o','o','t','h','T',
 4217                                     'o',0,0,0)
 4218 #define CTX_rel_ver_line_to CTX_STRH('r','e','l','_','v','e','r','_','l',
 4219                                      'i','n','e',0,0)
 4220 #define CTX_relVerLineTo   CTX_STRH('r','e','l','V','e','r','L','i','n','e',
 4221                                     'T','o',0,0)
 4222 #define CTX_restore        CTX_STRH('r','e','s','t','o','r','e',0,0,0,0,0,0,
 4223                                     0)
 4224 #define CTX_reset          CTX_STRH('r','e','s','e','t',0,0,0,0,0,0,0,0,0)
 4225 #define CTX_rgba           CTX_STRH('r','g','b','a',0,0,0,0,0,0,0,0,0,0)
 4226 #define CTX_rgb            CTX_STRH('r','g','b',0,0,0,0,0,0,0,0,0,0,0)
 4227 #define CTX_rgb_space      CTX_STRH('r','g','b','_','s','p','a','c','e',0,0,
 4228                                     0,0,0)
 4229 #define CTX_rgbSpace       CTX_STRH('r','g','b','S','p','a','c','e',0,0,0,0,
 4230                                     0,0)
 4231 #define CTX_right          CTX_STRH('r','i','g','h','t',0, 0, 0, 0, 0, 0, 0,
 4232                                     0,0)
 4233 #define CTX_rotate         CTX_STRH('r','o','t','a','t','e',0,0,0,0,0,0,0,0)
 4234 #define CTX_round          CTX_STRH('r','o','u','n','d',0, 0, 0, 0, 0, 0, 0,
 4235                                     0,0)
 4236 #define CTX_round_rectangle CTX_STRH('r','o','u','n','d','_','r','e','c',
 4237                                      't','a','n','g','l')
 4238 #define CTX_roundRectangle  CTX_STRH('r','o','u','n','d','R','e','c','t',
 4239                                      'a','n','g','l','e')
 4240 #define CTX_save           CTX_STRH('s','a','v','e',0,0,0,0,0,0,0,0,0,0)
 4241 #define CTX_save           CTX_STRH('s','a','v','e',0,0,0,0,0,0,0,0,0,0)
 4242 #define CTX_scale          CTX_STRH('s','c','a','l','e',0,0,0,0,0,0,0,0,0)
 4243 #define CTX_screen         CTX_STRH('s','c','r','e','e','n',0,0,0,0,0,0,0,0)
 4244 #define CTX_setkey         CTX_STRH('s','e','t','k','e','y',0,0,0,0,0,0,0,0)
 4245 #define CTX_shadowBlur     CTX_STRH('s','h','a','d','o','w','B','l','u','r',
 4246                                     0,0,0,0)
 4247 #define CTX_shadowColor    CTX_STRH('s','h','a','d','o','w','C','o','l','o',
 4248                                     'r',0,0,0)
 4249 #define CTX_shadowOffsetX  CTX_STRH('s','h','a','d','o','w','O','f','f','s',
 4250                                     'e','t','X',0)
 4251 #define CTX_shadowOffsetY  CTX_STRH('s','h','a','d','o','w','O','f','f','s',
 4252                                     'e','t','Y',0)
 4253 #define CTX_smooth_quad_to CTX_STRH('s','m','o','o','t','h','_','q','u','a',
 4254                                     'd','_','t','o')
 4255 #define CTX_smoothQuadTo   CTX_STRH('s','m','o','o','t','h','Q','u','a','d',
 4256                                     'T','o',0,0)
 4257 #define CTX_smooth_to      CTX_STRH('s','m','o','o','t','h','_','t','o',0,0,
 4258                                     0,0,0)
 4259 #define CTX_smoothTo       CTX_STRH('s','m','o','o','t','h','T','o',0,0,0,0,
 4260                                     0,0)
 4261 #define CTX_sourceIn       CTX_STRH('s','o','u','r','c','e','I','n',0,0,0,0,
 4262                                     0,0)
 4263 #define CTX_source_in      CTX_STRH('s','o','u','r','c','e','_','i','n',0,0,
 4264                                     0,0,0)
 4265 #define CTX_sourceAtop     CTX_STRH('s','o','u','r','c','e','A','t','o','p',
 4266                                     0,0,0,0)
 4267 #define CTX_source_atop    CTX_STRH('s','o','u','r','c','e','_','a','t','o',
 4268                                     'p',0,0,0)
 4269 #define CTX_sourceOut      CTX_STRH('s','o','u','r','c','e','O','u','t',0,0,
 4270                                     0,0,0)
 4271 #define CTX_source_out     CTX_STRH('s','o','u','r','c','e','_','o','u','t',
 4272                                     0,0,0,0)
 4273 #define CTX_sourceOver     CTX_STRH('s','o','u','r','c','e','O','v','e','r',
 4274                                     0,0,0,0)
 4275 #define CTX_source_over    CTX_STRH('s','o','u','r','c','e','_','o','v','e',
 4276                                     'r',0,0,0)
 4277 #define CTX_square         CTX_STRH('s','q','u','a','r','e', 0, 0, 0, 0, 0, 
 4278                                     0,0,0)
 4279 #define CTX_start          CTX_STRH('s','t','a','r','t',0, 0, 0, 0, 0, 0, 0,
 4280                                     0,0)
 4281 #define CTX_start_move     CTX_STRH('s','t','a','r','t','_','m','o','v','e',
 4282                                     0,0,0,0)
 4283 #define CTX_start_group    CTX_STRH('s','t','a','r','t','_','G','r','o','u',
 4284                                     'p',0,0,0)
 4285 #define CTX_startGroup     CTX_STRH('s','t','a','r','t','G','r','o','u','p',
 4286                                     0,0,0,0)
 4287 #define CTX_stroke         CTX_STRH('s','t','r','o','k','e',0,0,0,0,0,0,0,0)
 4288 #define CTX_text_align     CTX_STRH('t','e','x','t','_','a','l','i','g','n',
 4289                                     0, 0,0,0)
 4290 #define CTX_textAlign      CTX_STRH('t','e','x','t','A','l','i','g','n',0, 
 4291                                     0, 0,0,0)
 4292 #define CTX_texture        CTX_STRH('t','e','x','t','u','r','e',0,0,0, 0, 0,
 4293                                     0,0)
 4294 #define CTX_text_baseline  CTX_STRH('t','e','x','t','_','b','a','s','e','l',
 4295                                     'i','n','e',0)
 4296 #define CTX_text_baseline  CTX_STRH('t','e','x','t','_','b','a','s','e','l',
 4297                                     'i','n','e',0)
 4298 #define CTX_textBaseline   CTX_STRH('t','e','x','t','B','a','s','e','l','i',
 4299                                     'n','e',0,0)
 4300 #define CTX_text           CTX_STRH('t','e','x','t',0,0,0,0,0,0,0,0,0,0)
 4301 #define CTX_text_direction CTX_STRH('t','e','x','t','_','d','i','r','e','c',
 4302                                     't','i','o','n')
 4303 #define CTX_textDirection  CTX_STRH('t','e','x','t','D','i','r','e','c','t',
 4304                                     'i','o','n',0)
 4305 #define CTX_text_indent    CTX_STRH('t','e','x','t','_','i','n','d','e','n',
 4306                                     't', 0,0,0)
 4307 #define CTX_text_stroke    CTX_STRH('t','e','x','t','_','s','t','r','o','k',
 4308                                     'e', 0,0,0)
 4309 #define CTX_textStroke     CTX_STRH('t','e','x','t','S','t','r','o','k','e',
 4310                                     0, 0,0,0)
 4311 #define CTX_top            CTX_STRH('t','o','p',0,0,0, 0, 0, 0, 0, 0, 0,0,0)
 4312 #define CTX_transform      CTX_STRH('t','r','a','n','s','f','o','r','m',0,0,
 4313                                     0,0,0)
 4314 #define CTX_translate      CTX_STRH('t','r','a','n','s','l','a','t','e',0,0,
 4315                                     0,0,0)
 4316 #define CTX_verLineTo      CTX_STRH('v','e','r','L','i','n','e','T','o',0,0,
 4317                                     0,0,0)
 4318 #define CTX_ver_line_to    CTX_STRH('v','e','r','_','l','i','n','e','_','t',
 4319                                     'o',0,0,0)
 4320 #define CTX_width          CTX_STRH('w','i','d','t','h',0,0,0,0,0,0,0,0,0)
 4321 #define CTX_winding        CTX_STRH('w','i','n','d','i','n', 'g', 0, 0, 0, 
 4322                                     0, 0,0,0)
 4323 #define CTX_x              CTX_STRH('x',0,0,0,0,0,0,0,0,0,0,0,0,0)
 4324 #define CTX_xor            CTX_STRH('x','o','r',0,0,0,0,0,0,0,0,0,0,0)
 4325 #define CTX_y              CTX_STRH('y',0,0,0,0,0,0,0,0,0,0,0,0,0)
 4326 
 4327 #endif
 4328 #ifndef __CTX_LIBC_H
 4329 #define __CTX_LIBC_H
 4330 
 4331 #include <stddef.h>
 4332 
 4333 #if 0
 4334 static inline void
 4335 ctx_memset (void *ptr, uint8_t val, int length)
 4336 {
 4337   uint8_t *p = (uint8_t *) ptr;
 4338   for (int i = 0; i < length; i ++)
 4339     { p[i] = val; }
 4340 }
 4341 #else
 4342 #define ctx_memset memset
 4343 #endif
 4344 
 4345 
 4346 static inline void ctx_strcpy (char *dst, const char *src)
 4347 {
 4348   int i = 0;
 4349   for (i = 0; src[i]; i++)
 4350     { dst[i] = src[i]; }
 4351   dst[i] = 0;
 4352 }
 4353 
 4354 static inline char *_ctx_strchr (const char *haystack, char needle)
 4355 {
 4356   const char *p = haystack;
 4357   while (*p && *p != needle)
 4358     {
 4359       p++;
 4360     }
 4361   if (*p == needle)
 4362     { return (char *) p; }
 4363   return NULL;
 4364 }
 4365 static inline char *ctx_strchr (const char *haystack, char needle)
 4366 {
 4367   return _ctx_strchr (haystack, needle);
 4368 }
 4369 
 4370 static inline int ctx_strcmp (const char *a, const char *b)
 4371 {
 4372   int i;
 4373   for (i = 0; a[i] && b[i]; a++, b++)
 4374     if (a[0] != b[0])
 4375       { return 1; }
 4376   if (a[0] == 0 && b[0] == 0) { return 0; }
 4377   return 1;
 4378 }
 4379 
 4380 static inline int ctx_strncmp (const char *a, const char *b, size_t n)
 4381 {
 4382   size_t i;
 4383   for (i = 0; a[i] && b[i] && i < n; a++, b++)
 4384     if (a[0] != b[0])
 4385       { return 1; }
 4386   return 0;
 4387 }
 4388 
 4389 static inline int ctx_strlen (const char *s)
 4390 {
 4391   int len = 0;
 4392   for (; *s; s++) { len++; }
 4393   return len;
 4394 }
 4395 
 4396 static inline char *ctx_strstr (const char *h, const char *n)
 4397 {
 4398   int needle_len = ctx_strlen (n);
 4399   if (n[0]==0)
 4400     { return (char *) h; }
 4401   while (h)
 4402     {
 4403       h = ctx_strchr (h, n[0]);
 4404       if (!h)
 4405         { return NULL; }
 4406       if (!ctx_strncmp (h, n, needle_len) )
 4407         { return (char *) h; }
 4408       h++;
 4409     }
 4410   return NULL;
 4411 }
 4412 
 4413 #endif
 4414 
 4415 #ifdef CTX_IMPLEMENTATION
 4416 #ifndef CTX_DRAWLIST_H
 4417 #define CTX_DRAWLIST_H
 4418 
 4419 static int
 4420 ctx_conts_for_entry (CtxEntry *entry);
 4421 static void
 4422 ctx_iterator_init (CtxIterator      *iterator,
 4423                    CtxRenderstream  *renderstream,
 4424                    int               start_pos,
 4425                    int               flags);
 4426 
 4427 CtxCommand *
 4428 ctx_iterator_next (CtxIterator *iterator);
 4429 
 4430 static void ctx_renderstream_compact (CtxRenderstream *renderstream);
 4431 static void
 4432 ctx_renderstream_resize (CtxRenderstream *renderstream, int desired_size);
 4433 static int
 4434 ctx_renderstream_add_single (CtxRenderstream *renderstream, CtxEntry *entry)
 4435                              ;
 4436 int
 4437 ctx_add_single (Ctx *ctx, void *entry);
 4438 int
 4439 ctx_renderstream_add_entry (CtxRenderstream *renderstream, CtxEntry *entry);
 4440 int ctx_append_renderstream (Ctx *ctx, void *data, int length);
 4441 int ctx_set_renderstream (Ctx *ctx, void *data, int length);
 4442 int ctx_get_renderstream_count (Ctx *ctx);
 4443 const CtxEntry *ctx_get_renderstream (Ctx *ctx);
 4444 int
 4445 ctx_add_data (Ctx *ctx, void *data, int length);
 4446 
 4447 static int ctx_renderstream_add_u32 (CtxRenderstream *renderstream, CtxCode 
 4448                                      code, uint32_t u32[2]);
 4449 int ctx_renderstream_add_data (CtxRenderstream *renderstream, const void 
 4450                                *data, int length);
 4451 
 4452 static CtxEntry
 4453 ctx_void (CtxCode code);
 4454 static CtxEntry
 4455 ctx_f (CtxCode code, float x, float y);
 4456 static CtxEntry
 4457 ctx_u32 (CtxCode code, uint32_t x, uint32_t y);
 4458 #if 0
 4459 static CtxEntry
 4460 ctx_s32 (CtxCode code, int32_t x, int32_t y);
 4461 #endif
 4462 
 4463 static CtxEntry
 4464 ctx_s16 (CtxCode code, int x0, int y0, int x1, int y1);
 4465 static CtxEntry
 4466 ctx_u8 (CtxCode code,
 4467         uint8_t a, uint8_t b, uint8_t c, uint8_t d,
 4468         uint8_t e, uint8_t f, uint8_t g, uint8_t h);
 4469 
 4470 #define CTX_PROCESS_VOID(cmd) do {\
 4471   CtxEntry command = ctx_void (cmd); \
 4472   ctx_process (ctx, &command);}while(0) \
 4473 
 4474 #define CTX_PROCESS_F(cmd, x, y) do {\
 4475   CtxEntry command = ctx_f(cmd, x, y);\
 4476   ctx_process (ctx, &command);}while(0)
 4477 
 4478 #define CTX_PROCESS_F1(cmd, x) do {\
 4479   CtxEntry command = ctx_f(cmd, x, 0);\
 4480   ctx_process (ctx, &command);}while(0)
 4481 
 4482 #define CTX_PROCESS_U32(cmd, x, y) do {\
 4483   CtxEntry command = ctx_u32(cmd, x, y);\
 4484   ctx_process (ctx, &command);}while(0)
 4485 
 4486 #define CTX_PROCESS_U8(cmd, x) do {\
 4487   CtxEntry command = ctx_u8(cmd, x,0,0,0,0,0,0,0);\
 4488   ctx_process (ctx, &command);}while(0)
 4489 
 4490 
 4491 #if CTX_BITPACK_PACKER
 4492 static int
 4493 ctx_last_history (CtxRenderstream *renderstream);
 4494 #endif
 4495 
 4496 #if CTX_BITPACK
 4497 static void
 4498 ctx_renderstream_remove_tiny_curves (CtxRenderstream *renderstream, int 
 4499                                      start_pos);
 4500 #endif
 4501 
 4502 static void
 4503 ctx_renderstream_bitpack (CtxRenderstream *renderstream, int start_pos);
 4504 
 4505 static void
 4506 ctx_renderstream_compact (CtxRenderstream *renderstream);
 4507 static void
 4508 ctx_process_cmd_str (Ctx *ctx, CtxCode code, const char *string, uint32_t 
 4509                      arg0, uint32_t arg1);
 4510 
 4511 #endif
 4512 
 4513 #ifndef __CTX_UTIL_H
 4514 #define __CTX_UTIL_H
 4515 
 4516 inline static float ctx_fast_hypotf (float x, float y)
 4517 {
 4518   if (x < 0) { x = -x; }
 4519   if (y < 0) { y = -y; }
 4520   if (x < y)
 4521     { return 0.96f * y + 0.4f * x; }
 4522   else
 4523     { return 0.96f * x + 0.4f * y; }
 4524 }
 4525 
 4526 static int ctx_str_is_number (const char *str)
 4527 {
 4528   int got_digit = 0;
 4529   for (int i = 0; str[i]; i++)
 4530   {
 4531     if (str[i] >= '0' && str[i] <= '9')
 4532     {
 4533        got_digit ++;
 4534     }
 4535     else if (str[i] == '.')
 4536     {
 4537     }
 4538     else
 4539       return 0;
 4540   }
 4541   if (got_digit)
 4542     return 1;
 4543   return 0;
 4544 }
 4545 
 4546 #if CTX_FONTS_FROM_FILE
 4547 int
 4548 _ctx_file_get_contents (const char     *path,
 4549                         unsigned char **contents,
 4550                         long           *length)
 4551 {
 4552   FILE *file;
 4553   long  size;
 4554   long  remaining;
 4555   char *buffer;
 4556   file = fopen (path, "rb");
 4557   if (!file)
 4558     { return -1; }
 4559   fseek (file, 0, SEEK_END);
 4560   size = remaining = ftell (file);
 4561   if (length)
 4562     { *length =size; }
 4563   rewind (file);
 4564   buffer = (char*)malloc (size + 8);
 4565   if (!buffer)
 4566     {
 4567       fclose (file);
 4568       return -1;
 4569     }
 4570   remaining -= fread (buffer, 1, remaining, file);
 4571   if (remaining)
 4572     {
 4573       fclose (file);
 4574       free (buffer);
 4575       return -1;
 4576     }
 4577   fclose (file);
 4578   *contents = (unsigned char*) buffer;
 4579   buffer[size] = 0;
 4580   return 0;
 4581 }
 4582 #endif
 4583 
 4584 
 4585 #endif
 4586 
 4587 #ifndef __CTX_INTERNAL_H
 4588 #define __CTX_INTERNAL_H
 4589 
 4590 #include <stdlib.h>
 4591 #include <stdio.h>
 4592 #include <unistd.h>
 4593 #include <math.h>
 4594 #include <sys/select.h> 
 4595 
 4596 typedef struct _CtxRasterizer CtxRasterizer;
 4597 typedef struct _CtxGState     CtxGState;
 4598 typedef struct _CtxState      CtxState;
 4599 
 4600 typedef struct _CtxSource CtxSource;
 4601 
 4602 
 4603 #define CTX_VALID_RGBA_U8     (1<<0)
 4604 #define CTX_VALID_RGBA_DEVICE (1<<1)
 4605 #if CTX_ENABLE_CM
 4606 #define CTX_VALID_RGBA        (1<<2)
 4607 #endif
 4608 #if CTX_ENABLE_CMYK
 4609 #define CTX_VALID_CMYKA       (1<<3)
 4610 #define CTX_VALID_DCMYKA      (1<<4)
 4611 #endif
 4612 #define CTX_VALID_GRAYA       (1<<5)
 4613 #define CTX_VALID_GRAYA_U8    (1<<6)
 4614 #define CTX_VALID_LABA        ((1<<7) | CTX_VALID_GRAYA)
 4615 
 4616 //_ctx_target_space (ctx, icc);
 4617 //_ctx_space (ctx);
 4618 
 4619 struct _CtxColor
 4620 {
 4621   uint8_t magic; // for colors used in keydb, set to a non valid start of
 4622                  // string value.
 4623   uint8_t rgba[4];
 4624   uint8_t l_u8;
 4625   uint8_t original; // the bitmask of the originally set color
 4626   uint8_t valid;    // bitmask of which members contain valid
 4627   // values, gets denser populated as more
 4628   // formats are requested from a set color.
 4629   float   device_red;
 4630   float   device_green;
 4631   float   device_blue;
 4632   float   alpha;
 4633   float   l;        // luminance and gray
 4634 #if CTX_ENABLE_LAB  // NYI
 4635   float   a;
 4636   float   b;
 4637 #endif
 4638 #if CTX_ENABLE_CMYK
 4639   float   device_cyan;
 4640   float   device_magenta;
 4641   float   device_yellow;
 4642   float   device_key;
 4643   float   cyan;
 4644   float   magenta;
 4645   float   yellow;
 4646   float   key;
 4647 #endif
 4648 
 4649 #if CTX_ENABLE_CM
 4650 #if CTX_BABL
 4651   const Babl *space;
 4652 #else
 4653   void   *space; // gets copied from state when color is declared
 4654 #endif
 4655   float   red;
 4656   float   green;
 4657   float   blue;
 4658 #endif
 4659 };
 4660 
 4661 typedef struct _CtxGradientStop CtxGradientStop;
 4662 
 4663 struct _CtxGradientStop
 4664 {
 4665   float   pos;
 4666   CtxColor color;
 4667 };
 4668 
 4669 
 4670 enum _CtxSourceType
 4671 {
 4672   CTX_SOURCE_COLOR = 0,
 4673   CTX_SOURCE_IMAGE,
 4674   CTX_SOURCE_LINEAR_GRADIENT,
 4675   CTX_SOURCE_RADIAL_GRADIENT,
 4676 };
 4677 
 4678 typedef enum _CtxSourceType CtxSourceType;
 4679 
 4680 typedef struct _CtxPixelFormatInfo CtxPixelFormatInfo;
 4681 
 4682 
 4683 struct _CtxBuffer
 4684 {
 4685   void               *data;
 4686   int                 width;
 4687   int                 height;
 4688   int                 stride;
 4689   int                 revision; // XXX NYI, number to update when contents 
 4690   change
 4691                                 //
 4692   CtxPixelFormatInfo *format;
 4693   void (*free_func) (void *pixels, void *user_data);
 4694   void               *user_data;
 4695 };
 4696 
 4697 //void _ctx_user_to_device          (CtxState *state, float *x, float *y);
 4698 //void _ctx_user_to_device_distance (CtxState *state, float *x, float *y);
 4699 
 4700 typedef struct _CtxGradient CtxGradient;
 4701 struct _CtxGradient
 4702 {
 4703   CtxGradientStop stops[16];
 4704   int n_stops;
 4705 };
 4706 
 4707 struct _CtxSource
 4708 {
 4709   int type;
 4710   CtxMatrix  transform;
 4711   union
 4712   {
 4713     CtxColor color;
 4714     struct
 4715     {
 4716       uint8_t rgba[4]; // shares data with set color
 4717       uint8_t pad;
 4718       float x0;
 4719       float y0;
 4720       CtxBuffer *buffer;
 4721     } image;
 4722     struct
 4723     {
 4724       float x0;
 4725       float y0;
 4726       float x1;
 4727       float y1;
 4728       float dx;
 4729       float dy;
 4730       float start;
 4731       float end;
 4732       float length;
 4733       float rdelta;
 4734     } linear_gradient;
 4735     struct
 4736     {
 4737       float x0;
 4738       float y0;
 4739       float r0;
 4740       float x1;
 4741       float y1;
 4742       float r1;
 4743       float rdelta;
 4744     } radial_gradient;
 4745   };
 4746 };
 4747 
 4748 struct _CtxGState
 4749 {
 4750   int           keydb_pos;
 4751   int           stringpool_pos;
 4752 
 4753   CtxMatrix     transform;
 4754   //CtxSource   source_stroke;
 4755   CtxSource     source;
 4756   float         global_alpha_f;
 4757   uint8_t       global_alpha_u8;
 4758 
 4759   float         line_width;
 4760   float         miter_limit;
 4761   float         font_size;
 4762 #if CTX_ENABLE_SHADOW_BLUR
 4763   float         shadow_blur;
 4764   float         shadow_offset_x;
 4765   float         shadow_offset_y;
 4766 #endif
 4767   int           clipped:1;
 4768 
 4769   int16_t       clip_min_x;
 4770   int16_t       clip_min_y;
 4771   int16_t       clip_max_x;
 4772   int16_t       clip_max_y;
 4773 
 4774 #if CTX_ENABLE_CM
 4775 #if CTX_BABL
 4776   const Babl   *device_space;
 4777   const Babl   *rgb_space;       
 4778   const Babl   *cmyk_space;
 4779 #else
 4780   void         *device_space;
 4781   void         *rgb_space;       
 4782   void         *cmyk_space;
 4783 #endif
 4784 #endif
 4785   CtxCompositingMode  compositing_mode; // bitfield refs lead to
 4786   CtxBlend                  blend_mode; // non-vectorization
 4787 
 4788   CtxColorModel color_model;
 4789   /* bitfield-pack small state-parts */
 4790   CtxLineCap                  line_cap:2;
 4791   CtxLineJoin                line_join:2;
 4792   CtxFillRule                fill_rule:1;
 4793   unsigned int                    font:6;
 4794   unsigned int                    bold:1;
 4795   unsigned int                  italic:1;
 4796 };
 4797 
 4798 typedef enum
 4799 {
 4800   CTX_TRANSFORMATION_NONE         = 0,
 4801   CTX_TRANSFORMATION_SCREEN_SPACE = 1,
 4802   CTX_TRANSFORMATION_RELATIVE     = 2,
 4803 #if CTX_BITPACK
 4804   CTX_TRANSFORMATION_BITPACK      = 4,
 4805 #endif
 4806   CTX_TRANSFORMATION_STORE_CLEAR  = 16,
 4807 } CtxTransformation;
 4808 
 4809 #define CTX_RENDERSTREAM_DOESNT_OWN_ENTRIES   64
 4810 #define CTX_RENDERSTREAM_EDGE_LIST            128
 4811 #define CTX_RENDERSTREAM_CURRENT_PATH         512
 4812 // BITPACK
 4813 
 4814 struct _CtxRenderstream
 4815 {
 4816   CtxEntry *entries;
 4817   int       count;
 4818   int       size;
 4819   uint32_t  flags;
 4820   int       bitpack_pos;  // stream is bitpacked up to this offset
 4821 };
 4822 
 4823 
 4824 
 4825 #define CTX_MAX_KEYDB 64 // number of entries in keydb
 4826                          // entries are "copy-on-change" between states
 4827 
 4828 // the keydb consists of keys set to floating point values,
 4829 // that might also be interpreted as integers for enums.
 4830 //
 4831 // the hash
 4832 typedef struct _CtxKeyDbEntry CtxKeyDbEntry;
 4833 struct _CtxKeyDbEntry
 4834 {
 4835   uint32_t key;
 4836   float value;
 4837   //union { float f[1]; uint8_t u8[4]; }value;
 4838 };
 4839 
 4840 struct _CtxState
 4841 {
 4842   int           has_moved:1;
 4843   int           has_clipped:1;
 4844   float         x;
 4845   float         y;
 4846   int           min_x;
 4847   int           min_y;
 4848   int           max_x;
 4849   int           max_y;
 4850   CtxKeyDbEntry keydb[CTX_MAX_KEYDB];
 4851   char          stringpool[CTX_STRINGPOOL_SIZE];
 4852 #if CTX_GRADIENTS
 4853   CtxGradient   gradient; /* we keep only one gradient,
 4854                              this goes icky with multiple
 4855                              restores - it should really be part of
 4856                              graphics state..
 4857                              XXX, with the stringpool gradients
 4858                              can be stored there.
 4859                            */
 4860 #endif
 4861   int16_t       gstate_no;
 4862   CtxGState     gstate;
 4863   CtxGState     gstate_stack[CTX_MAX_STATES];//at end, so can be made 
 4864   dynamic
 4865 };
 4866 
 4867 
 4868 typedef struct _CtxFont       CtxFont;
 4869 typedef struct _CtxFontEngine CtxFontEngine;
 4870 
 4871 struct _CtxFontEngine
 4872 {
 4873 #if CTX_FONTS_FROM_FILE
 4874   int   (*load_file)   (const char *name, const char *path);
 4875 #endif
 4876   int   (*load_memory) (const char *name, const void *data, int length);
 4877   int   (*glyph)       (CtxFont *font, Ctx *ctx, uint32_t unichar, int 
 4878          stroke);
 4879   float (*glyph_width) (CtxFont *font, Ctx *ctx, uint32_t unichar);
 4880   float (*glyph_kern)  (CtxFont *font, Ctx *ctx, uint32_t unicharA, 
 4881          uint32_t unicharB);
 4882 };
 4883 
 4884 struct _CtxFont
 4885 {
 4886   CtxFontEngine *engine;
 4887   const char *name;
 4888   int type; // 0 ctx    1 stb    2 monobitmap
 4889   union
 4890   {
 4891     struct
 4892     {
 4893       CtxEntry *data;
 4894       int length;
 4895       int first_kern;
 4896       /* we've got ~110 bytes to fill to cover as
 4897          much data as stbtt_fontinfo */
 4898       //int16_t glyph_pos[26]; // for a..z
 4899       int       glyphs; // number of glyphs
 4900       uint32_t *index;
 4901     } ctx;
 4902 #if CTX_FONT_ENGINE_STB
 4903     struct
 4904     {
 4905       stbtt_fontinfo ttf_info;
 4906       int cache_index;
 4907       int cache_unichar;
 4908     } stb;
 4909 #endif
 4910     struct { int start; int end; int gw; int gh; const uint8_t *data;} 
 4911              monobitmap;
 4912   };
 4913 };
 4914 
 4915 
 4916 enum _CtxIteratorFlag
 4917 {
 4918   CTX_ITERATOR_FLAT           = 0,
 4919   CTX_ITERATOR_EXPAND_BITPACK = 2,
 4920   CTX_ITERATOR_DEFAULTS       = CTX_ITERATOR_EXPAND_BITPACK
 4921 };
 4922 typedef enum _CtxIteratorFlag CtxIteratorFlag;
 4923 
 4924 
 4925 struct
 4926   _CtxIterator
 4927 {
 4928   int              pos;
 4929   int              in_history;
 4930   CtxRenderstream *renderstream;
 4931   int              end_pos;
 4932   int              flags;
 4933 
 4934   int              bitpack_pos;
 4935   int              bitpack_length;     // if non 0 bitpack is active
 4936   CtxEntry         bitpack_command[6]; // the command returned to the
 4937   // user if unpacking is needed.
 4938 };
 4939 #define CTX_MAX_DEVICES 16
 4940 #define CTX_MAX_KEYBINDINGS         256
 4941 
 4942 #if CTX_EVENTS 
 4943 
 4944 // include list implementation - since it already is a header+inline online
 4945 // implementation?
 4946 
 4947 typedef struct CtxItemCb {
 4948   CtxEventType types;
 4949   CtxCb        cb;
 4950   void*        data1;
 4951   void*        data2;
 4952 
 4953   void (*finalize) (void *data1, void *data2, void *finalize_data);
 4954   void  *finalize_data;
 4955 
 4956 } CtxItemCb;
 4957 
 4958 
 4959 #define CTX_MAX_CBS              128
 4960 
 4961 typedef struct CtxItem {
 4962   CtxMatrix inv_matrix;  /* for event coordinate transforms */
 4963 
 4964   /* bounding box */
 4965   float          x0;
 4966   float          y0;
 4967   float          x1;
 4968   float          y1;
 4969 
 4970   void *path;
 4971   double          path_hash;
 4972 
 4973   CtxEventType   types;   /* all cb's ored together */
 4974   CtxItemCb cb[CTX_MAX_CBS];
 4975   int       cb_count;
 4976   int       ref_count;
 4977 } CtxItem;
 4978 
 4979 
 4980 typedef struct _CtxEvents CtxEvents;
 4981 struct _CtxEvents
 4982 {
 4983   int             frozen;
 4984   int             fullscreen;
 4985   CtxList        *grabs; /* could split the grabs per device in the same 
 4986   way,
 4987                             to make dispatch overhead smaller,. probably
 4988                             not much to win though. */
 4989   CtxItem         *prev[CTX_MAX_DEVICES];
 4990   float            pointer_x[CTX_MAX_DEVICES];
 4991   float            pointer_y[CTX_MAX_DEVICES];
 4992   unsigned char    pointer_down[CTX_MAX_DEVICES];
 4993   CtxEvent         drag_event[CTX_MAX_DEVICES];
 4994   CtxList         *idles;
 4995   CtxList         *events; // for ctx_get_event
 4996   int              ctx_get_event_enabled;
 4997   int              idle_id;
 4998   CtxBinding       bindings[CTX_MAX_KEYBINDINGS]; /*< better as list, uses 
 4999   no mem if unused */
 5000   int              n_bindings;
 5001   int              width;
 5002   int              height;
 5003   CtxList         *items;
 5004   CtxModifierState modifier_state;
 5005   int              tap_delay_min;
 5006   int              tap_delay_max;
 5007   int              tap_delay_hold;
 5008   double           tap_hysteresis;
 5009 };
 5010 
 5011 
 5012 #endif
 5013 
 5014 struct
 5015 _Ctx
 5016 {
 5017   CtxImplementation *renderer;
 5018   CtxRenderstream    renderstream;
 5019   CtxState           state;        /**/
 5020   int                transformation;
 5021   CtxBuffer          texture[CTX_MAX_TEXTURES];
 5022   int                rev;
 5023   void              *backend;
 5024 #if CTX_EVENTS 
 5025   CtxEvents          events;
 5026   int                mouse_fd;
 5027   int                mouse_x;
 5028   int                mouse_y;
 5029 #endif
 5030 #if CTX_CURRENT_PATH
 5031   CtxRenderstream    current_path; // possibly transformed coordinates !
 5032   CtxIterator        current_path_iterator;
 5033 #endif
 5034 };
 5035 
 5036 
 5037 void ctx_process (Ctx *ctx, CtxEntry *entry);
 5038 CtxBuffer *ctx_buffer_new (int width, int height,
 5039                            CtxPixelFormat pixel_format);
 5040 void ctx_buffer_free (CtxBuffer *buffer);
 5041 
 5042 void
 5043 ctx_state_gradient_clear_stops (CtxState *state);
 5044 
 5045 
 5046 void ctx_interpret_style         (CtxState *state, CtxEntry *entry, void 
 5047                                   *data);
 5048 void ctx_interpret_transforms    (CtxState *state, CtxEntry *entry, void 
 5049                                   *data);
 5050 void ctx_interpret_pos           (CtxState *state, CtxEntry *entry, void 
 5051                                   *data);
 5052 void ctx_interpret_pos_transform (CtxState *state, CtxEntry *entry, void 
 5053                                   *data);
 5054 
 5055 
 5056 struct _CtxPixelFormatInfo
 5057 {
 5058   CtxPixelFormat pixel_format;
 5059   uint8_t        components:4; /* number of components */
 5060   uint8_t        bpp; /* bits  per pixel - for doing offset computations
 5061                          along with rowstride found elsewhere, if 0 it 
 5062                          indicates
 5063                          1/8  */
 5064   uint8_t        ebpp; /*effective bytes per pixel - for doing offset
 5065                          computations, for formats that get converted, the
 5066                          ebpp of the working space applied */
 5067   uint8_t        dither_red_blue;
 5068   uint8_t        dither_green;
 5069   CtxPixelFormat composite_format;
 5070 
 5071   void         (*to_comp) (CtxRasterizer *r,
 5072                            int x, const void * __restrict__ src, uint8_t * 
 5073                            __restrict__ comp, int count);
 5074   void         (*from_comp) (CtxRasterizer *r,
 5075                              int x, const uint8_t * __restrict__ comp, void 
 5076                              *__restrict__ dst, int count);
 5077   void         (*apply_coverage) (CtxRasterizer *r, uint8_t * __restrict__ 
 5078                 dst, uint8_t * __restrict__ src, int x, uint8_t *coverage,
 5079                           int count);
 5080   void         (*setup) (CtxRasterizer *r);
 5081 };
 5082 
 5083 static void
 5084 _ctx_user_to_device (CtxState *state, float *x, float *y);
 5085 static void
 5086 _ctx_user_to_device_distance (CtxState *state, float *x, float *y);
 5087 static void ctx_state_init (CtxState *state);
 5088 void
 5089 ctx_interpret_pos_bare (CtxState *state, CtxEntry *entry, void *data);
 5090 void
 5091 ctx_renderstream_deinit (CtxRenderstream *renderstream);
 5092 
 5093 CtxPixelFormatInfo *
 5094 ctx_pixel_format_info (CtxPixelFormat format);
 5095 
 5096 
 5097 int ctx_utf8_len (const unsigned char first_byte);
 5098 const char *ctx_utf8_skip (const char *s, int utf8_length);
 5099 int ctx_utf8_strlen (const char *s);
 5100 int
 5101 ctx_unichar_to_utf8 (uint32_t  ch,
 5102                      uint8_t  *dest);
 5103 
 5104 uint32_t
 5105 ctx_utf8_to_unichar (const char *input);
 5106 typedef struct _CtxHasher CtxHasher;
 5107 
 5108 typedef struct CtxEdge
 5109 {
 5110 #if CTX_BLOATY_FAST_PATHS
 5111   uint32_t index;  // provide for more aligned memory accesses.
 5112   uint32_t pad;    //
 5113 #else
 5114   uint16_t index;
 5115 #endif
 5116   int32_t  x;     /* the center-line intersection      */
 5117   int32_t  dx;
 5118 } CtxEdge;
 5119 
 5120 typedef void (*CtxFragment) (CtxRasterizer *rasterizer, float x, float y, 
 5121               void *out);
 5122 
 5123 #define CTX_MAX_GAUSSIAN_KERNEL_DIM    512
 5124 
 5125 struct _CtxRasterizer
 5126 {
 5127   CtxImplementation vfuncs;
 5128   /* these should be initialized and used as the bounds for rendering into 
 5129   the
 5130      buffer as well XXX: not yet in use, and when in use will only be
 5131      correct for axis aligned clips - proper rasterization of a clipping 
 5132      path
 5133      would be yet another refinement on top.
 5134    */
 5135 
 5136 #if CTX_ENABLE_SHADOW_BLUR
 5137   float      kernel[CTX_MAX_GAUSSIAN_KERNEL_DIM];
 5138 #endif
 5139 
 5140   int        aa;          // level of vertical aa
 5141   int        force_aa;    // force full AA
 5142   int        active_edges;
 5143 #if CTX_RASTERIZER_FORCE_AA==0
 5144   int        pending_edges;   // this-scanline
 5145   int        ending_edges;    // count of edges ending this scanline
 5146 #endif
 5147   int        edge_pos;         // where we're at in iterating all edges
 5148   CtxEdge    edges[CTX_MAX_EDGES];
 5149 
 5150   int        scanline;
 5151   int        scan_min;
 5152   int        scan_max;
 5153   int        col_min;
 5154   int        col_max;
 5155 
 5156 #if CTX_BRAILLE_TEXT
 5157   CtxList   *glyphs;
 5158 #endif
 5159 
 5160   CtxRenderstream edge_list;
 5161 
 5162   CtxState  *state;
 5163   Ctx       *ctx;
 5164   Ctx       *texture_source; /* normally same as ctx */
 5165 
 5166   void      *buf;
 5167 
 5168 #if CTX_COMPOSITING_GROUPS
 5169   void      *saved_buf; // when group redirected
 5170   CtxBuffer *group[CTX_GROUP_MAX];
 5171 #endif
 5172 
 5173   float      x;  // < redundant? use state instead?
 5174   float      y;
 5175 
 5176   float      first_x;
 5177   float      first_y;
 5178   int8_t     needs_aa; // count of how many edges implies antialiasing
 5179   int        has_shape:2;
 5180   int        has_prev:2;
 5181   int        preserve:1;
 5182   int        uses_transforms:1;
 5183 #if CTX_BRAILLE_TEXT
 5184   int        term_glyphs:1; // store appropriate glyphs for redisplay
 5185 #endif
 5186 
 5187   int16_t    blit_x;
 5188   int16_t    blit_y;
 5189   int16_t    blit_width;
 5190   int16_t    blit_height;
 5191   int16_t    blit_stride;
 5192 
 5193   CtxPixelFormatInfo *format;
 5194 
 5195 #if CTX_ENABLE_SHADOW_BLUR
 5196   int in_shadow;
 5197 #endif
 5198   int in_text;
 5199   int shadow_x;
 5200   int shadow_y;
 5201 
 5202   CtxFragment         fragment;
 5203   uint8_t             color[4*5];
 5204 
 5205 #define CTX_COMPOSITE_ARGUMENTS CtxRasterizer *rasterizer, uint8_t * 
 5206 __restrict__ dst, uint8_t * __restrict__ src, int x0, uint8_t * 
 5207 __restrict__ coverage, int count
 5208 
 5209   void (*comp_op)(CTX_COMPOSITE_ARGUMENTS);
 5210 #if CTX_ENABLE_CLIP
 5211   CtxBuffer *clip_buffer;
 5212 #endif
 5213 
 5214   uint8_t *clip_mask;
 5215 };
 5216 
 5217 #if CTX_RASTERIZER
 5218 void ctx_rasterizer_deinit (CtxRasterizer *rasterizer);
 5219 #endif
 5220 
 5221 #if CTX_EVENTS
 5222 extern int ctx_native_events;
 5223 
 5224 #if CTX_SDL
 5225 extern int ctx_sdl_events;
 5226 int ctx_sdl_consume_events (Ctx *ctx);
 5227 #endif
 5228 
 5229 #if CTX_FB
 5230 extern int ctx_fb_events;
 5231 int ctx_fb_consume_events (Ctx *ctx);
 5232 #endif
 5233 
 5234 
 5235 int ctx_nct_consume_events (Ctx *ctx);
 5236 int ctx_ctx_consume_events (Ctx *ctx);
 5237 
 5238 #endif
 5239 
 5240 enum {
 5241   NC_MOUSE_NONE  = 0,
 5242   NC_MOUSE_PRESS = 1,  /* "mouse-pressed", "mouse-released" */
 5243   NC_MOUSE_DRAG  = 2,  /* + "mouse-drag"   (motion with pressed button) */
 5244   NC_MOUSE_ALL   = 3   /* + "mouse-motion" (also delivered for release) */
 5245 };
 5246 void _ctx_mouse (Ctx *term, int mode);
 5247 void nc_at_exit (void);
 5248 
 5249 int ctx_terminal_width  (void);
 5250 int ctx_terminal_height (void);
 5251 int ctx_terminal_cols   (void);
 5252 int ctx_terminal_rows   (void);
 5253 
 5254 int ctx_nct_consume_events (Ctx *ctx);
 5255 
 5256 typedef struct _CtxCtx CtxCtx;
 5257 struct _CtxCtx
 5258 {
 5259    void (*render) (void *ctxctx, CtxCommand *command);
 5260    void (*flush)  (void *ctxctx);
 5261    void (*free)   (void *ctxctx);
 5262    Ctx *ctx;
 5263    int  width;
 5264    int  height;
 5265    int  cols;
 5266    int  rows;
 5267    int  was_down;
 5268 };
 5269 
 5270 // XXX the common members of sdl and fbdev
 5271 typedef struct _CtxThreaded CtxThreaded;
 5272 struct _CtxThreaded
 5273 {
 5274    void (*render) (void *fb, CtxCommand *command);
 5275    void (*flush)  (void *fb);
 5276    void (*free)   (void *fb);
 5277    Ctx          *ctx;
 5278    Ctx          *ctx_copy;
 5279    int           width;
 5280    int           height;
 5281    int           cols;
 5282    int           rows;
 5283    int           was_down;
 5284    Ctx          *host[CTX_MAX_THREADS];
 5285    CtxAntialias  antialias;
 5286 };
 5287 
 5288 
 5289 extern int _ctx_threads;
 5290 extern int _ctx_enable_hash_cache;
 5291 void
 5292 ctx_set (Ctx *ctx, uint32_t key_hash, const char *string, int len);
 5293 const char *
 5294 ctx_get (Ctx *ctx,