📄 gview.c
字号:
if (vertical) { if ( !option_show_vert_hints ) return; v.x = hint->cur_pos; v.y = 0; nv_vector_transform( &v, &size_transform ); x1 = (int)(v.x + 0.5); v.x = hint->cur_pos + hint->cur_len; v.y = 0; nv_vector_transform( &v, &size_transform ); x2 = (int)(v.x + 0.5); nv_pixmap_fill_rect( target, x1, 0, 1, target->height, psh2_hint_is_ghost(hint) ? GHOST_HINT_COLOR : STEM_HINT_COLOR ); if ( psh2_hint_is_ghost(hint) ) { x1 --; x2 = x1 + 2; } else nv_pixmap_fill_rect( target, x2, 0, 1, target->height, psh2_hint_is_ghost(hint) ? GHOST_HINT_COLOR : STEM_HINT_COLOR ); nv_pixmap_fill_rect( target, x1, pshint_cpos, x2+1-x1, 1, STEM_JOIN_COLOR ); } else { if (!option_show_horz_hints) return; v.y = hint->cur_pos; v.x = 0; nv_vector_transform( &v, &size_transform ); x1 = (int)(v.y + 0.5); v.y = hint->cur_pos + hint->cur_len; v.x = 0; nv_vector_transform( &v, &size_transform ); x2 = (int)(v.y + 0.5); nv_pixmap_fill_rect( target, 0, x1, target->width, 1, psh2_hint_is_ghost(hint) ? GHOST_HINT_COLOR : STEM_HINT_COLOR ); if ( psh2_hint_is_ghost(hint) ) { x1 --; x2 = x1 + 2; } else nv_pixmap_fill_rect( target, 0, x2, target->width, 1, psh2_hint_is_ghost(hint) ? GHOST_HINT_COLOR : STEM_HINT_COLOR ); nv_pixmap_fill_rect( target, pshint_cpos, x2, 1, x1+1-x2, STEM_JOIN_COLOR ); }#if 0 printf( "[%7.3f %7.3f] %c\n", hint->cur_pos/64.0, (hint->cur_pos+hint->cur_len)/64.0, vertical ? 'v' : 'h' );#endif pshint_cpos += 10;}static voidps2_draw_control_points( void ){ if ( ps2_debug_glyph ) { PSH2_Glyph glyph = ps2_debug_glyph; PSH2_Point point = glyph->points; FT_UInt count = glyph->num_points; NV_Transform transform, *trans = &transform; NV_Path vert_rect; NV_Path horz_rect; NV_Path dot, circle; for ( ; count > 0; count--, point++ ) { NV_Vector vec; vec.x = point->cur_x; vec.y = point->cur_y; nv_vector_transform( &vec, &size_transform ); nv_transform_set_translate( trans, vec.x, vec.y ); if ( option_show_smooth && !psh2_point_is_smooth(point) ) { nv_painter_set_color( painter, SMOOTH_COLOR, 256 ); nv_painter_fill_path( painter, trans, 0, symbol_circle ); } if (option_show_horz_hints) { if ( point->flags_y & PSH2_POINT_STRONG ) { nv_painter_set_color( painter, STRONG_COLOR, 256 ); nv_painter_fill_path( painter, trans, 0, symbol_rect_h ); } } if (option_show_vert_hints) { if ( point->flags_x & PSH2_POINT_STRONG ) { nv_painter_set_color( painter, STRONG_COLOR, 256 ); nv_painter_fill_path( painter, trans, 0, symbol_rect_v ); } } } }}static voidps_print_hints( void ){ if ( ps_debug_hints ) { FT_Int dimension; PSH_Dimension dim; for ( dimension = 1; dimension >= 0; dimension-- ) { PS_Dimension dim = &ps_debug_hints->dimension[ dimension ]; PS_Mask mask = dim->masks.masks; FT_UInt count = dim->masks.num_masks; printf( "%s hints -------------------------\n", dimension ? "vertical" : "horizontal" ); for ( ; count > 0; count--, mask++ ) { FT_UInt index; printf( "mask -> %d\n", mask->end_point ); for ( index = 0; index < mask->num_bits; index++ ) { if ( mask->bytes[ index >> 3 ] & (0x80 >> (index & 7)) ) { PS_Hint hint = dim->hints.hints + index; printf( "%c [%3d %3d (%4d)]\n", dimension ? "v" : "h", hint->pos, hint->pos + hint->len, hint->len ); } } } } }} /************************************************************************/ /************************************************************************/ /***** *****/ /***** AUTOHINTER DRAWING ROUTINES *****/ /***** *****/ /************************************************************************/ /************************************************************************/static NV_Pathah_link_path( NV_Vector* p1, NV_Vector* p4, NV_Bool vertical ){ NV_PathWriter writer; NV_Vector p2, p3; NV_Path path, stroke; if ( vertical ) { p2.x = p4->x; p2.y = p1->y; p3.x = p1->x; p3.y = p4->y; } else { p2.x = p1->x; p2.y = p4->y; p3.x = p4->x; p3.y = p1->y; } nv_path_writer_new( renderer, &writer ); nv_path_writer_moveto( writer, p1 ); nv_path_writer_cubicto( writer, &p2, &p3, p4 ); nv_path_writer_end( writer ); path = nv_path_writer_get_path( writer ); nv_path_writer_destroy( writer ); nv_path_stroke( path, 1., nv_path_linecap_butt, nv_path_linejoin_round, 1., &stroke ); nv_path_destroy( path ); return stroke;}static voidah_draw_smooth_points( void ){ if ( ah_debug_hinter && option_show_smooth ) { AH_Outline* glyph = ah_debug_hinter->glyph; FT_UInt count = glyph->num_points; AH_Point* point = glyph->points; nv_painter_set_color( painter, SMOOTH_COLOR, 256 ); for ( ; count > 0; count--, point++ ) { if ( !( point->flags & ah_flag_weak_interpolation ) ) { NV_Transform transform, *trans = &transform; NV_Vector vec; vec.x = point->x - ah_debug_hinter->pp1.x; vec.y = point->y; nv_vector_transform( &vec, &size_transform ); nv_transform_set_translate( &transform, vec.x, vec.y ); nv_painter_fill_path( painter, trans, 0, symbol_circle ); } } }}static voidah_draw_edges( void ){ if ( ah_debug_hinter ) { AH_Outline* glyph = ah_debug_hinter->glyph; FT_UInt count; AH_Edge* edge; FT_Pos pp1 = ah_debug_hinter->pp1.x; nv_painter_set_color( painter, EDGE_COLOR, 256 ); if ( option_show_edges ) { /* draw verticla edges */ if ( option_show_vert_hints ) { count = glyph->num_vedges; edge = glyph->vert_edges; for ( ; count > 0; count--, edge++ ) { NV_Vector vec; NV_Pos x; vec.x = edge->pos - pp1; vec.y = 0; nv_vector_transform( &vec, &size_transform ); x = (FT_Pos)( vec.x + 0.5 ); nv_pixmap_fill_rect( target, x, 0, 1, target->height, EDGE_COLOR ); } } /* draw horizontal edges */ if ( option_show_horz_hints ) { count = glyph->num_hedges; edge = glyph->horz_edges; for ( ; count > 0; count--, edge++ ) { NV_Vector vec; NV_Pos x; vec.x = 0; vec.y = edge->pos; nv_vector_transform( &vec, &size_transform ); x = (FT_Pos)( vec.y + 0.5 ); nv_pixmap_fill_rect( target, 0, x, target->width, 1, EDGE_COLOR ); } } } if ( option_show_segments ) { /* draw vertical segments */ if ( option_show_vert_hints ) { AH_Segment* seg = glyph->vert_segments; FT_UInt count = glyph->num_vsegments; for ( ; count > 0; count--, seg++ ) { AH_Point *first, *last; NV_Vector v1, v2; NV_Pos y1, y2, x; first = seg->first; last = seg->last; v1.x = v2.x = first->x - pp1; if ( first->y <= last->y ) { v1.y = first->y; v2.y = last->y; } else { v1.y = last->y; v2.y = first->y; } nv_vector_transform( &v1, &size_transform ); nv_vector_transform( &v2, &size_transform ); y1 = (NV_Pos)( v1.y + 0.5 ); y2 = (NV_Pos)( v2.y + 0.5 ); x = (NV_Pos)( v1.x + 0.5 ); nv_pixmap_fill_rect( target, x-1, y2, 3, ABS(y1-y2)+1, SEGMENT_COLOR ); } } /* draw horizontal segments */ if ( option_show_horz_hints ) { AH_Segment* seg = glyph->horz_segments; FT_UInt count = glyph->num_hsegments; for ( ; count > 0; count--, seg++ ) { AH_Point *first, *last; NV_Vector v1, v2; NV_Pos y1, y2, x; first = seg->first; last = seg->last; v1.y = v2.y = first->y; if ( first->x <= last->x ) { v1.x = first->x - pp1; v2.x = last->x - pp1; } else { v1.x = last->x - pp1; v2.x = first->x - pp1; } nv_vector_transform( &v1, &size_transform ); nv_vector_transform( &v2, &size_transform ); y1 = (NV_Pos)( v1.x + 0.5 ); y2 = (NV_Pos)( v2.x + 0.5 ); x = (NV_Pos)( v1.y + 0.5 ); nv_pixmap_fill_rect( target, y1, x-1, ABS(y1-y2)+1, 3, SEGMENT_COLOR ); } } if ( option_show_vert_hints && option_show_links ) { AH_Segment* seg = glyph->vert_segments; FT_UInt count = glyph->num_vsegments; for ( ; count > 0; count--, seg++ ) { AH_Segment* seg2 = NULL; NV_Path link; NV_Vector v1, v2; if ( seg->link ) { if ( seg->link > seg ) seg2 = seg->link; } else if ( seg->serif ) seg2 = seg->serif; if ( seg2 ) { v1.x = seg->first->x - pp1; v2.x = seg2->first->x - pp1; v1.y = (seg->first->y + seg->last->y)/2; v2.y = (seg2->first->y + seg2->last->y)/2; link = ah_link_path( &v1, &v2, 1 ); nv_painter_set_color( painter, seg->serif ? SERIF_LINK_COLOR : LINK_COLOR, 256 ); nv_painter_fill_path( painter, &size_transform, 0, link ); nv_path_destroy( link ); } } } if ( option_show_horz_hints && option_show_links ) { AH_Segment* seg = glyph->horz_segments; FT_UInt count = glyph->num_hsegments; for ( ; count > 0; count--, seg++ ) { AH_Segment* seg2 = NULL; NV_Path link; NV_Vector v1, v2; if ( seg->link ) { if ( seg->link > seg ) seg2 = seg->link; } else if ( seg->serif ) seg2 = seg->serif; if ( seg2 ) { v1.y = seg->first->y; v2.y = seg2->first->y; v1.x = (seg->first->x + seg->last->x)/2 - pp1; v2.x = (seg2->first->x + seg2->last->x)/2 - pp1; link = ah_link_path( &v1, &v2, 0 ); nv_painter_set_color( painter, seg->serif ? SERIF_LINK_COLOR : LINK_COLOR, 256 ); nv_painter_fill_path( painter, &size_transform, 0, link ); nv_path_destroy( link ); } } } } }} /************************************************************************/ /************************************************************************/ /***** *****/ /***** MAIN LOOP(S) *****/ /***** *****/ /************************************************************************/ /************************************************************************/static voiddraw_glyph( int glyph_index ){ NV_Path path; pshint_vertical = -1; ps1_debug_hint_func = option_show_ps_hints ? draw_ps1_hint : 0; ps2_debug_hint_func = option_show_ps_hints ? draw_ps2_hint : 0; ah_debug_hinter = NULL; error = FT_Load_Glyph( face, glyph_index, option_hinting ? FT_LOAD_NO_BITMAP : FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING ); if (error) Panic( "could not load glyph" ); if ( face->glyph->format != ft_glyph_format_outline ) Panic( "could not load glyph outline" ); error = nv_path_new_from_outline( renderer, (NV_Outline*)&face->glyph->outline, &size_transform, &path ); if (error) Panic( "could not create glyph path" ); /* trac
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -