/* * Add a range of contiguous one-to-one mappings (ie 1..5 maps to 21..25) */ void pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, int low, int high, int offset) { add_range(ctx, cmap, low, high, high - low == 0 ? PDF_CMAP_SINGLE : PDF_CMAP_RANGE, offset); }
MRESULT EXPENTRY main_proc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { if( msg == WM_CREATE ) { PCREATESTRUCT pcreate; pcreate = ( CREATESTRUCT * ) mp2; Draw_area.xRight = pcreate->x + pcreate->cx; Draw_area.yTop = pcreate->y + pcreate->cy; Draw_area.yBottom = pcreate->y; Draw_area.xLeft = pcreate->x; // WinQueryWindowRect( hwnd, &Draw_area ); } else if( msg == WM_COMMAND || ( msg == WM_CONTROL && SHORT2FROMMP( mp1 ) != BN_PAINT ) ) { switch( SHORT1FROMMP( mp1 ) ) { case IDM_EXIT: new_display(); WinPostMsg( hwnd, WM_QUIT, 0L, 0L ); return( NULL ); case IDM_ROTATE_LEFT: new_display(); add_wrap( THREE_D_HORZ_ANGLE, -15, 0, 360 ); break; case IDM_ROTATE_RIGHT: new_display(); add_wrap( THREE_D_HORZ_ANGLE, 15, 0, 360 ); break; case IDM_ROTATE_UP: new_display(); add_range( THREE_D_VERT_ANGLE, 5, -90, 90 ); break; case IDM_ROTATE_DOWN: new_display(); add_range( THREE_D_VERT_ANGLE, -5, -90, 90 ); break; case IDM_MOVE_IN: new_display(); add_range(THREE_D_ZOOM, 10, 5, 200 ); break; case IDM_MOVE_OUT: new_display(); add_range( THREE_D_ZOOM, -10, 5, 200 ); break; case IDM_MORE_PERSPECTIVE: new_display(); add_range( THREE_D_PERSPECTIVE, 10, 5, 200 ); break; case IDM_LESS_PERSPECTIVE: new_display(); add_range( THREE_D_PERSPECTIVE, -10, 5, 200 ); break; case IDM_MORE_CONTRAST: new_display(); add_range( THREE_D_CONTRAST, 10, 0, 100 ); break; case IDM_LESS_CONTRAST: new_display(); add_range( THREE_D_CONTRAST, -10, 0, 100 ); break; case IDM_MORE_BRIGHTNESS: new_display(); add_range( THREE_D_BRIGHTNESS, 10, 0, 100 ); break; case IDM_LESS_BRIGHTNESS: new_display(); add_range( THREE_D_BRIGHTNESS, -10, 0, 100 ); break; case IDM_LIGHT_HORZ_LEFT: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 1 ); break; case IDM_LIGHT_HORZ_MIDDLE: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 2 ); break; case IDM_LIGHT_HORZ_RIGHT: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 3 ); break; case IDM_LIGHT_VERT_TOP: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_VERT, 1 ); break; case IDM_LIGHT_VERT_MIDDLE: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_VERT, 2 ); break; case IDM_LIGHT_VERT_BOTTOM: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_VERT, 3 ); break; case IDM_LIGHT_DEPTH_FRONT: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 1 ); break; case IDM_LIGHT_DEPTH_MIDDLE: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 2 ); break; case IDM_LIGHT_DEPTH_BACK: new_display(); three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 3 ); break; default: ; } WinInvalidateRect( hwnd, &Draw_area, SHORT1FROMMP( mp1 ) >= IDM_FIRST_REQUIRING_CLEAR ); } else if( msg == WM_DESTROY ) { WinPostMsg( hwnd, WM_QUIT, 0L, 0L ); return( 0 ); } else if( msg == WM_PAINT ) { draw_stuff( hwnd ); if( Auto_run ) { if( Auto_run == 5 ) { WinPostMsg( hwnd, WM_QUIT, 0L, 0L ); } else { long count; int will_be_one; will_be_one = 1; for(count = 0; count < 1000000; ++ count ) will_be_one ^= 1; Auto_run += will_be_one; WinPostMsg( hwnd, WM_COMMAND, MPFROMSHORT( IDM_ROTATE_LEFT ), 0L ); } } return( 0 ); } else if( msg == WM_SIZE ) { WinQueryWindowRect( hwnd, &Draw_area ); Draw_area.yTop -= Button_height; WinInvalidateRect( hwnd, NULL, TRUE ); return( 0 ); } else if( msg == WM_MEASUREITEM ) { return( (MRESULT) measure_button( hwnd, mp1, mp2 ) ); } else if( msg == WM_CONTROL && SHORT2FROMMP( mp1 ) == BN_PAINT ) { draw_button( mp1, mp2 ); return( (MRESULT) TRUE ); } return( (MRESULT) WinDefWindowProc( hwnd, msg, mp1, mp2 ) ); }
/* * This routine assumes that the line is a valid Unicode Character Database * entry. */ static void read_cdata(FILE *in) { ac_uint4 i, lineno, skip, code, ccl_code; short wnum, neg, number[2], compat; char line[512], *s, *e; lineno = skip = 0; while (fgets(line, sizeof(line), in)) { if( (s=strchr(line, '\n')) ) *s = '\0'; lineno++; /* * Skip blank lines and lines that start with a '#'. */ if (line[0] == 0 || line[0] == '#') continue; /* * If lines need to be skipped, do it here. */ if (skip) { skip--; continue; } /* * Collect the code. The code can be up to 6 hex digits in length to * allow surrogates to be specified. */ for (s = line, i = code = 0; *s != ';' && i < 6; i++, s++) { code <<= 4; if (*s >= '0' && *s <= '9') code += *s - '0'; else if (*s >= 'A' && *s <= 'F') code += (*s - 'A') + 10; else if (*s >= 'a' && *s <= 'f') code += (*s - 'a') + 10; } /* * Handle the following special cases: * 1. 4E00-9FA5 CJK Ideographs. * 2. AC00-D7A3 Hangul Syllables. * 3. D800-DFFF Surrogates. * 4. E000-F8FF Private Use Area. * 5. F900-FA2D Han compatibility. * ...Plus additional ranges in newer Unicode versions... */ switch (code) { case 0x3400: /* CJK Ideograph Extension A */ add_range(0x3400, 0x4db5, "Lo", "L"); add_range(0x3400, 0x4db5, "Cp", 0); skip = 1; break; case 0x4e00: /* * The Han ideographs. */ add_range(0x4e00, 0x9fff, "Lo", "L"); /* * Add the characters to the defined category. */ add_range(0x4e00, 0x9fa5, "Cp", 0); skip = 1; break; case 0xac00: /* * The Hangul syllables. */ add_range(0xac00, 0xd7a3, "Lo", "L"); /* * Add the characters to the defined category. */ add_range(0xac00, 0xd7a3, "Cp", 0); skip = 1; break; case 0xd800: /* * Make a range of all surrogates and assume some default * properties. */ add_range(0x010000, 0x10ffff, "Cs", "L"); skip = 5; break; case 0xe000: /* * The Private Use area. Add with a default set of properties. */ add_range(0xe000, 0xf8ff, "Co", "L"); skip = 1; break; case 0xf900: /* * The CJK compatibility area. */ add_range(0xf900, 0xfaff, "Lo", "L"); /* * Add the characters to the defined category. */ add_range(0xf900, 0xfaff, "Cp", 0); skip = 1; break; case 0x20000: /* CJK Ideograph Extension B */ add_range(0x20000, 0x2a6d6, "Lo", "L"); add_range(0x20000, 0x2a6d6, "Cp", 0); skip = 1; break; case 0xf0000: /* Plane 15 private use */ add_range(0xf0000, 0xffffd, "Co", "L"); skip = 1; break; case 0x100000: /* Plane 16 private use */ add_range(0x100000, 0x10fffd, "Co", "L"); skip = 1; break; } if (skip) continue; /* * Add the code to the defined category. */ ordered_range_insert(code, "Cp", 2); /* * Locate the first character property field. */ for (i = 0; *s != 0 && i < 2; s++) { if (*s == ';') i++; } for (e = s; *e && *e != ';'; e++) ; ordered_range_insert(code, s, e - s); /* * Locate the combining class code. */ for (s = e; *s != 0 && i < 3; s++) { if (*s == ';') i++; } /* * Convert the combining class code from decimal. */ for (ccl_code = 0, e = s; *e && *e != ';'; e++) ccl_code = (ccl_code * 10) + (*e - '0'); /* * Add the code if it not 0. */ if (ccl_code != 0) ordered_ccl_insert(code, ccl_code); /* * Locate the second character property field. */ for (s = e; *s != 0 && i < 4; s++) { if (*s == ';') i++; } for (e = s; *e && *e != ';'; e++) ; ordered_range_insert(code, s, e - s); /* * Check for a decomposition. */ s = ++e; if (*s != ';') { compat = *s == '<'; if (compat) { /* * Skip compatibility formatting tag. */ while (*s++ != '>'); } /* * Collect the codes of the decomposition. */ for (dectmp_size = 0; *s != ';'; ) { /* * Skip all leading non-hex digits. */ while (!ishdigit(*s)) s++; for (dectmp[dectmp_size] = 0; ishdigit(*s); s++) { dectmp[dectmp_size] <<= 4; if (*s >= '0' && *s <= '9') dectmp[dectmp_size] += *s - '0'; else if (*s >= 'A' && *s <= 'F') dectmp[dectmp_size] += (*s - 'A') + 10; else if (*s >= 'a' && *s <= 'f') dectmp[dectmp_size] += (*s - 'a') + 10; } dectmp_size++; } /* * If there are any codes in the temporary decomposition array, * then add the character with its decomposition. */ if (dectmp_size > 0) { if (!compat) { add_decomp(code, 0); } add_decomp(code, 1); } } /* * Skip to the number field. */ for (i = 0; i < 3 && *s; s++) { if (*s == ';') i++; } /* * Scan the number in. */ number[0] = number[1] = 0; for (e = s, neg = wnum = 0; *e && *e != ';'; e++) { if (*e == '-') { neg = 1; continue; } if (*e == '/') { /* * Move the the denominator of the fraction. */ if (neg) number[wnum] *= -1; neg = 0; e++; wnum++; } number[wnum] = (number[wnum] * 10) + (*e - '0'); } if (e > s) { /* * Adjust the denominator in case of integers and add the number. */ if (wnum == 0) number[1] = 1; add_number(code, number[0], number[1]); } /* * Skip to the start of the possible case mappings. */ for (s = e, i = 0; i < 4 && *s; s++) { if (*s == ';') i++; } /* * Collect the case mappings. */ cases[0] = cases[1] = cases[2] = 0; for (i = 0; i < 3; i++) { while (ishdigit(*s)) { cases[i] <<= 4; if (*s >= '0' && *s <= '9') cases[i] += *s - '0'; else if (*s >= 'A' && *s <= 'F') cases[i] += (*s - 'A') + 10; else if (*s >= 'a' && *s <= 'f') cases[i] += (*s - 'a') + 10; s++; } if (*s == ';') s++; } if (cases[0] && cases[1]) /* * Add the upper and lower mappings for a title case character. */ add_title(code); else if (cases[1]) /* * Add the lower and title case mappings for the upper case * character. */ add_upper(code); else if (cases[0]) /* * Add the upper and title case mappings for the lower case * character. */ add_lower(code); } }
LRESULT CALLBACK main_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { WORD cmd; switch( msg ) { case WM_CREATE: { GetClientRect( hwnd, &Draw_area ); make_buttons( hwnd ); break; } case WM_COMMAND: cmd = LOWORD( wparam ); switch( LOWORD( cmd ) ) { case IDM_EXIT: PostQuitMessage( 0 ); return( FALSE ); case IDM_ROTATE_LEFT: add_wrap( THREE_D_HORZ_ANGLE, -15, 0, 360 ); break; case IDM_ROTATE_RIGHT: add_wrap( THREE_D_HORZ_ANGLE, 15, 0, 360 ); break; case IDM_ROTATE_UP: add_range( THREE_D_VERT_ANGLE, 5, -90, 90 ); break; case IDM_ROTATE_DOWN: add_range( THREE_D_VERT_ANGLE, -5, -90, 90 ); break; case IDM_MOVE_IN: add_range(THREE_D_ZOOM, 10, 5, 200 ); break; case IDM_MOVE_OUT: add_range( THREE_D_ZOOM, -10, 5, 200 ); break; case IDM_MORE_PERSPECTIVE: add_range( THREE_D_PERSPECTIVE, 10, 5, 200 ); break; case IDM_LESS_PERSPECTIVE: add_range( THREE_D_PERSPECTIVE, -10, 5, 200 ); break; case IDM_MORE_CONTRAST: add_range( THREE_D_CONTRAST, 10, 0, 100 ); break; case IDM_LESS_CONTRAST: add_range( THREE_D_CONTRAST, -10, 0, 100 ); break; case IDM_MORE_BRIGHTNESS: add_range( THREE_D_BRIGHTNESS, 10, 0, 100 ); break; case IDM_LESS_BRIGHTNESS: add_range( THREE_D_BRIGHTNESS, -10, 0, 100 ); break; case IDM_LIGHT_HORZ_LEFT: three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 1 ); break; case IDM_LIGHT_HORZ_MIDDLE: three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 2 ); break; case IDM_LIGHT_HORZ_RIGHT: three_d_set( hThree_d, THREE_D_LIGHT_HORZ, 3 ); break; case IDM_LIGHT_VERT_TOP: three_d_set( hThree_d, THREE_D_LIGHT_VERT, 1 ); break; case IDM_LIGHT_VERT_MIDDLE: three_d_set( hThree_d, THREE_D_LIGHT_VERT, 2 ); break; case IDM_LIGHT_VERT_BOTTOM: three_d_set( hThree_d, THREE_D_LIGHT_VERT, 3 ); break; case IDM_LIGHT_DEPTH_FRONT: three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 1 ); break; case IDM_LIGHT_DEPTH_MIDDLE: three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 2 ); break; case IDM_LIGHT_DEPTH_BACK: three_d_set( hThree_d, THREE_D_LIGHT_DEPTH, 3 ); break; default: ; } InvalidateRect( hwnd, &Draw_area, cmd >= IDM_FIRST_REQUIRING_CLEAR ); break; case WM_DESTROY: PostQuitMessage( 0 ); return( FALSE ); case WM_PAINT: draw_stuff( hwnd ); if( Auto_run ) { if( Auto_run == 5 ) { PostQuitMessage( 0 ); } else { long count; int will_be_one; will_be_one = 1; for(count = 0; count < 1000000; ++ count ) will_be_one ^= 1; Auto_run += will_be_one; PostMessage( hwnd, WM_COMMAND, GET_WM_COMMAND_MPS( IDM_ROTATE_LEFT, 0, 0 ) ); } } return( FALSE ); case WM_SIZE: if( wparam != SIZEICONIC ) { int old_left = Draw_area.left; GetClientRect( hwnd, &Draw_area ); Draw_area.left = old_left; InvalidateRect( hwnd, NULL, TRUE ); return( FALSE ); } break; case WM_MEASUREITEM: measure_button( hwnd, wparam, _lparam_pointer( lparam ) ); return( TRUE ); case WM_DRAWITEM: draw_button( wparam, _lparam_pointer( lparam ) ); return( TRUE ); } return( DefWindowProc( hwnd, msg, wparam, lparam ) ); }