| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#include <fontforge-config.h> |
| 30 |
|
| 31 |
#include "autotrace.h" |
| 32 |
#include "autowidth.h" |
| 33 |
#include "bitmapchar.h" |
| 34 |
#include "bvedit.h" |
| 35 |
#include "cvundoes.h" |
| 36 |
#include "fontforgeui.h" |
| 37 |
#include "fvcomposite.h" |
| 38 |
#include "fvfonts.h" |
| 39 |
#include "gfile.h" |
| 40 |
#include "gkeysym.h" |
| 41 |
#include "gresedit.h" |
| 42 |
#include "lookups.h" |
| 43 |
#include "mm.h" |
| 44 |
#include "splinefill.h" |
| 45 |
#include "splineoverlap.h" |
| 46 |
#include "splineutil.h" |
| 47 |
#include "splineutil2.h" |
| 48 |
#include "tottf.h" |
| 49 |
#include "tottfgpos.h" |
| 50 |
#include "ustring.h" |
| 51 |
#include "utype.h" |
| 52 |
#include "wordlistparser.h" |
| 53 |
#include "shapers/shaper_shim.hpp" |
| 54 |
#include "mv_mids.h" |
| 55 |
|
| 56 |
#include <math.h> |
| 57 |
|
| 58 |
extern char* SFDCreateUndoForLookup( SplineFont *sf, int lookup_type ) ; |
| 59 |
|
| 60 |
|
| 61 |
int mv_width = 800, mv_height = 300; |
| 62 |
|
| 63 |
int fvmv_selectmax = 15; |
| 64 |
int mvshowgrid = mv_hidegrid; |
| 65 |
int mv_type = mv_widthonly; |
| 66 |
static int mv_antialias = true; |
| 67 |
static double mv_scales[] = { 8.0, 4.0, 2.0, 1.5, 1.0, 2.0/3.0, .5, 1.0/3.0, .25, .2, 1.0/6.0, .125, .1 }; |
| 68 |
#define SCALE_INDEX_NORMAL 4 |
| 69 |
|
| 70 |
static Color widthcol = 0x808080; |
| 71 |
static Color italicwidthcol = 0x909090; |
| 72 |
static Color glyphcol = 0x000000; |
| 73 |
static Color dividercol = 0x000000; |
| 74 |
static Color selglyphcol = 0x909090; |
| 75 |
static Color kernlinecol = 0x008000; |
| 76 |
static Color rbearinglinecol = 0x000080; |
| 77 |
|
| 78 |
static GResFont mv_font = GRESFONT_INIT("400 12px " SANS_UI_FAMILIES); |
| 79 |
|
| 80 |
int pref_mv_shift_and_arrow_skip = 10; |
| 81 |
int pref_mv_control_shift_and_arrow_skip = 5; |
| 82 |
|
| 83 |
static void MVSelectChar(MetricsView *mv, int i); |
| 84 |
static void MVSelectSetForAll(MetricsView *mv, int selected ); |
| 85 |
static void MVMoveInWordListByOffset( MetricsView *mv, int offset ); |
| 86 |
|
| 87 |
static int MVMoveToNextInWordList(GGadget *g, GEvent *e) |
| 88 |
{ |
| 89 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 90 |
MetricsView *mv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 91 |
MVMoveInWordListByOffset( mv, 1 ); |
| 92 |
} |
| 93 |
return 1; |
| 94 |
} |
| 95 |
static int MVMoveToPrevInWordList(GGadget *g, GEvent *e) |
| 96 |
{ |
| 97 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 98 |
MetricsView *mv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 99 |
MVMoveInWordListByOffset( mv, -1 ); |
| 100 |
} |
| 101 |
return 1; |
| 102 |
} |
| 103 |
|
| 104 |
static void MVMoveInTableByColumnByOffset(MetricsView *mv, int offset) { |
| 105 |
int current_pos = 0; |
| 106 |
|
| 107 |
for (current_pos = 0; current_pos < mv->clen && mv->perchar[current_pos].selected == 0; current_pos ++); |
| 108 |
|
| 109 |
if (current_pos >= mv->clen || mv->perchar[current_pos].selected == 0) return; |
| 110 |
|
| 111 |
if (current_pos + offset >= mv->clen) return; |
| 112 |
|
| 113 |
mv->perchar[current_pos].selected = 0; |
| 114 |
mv->perchar[current_pos + offset].selected = 1; |
| 115 |
|
| 116 |
GGadget *current_gadget = GWindowGetFocusGadgetOfWindow(mv->gw); |
| 117 |
|
| 118 |
int current_gadget_type = 0; |
| 119 |
|
| 120 |
GGadget *target_gadget = NULL; |
| 121 |
if (current_gadget == mv->perchar[current_pos].name) { |
| 122 |
current_gadget_type = 1; |
| 123 |
target_gadget = mv->perchar[current_pos+offset].name; |
| 124 |
} else if (current_gadget == mv->perchar[current_pos].width) { |
| 125 |
current_gadget_type = 2; |
| 126 |
target_gadget = mv->perchar[current_pos+offset].width; |
| 127 |
} else if (current_gadget == mv->perchar[current_pos].lbearing) { |
| 128 |
current_gadget_type = 3; |
| 129 |
target_gadget = mv->perchar[current_pos+offset].lbearing; |
| 130 |
} else if (current_gadget == mv->perchar[current_pos].rbearing) { |
| 131 |
current_gadget_type = 4; |
| 132 |
target_gadget = mv->perchar[current_pos+offset].rbearing; |
| 133 |
} else if (current_gadget == mv->perchar[current_pos].kern) { |
| 134 |
current_gadget_type = 5; |
| 135 |
target_gadget = mv->perchar[current_pos+offset].kern; |
| 136 |
} |
| 137 |
|
| 138 |
if (current_gadget_type == 0) return; |
| 139 |
|
| 140 |
if (target_gadget != NULL) { |
| 141 |
GWidgetIndicateFocusGadget(target_gadget); |
| 142 |
} |
| 143 |
return; |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
static int haveClassBasedKerningInView( MetricsView* mv ) |
| 155 |
{ |
| 156 |
if( mv->cur_subtable ) |
| 157 |
{ |
| 158 |
return mv->cur_subtable->kc > 0; |
| 159 |
} |
| 160 |
return 0; |
| 161 |
} |
| 162 |
|
| 163 |
static SplineChar* getSelectedChar( MetricsView* mv ) { |
| 164 |
int i=0; |
| 165 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 166 |
if ( mv->perchar[i].selected ) { |
| 167 |
return mv->chars[i]; |
| 168 |
} |
| 169 |
} |
| 170 |
if( mv->glyphcnt==1 ) { |
| 171 |
return mv->chars[0]; |
| 172 |
} |
| 173 |
return 0; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
static void selectUserChosenWordListGlyphs( MetricsView *mv, void* userdata ) |
| 178 |
{ |
| 179 |
|
| 180 |
MVSelectSetForAll( mv, 0 ); |
| 181 |
|
| 182 |
|
| 183 |
if( userdata != NULL) |
| 184 |
{ |
| 185 |
if (userdata == (void*)(-1) || userdata == (void*)(-2)) |
| 186 |
fprintf(stderr, "Possible error; see the code here.\n"); |
| 187 |
|
| 188 |
WordListLine wll = (WordListLine)userdata; |
| 189 |
for( ; wll->sc; wll++ ) { |
| 190 |
if( wll->isSelected ) { |
| 191 |
MVSelectChar( mv, wll->currentGlyphIndex ); |
| 192 |
} |
| 193 |
} |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
static int MVGetSplineFontPieceMealFlags( MetricsView *mv ) |
| 198 |
{ |
| 199 |
int ret = 0; |
| 200 |
|
| 201 |
ret = pf_ft_recontext; |
| 202 |
|
| 203 |
if( mv->antialias ) |
| 204 |
ret |= pf_antialias; |
| 205 |
if( !mv->usehinting ) |
| 206 |
ret |= pf_ft_nohints; |
| 207 |
|
| 208 |
return ret; |
| 209 |
} |
| 210 |
|
| 211 |
extern GResInfo metricsview_ri; |
| 212 |
void MVColInit( void ) { |
| 213 |
GResEditDoInit(&metricsview_ri); |
| 214 |
} |
| 215 |
|
| 216 |
static int MVSetVSb(MetricsView *mv); |
| 217 |
|
| 218 |
static int MVShowGrid(MetricsView *mv) { |
| 219 |
if ( mv->showgrid==mv_hidegrid || (mv->showgrid==mv_hidemovinggrid && mv->pressed )) |
| 220 |
return( false ); |
| 221 |
|
| 222 |
return( true ); |
| 223 |
} |
| 224 |
|
| 225 |
static void MVDrawLine(MetricsView *mv,GWindow pixmap, |
| 226 |
int xtop, int top,int xbot,int bot,Color col) { |
| 227 |
if ( mv->showgrid == mv_partialgrid ) { |
| 228 |
int y1, y2; |
| 229 |
int x1, x2; |
| 230 |
y1 = bot + ( top- bot)/4; |
| 231 |
x1 = xbot + (xtop-xbot)/4; |
| 232 |
y2 = bot + 4*( top- bot)/5; |
| 233 |
x2 = xbot + 4*(xtop-xbot)/5; |
| 234 |
GDrawDrawLine(pixmap,xtop,top,x2,y2,col); |
| 235 |
GDrawDrawLine(pixmap,x1,y1,xbot,bot,col); |
| 236 |
} else |
| 237 |
GDrawDrawLine(pixmap,xtop,top,xbot,bot,col); |
| 238 |
} |
| 239 |
|
| 240 |
static void MVSubVExpose(MetricsView *mv, GWindow pixmap, GEvent *event) { |
| 241 |
|
| 242 |
GRect *clip; |
| 243 |
int xbase, y, si, i, x, width, height; |
| 244 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 245 |
int as = rint(iscale*mv->pixelsize*mv->sf->ascent/(double) (mv->sf->ascent+mv->sf->descent)); |
| 246 |
BDFChar *bdfc; |
| 247 |
struct _GImage base; |
| 248 |
GImage gi; |
| 249 |
GClut clut; |
| 250 |
|
| 251 |
clip = &event->u.expose.rect; |
| 252 |
|
| 253 |
xbase = mv->vwidth/2; |
| 254 |
if ( mv->showgrid ) |
| 255 |
GDrawDrawLine(pixmap,xbase,0,xbase,mv->vheight,widthcol); |
| 256 |
|
| 257 |
if ( mv->bdf==NULL && MVShowGrid(mv) ) { |
| 258 |
y = mv->metrics[0].dy-mv->yoff; |
| 259 |
MVDrawLine(mv,pixmap,0,y,mv->vwidth,y,widthcol); |
| 260 |
} |
| 261 |
|
| 262 |
si = -1; |
| 263 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 264 |
if ( mv->perchar[i].selected ) si = i; |
| 265 |
y = mv->metrics[i].dy-mv->yoff; |
| 266 |
if ( mv->bdf==NULL && MVShowGrid(mv)) { |
| 267 |
int yp = y+mv->metrics[i].dheight+mv->metrics[i].kernafter; |
| 268 |
MVDrawLine(mv,pixmap,0, yp,mv->vwidth,yp, |
| 269 |
mv->type==mv_kernonly && i!=mv->glyphcnt-1 ?kernlinecol : |
| 270 |
mv->type==mv_widthonly ?rbearinglinecol : |
| 271 |
widthcol); |
| 272 |
} |
| 273 |
y += mv->metrics[i].yoff; |
| 274 |
bdfc = mv->bdf==NULL ? BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos) : |
| 275 |
BDFGetMergedChar( mv->bdf->glyphs[mv->glyphs[i].sc->orig_pos]); |
| 276 |
if ( bdfc==NULL ) |
| 277 |
continue; |
| 278 |
y += as-rint(iscale * bdfc->ymax); |
| 279 |
if ( mv->perchar[i].selected ) |
| 280 |
y += mv->activeoff; |
| 281 |
x = xbase - rint(iscale * (mv->pixelsize/2 + bdfc->xmin) - mv->metrics[i].xoff); |
| 282 |
width = bdfc->xmax-bdfc->xmin+1; height = bdfc->ymax-bdfc->ymin+1; |
| 283 |
if ( clip->y+clip->height<y ) |
| 284 |
break; |
| 285 |
if ( y+iscale*height>=clip->y && x<clip->x+clip->width && x+iscale*width >= clip->x ) { |
| 286 |
memset(&gi,'\0',sizeof(gi)); |
| 287 |
memset(&base,'\0',sizeof(base)); |
| 288 |
memset(&clut,'\0',sizeof(clut)); |
| 289 |
gi.u.image = &base; |
| 290 |
base.clut = &clut; |
| 291 |
if ( !bdfc->byte_data ) { |
| 292 |
base.image_type = it_mono; |
| 293 |
clut.clut_len = 2; |
| 294 |
clut.clut[0] = view_bgcol; |
| 295 |
clut.clut[1] = mv->perchar[i].selected ? selglyphcol : glyphcol; |
| 296 |
} else { |
| 297 |
int scale, l; |
| 298 |
Color fg, bg; |
| 299 |
if ( mv->bdf!=NULL ) |
| 300 |
scale = BDFDepth(mv->bdf); |
| 301 |
else |
| 302 |
scale = BDFDepth(mv->show); |
| 303 |
base.image_type = it_index; |
| 304 |
clut.clut_len = 1<<scale; |
| 305 |
bg = view_bgcol; |
| 306 |
fg = ( mv->perchar[i].selected ) ? selglyphcol : glyphcol; |
| 307 |
for ( l=0; l<(1<<scale); ++l ) |
| 308 |
clut.clut[l] = |
| 309 |
COLOR_CREATE( |
| 310 |
COLOR_RED(bg) + (l*(COLOR_RED(fg)-COLOR_RED(bg)))/((1<<scale)-1), |
| 311 |
COLOR_GREEN(bg) + (l*(COLOR_GREEN(fg)-COLOR_GREEN(bg)))/((1<<scale)-1), |
| 312 |
COLOR_BLUE(bg) + (l*(COLOR_BLUE(fg)-COLOR_BLUE(bg)))/((1<<scale)-1) ); |
| 313 |
} |
| 314 |
base.data = bdfc->bitmap; |
| 315 |
base.bytes_per_line = bdfc->bytes_per_line; |
| 316 |
base.width = width; |
| 317 |
base.height = height; |
| 318 |
if ( mv->pixelsize_set_by_window || mv->scale_index==SCALE_INDEX_NORMAL ) |
| 319 |
GDrawDrawGlyph(pixmap,&gi,NULL,x,y); |
| 320 |
else |
| 321 |
GDrawDrawImageMagnified(pixmap, &gi, NULL, x,y, |
| 322 |
(int) rint((width*mv_scales[mv->scale_index])), |
| 323 |
(int) rint((height*mv_scales[mv->scale_index]))); |
| 324 |
} |
| 325 |
if ( mv->bdf!=NULL ) BDFCharFree( bdfc ); |
| 326 |
} |
| 327 |
if ( si!=-1 && mv->bdf==NULL && MVShowGrid(mv) && mv->type==mv_kernwidth ) { |
| 328 |
y = mv->metrics[si].dy-mv->yoff; |
| 329 |
if ( si!=0 ) |
| 330 |
MVDrawLine(mv,pixmap,0,y,mv->vwidth,y,kernlinecol); |
| 331 |
y += mv->metrics[si].dheight+mv->metrics[si].kernafter; |
| 332 |
MVDrawLine(mv,pixmap,0,y,mv->vwidth,y,rbearinglinecol); |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
static void MVSubExpose(MetricsView *mv, GWindow pixmap, GEvent *event) { |
| 337 |
GRect old, *clip; |
| 338 |
int x,y,ybase, width,height, i; |
| 339 |
BDFChar *bdfc; |
| 340 |
struct _GImage base; |
| 341 |
GImage gi; |
| 342 |
GClut clut; |
| 343 |
int si; |
| 344 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 345 |
double s = sin(-mv->sf->italicangle*FF_PI/180.); |
| 346 |
int x_iaoffh = 0, x_iaoffl = 0; |
| 347 |
|
| 348 |
clip = &event->u.expose.rect; |
| 349 |
GDrawPushClip(pixmap,clip,&old); |
| 350 |
GDrawSetLineWidth(pixmap,0); |
| 351 |
|
| 352 |
if ( mv->vertical ) { |
| 353 |
MVSubVExpose(mv,pixmap,event); |
| 354 |
GDrawPopClip(pixmap,&old); |
| 355 |
return; |
| 356 |
} |
| 357 |
|
| 358 |
ybase = mv->ybaseline - mv->yoff; |
| 359 |
|
| 360 |
if ( mv->showgrid ) |
| 361 |
GDrawDrawLine(pixmap,0,ybase,mv->dwidth,ybase,widthcol); |
| 362 |
|
| 363 |
if ( mv->bdf==NULL && MVShowGrid(mv) ) { |
| 364 |
x = mv->metrics[0].dx-mv->xoff; |
| 365 |
if ( mv->right_to_left ) |
| 366 |
x = mv->vwidth - x - mv->metrics[0].dwidth - mv->metrics[0].kernafter; |
| 367 |
MVDrawLine(mv,pixmap,x,0,x,mv->vheight,widthcol); |
| 368 |
x_iaoffh = rint(ybase*s), x_iaoffl = rint((mv->vheight-ybase)*s); |
| 369 |
if ( ItalicConstrained && x_iaoffh!=0 ) { |
| 370 |
MVDrawLine(mv,pixmap,x+x_iaoffh,0,x-x_iaoffl,mv->vheight,italicwidthcol); |
| 371 |
} |
| 372 |
} |
| 373 |
si = -1; |
| 374 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 375 |
if ( mv->perchar[i].selected ) si = i; |
| 376 |
x = mv->metrics[i].dx-mv->xoff; |
| 377 |
if ( mv->right_to_left ) |
| 378 |
x = mv->vwidth - x - mv->metrics[i].dwidth - mv->metrics[i].kernafter; |
| 379 |
if ( mv->bdf==NULL && MVShowGrid(mv) ) { |
| 380 |
int xp = x+mv->metrics[i].dwidth+mv->metrics[i].kernafter; |
| 381 |
MVDrawLine(mv,pixmap,xp, 0,xp,mv->vheight, |
| 382 |
mv->type==mv_kernonly && i!=mv->glyphcnt-1 ?kernlinecol : |
| 383 |
mv->type==mv_widthonly ?rbearinglinecol : |
| 384 |
widthcol); |
| 385 |
if ( ItalicConstrained && x_iaoffh!=0 ) { |
| 386 |
MVDrawLine(mv,pixmap,xp+x_iaoffh,0,xp-x_iaoffl,mv->vheight,italicwidthcol); |
| 387 |
} |
| 388 |
} |
| 389 |
if ( mv->right_to_left ) |
| 390 |
x += mv->metrics[i].kernafter-mv->metrics[i].xoff; |
| 391 |
else |
| 392 |
x += mv->metrics[i].xoff; |
| 393 |
bdfc = mv->bdf==NULL ? BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos) : |
| 394 |
BDFGetMergedChar( mv->bdf->glyphs[mv->glyphs[i].sc->orig_pos]); |
| 395 |
if ( bdfc==NULL ) |
| 396 |
continue; |
| 397 |
x += rint( iscale * bdfc->xmin ); |
| 398 |
if ( mv->perchar[i].selected ) |
| 399 |
x += mv->activeoff; |
| 400 |
y = ybase - rint( iscale * bdfc->ymax ) - (iscale-1) - mv->metrics[i].yoff; |
| 401 |
width = bdfc->xmax-bdfc->xmin+1; height = bdfc->ymax-bdfc->ymin+1; |
| 402 |
if ( !mv->right_to_left && clip->x+clip->width<x ) |
| 403 |
break; |
| 404 |
if ( x+rint(iscale*width)>=clip->x && y<clip->y+clip->height && y+rint(iscale*height) >= clip->y ) { |
| 405 |
memset(&gi,'\0',sizeof(gi)); |
| 406 |
memset(&base,'\0',sizeof(base)); |
| 407 |
memset(&clut,'\0',sizeof(clut)); |
| 408 |
gi.u.image = &base; |
| 409 |
base.clut = &clut; |
| 410 |
if ( !bdfc->byte_data ) { |
| 411 |
base.image_type = it_mono; |
| 412 |
clut.clut_len = 2; |
| 413 |
clut.clut[0] = view_bgcol; |
| 414 |
clut.clut[1] = mv->perchar[i].selected ? selglyphcol : glyphcol; |
| 415 |
} else { |
| 416 |
int lscale = 3000/mv->pixelsize, l; |
| 417 |
Color fg, bg; |
| 418 |
int scale; |
| 419 |
if ( mv->bdf!=NULL ) |
| 420 |
lscale = BDFDepth(mv->bdf); |
| 421 |
else |
| 422 |
lscale = BDFDepth(mv->show); |
| 423 |
base.image_type = it_index; |
| 424 |
scale = lscale==8?256:lscale==4?16:4; |
| 425 |
clut.clut_len = scale; |
| 426 |
bg = view_bgcol; |
| 427 |
fg = ( mv->perchar[i].selected ) ? selglyphcol : glyphcol; |
| 428 |
for ( l=0; l<scale; ++l ) |
| 429 |
clut.clut[l] = |
| 430 |
COLOR_CREATE( |
| 431 |
COLOR_RED(bg) + ((int32_t) (l*(COLOR_RED(fg)-COLOR_RED(bg))))/(scale-1), |
| 432 |
COLOR_GREEN(bg) + ((int32_t) (l*(COLOR_GREEN(fg)-COLOR_GREEN(bg))))/(scale-1), |
| 433 |
COLOR_BLUE(bg) + ((int32_t) (l*(COLOR_BLUE(fg)-COLOR_BLUE(bg))))/(scale-1) ); |
| 434 |
} |
| 435 |
base.data = bdfc->bitmap; |
| 436 |
base.bytes_per_line = bdfc->bytes_per_line; |
| 437 |
base.width = width; |
| 438 |
base.height = height; |
| 439 |
if ( mv->pixelsize_set_by_window || mv->scale_index==SCALE_INDEX_NORMAL ) |
| 440 |
GDrawDrawGlyph(pixmap,&gi,NULL,x,y); |
| 441 |
else |
| 442 |
GDrawDrawImageMagnified(pixmap, &gi, NULL, x,y, |
| 443 |
(int) rint((width*mv_scales[mv->scale_index])), |
| 444 |
(int) rint((height*mv_scales[mv->scale_index]))); |
| 445 |
} |
| 446 |
if ( mv->bdf!=NULL ) BDFCharFree( bdfc ); |
| 447 |
} |
| 448 |
if ( si!=-1 && mv->bdf==NULL && MVShowGrid(mv) && mv->type==mv_kernwidth ) { |
| 449 |
x = mv->metrics[si].dx-mv->xoff; |
| 450 |
if ( mv->right_to_left ) |
| 451 |
x = mv->vwidth - x; |
| 452 |
if ( si!=0 ) |
| 453 |
MVDrawLine(mv,pixmap,x,0,x,mv->vheight,kernlinecol); |
| 454 |
if ( mv->right_to_left ) |
| 455 |
x -= mv->metrics[si].dwidth+mv->metrics[si].kernafter; |
| 456 |
else |
| 457 |
x += mv->metrics[si].dwidth+mv->metrics[si].kernafter; |
| 458 |
MVDrawLine(mv,pixmap,x, 0,x,mv->vheight,rbearinglinecol); |
| 459 |
} |
| 460 |
GDrawPopClip(pixmap,&old); |
| 461 |
} |
| 462 |
|
| 463 |
static void MVExpose(MetricsView *mv, GWindow pixmap, GEvent *event) { |
| 464 |
GRect old, *clip; |
| 465 |
int x; |
| 466 |
int ke = mv->height-mv->sbh-(mv->fh+4); |
| 467 |
|
| 468 |
clip = &event->u.expose.rect; |
| 469 |
if ( clip->y+clip->height < mv->topend ) |
| 470 |
return; |
| 471 |
GDrawPushClip(pixmap,clip,&old); |
| 472 |
GDrawSetLineWidth(pixmap,0); |
| 473 |
for ( x=mv->mwidth; x<mv->width; x+=mv->mwidth ) { |
| 474 |
GDrawDrawLine(pixmap,x,mv->displayend,x,ke,dividercol); |
| 475 |
GDrawDrawLine(pixmap,x+mv->mwidth/2,ke,x+mv->mwidth/2,mv->height-mv->sbh,dividercol); |
| 476 |
} |
| 477 |
GDrawDrawLine(pixmap,0,mv->topend,mv->width,mv->topend,dividercol); |
| 478 |
GDrawDrawLine(pixmap,0,mv->displayend,mv->width,mv->displayend,dividercol); |
| 479 |
GDrawDrawLine(pixmap,0,mv->displayend+mv->fh+4,mv->width,mv->displayend+mv->fh+4,dividercol); |
| 480 |
GDrawDrawLine(pixmap,0,mv->displayend+2*(mv->fh+4),mv->width,mv->displayend+2*(mv->fh+4),dividercol); |
| 481 |
GDrawDrawLine(pixmap,0,mv->displayend+3*(mv->fh+4),mv->width,mv->displayend+3*(mv->fh+4),dividercol); |
| 482 |
GDrawDrawLine(pixmap,0,mv->displayend+4*(mv->fh+4),mv->width,mv->displayend+4*(mv->fh+4),dividercol); |
| 483 |
GDrawDrawLine(pixmap,0,mv->displayend+5*(mv->fh+4),mv->width,mv->displayend+5*(mv->fh+4),dividercol); |
| 484 |
GDrawPopClip(pixmap,&old); |
| 485 |
} |
| 486 |
|
| 487 |
static void MVSetSubtables(SplineFont *sf) { |
| 488 |
GTextInfo **ti = NULL; |
| 489 |
OTLookup *otl; |
| 490 |
struct lookup_subtable *sub; |
| 491 |
int cnt, doit; |
| 492 |
MetricsView *mvs; |
| 493 |
int selected; |
| 494 |
|
| 495 |
if ( sf->cidmaster ) sf = sf->cidmaster; |
| 496 |
|
| 497 |
|
| 498 |
for ( mvs = sf->metrics; mvs!=NULL; mvs=mvs->next ) { |
| 499 |
selected = false; |
| 500 |
for ( doit = 0; doit<2; ++doit ) { |
| 501 |
cnt = 0; |
| 502 |
for ( otl=sf->gpos_lookups; otl!=NULL; otl=otl->next ) { |
| 503 |
if ( otl->lookup_type == gpos_pair && FeatureTagInFeatureScriptList( |
| 504 |
mvs->vertical?CHR('v','k','r','n') : CHR('k','e','r','n'), |
| 505 |
otl->features)) { |
| 506 |
for ( sub=otl->subtables; sub!=NULL; sub=sub->next ) { |
| 507 |
if ( doit ) { |
| 508 |
ti[cnt] = calloc(1,sizeof(GTextInfo)); |
| 509 |
ti[cnt]->text = utf82u_copy(sub->subtable_name); |
| 510 |
ti[cnt]->userdata = sub; |
| 511 |
if ( sub==mvs->cur_subtable ) |
| 512 |
ti[cnt]->selected = selected = true; |
| 513 |
ti[cnt]->disabled = sub->kc!=NULL; |
| 514 |
ti[cnt]->fg = ti[cnt]->bg = COLOR_DEFAULT; |
| 515 |
} |
| 516 |
++cnt; |
| 517 |
} |
| 518 |
} |
| 519 |
} |
| 520 |
if ( !doit ) |
| 521 |
ti = calloc(cnt+3,sizeof(GTextInfo *)); |
| 522 |
else { |
| 523 |
if ( cnt!=0 ) { |
| 524 |
ti[cnt] = calloc(1,sizeof(GTextInfo)); |
| 525 |
ti[cnt]->line = true; |
| 526 |
ti[cnt]->fg = ti[cnt]->bg = COLOR_DEFAULT; |
| 527 |
++cnt; |
| 528 |
} |
| 529 |
ti[cnt] = calloc(1,sizeof(GTextInfo)); |
| 530 |
ti[cnt]->text = utf82u_copy(_("New Lookup Subtable...")); |
| 531 |
ti[cnt]->userdata = NULL; |
| 532 |
ti[cnt]->fg = ti[cnt]->bg = COLOR_DEFAULT; |
| 533 |
ti[cnt]->selected = !selected; |
| 534 |
++cnt; |
| 535 |
ti[cnt] = calloc(1,sizeof(GTextInfo)); |
| 536 |
} |
| 537 |
} |
| 538 |
if ( !selected ) |
| 539 |
mvs->cur_subtable = NULL; |
| 540 |
|
| 541 |
GGadgetSetList(mvs->subtable_list,ti,false); |
| 542 |
} |
| 543 |
} |
| 544 |
|
| 545 |
static void MVSetFeatures(MetricsView *mv) { |
| 546 |
SplineFont *sf = mv->sf; |
| 547 |
int i, j, cnt; |
| 548 |
GTextInfo **ti=NULL; |
| 549 |
uint32_t *tags = NULL, script, lang; |
| 550 |
char buf[16]; |
| 551 |
uint32_t *stds; |
| 552 |
const unichar_t *pt = _GGadgetGetTitle(mv->script); |
| 553 |
|
| 554 |
if ( sf->cidmaster ) sf=sf->cidmaster; |
| 555 |
|
| 556 |
script = DEFAULT_SCRIPT; |
| 557 |
lang = DEFAULT_LANG; |
| 558 |
if ( u_strlen(pt)>=4 ) |
| 559 |
script = (pt[0]<<24) | (pt[1]<<16) | (pt[2]<<8) | pt[3]; |
| 560 |
if ( pt[4]=='{' && u_strlen(pt)>=9 ) |
| 561 |
lang = (pt[5]<<24) | (pt[6]<<16) | (pt[7]<<8) | pt[8]; |
| 562 |
if ( (uint32_t)mv->oldscript!=script || (uint32_t)mv->oldlang!=lang ) |
| 563 |
stds = shaper_default_features(mv->shaper, script, lang, mv->vertical); |
| 564 |
else { |
| 565 |
int32_t len, sc; |
| 566 |
ti = GGadgetGetList(mv->features,&len); |
| 567 |
stds = malloc((len+1)*sizeof(uint32_t)); |
| 568 |
for ( i=sc=0; i<len; ++i ) if ( ti[i]->selected ) |
| 569 |
stds[sc++] = (uint32_t) (intptr_t) ti[i]->userdata; |
| 570 |
stds[sc] = 0; |
| 571 |
} |
| 572 |
|
| 573 |
tags = SFFeaturesInScriptLang(sf,-2,script,lang); |
| 574 |
|
| 575 |
for ( cnt=0; tags[cnt]!=0; ++cnt ); |
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
if ( mv->cur_subtable != NULL && |
| 581 |
mv->cur_subtable->lookup != NULL && |
| 582 |
mv->cur_subtable->lookup->features != NULL) { |
| 583 |
FeatureScriptLangList *active_features = mv->cur_subtable->lookup->features; |
| 584 |
uint32_t active_feat = active_features[0].featuretag; |
| 585 |
|
| 586 |
for ( i=0; i<cnt; ++i ) { |
| 587 |
if (tags[i] == active_feat) |
| 588 |
break; |
| 589 |
} |
| 590 |
|
| 591 |
if (i == cnt) { |
| 592 |
|
| 593 |
++cnt; |
| 594 |
tags = realloc(tags,(cnt+1)*sizeof(uint32_t)); |
| 595 |
tags[cnt-1] = active_feat; |
| 596 |
tags[cnt] = 0; |
| 597 |
} |
| 598 |
} |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
ti = malloc((cnt+2)*sizeof(GTextInfo *)); |
| 603 |
for ( i=0; i<cnt; ++i ) { |
| 604 |
ti[i] = calloc( 1,sizeof(GTextInfo)); |
| 605 |
ti[i]->fg = ti[i]->bg = COLOR_DEFAULT; |
| 606 |
if ( (tags[i]>>24)<' ' || (tags[i]>>24)>0x7e ) |
| 607 |
sprintf( buf, "<%d,%d>", tags[i]>>16, tags[i]&0xffff ); |
| 608 |
else { |
| 609 |
buf[0] = tags[i]>>24; buf[1] = tags[i]>>16; buf[2] = tags[i]>>8; buf[3] = tags[i]; buf[4] = 0; |
| 610 |
} |
| 611 |
ti[i]->text = uc_copy(buf); |
| 612 |
ti[i]->userdata = (void *) (intptr_t) tags[i]; |
| 613 |
for ( j=0; stds[j]!=0; ++j ) { |
| 614 |
if ( stds[j] == tags[i] ) { |
| 615 |
ti[i]->selected = true; |
| 616 |
break; |
| 617 |
} |
| 618 |
} |
| 619 |
} |
| 620 |
ti[i] = calloc(1,sizeof(GTextInfo)); |
| 621 |
GGadgetSetList(mv->features,ti,false); |
| 622 |
mv->oldscript = script; mv->oldlang = lang; |
| 623 |
|
| 624 |
free(stds); |
| 625 |
} |
| 626 |
|
| 627 |
static void MVSelectSubtable(MetricsView *mv, struct lookup_subtable *sub) { |
| 628 |
int32_t len; int i; |
| 629 |
GTextInfo **old = GGadgetGetList(mv->subtable_list,&len); |
| 630 |
|
| 631 |
for ( i=0; i<len && (old[i]->userdata!=sub || old[i]->line); ++i ) |
| 632 |
{ |
| 633 |
|
| 634 |
} |
| 635 |
|
| 636 |
GGadgetSelectOneListItem(mv->subtable_list,i); |
| 637 |
if ( sub ) |
| 638 |
mv->cur_subtable = sub; |
| 639 |
} |
| 640 |
|
| 641 |
static void MVRedrawI(MetricsView *mv,int i,int oldxmin,int oldxmax) { |
| 642 |
GRect r; |
| 643 |
BDFChar *bdfc; |
| 644 |
int off = 0; |
| 645 |
|
| 646 |
if ( mv->right_to_left || mv->vertical ) { |
| 647 |
|
| 648 |
|
| 649 |
GDrawRequestExpose(mv->v,NULL,false); |
| 650 |
return; |
| 651 |
} |
| 652 |
if ( mv->perchar[i].selected ) |
| 653 |
off = mv->activeoff; |
| 654 |
r.y = 0; r.height = mv->vheight; |
| 655 |
r.x = mv->metrics[i].dx-mv->xoff; r.width = mv->metrics[i].dwidth; |
| 656 |
if ( mv->metrics[i].kernafter>0 ) |
| 657 |
r.width += mv->metrics[i].kernafter; |
| 658 |
if ( mv->metrics[i].xoff<0 ) { |
| 659 |
r.x += mv->metrics[i].xoff; |
| 660 |
r.width -= mv->metrics[i].xoff; |
| 661 |
} else |
| 662 |
r.width += mv->metrics[i].xoff; |
| 663 |
bdfc = mv->bdf==NULL ? BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos) : |
| 664 |
mv->bdf->glyphs[mv->glyphs[i].sc->orig_pos]; |
| 665 |
if ( bdfc==NULL ) |
| 666 |
return; |
| 667 |
if ( bdfc->xmax+off+1>r.width ) r.width = bdfc->xmax+off+1; |
| 668 |
if ( oldxmax+1>r.width ) r.width = oldxmax+1; |
| 669 |
if ( bdfc->xmin+off<0 ) { |
| 670 |
r.x += bdfc->xmin+off; |
| 671 |
r.width -= bdfc->xmin+off; |
| 672 |
} |
| 673 |
if ( oldxmin<bdfc->xmin ) { |
| 674 |
r.width += (bdfc->xmin+off-oldxmin); |
| 675 |
r.x -= (bdfc->xmin+off-oldxmin); |
| 676 |
} |
| 677 |
if ( mv->right_to_left ) |
| 678 |
r.x = mv->dwidth - r.x - r.width; |
| 679 |
GDrawRequestExpose(mv->v,&r,false); |
| 680 |
if ( mv->perchar[i].selected && i!=0 ) { |
| 681 |
struct lookup_subtable *sub = mv->glyphs[i].kp!=NULL ? mv->glyphs[i].kp->subtable : mv->glyphs[i].kc!=NULL && mv->glyphs[i].kc->offsets[mv->glyphs[i].kc_index]!=0 ? mv->glyphs[i].kc->subtable : NULL; |
| 682 |
if ( sub!=NULL ) |
| 683 |
MVSelectSubtable(mv,sub); |
| 684 |
} |
| 685 |
} |
| 686 |
|
| 687 |
static void MVDeselectChar(MetricsView *mv, int i) { |
| 688 |
|
| 689 |
mv->perchar[i].selected = false; |
| 690 |
if ( mv->perchar[i].name!=NULL ) |
| 691 |
GGadgetSetEnabled(mv->perchar[i].name,mv->bdf==NULL); |
| 692 |
MVRedrawI(mv,i,0,0); |
| 693 |
} |
| 694 |
|
| 695 |
static void MVSelectSubtableForScript(MetricsView *mv,uint32_t script) { |
| 696 |
int32_t len; |
| 697 |
GTextInfo **ti = GGadgetGetList(mv->subtable_list,&len); |
| 698 |
struct lookup_subtable *sub; |
| 699 |
int i; |
| 700 |
|
| 701 |
if ( mv->cur_subtable != NULL && FeatureScriptTagInFeatureScriptList( |
| 702 |
mv->vertical?CHR('v','k','r','n') : CHR('k','e','r','n'),script, |
| 703 |
mv->cur_subtable->lookup->features )) |
| 704 |
return; |
| 705 |
|
| 706 |
sub = NULL; |
| 707 |
for ( i=0; i<len; ++i ) |
| 708 |
if ( ti[i]->userdata!=NULL && |
| 709 |
FeatureScriptTagInFeatureScriptList( |
| 710 |
mv->vertical?CHR('v','k','r','n') : CHR('k','e','r','n'), |
| 711 |
script,((struct lookup_subtable *) (ti[i]->userdata))->lookup->features)) { |
| 712 |
sub = ti[i]->userdata; |
| 713 |
break; |
| 714 |
} |
| 715 |
if ( sub!=NULL ) |
| 716 |
MVSelectSubtable(mv,sub); |
| 717 |
} |
| 718 |
|
| 719 |
|
| 720 |
static void MVSelectChar(MetricsView *mv, int i) { |
| 721 |
|
| 722 |
if ( i>=mv->glyphcnt || i<0 ) |
| 723 |
return; |
| 724 |
mv->perchar[i].selected = true; |
| 725 |
if ( mv->perchar[i].name!=NULL ) |
| 726 |
GGadgetSetEnabled(mv->perchar[i].name,false); |
| 727 |
if ( mv->glyphs[i].kp!=NULL ) |
| 728 |
MVSelectSubtable(mv,mv->glyphs[i].kp->subtable); |
| 729 |
else if ( mv->glyphs[i].kc!=NULL && mv->glyphs[i].kc->offsets[mv->glyphs[i].kc_index]!=0 ) |
| 730 |
MVSelectSubtable(mv,mv->glyphs[i].kc->subtable); |
| 731 |
else |
| 732 |
MVSelectSubtableForScript(mv,SCScriptFromUnicode(mv->glyphs[i].sc)); |
| 733 |
MVRedrawI(mv,i,0,0); |
| 734 |
} |
| 735 |
|
| 736 |
static void MVDoSelect(MetricsView *mv, int i) { |
| 737 |
int j; |
| 738 |
|
| 739 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 740 |
if ( j!=i && mv->perchar[j].selected ) |
| 741 |
MVDeselectChar(mv,j); |
| 742 |
MVSelectChar(mv,i); |
| 743 |
} |
| 744 |
|
| 745 |
static void MVSelectSetForAll(MetricsView *mv, int selected ) |
| 746 |
{ |
| 747 |
int i; |
| 748 |
|
| 749 |
for ( i=0 ; i<mv->glyphcnt; ++i ) |
| 750 |
{ |
| 751 |
if( selected ) |
| 752 |
MVSelectChar(mv,i); |
| 753 |
else |
| 754 |
MVDeselectChar(mv,i); |
| 755 |
} |
| 756 |
} |
| 757 |
|
| 758 |
void MVRefreshChar(MetricsView *mv, SplineChar *sc) { |
| 759 |
int i; |
| 760 |
for ( i=0; i<mv->glyphcnt; ++i ) if ( mv->glyphs[i].sc == sc ) |
| 761 |
MVRedrawI(mv,i,0,0); |
| 762 |
} |
| 763 |
|
| 764 |
static int MVGetKernOffset(struct opentype_str* glyph) { |
| 765 |
int kern_offset = INVALID_KERN_OFFSET; |
| 766 |
|
| 767 |
if (glyph->kp != NULL) |
| 768 |
kern_offset = glyph->kp->off; |
| 769 |
else if (glyph->kc != NULL) |
| 770 |
kern_offset = glyph->kc->offsets[glyph->kc_index]; |
| 771 |
|
| 772 |
return kern_offset; |
| 773 |
} |
| 774 |
|
| 775 |
static void MVRefreshValues(MetricsView *mv, int i) { |
| 776 |
char buf[40]; |
| 777 |
DBounds bb; |
| 778 |
SplineChar *sc = mv->glyphs[i].sc; |
| 779 |
int kern_offset; |
| 780 |
|
| 781 |
SplineCharFindBounds(sc,&bb); |
| 782 |
|
| 783 |
if( !mv->perchar[i].name ) |
| 784 |
return; |
| 785 |
GGadgetSetTitle8(mv->perchar[i].name,sc->name); |
| 786 |
|
| 787 |
if( !mv->perchar[i].width ) |
| 788 |
return; |
| 789 |
|
| 790 |
|
| 791 |
sprintf(buf,"%d",mv->vertical ? sc->vwidth : sc->width); |
| 792 |
GGadgetSetTitle8(mv->perchar[i].width,buf); |
| 793 |
|
| 794 |
sprintf(buf,"%.2f",mv->vertical ? sc->parent->ascent-(double) bb.maxy : (double) bb.minx); |
| 795 |
if ( buf[strlen(buf)-1]=='0' ) { |
| 796 |
buf[strlen(buf)-1] = '\0'; |
| 797 |
if ( buf[strlen(buf)-1]=='0' ) { |
| 798 |
buf[strlen(buf)-1] = '\0'; |
| 799 |
if ( buf[strlen(buf)-1]=='.' ) |
| 800 |
buf[strlen(buf)-1] = '\0'; |
| 801 |
} |
| 802 |
} |
| 803 |
GGadgetSetTitle8(mv->perchar[i].lbearing,buf); |
| 804 |
|
| 805 |
sprintf(buf,"%.2f",(double) (mv->vertical ? sc->vwidth-(sc->parent->ascent-bb.miny) : sc->width-bb.maxx)); |
| 806 |
if ( buf[strlen(buf)-1]=='0' ) { |
| 807 |
buf[strlen(buf)-1] = '\0'; |
| 808 |
if ( buf[strlen(buf)-1]=='0' ) { |
| 809 |
buf[strlen(buf)-1] = '\0'; |
| 810 |
if ( buf[strlen(buf)-1]=='.' ) |
| 811 |
buf[strlen(buf)-1] = '\0'; |
| 812 |
} |
| 813 |
} |
| 814 |
GGadgetSetTitle8(mv->perchar[i].rbearing,buf); |
| 815 |
|
| 816 |
kern_offset = MVGetKernOffset(mv->glyphs + i); |
| 817 |
if( !mv->perchar[i+1].kern ) |
| 818 |
return; |
| 819 |
|
| 820 |
if ( kern_offset!=INVALID_KERN_OFFSET && i!=mv->glyphcnt-1 ) { |
| 821 |
sprintf(buf,"%d",kern_offset); |
| 822 |
GGadgetSetTitle8(mv->perchar[i+1].kern,buf); |
| 823 |
} else if ( i!=mv->glyphcnt-1 ) |
| 824 |
GGadgetSetTitle8(mv->perchar[i+1].kern,""); |
| 825 |
} |
| 826 |
|
| 827 |
static void MVMakeLabels(MetricsView *mv) { |
| 828 |
static GBox small = GBOX_EMPTY; |
| 829 |
GGadgetData gd; |
| 830 |
GTextInfo label; |
| 831 |
|
| 832 |
small.main_background = small.main_foreground = COLOR_DEFAULT; |
| 833 |
memset(&gd,'\0',sizeof(gd)); |
| 834 |
memset(&label,'\0',sizeof(label)); |
| 835 |
|
| 836 |
mv->mwidth = GGadgetScale(60); |
| 837 |
mv->displayend = mv->height- mv->sbh - 5*(mv->fh+4); |
| 838 |
|
| 839 |
if ( mv->pixelsize_set_by_window ) |
| 840 |
mv->pixelsize = mv_scales[mv->scale_index]*(mv->displayend - mv->topend - 4); |
| 841 |
|
| 842 |
label.text = (unichar_t *) _("Name:"); |
| 843 |
label.text_is_1byte = true; |
| 844 |
label.font = mv->font; |
| 845 |
gd.pos.x = 2; gd.pos.width = mv->mwidth-4; |
| 846 |
gd.pos.y = mv->displayend+2; |
| 847 |
gd.pos.height = mv->fh; |
| 848 |
gd.label = &label; |
| 849 |
|
| 850 |
|
| 851 |
gd.flags = gg_visible | gg_enabled | gg_pos_in_pixels; |
| 852 |
mv->namelab = GLabelCreate(mv->gw,&gd,NULL); |
| 853 |
|
| 854 |
label.text = (unichar_t *) (mv->vertical ? _("Height:") : _("Width:") ); |
| 855 |
gd.pos.y += mv->fh+4; |
| 856 |
mv->widthlab = GLabelCreate(mv->gw,&gd,NULL); |
| 857 |
|
| 858 |
|
| 859 |
label.text = (unichar_t *) (mv->vertical ? _("TBearing:") : _("LBearing:") ); |
| 860 |
gd.pos.y += mv->fh+4; |
| 861 |
mv->lbearinglab = GLabelCreate(mv->gw,&gd,NULL); |
| 862 |
|
| 863 |
|
| 864 |
label.text = (unichar_t *) (mv->vertical ? _("BBearing:") : _("RBearing:") ); |
| 865 |
gd.pos.y += mv->fh+4; |
| 866 |
mv->rbearinglab = GLabelCreate(mv->gw,&gd,NULL); |
| 867 |
|
| 868 |
label.text = (unichar_t *) (mv->vertical ? _("VKern:") : _("Kern:")); |
| 869 |
gd.pos.y += mv->fh+4; |
| 870 |
mv->kernlab = GLabelCreate(mv->gw,&gd,NULL); |
| 871 |
} |
| 872 |
|
| 873 |
static int MV_KernChanged(GGadget *g, GEvent *e); |
| 874 |
static int MV_RBearingChanged(GGadget *g, GEvent *e); |
| 875 |
static int MV_LBearingChanged(GGadget *g, GEvent *e); |
| 876 |
static int MV_WidthChanged(GGadget *g, GEvent *e); |
| 877 |
|
| 878 |
static void MVCreateFields(MetricsView *mv,int i) { |
| 879 |
static GBox small = GBOX_EMPTY; |
| 880 |
GGadgetData gd; |
| 881 |
GTextInfo label; |
| 882 |
static unichar_t nullstr[1] = { 0 }; |
| 883 |
extern GBox _GGadget_gtextfield_box; |
| 884 |
int udaidx = 1; |
| 885 |
|
| 886 |
small = _GGadget_gtextfield_box; |
| 887 |
small.flags = 0; |
| 888 |
small.border_type = bt_none; |
| 889 |
small.border_shape = bs_rect; |
| 890 |
small.border_width = 0; |
| 891 |
small.padding = 0; |
| 892 |
|
| 893 |
memset(&gd,'\0',sizeof(gd)); |
| 894 |
memset(&label,'\0',sizeof(label)); |
| 895 |
memset(mv->perchar[i].updownkparray,'\0',sizeof(GGadget*)*10); |
| 896 |
label.text = nullstr; |
| 897 |
label.font = mv->font; |
| 898 |
mv->perchar[i].mx = gd.pos.x = mv->mbase+(i+1-mv->coff)*mv->mwidth+2; |
| 899 |
mv->perchar[i].mwidth = gd.pos.width = mv->mwidth-4; |
| 900 |
gd.pos.y = mv->displayend+2; |
| 901 |
gd.pos.height = mv->fh; |
| 902 |
gd.label = &label; |
| 903 |
gd.box = &small; |
| 904 |
gd.flags = gg_visible | gg_pos_in_pixels | gg_dontcopybox; |
| 905 |
if ( mv->bdf==NULL ) |
| 906 |
gd.flags |= gg_enabled; |
| 907 |
mv->perchar[i].name = GLabelCreate(mv->gw,&gd,(void *) (intptr_t) i); |
| 908 |
if ( mv->perchar[i].selected ) |
| 909 |
GGadgetSetEnabled(mv->perchar[i].name,false); |
| 910 |
|
| 911 |
gd.pos.y += mv->fh+4; |
| 912 |
gd.handle_controlevent = MV_WidthChanged; |
| 913 |
mv->perchar[i].width = GTextFieldCreate(mv->gw,&gd,(void *) (intptr_t) i); |
| 914 |
mv->perchar[i].updownkparray[udaidx++] = mv->perchar[i].width; |
| 915 |
|
| 916 |
gd.pos.y += mv->fh+4; |
| 917 |
gd.handle_controlevent = MV_LBearingChanged; |
| 918 |
mv->perchar[i].lbearing = GTextFieldCreate(mv->gw,&gd,(void *) (intptr_t) i); |
| 919 |
mv->perchar[i].updownkparray[udaidx++] = mv->perchar[i].lbearing; |
| 920 |
|
| 921 |
gd.pos.y += mv->fh+4; |
| 922 |
gd.handle_controlevent = MV_RBearingChanged; |
| 923 |
mv->perchar[i].rbearing = GTextFieldCreate(mv->gw,&gd,(void *) (intptr_t) i); |
| 924 |
mv->perchar[i].updownkparray[udaidx++] = mv->perchar[i].rbearing; |
| 925 |
|
| 926 |
if ( i!=0 ) { |
| 927 |
gd.pos.y += mv->fh+4; |
| 928 |
gd.pos.x -= mv->mwidth/2; |
| 929 |
gd.handle_controlevent = MV_KernChanged; |
| 930 |
mv->perchar[i].kern = GTextFieldCreate(mv->gw,&gd,(void *) (intptr_t) i); |
| 931 |
if( i==1 ) { |
| 932 |
mv->perchar[i-1].updownkparray[udaidx] = mv->perchar[i].kern; |
| 933 |
} |
| 934 |
mv->perchar[i].updownkparray[udaidx++] = mv->perchar[i].kern; |
| 935 |
} |
| 936 |
|
| 937 |
GWidgetIndicateFocusGadget(mv->text); |
| 938 |
} |
| 939 |
|
| 940 |
static void MVSetSb(MetricsView *mv); |
| 941 |
static int MVSetVSb(MetricsView *mv); |
| 942 |
|
| 943 |
static void MVCharMetrics(MetricsView* mv, SplineChar* sc, int16_t* width, |
| 944 |
int16_t* vwidth) { |
| 945 |
if (width) { |
| 946 |
if (mv) { |
| 947 |
BDFChar* bdfc = mv->bdf != NULL |
| 948 |
? mv->bdf->glyphs[sc->orig_pos] |
| 949 |
: BDFPieceMealCheck(mv->show, sc->orig_pos); |
| 950 |
*width = bdfc->width; |
| 951 |
} else |
| 952 |
*width = sc->width; |
| 953 |
} |
| 954 |
|
| 955 |
if (vwidth) *vwidth = sc->vwidth; |
| 956 |
} |
| 957 |
|
| 958 |
void MVRefreshMetric(MetricsView *mv) { |
| 959 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 960 |
double scale = iscale*mv->pixelsize/(double) (mv->sf->ascent+mv->sf->descent); |
| 961 |
int cnt; |
| 962 |
|
| 963 |
for ( cnt=0; mv->glyphs[cnt].sc!=NULL; ++cnt ) { |
| 964 |
MVRefreshValues(mv,cnt); |
| 965 |
} |
| 966 |
shaper_scale_metrics(mv->shaper, mv, mv->metrics, iscale, scale, mv->vertical); |
| 967 |
MVSetVSb(mv); |
| 968 |
MVSetSb(mv); |
| 969 |
} |
| 970 |
|
| 971 |
static void MVRemetric(MetricsView *mv) { |
| 972 |
SplineChar *anysc, *goodsc; |
| 973 |
int i, cnt; |
| 974 |
const unichar_t *_script = _GGadgetGetTitle(mv->script); |
| 975 |
uint32_t script, lang; |
| 976 |
FeatureMap *feats; |
| 977 |
char buf[20]; |
| 978 |
int32_t len; |
| 979 |
GTextInfo **ti; |
| 980 |
SplineFont *sf; |
| 981 |
struct shaper_out applied_feats = {0, 0}; |
| 982 |
|
| 983 |
anysc = goodsc = NULL; |
| 984 |
|
| 985 |
for ( i=0; i<mv->clen && mv->chars[i] ; ++i ) { |
| 986 |
|
| 987 |
if ( anysc==NULL ) anysc = mv->chars[i]; |
| 988 |
|
| 989 |
if ( SCScriptFromUnicode(mv->chars[i])!=DEFAULT_SCRIPT ) { |
| 990 |
goodsc = mv->chars[i]; |
| 991 |
break; |
| 992 |
} |
| 993 |
} |
| 994 |
if ( _script[0]=='D' && _script[1]=='F' && _script[2]=='L' && _script[3]=='T' ) { |
| 995 |
if ( goodsc!=NULL ) { |
| 996 |
|
| 997 |
|
| 998 |
script = SCScriptFromUnicode(goodsc); |
| 999 |
buf[0] = script>>24; buf[1] = script>>16; buf[2] = script>>8; buf[3] = script; |
| 1000 |
strcpy(buf+4,"{dflt}"); |
| 1001 |
GGadgetSetTitle8(mv->script,buf); |
| 1002 |
MVSelectSubtableForScript(mv,script); |
| 1003 |
MVSetFeatures(mv); |
| 1004 |
} |
| 1005 |
} else { |
| 1006 |
if ( anysc==NULL ) { |
| 1007 |
|
| 1008 |
GGadgetSetTitle8(mv->script,"DFLT{dflt}"); |
| 1009 |
|
| 1010 |
MVSetFeatures(mv); |
| 1011 |
} |
| 1012 |
} |
| 1013 |
_script = _GGadgetGetTitle(mv->script); |
| 1014 |
script = DEFAULT_SCRIPT; lang = DEFAULT_LANG; |
| 1015 |
if ( u_strlen(_script)>=4 && (u_strchr(_script,'{')==NULL || u_strchr(_script,'{')-_script>=4)) { |
| 1016 |
|
| 1017 |
|
| 1018 |
unichar_t *pt; |
| 1019 |
script = (_script[0]<<24) | (_script[1]<<16) | (_script[2]<<8) | _script[3]; |
| 1020 |
if ( (pt = u_strchr(_script,'{'))!=NULL && u_strlen(pt+1)>=4 && |
| 1021 |
(u_strchr(pt+1,'}')==NULL || u_strchr(pt+1,'}')-(pt+1)>=4 )) |
| 1022 |
lang = (pt[1]<<24) | (pt[2]<<16) | (pt[3]<<8) | pt[4]; |
| 1023 |
} |
| 1024 |
|
| 1025 |
|
| 1026 |
ti = GGadgetGetList(mv->features,&len); |
| 1027 |
feats = calloc(len+1,sizeof(FeatureMap)); |
| 1028 |
for ( i=0; i<len; ++i ) |
| 1029 |
feats[i] = (FeatureMap){ (intptr_t) ti[i]->userdata, ti[i]->selected }; |
| 1030 |
|
| 1031 |
|
| 1032 |
free(mv->glyphs); mv->glyphs = NULL; |
| 1033 |
free(mv->metrics); mv->metrics = NULL; |
| 1034 |
sf = mv->sf; |
| 1035 |
if ( sf->cidmaster ) sf = sf->cidmaster; |
| 1036 |
applied_feats = shaper_apply_features(mv->shaper, mv->chars, feats, |
| 1037 |
script, lang, mv->pixelsize, mv->vertical); |
| 1038 |
mv->glyphs = applied_feats.glyphs; |
| 1039 |
mv->metrics = applied_feats.metrics; |
| 1040 |
|
| 1041 |
if (mv->glyphs == NULL) { |
| 1042 |
mv->glyphs = calloc(1, sizeof(struct opentype_str)); |
| 1043 |
} |
| 1044 |
free(feats); |
| 1045 |
if ( goodsc!=NULL ) |
| 1046 |
mv->right_to_left = SCRightToLeft(goodsc)?1:0; |
| 1047 |
else |
| 1048 |
mv->right_to_left = mv->glyphs[0].r2l; |
| 1049 |
|
| 1050 |
|
| 1051 |
for ( cnt=0; mv->glyphs[cnt].sc!=NULL; ++cnt ); |
| 1052 |
|
| 1053 |
if ( cnt>=mv->max ) { |
| 1054 |
int oldmax=mv->max; |
| 1055 |
mv->max = cnt+10; |
| 1056 |
mv->perchar = realloc(mv->perchar,mv->max*sizeof(struct metrics_ui)); |
| 1057 |
memset(mv->perchar+oldmax,'\0',(mv->max-oldmax)*sizeof(struct metrics_ui)); |
| 1058 |
} |
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
for ( i=cnt; i<mv->glyphcnt; ++i ) { |
| 1064 |
static unichar_t nullstr[] = { 0 }; |
| 1065 |
GGadgetSetTitle(mv->perchar[i].name,nullstr); |
| 1066 |
GGadgetSetTitle(mv->perchar[i].width,nullstr); |
| 1067 |
GGadgetSetTitle(mv->perchar[i].lbearing,nullstr); |
| 1068 |
GGadgetSetTitle(mv->perchar[i].rbearing,nullstr); |
| 1069 |
if ( mv->perchar[i].kern!=NULL ) |
| 1070 |
GGadgetSetTitle(mv->perchar[i].kern,nullstr); |
| 1071 |
} |
| 1072 |
|
| 1073 |
mv->glyphcnt = cnt; |
| 1074 |
|
| 1075 |
for ( i=0; i<cnt; ++i ) { |
| 1076 |
if ( mv->perchar[i].width==NULL ) { |
| 1077 |
MVCreateFields(mv,i); |
| 1078 |
} |
| 1079 |
} |
| 1080 |
|
| 1081 |
MVRefreshMetric(mv); |
| 1082 |
} |
| 1083 |
|
| 1084 |
void MVReKern(MetricsView *mv) { |
| 1085 |
MVRemetric(mv); |
| 1086 |
GDrawRequestExpose(mv->v,NULL,false); |
| 1087 |
} |
| 1088 |
|
| 1089 |
void MVRegenChar(MetricsView *mv, SplineChar *sc) { |
| 1090 |
int i; |
| 1091 |
|
| 1092 |
if( !sc->suspendMetricsViewEventPropagation ) |
| 1093 |
{ |
| 1094 |
if ( mv->bdf==NULL && sc->orig_pos<mv->show->glyphcnt ) |
| 1095 |
{ |
| 1096 |
BDFCharFree(mv->show->glyphs[sc->orig_pos]); |
| 1097 |
mv->show->glyphs[sc->orig_pos] = NULL; |
| 1098 |
} |
| 1099 |
} |
| 1100 |
|
| 1101 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 1102 |
MVRefreshValues(mv,i); |
| 1103 |
} |
| 1104 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 1105 |
{ |
| 1106 |
if ( mv->glyphs[i].sc == sc ) |
| 1107 |
break; |
| 1108 |
} |
| 1109 |
if ( i>=mv->glyphcnt ) |
| 1110 |
return; |
| 1111 |
MVRemetric(mv); |
| 1112 |
GDrawRequestExpose(mv->v,NULL,false); |
| 1113 |
} |
| 1114 |
|
| 1115 |
static void MVChangeDisplayFont(MetricsView *mv, BDFFont *bdf) { |
| 1116 |
int i; |
| 1117 |
|
| 1118 |
if ( mv->bdf==bdf ) |
| 1119 |
return; |
| 1120 |
if ( (mv->bdf==NULL) != (bdf==NULL) ) { |
| 1121 |
for ( i=0; i<mv->max; ++i ) if ( mv->perchar[i].width!=NULL ) { |
| 1122 |
GGadgetSetEnabled(mv->perchar[i].width,bdf==NULL); |
| 1123 |
GGadgetSetEnabled(mv->perchar[i].lbearing,bdf==NULL); |
| 1124 |
GGadgetSetEnabled(mv->perchar[i].rbearing,bdf==NULL); |
| 1125 |
if ( i!=0 ) |
| 1126 |
GGadgetSetEnabled(mv->perchar[i].kern,bdf==NULL); |
| 1127 |
} |
| 1128 |
} |
| 1129 |
if ( mv->bdf==NULL ) { |
| 1130 |
BDFFontFree(mv->show); |
| 1131 |
mv->show = NULL; |
| 1132 |
} else if ( bdf==NULL ) { |
| 1133 |
BDFFontFree(mv->show); |
| 1134 |
mv->show = SplineFontPieceMeal(mv->sf,mv->layer,mv->ptsize,mv->dpi, |
| 1135 |
MVGetSplineFontPieceMealFlags( mv ), NULL ); |
| 1136 |
} |
| 1137 |
mv->bdf = bdf; |
| 1138 |
MVRemetric(mv); |
| 1139 |
} |
| 1140 |
|
| 1141 |
static int isValidInt(unichar_t *end) { |
| 1142 |
if ( *end && !(*end=='-' && end[1]=='\0')) |
| 1143 |
return 0; |
| 1144 |
return 1; |
| 1145 |
} |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
static real GGadgetToReal(GGadget *g) |
| 1158 |
{ |
| 1159 |
unichar_t *end; |
| 1160 |
real val = u_strtod(_GGadgetGetTitle(g),&end); |
| 1161 |
return val; |
| 1162 |
} |
| 1163 |
|
| 1164 |
static int MV_WidthChanged(GGadget *g, GEvent *e) { |
| 1165 |
|
| 1166 |
|
| 1167 |
MetricsView *mv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1168 |
int which = (intptr_t) GGadgetGetUserData(g); |
| 1169 |
int i; |
| 1170 |
|
| 1171 |
if ( e->type!=et_controlevent ) |
| 1172 |
return( true ); |
| 1173 |
if ( which>=mv->glyphcnt ) |
| 1174 |
return( true ); |
| 1175 |
if ( e->u.control.subtype == et_textchanged ) { |
| 1176 |
unichar_t *end; |
| 1177 |
int val = u_strtol(_GGadgetGetTitle(g),&end,10); |
| 1178 |
SplineChar *sc = mv->glyphs[which].sc; |
| 1179 |
if (!isValidInt(end)) |
| 1180 |
GDrawBeep(NULL); |
| 1181 |
else if ( !mv->vertical && val!=sc->width ) { |
| 1182 |
SCPreserveWidth(sc); |
| 1183 |
|
| 1184 |
|
| 1185 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 1186 |
if ( mv->perchar[i].width == g ) |
| 1187 |
break; |
| 1188 |
} |
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
real offset = GGadgetToReal(mv->perchar[i].lbearing); |
| 1193 |
offset += (val - sc->width * 1.0)/2; |
| 1194 |
real transform[6]; |
| 1195 |
transform[0] = transform[3] = 1.0; |
| 1196 |
transform[1] = transform[2] = transform[5] = 0; |
| 1197 |
DBounds bb; |
| 1198 |
SplineCharFindBounds(sc,&bb); |
| 1199 |
transform[4] = offset-bb.minx; |
| 1200 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, 0 | fvt_alllayers ); |
| 1201 |
|
| 1202 |
SCSynchronizeWidth(sc,val,sc->width,NULL); |
| 1203 |
SCCharChangedUpdate(sc,ly_none); |
| 1204 |
|
| 1205 |
} else if ( mv->vertical && val!=sc->vwidth ) { |
| 1206 |
SCPreserveVWidth(sc); |
| 1207 |
sc->vwidth = val; |
| 1208 |
SCCharChangedUpdate(sc,ly_none); |
| 1209 |
} |
| 1210 |
} else if ( e->u.control.subtype == et_textfocuschanged && |
| 1211 |
e->u.control.u.tf_focus.gained_focus ) { |
| 1212 |
for ( i=0 ; i<mv->glyphcnt; ++i ) |
| 1213 |
if ( i!=which && mv->perchar[i].selected ) |
| 1214 |
MVDeselectChar(mv,i); |
| 1215 |
MVSelectChar(mv,which); |
| 1216 |
} |
| 1217 |
return( true ); |
| 1218 |
} |
| 1219 |
|
| 1220 |
static int MV_LBearingChanged(GGadget *g, GEvent *e) |
| 1221 |
{ |
| 1222 |
|
| 1223 |
|
| 1224 |
MetricsView *mv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1225 |
int which = (intptr_t) GGadgetGetUserData(g); |
| 1226 |
int i; |
| 1227 |
|
| 1228 |
if ( e->type!=et_controlevent ) |
| 1229 |
return( true ); |
| 1230 |
if ( which>=mv->glyphcnt ) |
| 1231 |
return( true ); |
| 1232 |
if ( e->u.control.subtype == et_textchanged ) { |
| 1233 |
unichar_t *end; |
| 1234 |
double val = u_strtod(_GGadgetGetTitle(g),&end); |
| 1235 |
SplineChar *sc = mv->glyphs[which].sc; |
| 1236 |
DBounds bb; |
| 1237 |
SplineCharFindBounds(sc,&bb); |
| 1238 |
if (!isValidInt(end)) |
| 1239 |
GDrawBeep(NULL); |
| 1240 |
else if ( !mv->vertical && val!=bb.minx ) { |
| 1241 |
real transform[6]; |
| 1242 |
transform[0] = transform[3] = 1.0; |
| 1243 |
transform[1] = transform[2] = transform[5] = 0; |
| 1244 |
transform[4] = val-bb.minx; |
| 1245 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,0 | fvt_alllayers ); |
| 1246 |
} else if ( mv->vertical && val!=sc->parent->ascent-bb.maxy ) { |
| 1247 |
real transform[6]; |
| 1248 |
transform[0] = transform[3] = 1.0; |
| 1249 |
transform[1] = transform[2] = transform[4] = 0; |
| 1250 |
transform[5] = sc->parent->ascent-bb.maxy-val; |
| 1251 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, fvt_dontmovewidth | fvt_alllayers ); |
| 1252 |
} |
| 1253 |
|
| 1254 |
} else if ( e->u.control.subtype == et_textfocuschanged && |
| 1255 |
e->u.control.u.tf_focus.gained_focus ) { |
| 1256 |
for ( i=0 ; i<mv->glyphcnt; ++i ) |
| 1257 |
if ( i!=which && mv->perchar[i].selected ) |
| 1258 |
MVDeselectChar(mv,i); |
| 1259 |
MVSelectChar(mv,which); |
| 1260 |
} |
| 1261 |
return( true ); |
| 1262 |
} |
| 1263 |
|
| 1264 |
static int MV_RBearingChanged(GGadget *g, GEvent *e) { |
| 1265 |
|
| 1266 |
|
| 1267 |
MetricsView *mv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1268 |
int which = (intptr_t) GGadgetGetUserData(g); |
| 1269 |
int i; |
| 1270 |
|
| 1271 |
if ( e->type!=et_controlevent ) |
| 1272 |
return( true ); |
| 1273 |
if ( which>=mv->glyphcnt ) |
| 1274 |
return( true ); |
| 1275 |
if ( e->u.control.subtype == et_textchanged ) { |
| 1276 |
unichar_t *end; |
| 1277 |
int val = u_strtod(_GGadgetGetTitle(g),&end); |
| 1278 |
SplineChar *sc = mv->glyphs[which].sc; |
| 1279 |
DBounds bb; |
| 1280 |
SplineCharFindBounds(sc,&bb); |
| 1281 |
if (!isValidInt(end)) |
| 1282 |
GDrawBeep(NULL); |
| 1283 |
else if ( !mv->vertical && rint(val+bb.maxx)!=sc->width ) { |
| 1284 |
int newwidth = rint(bb.maxx+val); |
| 1285 |
SCPreserveWidth(sc); |
| 1286 |
|
| 1287 |
|
| 1288 |
if ( newwidth!=bb.maxx+val ) { |
| 1289 |
real transform[6]; |
| 1290 |
transform[0] = transform[3] = 1.0; |
| 1291 |
transform[1] = transform[2] = transform[5] = 0; |
| 1292 |
transform[4] = newwidth-val-bb.maxx; |
| 1293 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth); |
| 1294 |
} |
| 1295 |
SCSynchronizeWidth(sc,newwidth,sc->width,NULL); |
| 1296 |
SCCharChangedUpdate(sc,ly_none); |
| 1297 |
} else if ( mv->vertical && val!=sc->vwidth-(sc->parent->ascent-bb.miny) ) { |
| 1298 |
double vw = val+(sc->parent->ascent-bb.miny); |
| 1299 |
SCPreserveWidth(sc); |
| 1300 |
sc->vwidth = rint(vw); |
| 1301 |
|
| 1302 |
|
| 1303 |
if ( sc->width!=vw ) { |
| 1304 |
real transform[6]; |
| 1305 |
transform[0] = transform[3] = 1.0; |
| 1306 |
transform[1] = transform[2] = transform[4] = 0; |
| 1307 |
transform[5] = vw-sc->vwidth; |
| 1308 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,fvt_dontmovewidth); |
| 1309 |
} |
| 1310 |
SCCharChangedUpdate(sc,ly_none); |
| 1311 |
} |
| 1312 |
} else if ( e->u.control.subtype == et_textfocuschanged && |
| 1313 |
e->u.control.u.tf_focus.gained_focus ) { |
| 1314 |
for ( i=0 ; i<mv->glyphcnt; ++i ) |
| 1315 |
if ( i!=which && mv->perchar[i].selected ) |
| 1316 |
MVDeselectChar(mv,i); |
| 1317 |
MVSelectChar(mv,which); |
| 1318 |
} |
| 1319 |
return( true ); |
| 1320 |
} |
| 1321 |
|
| 1322 |
static int AskNewKernClassEntry(SplineChar *fsc,SplineChar *lsc,int first_is_0,int second_is_0) { |
| 1323 |
char *yesno[3]; |
| 1324 |
yesno[0] = _("_Alter Class"); |
| 1325 |
yesno[1] = _("_Create Pair"); |
| 1326 |
yesno[2] = NULL; |
| 1327 |
return( gwwv_ask(_("Use Kerning Class?"),(const char **) yesno,0,1, |
| 1328 |
_("This kerning pair (%.20s and %.20s) is currently part of a kerning class with a 0 offset for this combination. Would you like to alter this kerning class entry (or create a kerning pair for just these two glyphs)?"), |
| 1329 |
first_is_0 ? _("{Everything Else}") : fsc->name, |
| 1330 |
second_is_0 ? _("{Everything Else}") : lsc->name)==0 ); |
| 1331 |
} |
| 1332 |
|
| 1333 |
|
| 1334 |
static int MV_ChangeKerning(MetricsView *mv, int which, int offset, int is_diff) { |
| 1335 |
SplineChar *sc = mv->glyphs[which].sc; |
| 1336 |
SplineChar *psc = mv->glyphs[which-1].sc; |
| 1337 |
KernPair *kp = 0; |
| 1338 |
KernClass *kc; int index; |
| 1339 |
int i; |
| 1340 |
struct lookup_subtable *sub = GGadgetGetListItemSelected(mv->subtable_list)->userdata; |
| 1341 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 1342 |
|
| 1343 |
kp = mv->glyphs[which-1].kp; |
| 1344 |
kc = mv->glyphs[which-1].kc; |
| 1345 |
index = mv->glyphs[which-1].kc_index; |
| 1346 |
|
| 1347 |
if ( kc!=NULL ) { |
| 1348 |
if ( index==-1 ) |
| 1349 |
kc = NULL; |
| 1350 |
else if ( kp != NULL && kp->off != 0 ) |
| 1351 |
kc=NULL; |
| 1352 |
else if ( (!is_diff && offset==kc->offsets[index]) || |
| 1353 |
( is_diff && offset==0)) |
| 1354 |
return( true ); |
| 1355 |
|
| 1356 |
else if ( kc->offsets[index]==0 && !AskNewKernClassEntry(psc,sc,mv->glyphs[which-1].prev_kc0,mv->glyphs[which-1].next_kc0)) |
| 1357 |
kc=NULL; |
| 1358 |
else |
| 1359 |
offset = kc->offsets[index] = is_diff ? kc->offsets[index]+offset : offset; |
| 1360 |
} |
| 1361 |
if ( kc==NULL ) { |
| 1362 |
if ( sub!=NULL && sub->kc!=NULL ) { |
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
struct lookup_subtable *s; |
| 1368 |
for ( s = sub->lookup->subtables; s!=NULL && s->kc!=NULL; s=s->next ); |
| 1369 |
sub = s; |
| 1370 |
} |
| 1371 |
if ( sub==NULL ) { |
| 1372 |
struct subtable_data sd; |
| 1373 |
memset(&sd,0,sizeof(sd)); |
| 1374 |
sd.flags = (mv->vertical ? sdf_verticalkern : sdf_horizontalkern ) | |
| 1375 |
sdf_kernclass; |
| 1376 |
sub = SFNewLookupSubtableOfType(psc->parent,gpos_pair,&sd,mv->layer); |
| 1377 |
if ( sub==NULL ) |
| 1378 |
return( false ); |
| 1379 |
mv->cur_subtable = sub; |
| 1380 |
MVSetSubtables(mv->sf); |
| 1381 |
MVSetFeatures(mv); |
| 1382 |
} |
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
if ( kp != NULL && ((!is_diff && kp->off!=offset) || ( is_diff && offset!=0)) ) { |
| 1388 |
DeviceTableFree(kp->adjust); |
| 1389 |
kp->adjust = NULL; |
| 1390 |
} |
| 1391 |
|
| 1392 |
offset = is_diff && kp != NULL ? kp->off+offset : offset; |
| 1393 |
|
| 1394 |
if ( kp != NULL && offset == 0 ) { |
| 1395 |
KernPair *kpcur, *kpprev; |
| 1396 |
KernPair **kphead = mv->vertical ? &psc->vkerns : &psc->kerns; |
| 1397 |
if ( kp == *kphead ) { |
| 1398 |
*kphead = kp->next; |
| 1399 |
} else { |
| 1400 |
kpprev = *kphead; |
| 1401 |
for ( kpcur=kpprev->next; kpcur != NULL; kpcur = kpcur->next ) { |
| 1402 |
if ( kpcur == kp ) { |
| 1403 |
kpprev->next = kp->next; |
| 1404 |
break; |
| 1405 |
} |
| 1406 |
kpprev = kpcur; |
| 1407 |
} |
| 1408 |
} |
| 1409 |
|
| 1410 |
|
| 1411 |
int i = 0; |
| 1412 |
for( i=0; mv->glyphs[i].sc; i++ ) { |
| 1413 |
if( i!=which && mv->glyphs[i].kp == kp ) { |
| 1414 |
mv->glyphs[i].kp = 0; |
| 1415 |
} |
| 1416 |
} |
| 1417 |
chunkfree( kp,sizeof(KernPair) ); |
| 1418 |
kp = mv->glyphs[which-1].kp = NULL; |
| 1419 |
} else if ( offset != 0 ) { |
| 1420 |
if ( kp==NULL ) { |
| 1421 |
kp = chunkalloc(sizeof(KernPair)); |
| 1422 |
kp->sc = sc; |
| 1423 |
if ( !mv->vertical ) { |
| 1424 |
kp->next = psc->kerns; |
| 1425 |
psc->kerns = kp; |
| 1426 |
} else { |
| 1427 |
kp->next = psc->vkerns; |
| 1428 |
psc->vkerns = kp; |
| 1429 |
} |
| 1430 |
mv->glyphs[which-1].kp = kp; |
| 1431 |
} |
| 1432 |
kp->off = offset; |
| 1433 |
kp->subtable = sub; |
| 1434 |
if ( !mv->vertical ) |
| 1435 |
MMKern(sc->parent,psc,sc,is_diff?offset:offset-kp->off,sub,kp); |
| 1436 |
} |
| 1437 |
} |
| 1438 |
int16_t newkernafter = iscale * (offset*mv->pixelsize)/ |
| 1439 |
(mv->sf->ascent+mv->sf->descent); |
| 1440 |
mv->metrics[which-1].kernafter = newkernafter; |
| 1441 |
|
| 1442 |
if ( mv->vertical ) { |
| 1443 |
for ( i=which; i<mv->glyphcnt; ++i ) { |
| 1444 |
mv->metrics[i].dy = mv->metrics[i-1].dy+mv->metrics[i-1].dheight + |
| 1445 |
mv->metrics[i-1].kernafter ; |
| 1446 |
} |
| 1447 |
} else { |
| 1448 |
for ( i=which; i<mv->glyphcnt; ++i ) { |
| 1449 |
mv->metrics[i].dx = mv->metrics[i-1].dx + mv->metrics[i-1].dwidth + |
| 1450 |
mv->metrics[i-1].kernafter; |
| 1451 |
} |
| 1452 |
} |
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
if( kc && psc && sc ) |
| 1467 |
{ |
| 1468 |
|
| 1469 |
|
| 1470 |
int pscidx = KernClassFindIndexContaining( kc->firsts, kc->first_cnt, psc->name ); |
| 1471 |
int scidx = KernClassFindIndexContaining( kc->seconds, kc->second_cnt, sc->name ); |
| 1472 |
|
| 1473 |
if( pscidx > 0 && scidx > 0 ) |
| 1474 |
{ |
| 1475 |
for ( i=1; i<mv->glyphcnt; ++i ) |
| 1476 |
{ |
| 1477 |
|
| 1478 |
if( i-1 == which ) |
| 1479 |
continue; |
| 1480 |
|
| 1481 |
|
| 1482 |
|
| 1483 |
|
| 1484 |
int pidx = KernClassFindIndexContaining( kc->firsts, |
| 1485 |
kc->first_cnt, |
| 1486 |
mv->glyphs[i-1].sc->name ); |
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
if( pidx == pscidx ) |
| 1491 |
{ |
| 1492 |
int idx = KernClassFindIndexContaining( kc->seconds, |
| 1493 |
kc->second_cnt, |
| 1494 |
mv->glyphs[ i ].sc->name ); |
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
if( scidx == idx ) |
| 1502 |
{ |
| 1503 |
|
| 1504 |
|
| 1505 |
MVRefreshValues( mv, i-1 ); |
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
mv->metrics[i-1].kernafter = newkernafter; |
| 1513 |
int j; |
| 1514 |
for ( j=i; j<mv->glyphcnt; ++j ) { |
| 1515 |
mv->metrics[j].dx = mv->metrics[j-1].dx + mv->metrics[j-1].dwidth + |
| 1516 |
mv->metrics[j-1].kernafter; |
| 1517 |
} |
| 1518 |
} |
| 1519 |
} |
| 1520 |
} |
| 1521 |
} |
| 1522 |
} |
| 1523 |
|
| 1524 |
|
| 1525 |
static int MV_ChangeKerning_Nested = 0; |
| 1526 |
int refreshOtherPairEntries = true; |
| 1527 |
if( !MV_ChangeKerning_Nested && refreshOtherPairEntries && mv->glyphs[0].sc ) |
| 1528 |
{ |
| 1529 |
int i = 1; |
| 1530 |
for( ; mv->glyphs[i].sc; i++ ) |
| 1531 |
{ |
| 1532 |
if( i != which |
| 1533 |
&& sc == mv->glyphs[i].sc |
| 1534 |
&& psc == mv->glyphs[i-1].sc ) |
| 1535 |
{ |
| 1536 |
|
| 1537 |
GGadget *g = mv->perchar[i].kern; |
| 1538 |
|
| 1539 |
MV_ChangeKerning_Nested = 1; |
| 1540 |
int which = (intptr_t) GGadgetGetUserData(g); |
| 1541 |
MV_ChangeKerning( mv, which, offset, is_diff ); |
| 1542 |
GGadgetSetTitle8( g, tostr(offset) ); |
| 1543 |
MV_ChangeKerning_Nested = 0; |
| 1544 |
} |
| 1545 |
} |
| 1546 |
} |
| 1547 |
|
| 1548 |
mv->sf->changed = true; |
| 1549 |
GDrawRequestExpose(mv->v,NULL,false); |
| 1550 |
|
| 1551 |
return( true ); |
| 1552 |
} |
| 1553 |
|
| 1554 |
static int MV_KernChanged(GGadget *g, GEvent *e) { |
| 1555 |
|
| 1556 |
|
| 1557 |
MetricsView *mv = GDrawGetUserData(GGadgetGetWindow(g)); |
| 1558 |
int which = (intptr_t) GGadgetGetUserData(g); |
| 1559 |
int i; |
| 1560 |
|
| 1561 |
if ( e->type!=et_controlevent ) |
| 1562 |
return( true ); |
| 1563 |
if ( which>mv->glyphcnt-1 || which==0 ) |
| 1564 |
return( true ); |
| 1565 |
|
| 1566 |
if ( e->u.control.subtype == et_textchanged ) { |
| 1567 |
char* title = GGadgetGetTitle8(g); |
| 1568 |
|
| 1569 |
int negatives = 0; |
| 1570 |
for (char* p = title; *p != '\0'; p++) { |
| 1571 |
if (*p == '-') negatives++; |
| 1572 |
} |
| 1573 |
|
| 1574 |
char* new = str_replace_all(title, "-", "", true); |
| 1575 |
int val = strtol(new,NULL,10); |
| 1576 |
free(new); |
| 1577 |
|
| 1578 |
if (negatives%2==1) { |
| 1579 |
val *= -1; |
| 1580 |
} |
| 1581 |
|
| 1582 |
MV_ChangeKerning(mv,which,val, false); |
| 1583 |
MVRemetric(mv); |
| 1584 |
} else if ( e->u.control.subtype == et_textfocuschanged && |
| 1585 |
e->u.control.u.tf_focus.gained_focus ) { |
| 1586 |
for ( i=0 ; i<mv->glyphcnt; ++i ) |
| 1587 |
if ( i!=which && mv->perchar[i].selected ) |
| 1588 |
MVDeselectChar(mv,i); |
| 1589 |
MVSelectChar(mv,which); |
| 1590 |
} |
| 1591 |
|
| 1592 |
return( true ); |
| 1593 |
} |
| 1594 |
|
| 1595 |
static void MVToggleVertical(MetricsView *mv) { |
| 1596 |
int size; |
| 1597 |
|
| 1598 |
mv->vertical = !mv->vertical; |
| 1599 |
|
| 1600 |
GGadgetSetTitle8( mv->widthlab, mv->vertical ? "Height:" : "Width:" ); |
| 1601 |
GGadgetSetTitle8( mv->lbearinglab, mv->vertical ? "TBearing:" : "LBearing:" ); |
| 1602 |
GGadgetSetTitle8( mv->rbearinglab, mv->vertical ? "BBearing:" : "RBearing:" ); |
| 1603 |
GGadgetSetTitle8( mv->kernlab, mv->vertical ? "VKern:" : "Kern:" ); |
| 1604 |
|
| 1605 |
if ( mv->vertical ) |
| 1606 |
if ( mv->scale_index<4 ) mv->scale_index = 4; |
| 1607 |
|
| 1608 |
if ( mv->pixelsize_set_by_window ) { |
| 1609 |
size = (mv->displayend - mv->topend - 4); |
| 1610 |
if ( mv->dwidth-20<size ) |
| 1611 |
size = mv->dwidth-20; |
| 1612 |
size *= mv_scales[mv->scale_index]; |
| 1613 |
if ( mv->pixelsize != size ) { |
| 1614 |
mv->pixelsize = size; |
| 1615 |
mv->dpi = 72; |
| 1616 |
if ( mv->bdf==NULL ) { |
| 1617 |
BDFFontFree(mv->show); |
| 1618 |
mv->show = SplineFontPieceMeal(mv->sf,mv->layer,mv->pixelsize,72, |
| 1619 |
MVGetSplineFontPieceMealFlags( mv ), NULL ); |
| 1620 |
} |
| 1621 |
} |
| 1622 |
} |
| 1623 |
MVRemetric(mv); |
| 1624 |
} |
| 1625 |
|
| 1626 |
static SplineChar *MVSCFromUnicode(MetricsView *mv, SplineFont *sf, EncMap *map, int ch,BDFFont *bdf) { |
| 1627 |
int i; |
| 1628 |
SplineChar *sc; |
| 1629 |
|
| 1630 |
if ( ch>=FAKE_UNICODE_BASE && ch<FAKE_UNICODE_BASE+mv->sf->glyphcnt ) |
| 1631 |
return( mv->sf->glyphs[ch-FAKE_UNICODE_BASE] ); |
| 1632 |
|
| 1633 |
i = SFFindSlot(sf,map,ch,NULL); |
| 1634 |
if ( i==-1 ) |
| 1635 |
return( NULL ); |
| 1636 |
else { |
| 1637 |
sc = SFMakeChar(sf,map,i); |
| 1638 |
if ( bdf!=NULL ) |
| 1639 |
BDFMakeChar(bdf,map,i); |
| 1640 |
} |
| 1641 |
return( sc ); |
| 1642 |
} |
| 1643 |
|
| 1644 |
static void MVMoveFieldsBy(MetricsView *mv,int diff) { |
| 1645 |
int i; |
| 1646 |
int y,x; |
| 1647 |
|
| 1648 |
for ( i=0; i<mv->max && mv->perchar[i].width!=NULL; ++i ) { |
| 1649 |
y = mv->displayend+2; |
| 1650 |
x = mv->perchar[i].mx-diff; |
| 1651 |
if ( x<mv->mbase+mv->mwidth ) x = -2*mv->mwidth; |
| 1652 |
GGadgetMove(mv->perchar[i].name,x,y); |
| 1653 |
y += mv->fh+4; |
| 1654 |
GGadgetMove(mv->perchar[i].width,x,y); |
| 1655 |
y += mv->fh+4; |
| 1656 |
GGadgetMove(mv->perchar[i].lbearing,x,y); |
| 1657 |
y += mv->fh+4; |
| 1658 |
GGadgetMove(mv->perchar[i].rbearing,x,y); |
| 1659 |
y += mv->fh+4; |
| 1660 |
if ( i!=0 ) |
| 1661 |
GGadgetMove(mv->perchar[i].kern,x-mv->mwidth/2,y); |
| 1662 |
} |
| 1663 |
} |
| 1664 |
|
| 1665 |
static int MVDisplayedCnt(MetricsView *mv) { |
| 1666 |
int i, wid = mv->mbase; |
| 1667 |
|
| 1668 |
for ( i=mv->coff; i<mv->glyphcnt; ++i ) { |
| 1669 |
wid += mv->metrics[i].dwidth; |
| 1670 |
if ( wid>mv->dwidth ) |
| 1671 |
return( i-mv->coff ); |
| 1672 |
} |
| 1673 |
return( i-mv->coff ); |
| 1674 |
} |
| 1675 |
|
| 1676 |
static void MVSetSb(MetricsView *mv) { |
| 1677 |
int cnt = (mv->dwidth-mv->mbase-mv->mwidth)/mv->mwidth; |
| 1678 |
int dcnt = MVDisplayedCnt(mv); |
| 1679 |
|
| 1680 |
if ( cnt>dcnt ) cnt = dcnt; |
| 1681 |
if ( cnt==0 ) cnt = 1; |
| 1682 |
|
| 1683 |
GScrollBarSetBounds(mv->hsb,0,mv->glyphcnt,cnt); |
| 1684 |
GScrollBarSetPos(mv->hsb,mv->coff); |
| 1685 |
} |
| 1686 |
|
| 1687 |
static int MVSetVSb(MetricsView *mv) { |
| 1688 |
int max, min, ret, yoff; |
| 1689 |
int fudge; |
| 1690 |
|
| 1691 |
if ( mv->displayend==0 ) |
| 1692 |
return(0); |
| 1693 |
|
| 1694 |
if ( mv->vertical ) { |
| 1695 |
min = max = 0; |
| 1696 |
if ( mv->glyphcnt!=0 ) |
| 1697 |
max = mv->metrics[mv->glyphcnt-1].dy + mv->metrics[mv->glyphcnt-1].dheight; |
| 1698 |
fudge = 10; |
| 1699 |
} else { |
| 1700 |
SplineFont *sf = mv->sf; |
| 1701 |
int pixels = mv->pixelsize_set_by_window ? mv->vheight : mv->pixelsize; |
| 1702 |
fudge = pixels/4; |
| 1703 |
min = -(pixels*sf->descent)/(sf->ascent+sf->descent); |
| 1704 |
max = pixels + min; |
| 1705 |
min *= mv_scales[mv->scale_index]; |
| 1706 |
max *= mv_scales[mv->scale_index]; |
| 1707 |
} |
| 1708 |
mv->ybaseline = max; |
| 1709 |
max += fudge*mv_scales[mv->scale_index] + mv->vheight; |
| 1710 |
min -= fudge*mv_scales[mv->scale_index]; |
| 1711 |
GScrollBarSetBounds(mv->vsb,min,max,mv->vheight); |
| 1712 |
yoff = mv->yoff; |
| 1713 |
if ( yoff+mv->vheight > max ) |
| 1714 |
yoff = max - mv->vheight; |
| 1715 |
if ( yoff<min ) yoff = min; |
| 1716 |
ret = yoff!=mv->yoff; |
| 1717 |
mv->yoff = yoff; |
| 1718 |
GScrollBarSetPos(mv->vsb,yoff); |
| 1719 |
return( ret ); |
| 1720 |
} |
| 1721 |
|
| 1722 |
static void MVHScroll(MetricsView *mv,struct sbevent *sb) { |
| 1723 |
int newpos = mv->coff; |
| 1724 |
int cnt = (mv->dwidth-mv->mbase-mv->mwidth)/mv->mwidth; |
| 1725 |
int dcnt = MVDisplayedCnt(mv); |
| 1726 |
|
| 1727 |
if ( cnt>dcnt ) cnt = dcnt; |
| 1728 |
if ( cnt==0 ) cnt = 1; |
| 1729 |
|
| 1730 |
switch( sb->type ) { |
| 1731 |
case et_sb_top: |
| 1732 |
newpos = 0; |
| 1733 |
break; |
| 1734 |
case et_sb_uppage: |
| 1735 |
newpos -= cnt; |
| 1736 |
break; |
| 1737 |
case et_sb_up: |
| 1738 |
--newpos; |
| 1739 |
break; |
| 1740 |
case et_sb_down: |
| 1741 |
++newpos; |
| 1742 |
break; |
| 1743 |
case et_sb_downpage: |
| 1744 |
newpos += cnt; |
| 1745 |
break; |
| 1746 |
case et_sb_bottom: |
| 1747 |
newpos = mv->glyphcnt-cnt; |
| 1748 |
break; |
| 1749 |
case et_sb_thumb: |
| 1750 |
case et_sb_thumbrelease: |
| 1751 |
newpos = sb->pos; |
| 1752 |
break; |
| 1753 |
case et_sb_halfup: case et_sb_halfdown: break; |
| 1754 |
} |
| 1755 |
if ( newpos>mv->glyphcnt-cnt ) |
| 1756 |
newpos = mv->glyphcnt-cnt; |
| 1757 |
if ( newpos<0 ) newpos =0; |
| 1758 |
if ( newpos!=mv->coff ) { |
| 1759 |
int old = mv->coff; |
| 1760 |
int diff = newpos-mv->coff; |
| 1761 |
int charsize = mv->metrics[newpos].dx-mv->metrics[old].dx; |
| 1762 |
GRect fieldrect, charrect; |
| 1763 |
|
| 1764 |
mv->coff = newpos; |
| 1765 |
charrect.x = 0; charrect.width = mv->vwidth; |
| 1766 |
charrect.y = 0; charrect.height = mv->vheight; |
| 1767 |
fieldrect.x = mv->mbase+mv->mwidth; fieldrect.width = mv->width-mv->mbase; |
| 1768 |
fieldrect.y = mv->displayend; fieldrect.height = mv->height-mv->sbh-mv->displayend; |
| 1769 |
GScrollBarSetBounds(mv->hsb,0,mv->glyphcnt,cnt); |
| 1770 |
GScrollBarSetPos(mv->hsb,mv->coff); |
| 1771 |
MVMoveFieldsBy(mv,newpos*mv->mwidth); |
| 1772 |
GDrawScroll(mv->gw,&fieldrect,-diff*mv->mwidth,0); |
| 1773 |
mv->xoff = mv->metrics[newpos].dx-mv->metrics[0].dx; |
| 1774 |
if ( mv->right_to_left ) { |
| 1775 |
charsize = -charsize; |
| 1776 |
} |
| 1777 |
GDrawScroll(mv->v,&charrect,-charsize,0); |
| 1778 |
} |
| 1779 |
} |
| 1780 |
|
| 1781 |
static void MVVScroll(MetricsView *mv,struct sbevent *sb) { |
| 1782 |
int newpos = mv->yoff; |
| 1783 |
int32_t min, max, page; |
| 1784 |
|
| 1785 |
GScrollBarGetBounds(mv->vsb,&min,&max,&page); |
| 1786 |
switch( sb->type ) { |
| 1787 |
case et_sb_top: |
| 1788 |
newpos = 0; |
| 1789 |
break; |
| 1790 |
case et_sb_uppage: |
| 1791 |
newpos -= page; |
| 1792 |
break; |
| 1793 |
case et_sb_up: |
| 1794 |
newpos -= (page)/15; |
| 1795 |
break; |
| 1796 |
case et_sb_down: |
| 1797 |
newpos += (page)/15; |
| 1798 |
break; |
| 1799 |
case et_sb_downpage: |
| 1800 |
newpos += page; |
| 1801 |
break; |
| 1802 |
case et_sb_bottom: |
| 1803 |
newpos = max-page; |
| 1804 |
break; |
| 1805 |
case et_sb_thumb: |
| 1806 |
case et_sb_thumbrelease: |
| 1807 |
newpos = sb->pos; |
| 1808 |
break; |
| 1809 |
case et_sb_halfup: case et_sb_halfdown: break; |
| 1810 |
} |
| 1811 |
if ( newpos>max-page ) |
| 1812 |
newpos = max-page; |
| 1813 |
if ( newpos<min ) newpos = min; |
| 1814 |
if ( newpos!=mv->yoff ) { |
| 1815 |
int diff = newpos-mv->yoff; |
| 1816 |
GRect charrect; |
| 1817 |
|
| 1818 |
mv->yoff = newpos; |
| 1819 |
charrect.x = 0; charrect.width = mv->vwidth; |
| 1820 |
charrect.y = 0; charrect.height = mv->vheight; |
| 1821 |
GScrollBarSetPos(mv->vsb,mv->yoff); |
| 1822 |
GDrawScroll(mv->v,&charrect,0,diff); |
| 1823 |
} |
| 1824 |
} |
| 1825 |
|
| 1826 |
static int MVFakeUnicodeOfSc(MetricsView *mv, SplineChar *sc) { |
| 1827 |
if (sc->unicodeenc != -1) |
| 1828 |
return sc->unicodeenc; |
| 1829 |
else |
| 1830 |
return FAKE_UNICODE_BASE + sc->orig_pos; |
| 1831 |
} |
| 1832 |
|
| 1833 |
static int MVOddMatch(MetricsView *mv,int uni,SplineChar *sc) { |
| 1834 |
if ( sc->unicodeenc!=-1 ) |
| 1835 |
return( false ); |
| 1836 |
else |
| 1837 |
return( uni>=FAKE_UNICODE_BASE && sc->orig_pos == uni-FAKE_UNICODE_BASE ); |
| 1838 |
} |
| 1839 |
|
| 1840 |
void MVSetSCs(MetricsView *mv, SplineChar **scs) { |
| 1841 |
|
| 1842 |
int len; |
| 1843 |
unichar_t *ustr; |
| 1844 |
|
| 1845 |
for ( len=0; scs[len]!=NULL; ++len ); |
| 1846 |
if ( len>=mv->cmax ) |
| 1847 |
mv->chars = realloc(mv->chars,(mv->cmax=len+10)*sizeof(SplineChar *)); |
| 1848 |
memcpy(mv->chars,scs,(len+1)*sizeof(SplineChar *)); |
| 1849 |
mv->clen = len; |
| 1850 |
|
| 1851 |
ustr = malloc((len+1)*sizeof(unichar_t)); |
| 1852 |
for ( len=0; scs[len]!=NULL; ++len ) |
| 1853 |
if ( scs[len]->unicodeenc>0 ) |
| 1854 |
ustr[len] = scs[len]->unicodeenc; |
| 1855 |
else |
| 1856 |
ustr[len] = MVFakeUnicodeOfSc(mv,scs[len]); |
| 1857 |
ustr[len] = 0; |
| 1858 |
GGadgetSetTitle(mv->text,ustr); |
| 1859 |
free(ustr); |
| 1860 |
|
| 1861 |
MVRemetric(mv); |
| 1862 |
|
| 1863 |
GDrawRequestExpose(mv->v,NULL,false); |
| 1864 |
} |
| 1865 |
|
| 1866 |
|
| 1867 |
static int WordlistEscapedInputStringToRealString_getFakeUnicodeAs_MVFakeUnicodeOfSc( SplineChar *sc, void* udata ) |
| 1868 |
{ |
| 1869 |
MetricsView *mv = (MetricsView *)udata; |
| 1870 |
int n = MVFakeUnicodeOfSc( mv, sc ); |
| 1871 |
return n; |
| 1872 |
} |
| 1873 |
|
| 1874 |
|
| 1875 |
static void MVTextChanged(MetricsView *mv) { |
| 1876 |
const unichar_t *ret = 0, *pt, *ept, *tpt; |
| 1877 |
int i,ei, j, start=0, end=0; |
| 1878 |
int missing; |
| 1879 |
SplineChar **hold = NULL; |
| 1880 |
|
| 1881 |
ret = _GGadgetGetTitle(mv->text); |
| 1882 |
|
| 1883 |
|
| 1884 |
|
| 1885 |
WordListLine wll = WordlistEscapedInputStringToParsedDataComplex( |
| 1886 |
mv->sf, _GGadgetGetTitle(mv->text), |
| 1887 |
WordlistEscapedInputStringToRealString_getFakeUnicodeAs_MVFakeUnicodeOfSc, mv ); |
| 1888 |
ret = WordListLine_toustr( wll ); |
| 1889 |
|
| 1890 |
if (( isrighttoleft(ret[0]) && !mv->right_to_left ) || |
| 1891 |
( !isrighttoleft(ret[0]) && mv->right_to_left )) { |
| 1892 |
mv->right_to_left = !mv->right_to_left; |
| 1893 |
} |
| 1894 |
for ( pt=ret, i=0; i<mv->clen && *pt!='\0'; ++i, ++pt ) |
| 1895 |
if ( *pt!=mv->chars[i]->unicodeenc && |
| 1896 |
!MVOddMatch(mv,*pt,mv->chars[i])) |
| 1897 |
break; |
| 1898 |
if ( i==mv->clen && *pt=='\0' ) |
| 1899 |
return; |
| 1900 |
for ( ept=ret+u_strlen(ret)-1, ei=mv->clen-1; ; --ei, --ept ) |
| 1901 |
if ( ei<0 || ept<ret || (*ept!=mv->chars[ei]->unicodeenc && |
| 1902 |
!MVOddMatch(mv,*ept,mv->chars[ei]))) { |
| 1903 |
++ei; ++ept; |
| 1904 |
break; |
| 1905 |
} else if ( ei<i || ept<pt ) { |
| 1906 |
++ei; ++ept; |
| 1907 |
break; |
| 1908 |
} |
| 1909 |
if ( ei==i && ept==pt ) |
| 1910 |
IError("No change when there should have been one in MV_TextChanged"); |
| 1911 |
if ( u_strlen(ret)>=mv->cmax ) { |
| 1912 |
int oldmax=mv->cmax; |
| 1913 |
mv->cmax = u_strlen(ret)+10; |
| 1914 |
mv->chars = realloc(mv->chars,mv->cmax*sizeof(SplineChar *)); |
| 1915 |
memset(mv->chars+oldmax,'\0',(mv->cmax-oldmax)*sizeof(SplineChar *)); |
| 1916 |
} |
| 1917 |
|
| 1918 |
missing = 0; |
| 1919 |
for ( tpt=pt; tpt<ept; ++tpt ) |
| 1920 |
if ( *tpt>=FAKE_UNICODE_BASE && *tpt<FAKE_UNICODE_BASE+mv->sf->glyphcnt ) |
| 1921 |
; |
| 1922 |
else if ( SFFindSlot(mv->sf,mv->fv->b.map,*tpt,NULL)==-1 ) |
| 1923 |
++missing; |
| 1924 |
|
| 1925 |
if ( ept-pt-missing > ei-i ) { |
| 1926 |
if ( i<mv->clen ) { |
| 1927 |
int diff = (ept-pt-missing) - (ei-i); |
| 1928 |
hold = malloc((mv->clen+diff+6)*sizeof(SplineChar *)); |
| 1929 |
for ( j=mv->clen-1; j>=ei; --j ) |
| 1930 |
hold[j+diff] = mv->chars[j]; |
| 1931 |
start = ei+diff; end = mv->clen+diff; |
| 1932 |
} |
| 1933 |
} else if ( ept-pt-missing != ei-i ) { |
| 1934 |
int diff = (ept-pt-missing) - (ei-i); |
| 1935 |
for ( j=ei; j<mv->clen; ++j ) |
| 1936 |
if ( j+diff>=0 ) |
| 1937 |
mv->chars[j+diff] = mv->chars[j]; |
| 1938 |
} |
| 1939 |
for ( j=i; pt<ept; ++pt ) { |
| 1940 |
SplineChar *sc; |
| 1941 |
sc = MVSCFromUnicode(mv,mv->sf,mv->fv->b.map,*pt,mv->bdf); |
| 1942 |
if ( sc!=NULL ) |
| 1943 |
mv->chars[j++] = sc; |
| 1944 |
} |
| 1945 |
if ( hold!=NULL ) { |
| 1946 |
|
| 1947 |
|
| 1948 |
|
| 1949 |
for ( j=start; j<end; ++j ) |
| 1950 |
mv->chars[j] = hold[j]; |
| 1951 |
free(hold); |
| 1952 |
} |
| 1953 |
mv->clen = u_strlen(ret)-missing; |
| 1954 |
mv->chars[mv->clen] = NULL; |
| 1955 |
MVRemetric(mv); |
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
|
| 1961 |
GTextInfo* gt = GGadgetGetListItemSelected(mv->text); |
| 1962 |
if( !gt ) |
| 1963 |
{ |
| 1964 |
GTextInfo **ti=NULL; |
| 1965 |
int32_t len; |
| 1966 |
ti = GGadgetGetList(mv->text,&len); |
| 1967 |
if( len ) |
| 1968 |
gt = ti[0]; |
| 1969 |
} |
| 1970 |
|
| 1971 |
selectUserChosenWordListGlyphs( mv, wll ); |
| 1972 |
GDrawRequestExpose(mv->v,NULL,false); |
| 1973 |
} |
| 1974 |
|
| 1975 |
GTextInfo mv_text_init[] = { |
| 1976 |
{ (unichar_t *) "", NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 1, 0, 1, 0, 0, '\0'}, |
| 1977 |
{ NULL, NULL, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 1, 0, 0, 0, '\0'}, |
| 1978 |
{ (unichar_t *) N_("Load Word List..."), NULL, 0, 0, (void *) -1, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'}, |
| 1979 |
{ (unichar_t *) N_("Load Glyph Name List..."), NULL, 0, 0, (void *) -2, NULL, 0, 0, 0, 0, 0, 0, 1, 0, 0, '\0'}, |
| 1980 |
GTEXTINFO_EMPTY |
| 1981 |
}; |
| 1982 |
|
| 1983 |
static void MVFigureGlyphNames(MetricsView *mv,const unichar_t *names) { |
| 1984 |
char buffer[400], *pt, *start; |
| 1985 |
SplineChar *founds[40]; |
| 1986 |
int i,cnt,ch; |
| 1987 |
unichar_t *newtext; |
| 1988 |
|
| 1989 |
u2utf8_strcpy(buffer,names); |
| 1990 |
start = buffer; |
| 1991 |
for ( i=0; *start; ) { |
| 1992 |
while ( *start==' ' ) ++start; |
| 1993 |
if ( *start=='\0' ) |
| 1994 |
break; |
| 1995 |
for ( pt=start; *pt && *pt!=' '; ++pt ); |
| 1996 |
ch = *pt; *pt = '\0'; |
| 1997 |
if ( i>=40 ) |
| 1998 |
break; |
| 1999 |
if ( (founds[i]=SFGetChar(mv->sf,-1,start))!=NULL ) |
| 2000 |
++i; |
| 2001 |
*pt = ch; |
| 2002 |
start = pt; |
| 2003 |
} |
| 2004 |
cnt = i; |
| 2005 |
|
| 2006 |
if ( cnt>=mv->cmax ) { |
| 2007 |
mv->cmax = mv->clen+cnt+10; |
| 2008 |
mv->chars = realloc(mv->chars,mv->cmax*sizeof(SplineChar *)); |
| 2009 |
} |
| 2010 |
newtext = malloc((cnt+1)*sizeof(unichar_t)); |
| 2011 |
for ( i=0; i<cnt; ++i ) { |
| 2012 |
newtext[i] = founds[i]->unicodeenc==-1 ? |
| 2013 |
MVFakeUnicodeOfSc(mv,founds[i]) : |
| 2014 |
founds[i]->unicodeenc; |
| 2015 |
mv->chars[i] = founds[i]; |
| 2016 |
} |
| 2017 |
newtext[i] = 0; |
| 2018 |
mv->chars[i] = NULL; |
| 2019 |
mv->clen = cnt; |
| 2020 |
MVRemetric(mv); |
| 2021 |
|
| 2022 |
GGadgetSetTitle(mv->text,newtext); |
| 2023 |
free(newtext); |
| 2024 |
|
| 2025 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2026 |
} |
| 2027 |
|
| 2028 |
static void MVLoadWordList(MetricsView *mv, int type) { |
| 2029 |
int words_max = 1024*128; |
| 2030 |
GTextInfo** words = WordlistLoadFileToGTextInfo( type, words_max ); |
| 2031 |
if ( !words ) { |
| 2032 |
GGadgetSetTitle8(mv->text,""); |
| 2033 |
return; |
| 2034 |
} |
| 2035 |
|
| 2036 |
if ( words[0] ) { |
| 2037 |
GGadgetSetList(mv->text,words,true); |
| 2038 |
GGadgetSetTitle8(mv->text,(char *) (words[0]->text)); |
| 2039 |
if ( type==-2 ) |
| 2040 |
MVFigureGlyphNames(mv,_GGadgetGetTitle(mv->text)+1); |
| 2041 |
mv->word_index = 0; |
| 2042 |
} |
| 2043 |
GTextInfoArrayFree(words); |
| 2044 |
} |
| 2045 |
|
| 2046 |
static int MV_TextChanged(GGadget *g, GEvent *e) { |
| 2047 |
|
| 2048 |
if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) { |
| 2049 |
MetricsView *mv = GGadgetGetUserData(g); |
| 2050 |
int pos = e->u.control.u.tf_changed.from_pulldown; |
| 2051 |
if ( pos!=-1 ) { |
| 2052 |
int32_t len; |
| 2053 |
GTextInfo **ti = GGadgetGetList(g,&len); |
| 2054 |
GTextInfo *cur = ti[pos]; |
| 2055 |
int type = (intptr_t) cur->userdata; |
| 2056 |
if ( type < 0 ) |
| 2057 |
MVLoadWordList(mv,type); |
| 2058 |
else if ( cur->text!=NULL ) { |
| 2059 |
mv->word_index = pos; |
| 2060 |
if ( cur->text[0]==0x200b ) |
| 2061 |
MVFigureGlyphNames(mv,cur->text+1); |
| 2062 |
} |
| 2063 |
} |
| 2064 |
MVTextChanged(mv); |
| 2065 |
} |
| 2066 |
return( true ); |
| 2067 |
} |
| 2068 |
|
| 2069 |
static int MV_ScriptLangChanged(GGadget *g, GEvent *e) { |
| 2070 |
|
| 2071 |
if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) { |
| 2072 |
const unichar_t *sstr = _GGadgetGetTitle(g); |
| 2073 |
MetricsView *mv = GGadgetGetUserData(g); |
| 2074 |
if ( e->u.control.u.tf_changed.from_pulldown!=-1 ) { |
| 2075 |
GGadgetSetTitle8(g,mv->scriptlangs[e->u.control.u.tf_changed.from_pulldown].userdata ); |
| 2076 |
sstr = _GGadgetGetTitle(g); |
| 2077 |
} else { |
| 2078 |
if ( u_strlen(sstr)<4 || !isalpha(sstr[0]) || !isalnum(sstr[1]) ) |
| 2079 |
return( true ); |
| 2080 |
if ( u_strlen(sstr)==4 ) |
| 2081 |
; |
| 2082 |
else if ( u_strlen(sstr)!=10 || sstr[4]!='{' || sstr[9]!='}' || |
| 2083 |
!isalpha(sstr[5]) || !isalpha(sstr[6]) || !isalpha(sstr[7]) ) |
| 2084 |
return( true ); |
| 2085 |
} |
| 2086 |
MVSetFeatures(mv); |
| 2087 |
if ( mv->clen!=0 ) |
| 2088 |
MVRemetric(mv); |
| 2089 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2090 |
} |
| 2091 |
return( true ); |
| 2092 |
} |
| 2093 |
|
| 2094 |
static int MV_FeaturesChanged(GGadget *g, GEvent *e) { |
| 2095 |
|
| 2096 |
if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) { |
| 2097 |
MetricsView *mv = GGadgetGetUserData(g); |
| 2098 |
MVRemetric(mv); |
| 2099 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2100 |
} |
| 2101 |
return( true ); |
| 2102 |
} |
| 2103 |
|
| 2104 |
void MV_FriendlyFeatures(GGadget *g, int pos) { |
| 2105 |
int32_t len; |
| 2106 |
GTextInfo **ti = GGadgetGetList(g,&len); |
| 2107 |
|
| 2108 |
if ( pos<0 || pos>=len ) |
| 2109 |
GGadgetEndPopup(); |
| 2110 |
else { |
| 2111 |
const unichar_t *pt = ti[pos]->text; |
| 2112 |
uint32_t tag; |
| 2113 |
int i; |
| 2114 |
tag = (pt[0]<<24) | (pt[1]<<16) | (pt[2]<<8) | pt[3]; |
| 2115 |
LookupUIInit(); |
| 2116 |
for ( i=0; friendlies[i].friendlyname!=NULL; ++i ) |
| 2117 |
if ( friendlies[i].tag==tag ) |
| 2118 |
break; |
| 2119 |
if ( friendlies[i].friendlyname!=NULL ) |
| 2120 |
GGadgetPreparePopup8(GGadgetGetWindow(g),friendlies[i].friendlyname); |
| 2121 |
} |
| 2122 |
} |
| 2123 |
|
| 2124 |
static int MV_SubtableChanged(GGadget *g, GEvent *e) { |
| 2125 |
|
| 2126 |
if ( e->type==et_controlevent && e->u.control.subtype == et_listselected ) { |
| 2127 |
MetricsView *mv = GGadgetGetUserData(g); |
| 2128 |
int32_t len; |
| 2129 |
GTextInfo **ti = GGadgetGetList(g,&len); |
| 2130 |
int i; |
| 2131 |
KernPair *kp; |
| 2132 |
struct lookup_subtable *sub; |
| 2133 |
SplineFont *sf = mv->sf; |
| 2134 |
|
| 2135 |
if ( sf->cidmaster!=NULL ) sf = sf->cidmaster; |
| 2136 |
|
| 2137 |
if ( ti[len-1]->selected ) { |
| 2138 |
struct subtable_data sd; |
| 2139 |
memset(&sd,0,sizeof(sd)); |
| 2140 |
sd.flags = (mv->vertical ? sdf_verticalkern : sdf_horizontalkern ) | |
| 2141 |
sdf_kernpair | sdf_dontedit; |
| 2142 |
sub = SFNewLookupSubtableOfType(sf,gpos_pair,&sd,mv->layer); |
| 2143 |
if ( sub==NULL ) |
| 2144 |
return( true ); |
| 2145 |
mv->cur_subtable = sub; |
| 2146 |
MVSetSubtables(mv->sf); |
| 2147 |
MVSetFeatures(mv); |
| 2148 |
} else if ( ti[len-2]->selected ) { |
| 2149 |
MVSetSubtables(mv->sf); |
| 2150 |
sub = mv->cur_subtable; |
| 2151 |
} else |
| 2152 |
mv->cur_subtable = GGadgetGetListItemSelected(mv->subtable_list)->userdata; |
| 2153 |
|
| 2154 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 2155 |
if ( mv->perchar[i].selected ) |
| 2156 |
break; |
| 2157 |
} |
| 2158 |
kp = mv->glyphs[i].kp; |
| 2159 |
if ( kp!=NULL ) |
| 2160 |
kp->subtable = mv->cur_subtable; |
| 2161 |
} |
| 2162 |
return( true ); |
| 2163 |
} |
| 2164 |
|
| 2165 |
static void MVMenuOpen(GWindow gw, struct gmenuitem *mi, GEvent *g) { |
| 2166 |
MetricsView *d = (MetricsView*)GDrawGetUserData(gw); |
| 2167 |
FontView *fv = NULL; |
| 2168 |
if (d) { |
| 2169 |
fv = (FontView*)d->fv; |
| 2170 |
} |
| 2171 |
_FVMenuOpen(fv); |
| 2172 |
} |
| 2173 |
|
| 2174 |
static void MVMenuClose(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2175 |
GDrawDestroyWindow(gw); |
| 2176 |
} |
| 2177 |
|
| 2178 |
static void MVMenuOpenBitmap(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2179 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2180 |
EncMap *map; |
| 2181 |
int i; |
| 2182 |
|
| 2183 |
if ( mv->sf->bitmaps==NULL ) |
| 2184 |
return; |
| 2185 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 2186 |
if ( mv->perchar[i].selected ) |
| 2187 |
break; |
| 2188 |
map = mv->fv->b.map; |
| 2189 |
if ( i!=mv->glyphcnt ) |
| 2190 |
BitmapViewCreatePick(map->backmap[mv->glyphs[i].sc->orig_pos],mv->fv); |
| 2191 |
} |
| 2192 |
|
| 2193 |
static void MVMenuMergeKern(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2194 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2195 |
MergeKernInfo(mv->sf,mv->fv->b.map); |
| 2196 |
} |
| 2197 |
|
| 2198 |
static void MVMenuAddWordList(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) |
| 2199 |
{ |
| 2200 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2201 |
MVLoadWordList(mv,-1); |
| 2202 |
GWidgetIndicateFocusGadget( mv->text ); |
| 2203 |
|
| 2204 |
GEvent e; |
| 2205 |
e.type = et_controlevent; |
| 2206 |
e.u.control.subtype = et_textchanged; |
| 2207 |
e.u.control.u.tf_changed.from_pulldown = 0; |
| 2208 |
MV_TextChanged(mv->text, &e ); |
| 2209 |
} |
| 2210 |
|
| 2211 |
|
| 2212 |
static void MVMenuOpenOutline(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2213 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2214 |
int i; |
| 2215 |
|
| 2216 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 2217 |
if ( mv->perchar[i].selected ) |
| 2218 |
break; |
| 2219 |
if ( i!=mv->glyphcnt ) |
| 2220 |
CharViewCreate(mv->glyphs[i].sc, mv->fv, -1); |
| 2221 |
} |
| 2222 |
|
| 2223 |
static void MVMenuSave(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2224 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2225 |
_FVMenuSave(mv->fv); |
| 2226 |
} |
| 2227 |
|
| 2228 |
static void MVMenuSaveAs(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2229 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2230 |
_FVMenuSaveAs(mv->fv); |
| 2231 |
} |
| 2232 |
|
| 2233 |
static void MVMenuGenerate(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2234 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2235 |
_FVMenuGenerate(mv->fv, false); |
| 2236 |
} |
| 2237 |
|
| 2238 |
static void MVMenuGenerateFamily(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2239 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2240 |
_FVMenuGenerate(mv->fv, gf_macfamily); |
| 2241 |
} |
| 2242 |
|
| 2243 |
static void MVMenuGenerateTTC(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2244 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2245 |
_FVMenuGenerate(mv->fv, gf_ttc); |
| 2246 |
} |
| 2247 |
|
| 2248 |
static void MVMenuPrint(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2249 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2250 |
PrintFFDlg(NULL, NULL, mv); |
| 2251 |
} |
| 2252 |
|
| 2253 |
static void MVUndo(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2254 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2255 |
int i; |
| 2256 |
|
| 2257 |
if ( GGadgetActiveGadgetEditCmd(mv->gw,ec_undo) ) |
| 2258 |
; |
| 2259 |
else { |
| 2260 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2261 |
if ( mv->perchar[i].selected ) |
| 2262 |
break; |
| 2263 |
if ( i==-1 ) |
| 2264 |
return; |
| 2265 |
if ( mv->glyphs[i].sc->layers[mv->layer].undoes!=NULL ) |
| 2266 |
SCDoUndo(mv->glyphs[i].sc, mv->layer); |
| 2267 |
} |
| 2268 |
} |
| 2269 |
|
| 2270 |
static void MVRedo(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2271 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2272 |
int i; |
| 2273 |
|
| 2274 |
if ( GGadgetActiveGadgetEditCmd(mv->gw,ec_redo) ) |
| 2275 |
; |
| 2276 |
else { |
| 2277 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2278 |
if ( mv->perchar[i].selected ) |
| 2279 |
break; |
| 2280 |
if ( i==-1 ) |
| 2281 |
return; |
| 2282 |
if ( mv->glyphs[i].sc->layers[mv->layer].redoes!=NULL ) |
| 2283 |
SCDoRedo(mv->glyphs[i].sc, mv->layer); |
| 2284 |
} |
| 2285 |
} |
| 2286 |
|
| 2287 |
static void MVClear(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2288 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2289 |
int i; |
| 2290 |
SplineChar *sc; |
| 2291 |
BDFFont *bdf; |
| 2292 |
extern int onlycopydisplayed; |
| 2293 |
|
| 2294 |
if ( GGadgetActiveGadgetEditCmd(mv->gw, ec_clear) ) |
| 2295 |
; |
| 2296 |
else { |
| 2297 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2298 |
if ( mv->perchar[i].selected ) |
| 2299 |
break; |
| 2300 |
if ( i==-1 ) |
| 2301 |
return; |
| 2302 |
sc = mv->glyphs[i].sc; |
| 2303 |
if ( sc->dependents!=NULL ) { |
| 2304 |
int yes; |
| 2305 |
char *buts[4]; |
| 2306 |
buts[1] = _("_Unlink"); |
| 2307 |
buts[0] = _("_Yes"); |
| 2308 |
buts[2] = _("_Cancel"); |
| 2309 |
buts[3] = NULL; |
| 2310 |
yes = gwwv_ask(_("Bad Reference"), (const char **) buts, 1, 2, _("You are attempting to clear %.30s which is referred to by\nanother character. Are you sure you want to clear it?"), sc->name); |
| 2311 |
if ( yes==2 ) |
| 2312 |
return; |
| 2313 |
if ( yes==1 ) |
| 2314 |
UnlinkThisReference(NULL, sc, mv->layer); |
| 2315 |
} |
| 2316 |
|
| 2317 |
if ( onlycopydisplayed && mv->bdf==NULL ) { |
| 2318 |
SCClearAll(sc, mv->layer); |
| 2319 |
} else if ( onlycopydisplayed ) { |
| 2320 |
BCClearAll(mv->bdf->glyphs[sc->orig_pos]); |
| 2321 |
} else { |
| 2322 |
SCClearAll(sc,mv->layer); |
| 2323 |
for ( bdf=mv->sf->bitmaps; bdf!=NULL; bdf = bdf->next ) |
| 2324 |
BCClearAll(bdf->glyphs[sc->orig_pos]); |
| 2325 |
} |
| 2326 |
} |
| 2327 |
} |
| 2328 |
|
| 2329 |
static void MVCut(GWindow gw, struct gmenuitem *mi, GEvent *e) { |
| 2330 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2331 |
int i; |
| 2332 |
|
| 2333 |
if ( GGadgetActiveGadgetEditCmd(mv->gw, ec_cut) ) |
| 2334 |
; |
| 2335 |
else { |
| 2336 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2337 |
if ( mv->perchar[i].selected ) |
| 2338 |
break; |
| 2339 |
if ( i==-1 ) |
| 2340 |
return; |
| 2341 |
MVCopyChar(&mv->fv->b,mv->bdf,mv->glyphs[i].sc,ct_fullcopy); |
| 2342 |
MVClear(gw, mi, e); |
| 2343 |
} |
| 2344 |
} |
| 2345 |
|
| 2346 |
static void MVCopy(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2347 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2348 |
int i; |
| 2349 |
|
| 2350 |
if ( GGadgetActiveGadgetEditCmd(mv->gw, ec_copy) ) |
| 2351 |
; |
| 2352 |
else { |
| 2353 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2354 |
if ( mv->perchar[i].selected ) |
| 2355 |
break; |
| 2356 |
if ( i==-1 ) |
| 2357 |
return; |
| 2358 |
MVCopyChar(&mv->fv->b, mv->bdf, mv->glyphs[i].sc, ct_fullcopy); |
| 2359 |
} |
| 2360 |
} |
| 2361 |
|
| 2362 |
static void MVMenuCopyRef(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2363 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2364 |
int i; |
| 2365 |
|
| 2366 |
if ( GWindowGetFocusGadgetOfWindow(gw)!=NULL ) |
| 2367 |
return; |
| 2368 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2369 |
if ( mv->perchar[i].selected ) |
| 2370 |
break; |
| 2371 |
if ( i==-1 ) |
| 2372 |
return; |
| 2373 |
MVCopyChar(&mv->fv->b, mv->bdf, mv->glyphs[i].sc, ct_reference); |
| 2374 |
} |
| 2375 |
|
| 2376 |
static void MVMenuCopyWidth(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2377 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2378 |
int i; |
| 2379 |
|
| 2380 |
if ( GWindowGetFocusGadgetOfWindow(gw)!=NULL ) |
| 2381 |
return; |
| 2382 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2383 |
if ( mv->perchar[i].selected ) |
| 2384 |
break; |
| 2385 |
if ( i==-1 ) |
| 2386 |
return; |
| 2387 |
SCCopyWidth(mv->glyphs[i].sc, |
| 2388 |
mi->mid==MV_MID_CopyWidth?ut_width: |
| 2389 |
mi->mid==MV_MID_CopyVWidth?ut_vwidth: |
| 2390 |
mi->mid==MV_MID_CopyLBearing?ut_lbearing: |
| 2391 |
ut_rbearing); |
| 2392 |
} |
| 2393 |
|
| 2394 |
static void MVMenuJoin(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2395 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2396 |
int i, changed; |
| 2397 |
extern float joinsnap; |
| 2398 |
|
| 2399 |
if ( GWindowGetFocusGadgetOfWindow(gw)!=NULL ) |
| 2400 |
return; |
| 2401 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2402 |
if ( mv->perchar[i].selected ) |
| 2403 |
break; |
| 2404 |
if ( i==-1 ) |
| 2405 |
return; |
| 2406 |
SCPreserveLayer(mv->glyphs[i].sc, mv->layer, false); |
| 2407 |
mv->glyphs[i].sc->layers[mv->layer].splines = |
| 2408 |
SplineSetJoin(mv->glyphs[i].sc->layers[mv->layer].splines, true, joinsnap, &changed, true); |
| 2409 |
if ( changed ) |
| 2410 |
SCCharChangedUpdate(mv->glyphs[i].sc, mv->layer); |
| 2411 |
} |
| 2412 |
|
| 2413 |
static void MVPaste(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2414 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2415 |
int i; |
| 2416 |
|
| 2417 |
if ( GGadgetActiveGadgetEditCmd(mv->gw, ec_paste) ) |
| 2418 |
; |
| 2419 |
else { |
| 2420 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2421 |
if ( mv->perchar[i].selected ) |
| 2422 |
break; |
| 2423 |
if ( i==-1 ) |
| 2424 |
return; |
| 2425 |
PasteIntoMV(&mv->fv->b, mv->bdf, mv->glyphs[i].sc, true); |
| 2426 |
} |
| 2427 |
} |
| 2428 |
|
| 2429 |
static void MVUnlinkRef(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2430 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2431 |
int i; |
| 2432 |
SplineChar *sc; |
| 2433 |
RefChar *rf, *next; |
| 2434 |
|
| 2435 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2436 |
if ( mv->perchar[i].selected ) |
| 2437 |
break; |
| 2438 |
if ( i==-1 ) |
| 2439 |
return; |
| 2440 |
sc = mv->glyphs[i].sc; |
| 2441 |
SCPreserveLayer(sc, mv->layer,false); |
| 2442 |
for ( rf=sc->layers[mv->layer].refs; rf!=NULL ; rf=next ) { |
| 2443 |
next = rf->next; |
| 2444 |
SCRefToSplines(sc, rf, mv->layer); |
| 2445 |
} |
| 2446 |
SCCharChangedUpdate(sc, mv->layer); |
| 2447 |
} |
| 2448 |
|
| 2449 |
static void MVSelectAll(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2450 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2451 |
GGadgetActiveGadgetEditCmd(mv->gw, ec_selectall); |
| 2452 |
} |
| 2453 |
|
| 2454 |
static void MVClearSelection(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2455 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2456 |
int i; |
| 2457 |
|
| 2458 |
GWindowClearFocusGadgetOfWindow(mv->gw); |
| 2459 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 2460 |
if ( mv->perchar[i].selected ) |
| 2461 |
MVDeselectChar(mv,i); |
| 2462 |
} |
| 2463 |
|
| 2464 |
static void MVMenuFontInfo(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2465 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2466 |
DelayEvent(FontMenuFontInfo, mv->fv); |
| 2467 |
} |
| 2468 |
|
| 2469 |
static void MVMenuCharInfo(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2470 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2471 |
int i; |
| 2472 |
|
| 2473 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2474 |
if ( mv->perchar[i].selected ) |
| 2475 |
break; |
| 2476 |
if ( i!=-1 ) |
| 2477 |
SCCharInfo(mv->glyphs[i].sc, mv->layer, mv->fv->b.map, -1); |
| 2478 |
} |
| 2479 |
|
| 2480 |
static void MVMenuShowDependents(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2481 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2482 |
int i; |
| 2483 |
|
| 2484 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2485 |
if ( mv->perchar[i].selected ) |
| 2486 |
break; |
| 2487 |
if ( i!=-1 ) |
| 2488 |
return; |
| 2489 |
if ( mv->glyphs[i].sc->dependents==NULL ) |
| 2490 |
return; |
| 2491 |
SCRefBy(mv->glyphs[i].sc); |
| 2492 |
} |
| 2493 |
|
| 2494 |
static void MVMenuFindProblems(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2495 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2496 |
int i; |
| 2497 |
|
| 2498 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2499 |
if ( mv->perchar[i].selected ) |
| 2500 |
break; |
| 2501 |
if ( i!=-1 ) |
| 2502 |
FindProblems(mv->fv, NULL, mv->glyphs[i].sc); |
| 2503 |
} |
| 2504 |
|
| 2505 |
static void MVMenuBitmaps(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2506 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2507 |
int i; |
| 2508 |
|
| 2509 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 2510 |
if ( mv->perchar[i].selected ) |
| 2511 |
break; |
| 2512 |
if ( i!=mv->glyphcnt ) |
| 2513 |
BitmapDlg(&mv->fv->b, gw, mv->glyphs[i].sc, mi->mid==MV_MID_AvailBitmaps ); |
| 2514 |
else if ( mi->mid==MV_MID_AvailBitmaps ) |
| 2515 |
BitmapDlg(&mv->fv->b, gw, NULL, true ); |
| 2516 |
} |
| 2517 |
|
| 2518 |
static int getorigin(void *d, BasePoint *base, int index) { |
| 2519 |
SplineChar *sc = (SplineChar *) d; |
| 2520 |
DBounds bb; |
| 2521 |
|
| 2522 |
base->x = base->y = 0; |
| 2523 |
switch ( index ) { |
| 2524 |
case 0: |
| 2525 |
|
| 2526 |
break; |
| 2527 |
case 1: |
| 2528 |
SplineCharFindBounds(sc,&bb); |
| 2529 |
base->x = (bb.minx+bb.maxx)/2; |
| 2530 |
base->y = (bb.miny+bb.maxy)/2; |
| 2531 |
break; |
| 2532 |
default: |
| 2533 |
return( false ); |
| 2534 |
} |
| 2535 |
return( true ); |
| 2536 |
} |
| 2537 |
|
| 2538 |
static void MVTransFunc(void *_sc, real transform[6], int UNUSED(otype), |
| 2539 |
BVTFunc *UNUSED(bvts), enum fvtrans_flags flags ) { |
| 2540 |
SplineChar *sc = _sc; |
| 2541 |
FVTrans( (FontViewBase *)sc->parent->fv, sc, transform, NULL, flags); |
| 2542 |
} |
| 2543 |
|
| 2544 |
static void MVMenuTransform(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2545 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2546 |
int i; |
| 2547 |
|
| 2548 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2549 |
if ( mv->perchar[i].selected ) |
| 2550 |
break; |
| 2551 |
if ( i!=-1 ) |
| 2552 |
TransformDlgCreate( mv->glyphs[i].sc, MVTransFunc, getorigin, true, cvt_none ); |
| 2553 |
} |
| 2554 |
|
| 2555 |
#ifdef FONTFORGE_CONFIG_TILEPATH |
| 2556 |
static void MVMenuTilePath(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2557 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2558 |
int i; |
| 2559 |
|
| 2560 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2561 |
if ( mv->perchar[i].selected ) |
| 2562 |
break; |
| 2563 |
if ( i!=-1 ) |
| 2564 |
SCTile(mv->glyphs[i].sc, mv->layer); |
| 2565 |
} |
| 2566 |
#endif |
| 2567 |
|
| 2568 |
static void _MVMenuOverlap(MetricsView *mv, enum overlap_type ot) { |
| 2569 |
int i; |
| 2570 |
|
| 2571 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2572 |
if ( mv->perchar[i].selected ) |
| 2573 |
break; |
| 2574 |
if ( i!=-1 ) { |
| 2575 |
SplineChar *sc = mv->glyphs[i].sc; |
| 2576 |
if ( !SCRoundToCluster(sc, mv->layer, false, 0.03, 0.12)) |
| 2577 |
SCPreserveLayer(sc, mv->layer, false); |
| 2578 |
MinimumDistancesFree(sc->md); |
| 2579 |
sc->md = NULL; |
| 2580 |
sc->layers[mv->layer].splines = SplineSetRemoveOverlap(sc, sc->layers[mv->layer].splines, ot); |
| 2581 |
SCCharChangedUpdate(sc, mv->layer); |
| 2582 |
} |
| 2583 |
} |
| 2584 |
|
| 2585 |
static void MVMenuOverlap(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2586 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2587 |
_MVMenuOverlap(mv, mi->mid==MV_MID_RmOverlap ? over_remove : |
| 2588 |
mi->mid==MV_MID_Intersection ? over_intersect : |
| 2589 |
over_findinter); |
| 2590 |
} |
| 2591 |
|
| 2592 |
static void MVMenuInline(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2593 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2594 |
OutlineDlg(NULL, NULL, mv, true); |
| 2595 |
} |
| 2596 |
|
| 2597 |
static void MVMenuOutline(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2598 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2599 |
OutlineDlg(NULL, NULL, mv, false); |
| 2600 |
} |
| 2601 |
|
| 2602 |
static void MVMenuShadow(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2603 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2604 |
ShadowDlg(NULL, NULL, mv, false); |
| 2605 |
} |
| 2606 |
|
| 2607 |
static void MVMenuWireframe(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2608 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2609 |
ShadowDlg(NULL, NULL, mv, true); |
| 2610 |
} |
| 2611 |
|
| 2612 |
static void MVSimplify( MetricsView *mv,int type ) { |
| 2613 |
int i; |
| 2614 |
static struct simplifyinfo smpls[] = { |
| 2615 |
{ sf_normal, 0, 0, 0, 0, 0, 0 }, |
| 2616 |
{ sf_normal,.75,.05,0,-1, 0, 0 }, |
| 2617 |
{ sf_normal,.75,.05,0,-1, 0, 0 }}; |
| 2618 |
struct simplifyinfo *smpl = &smpls[type+1]; |
| 2619 |
|
| 2620 |
if ( smpl->linelenmax==-1 ) { |
| 2621 |
smpl->err = (mv->sf->ascent+mv->sf->descent)/1000.; |
| 2622 |
smpl->linelenmax = (mv->sf->ascent+mv->sf->descent)/100.; |
| 2623 |
} |
| 2624 |
|
| 2625 |
if ( type==1 ) { |
| 2626 |
if ( !SimplifyDlg(mv->sf,smpl)) |
| 2627 |
return; |
| 2628 |
if ( smpl->set_as_default ) |
| 2629 |
smpls[1] = *smpl; |
| 2630 |
} |
| 2631 |
|
| 2632 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2633 |
if ( mv->perchar[i].selected ) |
| 2634 |
break; |
| 2635 |
if ( i!=-1 ) { |
| 2636 |
SplineChar *sc = mv->glyphs[i].sc; |
| 2637 |
SCPreserveLayer(sc,mv->layer,false); |
| 2638 |
sc->layers[mv->layer].splines = SplineCharSimplify(sc,sc->layers[mv->layer].splines,smpl); |
| 2639 |
SCCharChangedUpdate(sc,mv->layer); |
| 2640 |
} |
| 2641 |
} |
| 2642 |
|
| 2643 |
static void MVMenuSimplify(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2644 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2645 |
MVSimplify(mv, false); |
| 2646 |
} |
| 2647 |
|
| 2648 |
static void MVMenuSimplifyMore(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2649 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2650 |
MVSimplify(mv, true); |
| 2651 |
} |
| 2652 |
|
| 2653 |
static void MVMenuCleanup(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2654 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2655 |
MVSimplify(mv, -1); |
| 2656 |
} |
| 2657 |
|
| 2658 |
static void MVMenuAddExtrema(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2659 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2660 |
int i; |
| 2661 |
SplineFont *sf = mv->sf; |
| 2662 |
int emsize = sf->ascent+sf->descent; |
| 2663 |
|
| 2664 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2665 |
if ( mv->perchar[i].selected ) |
| 2666 |
break; |
| 2667 |
if ( i!=-1 ) { |
| 2668 |
SplineChar *sc = mv->glyphs[i].sc; |
| 2669 |
SCPreserveLayer(sc, mv->layer, false); |
| 2670 |
SplineCharAddExtrema(sc, sc->layers[mv->layer].splines, ae_only_good, emsize); |
| 2671 |
SCCharChangedUpdate(sc, mv->layer); |
| 2672 |
} |
| 2673 |
} |
| 2674 |
|
| 2675 |
static void MVMenuAddInflections(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2676 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2677 |
int i; |
| 2678 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2679 |
if ( mv->perchar[i].selected ) |
| 2680 |
break; |
| 2681 |
if ( i!=-1 ) { |
| 2682 |
SplineChar *sc = mv->glyphs[i].sc; |
| 2683 |
SCPreserveLayer(sc, mv->layer, false); |
| 2684 |
SplineCharAddInflections(sc, sc->layers[mv->layer].splines, false); |
| 2685 |
SCCharChangedUpdate(sc, mv->layer); |
| 2686 |
} |
| 2687 |
} |
| 2688 |
|
| 2689 |
static void MVMenuRound2Int(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2690 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2691 |
int i; |
| 2692 |
|
| 2693 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2694 |
if ( mv->perchar[i].selected ) |
| 2695 |
break; |
| 2696 |
if ( i!=-1 ) { |
| 2697 |
SCPreserveLayer(mv->glyphs[i].sc, mv->layer, false); |
| 2698 |
SCRound2Int( mv->glyphs[i].sc, mv->layer, 1.0); |
| 2699 |
} |
| 2700 |
} |
| 2701 |
|
| 2702 |
static void MVMenuAutotrace(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *e) { |
| 2703 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2704 |
int i; |
| 2705 |
GCursor ct; |
| 2706 |
|
| 2707 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2708 |
if ( mv->perchar[i].selected ) |
| 2709 |
break; |
| 2710 |
if ( i!=-1 ) { |
| 2711 |
ct = GDrawGetCursor(mv->gw); |
| 2712 |
GDrawSetCursor(mv->gw, ct_watch); |
| 2713 |
ff_progress_allow_events(); |
| 2714 |
SCAutoTrace(mv->glyphs[i].sc, mv->layer, e!=NULL && (e->u.mouse.state&ksm_shift)); |
| 2715 |
GDrawSetCursor(mv->gw, ct); |
| 2716 |
} |
| 2717 |
} |
| 2718 |
|
| 2719 |
static void MVMenuCorrectDir(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2720 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2721 |
int i; |
| 2722 |
|
| 2723 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2724 |
if ( mv->perchar[i].selected ) |
| 2725 |
break; |
| 2726 |
if ( i!=-1 ) { |
| 2727 |
SplineChar *sc = mv->glyphs[i].sc; |
| 2728 |
int changed = false, refchanged=false; |
| 2729 |
RefChar *ref; |
| 2730 |
int asked=-1; |
| 2731 |
|
| 2732 |
for ( ref=sc->layers[mv->layer].refs; ref!=NULL; ref=ref->next ) { |
| 2733 |
if ( ref->transform[0]*ref->transform[3]<0 || |
| 2734 |
(ref->transform[0]==0 && ref->transform[1]*ref->transform[2]>0)) { |
| 2735 |
if ( asked==-1 ) { |
| 2736 |
char *buts[4]; |
| 2737 |
buts[0] = _("_Unlink"); |
| 2738 |
buts[1] = _("_No"); |
| 2739 |
buts[2] = _("_Cancel"); |
| 2740 |
buts[3] = NULL; |
| 2741 |
asked = gwwv_ask(_("Flipped Reference"),(const char **) buts,0,2,_("%.50s contains a flipped reference. This cannot be corrected as is. Would you like me to unlink it and then correct it?"), sc->name ); |
| 2742 |
if ( asked==2 ) |
| 2743 |
return; |
| 2744 |
else if ( asked==1 ) |
| 2745 |
break; |
| 2746 |
} |
| 2747 |
if ( asked==0 ) { |
| 2748 |
if ( !refchanged ) { |
| 2749 |
refchanged = true; |
| 2750 |
SCPreserveLayer(sc,mv->layer,false); |
| 2751 |
} |
| 2752 |
SCRefToSplines(sc,ref,mv->layer); |
| 2753 |
} |
| 2754 |
} |
| 2755 |
} |
| 2756 |
|
| 2757 |
if ( !refchanged ) |
| 2758 |
SCPreserveLayer(sc,mv->layer,false); |
| 2759 |
sc->layers[mv->layer].splines = SplineSetsCorrect(sc->layers[mv->layer].splines,&changed); |
| 2760 |
if ( changed || refchanged ) |
| 2761 |
SCCharChangedUpdate(sc,mv->layer); |
| 2762 |
} |
| 2763 |
} |
| 2764 |
|
| 2765 |
static void _MVMenuBuildAccent(MetricsView *mv,int onlyaccents) { |
| 2766 |
int i; |
| 2767 |
extern int onlycopydisplayed; |
| 2768 |
|
| 2769 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 2770 |
if ( mv->perchar[i].selected ) |
| 2771 |
break; |
| 2772 |
if ( i!=-1 ) { |
| 2773 |
SplineChar *sc = mv->glyphs[i].sc; |
| 2774 |
if ( SFIsSomethingBuildable(mv->sf,sc,mv->layer,onlyaccents) ) |
| 2775 |
SCBuildComposit(mv->sf,sc,mv->layer,NULL,onlycopydisplayed,onlyaccents); |
| 2776 |
} |
| 2777 |
} |
| 2778 |
|
| 2779 |
static void MVMenuBuildAccent(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2780 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2781 |
_MVMenuBuildAccent(mv, false); |
| 2782 |
} |
| 2783 |
|
| 2784 |
static void MVMenuBuildComposite(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2785 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2786 |
_MVMenuBuildAccent(mv, true); |
| 2787 |
} |
| 2788 |
|
| 2789 |
static void MVResetText(MetricsView *mv) { |
| 2790 |
unichar_t *new, *pt; |
| 2791 |
int i; |
| 2792 |
|
| 2793 |
new = malloc((mv->clen+1)*sizeof(unichar_t)); |
| 2794 |
for ( pt=new, i=0; i<mv->clen; ++i ) { |
| 2795 |
if ( mv->chars[i]->unicodeenc==-1 ) |
| 2796 |
*pt++ = MVFakeUnicodeOfSc(mv,mv->chars[i]); |
| 2797 |
else |
| 2798 |
*pt++ = mv->chars[i]->unicodeenc; |
| 2799 |
} |
| 2800 |
*pt = '\0'; |
| 2801 |
GGadgetSetTitle(mv->text,new); |
| 2802 |
free(new ); |
| 2803 |
} |
| 2804 |
|
| 2805 |
static void MVMenuLigatures(GWindow gw,struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2806 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2807 |
SFShowLigatures(mv->sf, NULL); |
| 2808 |
} |
| 2809 |
|
| 2810 |
static void MVMenuKernPairs(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2811 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2812 |
SFShowKernPairs(mv->sf, NULL, NULL, mv->layer); |
| 2813 |
} |
| 2814 |
|
| 2815 |
static void MVMenuAnchorPairs(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2816 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2817 |
SFShowKernPairs(mv->sf, NULL, mi->ti.userdata, mv->layer); |
| 2818 |
} |
| 2819 |
|
| 2820 |
static void _MVMenuScale( MetricsView *mv, int mid ) { |
| 2821 |
|
| 2822 |
if ( mid==MV_MID_ZoomIn ) { |
| 2823 |
if ( --mv->scale_index<0 ) mv->scale_index = 0; |
| 2824 |
} else { |
| 2825 |
if ( ++mv->scale_index >= sizeof(mv_scales)/sizeof(mv_scales[0]) ) |
| 2826 |
mv->scale_index = sizeof(mv_scales)/sizeof(mv_scales[0])-1; |
| 2827 |
} |
| 2828 |
|
| 2829 |
if ( mv->pixelsize_set_by_window ) { |
| 2830 |
mv->pixelsize = mv_scales[mv->scale_index]*(mv->vheight - 2); |
| 2831 |
if ( mv->bdf==NULL ) { |
| 2832 |
BDFFontFree(mv->show); |
| 2833 |
mv->show = SplineFontPieceMeal(mv->sf,mv->layer,mv->pixelsize,72, |
| 2834 |
MVGetSplineFontPieceMealFlags( mv ), NULL ); |
| 2835 |
} else |
| 2836 |
mv->pixelsize_set_by_window = false; |
| 2837 |
} |
| 2838 |
MVReKern(mv); |
| 2839 |
MVSetVSb(mv); |
| 2840 |
} |
| 2841 |
|
| 2842 |
static void MVMenuScale(GWindow gw,struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2843 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2844 |
_MVMenuScale(mv, mi->mid); |
| 2845 |
} |
| 2846 |
|
| 2847 |
static void MVMenuInsertChar(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2848 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2849 |
SplineFont *sf = mv->sf; |
| 2850 |
int i, j, pos = GotoChar(sf,mv->fv->b.map,NULL); |
| 2851 |
|
| 2852 |
if ( pos==-1 || pos>=mv->fv->b.map->enccount ) |
| 2853 |
return; |
| 2854 |
|
| 2855 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 2856 |
if ( mv->perchar[i].selected ) |
| 2857 |
break; |
| 2858 |
if ( i!=mv->glyphcnt ) |
| 2859 |
; |
| 2860 |
else if ( mi->mid==MV_MID_InsertCharA ) |
| 2861 |
i = mv->glyphcnt; |
| 2862 |
else |
| 2863 |
i = 0; |
| 2864 |
if ( mi->mid==MV_MID_InsertCharA ) { |
| 2865 |
if ( i!=mv->glyphcnt ) |
| 2866 |
++i; |
| 2867 |
} else { |
| 2868 |
if ( i==mv->glyphcnt ) i = 0; |
| 2869 |
} |
| 2870 |
if ( i==mv->glyphcnt ) |
| 2871 |
i = mv->clen; |
| 2872 |
else |
| 2873 |
i = mv->glyphs[i].orig_index; |
| 2874 |
|
| 2875 |
if ( mv->clen+1>=mv->cmax ) { |
| 2876 |
int oldmax=mv->cmax; |
| 2877 |
mv->cmax = mv->clen+10; |
| 2878 |
mv->chars = realloc(mv->chars,mv->cmax*sizeof(SplineChar *)); |
| 2879 |
memset(mv->chars+oldmax,'\0',(mv->cmax-oldmax)*sizeof(SplineChar *)); |
| 2880 |
} |
| 2881 |
for ( j=mv->clen; j>i; --j ) |
| 2882 |
mv->chars[j] = mv->chars[j-1]; |
| 2883 |
mv->chars[i] = SFMakeChar(sf,mv->fv->b.map,pos); |
| 2884 |
++mv->clen; |
| 2885 |
MVRemetric(mv); |
| 2886 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 2887 |
if ( mv->glyphs[j].orig_index==i ) { |
| 2888 |
MVDoSelect(mv,j); |
| 2889 |
break; |
| 2890 |
} |
| 2891 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2892 |
MVResetText(mv); |
| 2893 |
} |
| 2894 |
|
| 2895 |
static void MVMenuChangeChar(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2896 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2897 |
SplineFont *sf = mv->sf; |
| 2898 |
SplineChar *sc; |
| 2899 |
EncMap *map = mv->fv->b.map; |
| 2900 |
int i, pos, gid; |
| 2901 |
|
| 2902 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 2903 |
if ( mv->perchar[i].selected ) |
| 2904 |
break; |
| 2905 |
if ( i!=mv->glyphcnt ) { |
| 2906 |
pos = -1; |
| 2907 |
i = mv->glyphs[i].orig_index; |
| 2908 |
sc = mv->chars[ i ]; |
| 2909 |
if ( mi->mid == MV_MID_Next ) { |
| 2910 |
pos = map->backmap[sc->orig_pos]+1; |
| 2911 |
} else if ( mi->mid==MV_MID_Prev ) { |
| 2912 |
pos = map->backmap[sc->orig_pos]-1; |
| 2913 |
} else if ( mi->mid==MV_MID_NextDef ) { |
| 2914 |
for ( pos = map->backmap[sc->orig_pos]+1; |
| 2915 |
pos<map->enccount && ((gid=map->map[pos])==-1 || sf->glyphs[gid]==NULL); ++pos ); |
| 2916 |
if ( pos>=map->enccount ) |
| 2917 |
return; |
| 2918 |
} else if ( mi->mid==MV_MID_PrevDef ) { |
| 2919 |
for ( pos = map->backmap[sc->orig_pos]-1; |
| 2920 |
pos<map->enccount && ((gid=map->map[pos])==-1 || sf->glyphs[gid]==NULL); --pos ); |
| 2921 |
if ( pos<0 ) |
| 2922 |
return; |
| 2923 |
} else if ( mi->mid==MV_MID_ReplaceChar ) { |
| 2924 |
pos = GotoChar(sf,mv->fv->b.map,NULL); |
| 2925 |
if ( pos<0 || pos>=mv->fv->b.map->enccount) |
| 2926 |
return; |
| 2927 |
} |
| 2928 |
if ( pos>=0 && pos<map->enccount ) { |
| 2929 |
mv->chars[i] = SFMakeChar(sf,mv->fv->b.map,pos); |
| 2930 |
MVRemetric(mv); |
| 2931 |
MVResetText(mv); |
| 2932 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2933 |
} |
| 2934 |
} |
| 2935 |
} |
| 2936 |
|
| 2937 |
static void MVMenuFindInFontView(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2938 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2939 |
int i; |
| 2940 |
|
| 2941 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 2942 |
if ( mv->perchar[i].selected ) { |
| 2943 |
FVChangeChar(mv->fv, mv->fv->b.map->backmap[mv->glyphs[i].sc->orig_pos]); |
| 2944 |
GDrawSetVisible(mv->fv->gw, true); |
| 2945 |
GDrawRaise(mv->fv->gw); |
| 2946 |
break; |
| 2947 |
} |
| 2948 |
} |
| 2949 |
} |
| 2950 |
|
| 2951 |
static void MVMenuShowGrid(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2952 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2953 |
if ( mi->mid == MV_MID_ShowGrid ) |
| 2954 |
mv->showgrid = mv_showgrid; |
| 2955 |
else if ( mi->mid == MV_MID_HideGrid ) |
| 2956 |
mv->showgrid = mv_hidegrid; |
| 2957 |
else if ( mi->mid == MV_MID_PartialGrid ) |
| 2958 |
mv->showgrid = mv_partialgrid; |
| 2959 |
else if ( mi->mid == MV_MID_HideGridWhenMoving ) |
| 2960 |
mv->showgrid = mv_hidemovinggrid; |
| 2961 |
mvshowgrid = mv->showgrid; |
| 2962 |
SavePrefs(true); |
| 2963 |
GDrawRequestExpose(mv->v, NULL, false); |
| 2964 |
} |
| 2965 |
|
| 2966 |
static void MVMenuAA(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2967 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2968 |
|
| 2969 |
mv_antialias = mv->antialias = !mv->antialias; |
| 2970 |
mv->bdf = NULL; |
| 2971 |
BDFFontFree(mv->show); |
| 2972 |
mv->show = SplineFontPieceMeal(mv->sf, mv->layer, mv->ptsize, mv->dpi, |
| 2973 |
MVGetSplineFontPieceMealFlags( mv ), |
| 2974 |
NULL); |
| 2975 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2976 |
} |
| 2977 |
|
| 2978 |
|
| 2979 |
static void MVMenuRenderUsingHinting(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 2980 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2981 |
|
| 2982 |
mv->usehinting = !mv->usehinting; |
| 2983 |
mv->bdf = NULL; |
| 2984 |
BDFFontFree(mv->show); |
| 2985 |
mv->show = SplineFontPieceMeal(mv->sf, mv->layer, mv->ptsize, mv->dpi, |
| 2986 |
MVGetSplineFontPieceMealFlags( mv ), |
| 2987 |
NULL); |
| 2988 |
GDrawRequestExpose(mv->v,NULL,false); |
| 2989 |
} |
| 2990 |
|
| 2991 |
static char* MVWindowTitle(MetricsView *mv) { |
| 2992 |
return smprintf(mv->type == mv_kernonly ? _("Kerning Metrics For %.50s") : |
| 2993 |
mv->type == mv_widthonly ? _("Advance Width Metrics For %.50s") : |
| 2994 |
_("Metrics For %.50s"), mv->sf->fontname); |
| 2995 |
} |
| 2996 |
|
| 2997 |
static void MVMenuWindowType(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 2998 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 2999 |
|
| 3000 |
mv_type = mv->type = mi->mid==MV_MID_KernOnly ? mv_kernonly : |
| 3001 |
mi->mid==MV_MID_WidthOnly ? mv_widthonly : |
| 3002 |
mv_kernwidth; |
| 3003 |
char* buf = MVWindowTitle(mv); |
| 3004 |
GDrawSetWindowTitles8(mv->gw, buf, buf); |
| 3005 |
free(buf); |
| 3006 |
GDrawRequestExpose(mv->v, NULL, false); |
| 3007 |
GDrawRequestExpose(mv->gw, NULL, false); |
| 3008 |
} |
| 3009 |
|
| 3010 |
static void MVMenuVertical(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3011 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3012 |
|
| 3013 |
if ( !mv->sf->hasvmetrics ) { |
| 3014 |
if ( mv->vertical ) |
| 3015 |
MVToggleVertical(mv); |
| 3016 |
} else |
| 3017 |
MVToggleVertical(mv); |
| 3018 |
GDrawRequestExpose(mv->gw, NULL, false); |
| 3019 |
GDrawRequestExpose(mv->v, NULL, false); |
| 3020 |
} |
| 3021 |
|
| 3022 |
static void MVMenuShowBitmap(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3023 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3024 |
BDFFont *bdf = mi->ti.userdata; |
| 3025 |
|
| 3026 |
if ( mv->bdf!=bdf ) { |
| 3027 |
mv->pixelsize_set_by_window = bdf==NULL; |
| 3028 |
if ( bdf!=NULL ) { |
| 3029 |
mv->pixelsize = mv->ptsize = bdf->pixelsize; |
| 3030 |
mv->dpi = 72; |
| 3031 |
} |
| 3032 |
MVChangeDisplayFont(mv, bdf); |
| 3033 |
GDrawRequestExpose(mv->v, NULL, false); |
| 3034 |
} |
| 3035 |
} |
| 3036 |
|
| 3037 |
static void MVMoveInWordListByOffset( MetricsView *mv, int offset ) |
| 3038 |
{ |
| 3039 |
if ( mv->word_index!=-1 ) { |
| 3040 |
int32_t len; |
| 3041 |
GGadgetGetList(mv->text,&len); |
| 3042 |
|
| 3043 |
|
| 3044 |
if ( mv->word_index+offset >=0 && mv->word_index+offset<len-3 ) { |
| 3045 |
const unichar_t *tit; |
| 3046 |
mv->word_index += offset; |
| 3047 |
GGadgetSelectOneListItem(mv->text,mv->word_index); |
| 3048 |
tit = _GGadgetGetTitle(mv->text); |
| 3049 |
if ( tit!=NULL && tit[0]==0x200b ) |
| 3050 |
MVFigureGlyphNames(mv,tit+1); |
| 3051 |
else |
| 3052 |
MVTextChanged(mv); |
| 3053 |
} |
| 3054 |
} |
| 3055 |
} |
| 3056 |
|
| 3057 |
static void MVMenuNextLineInWordList(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3058 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3059 |
MVMoveInWordListByOffset( mv, 1 ); |
| 3060 |
} |
| 3061 |
static void MVMenuPrevLineInWordList(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3062 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3063 |
MVMoveInWordListByOffset( mv, -1 ); |
| 3064 |
} |
| 3065 |
|
| 3066 |
|
| 3067 |
#define CID_DPI 1002 |
| 3068 |
#define CID_Size 1003 |
| 3069 |
|
| 3070 |
struct pxsz { |
| 3071 |
MetricsView *mv; |
| 3072 |
GWindow gw; |
| 3073 |
int done; |
| 3074 |
}; |
| 3075 |
|
| 3076 |
static int PXSZ_OK(GGadget *g, GEvent *e) { |
| 3077 |
|
| 3078 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 3079 |
struct pxsz *pxsz = GDrawGetUserData(GGadgetGetWindow(g)); |
| 3080 |
MetricsView *mv = pxsz->mv; |
| 3081 |
int ptsize, dpi, err=0; |
| 3082 |
|
| 3083 |
ptsize = GetInt8( pxsz->gw, CID_Size, _("Point Size"), &err ); |
| 3084 |
dpi = GetInt8( pxsz->gw, CID_DPI, _("DPI"), &err ); |
| 3085 |
if ( err ) |
| 3086 |
return(true); |
| 3087 |
if ( ptsize<3 || ptsize>1500 || dpi<10 || dpi > 2000 ) { |
| 3088 |
ff_post_error(_("Number out of range"),_("Number out of range")); |
| 3089 |
return( true ); |
| 3090 |
} |
| 3091 |
mv->pixelsize_set_by_window = false; |
| 3092 |
mv->ptsize = ptsize; |
| 3093 |
mv->dpi = dpi; |
| 3094 |
mv->pixelsize = rint( (ptsize*dpi)/72.0 ); |
| 3095 |
if ( mv->bdf==NULL ) |
| 3096 |
BDFFontFree(mv->show); |
| 3097 |
mv->bdf = NULL; |
| 3098 |
mv->show = SplineFontPieceMeal(mv->sf,mv->layer,mv->ptsize,mv->dpi, |
| 3099 |
MVGetSplineFontPieceMealFlags( mv ), NULL ); |
| 3100 |
|
| 3101 |
MVReKern(mv); |
| 3102 |
MVSetVSb(mv); |
| 3103 |
pxsz->done = 2; |
| 3104 |
} |
| 3105 |
return( true ); |
| 3106 |
} |
| 3107 |
|
| 3108 |
static int PXSZ_Cancel(GGadget *g, GEvent *e) { |
| 3109 |
|
| 3110 |
if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) { |
| 3111 |
struct pxsz *pxsz = GDrawGetUserData(GGadgetGetWindow(g)); |
| 3112 |
pxsz->done = true; |
| 3113 |
} |
| 3114 |
return( true ); |
| 3115 |
} |
| 3116 |
|
| 3117 |
static int pxsz_e_h(GWindow gw, GEvent *event) { |
| 3118 |
struct pxsz *pxsz = GDrawGetUserData(gw); |
| 3119 |
|
| 3120 |
switch ( event->type ) { |
| 3121 |
case et_char: |
| 3122 |
return( false ); |
| 3123 |
case et_close: |
| 3124 |
pxsz->done = true; |
| 3125 |
break; |
| 3126 |
default: break; |
| 3127 |
} |
| 3128 |
return( true ); |
| 3129 |
} |
| 3130 |
|
| 3131 |
static void MVMenuPointSize(GWindow mgw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3132 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(mgw); |
| 3133 |
struct pxsz pxsz; |
| 3134 |
GRect pos; |
| 3135 |
GWindow gw; |
| 3136 |
GWindowAttrs wattrs; |
| 3137 |
GGadgetCreateData gcd[7], *hvarray[5][3], *barray[8], boxes[3]; |
| 3138 |
GTextInfo label[7]; |
| 3139 |
int i,k; |
| 3140 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 3141 |
char buffer[20], dbuffer[20]; |
| 3142 |
|
| 3143 |
memset(&pxsz,0,sizeof(pxsz)); |
| 3144 |
pxsz.mv = mv; |
| 3145 |
|
| 3146 |
memset(&wattrs,0,sizeof(wattrs)); |
| 3147 |
memset(&gcd,0,sizeof(gcd)); |
| 3148 |
memset(&label,0,sizeof(label)); |
| 3149 |
memset(&boxes,0,sizeof(boxes)); |
| 3150 |
|
| 3151 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict; |
| 3152 |
wattrs.event_masks = ~(1<<et_charup); |
| 3153 |
wattrs.restrict_input_to_me = true; |
| 3154 |
wattrs.undercursor = 1; |
| 3155 |
wattrs.cursor = ct_pointer; |
| 3156 |
wattrs.utf8_window_title = _("Set Point Size"); |
| 3157 |
wattrs.is_dlg = true; |
| 3158 |
pos.x = pos.y = 0; |
| 3159 |
pos.width = 100; |
| 3160 |
pos.height = 100; |
| 3161 |
pxsz.gw = gw = GDrawCreateTopWindow(NULL,&pos,pxsz_e_h,&pxsz,&wattrs); |
| 3162 |
|
| 3163 |
k = i = 0; |
| 3164 |
|
| 3165 |
label[k].text = (unichar_t *) _("Point Size:"); |
| 3166 |
label[k].text_is_1byte = true; |
| 3167 |
gcd[k].gd.label = &label[k]; |
| 3168 |
gcd[k].gd.flags = gg_visible|gg_enabled ; |
| 3169 |
|
| 3170 |
gcd[k++].creator = GLabelCreate; |
| 3171 |
hvarray[i][0] = &gcd[k-1]; |
| 3172 |
|
| 3173 |
sprintf( buffer, "%d", (int) rint( mv->ptsize/iscale )); |
| 3174 |
label[k].text = (unichar_t *) buffer; |
| 3175 |
label[k].text_is_1byte = true; |
| 3176 |
gcd[k].gd.label = &label[k]; |
| 3177 |
gcd[k].gd.flags = gg_visible|gg_enabled; |
| 3178 |
gcd[k].gd.cid = CID_Size; |
| 3179 |
gcd[k++].creator = GTextFieldCreate; |
| 3180 |
hvarray[i][1] = &gcd[k-1]; hvarray[i++][2] = NULL; |
| 3181 |
|
| 3182 |
label[k].text = (unichar_t *) _("DPI:"); |
| 3183 |
label[k].text_is_1byte = true; |
| 3184 |
gcd[k].gd.label = &label[k]; |
| 3185 |
gcd[k].gd.flags = gg_visible|gg_enabled ; |
| 3186 |
|
| 3187 |
gcd[k++].creator = GLabelCreate; |
| 3188 |
hvarray[i][0] = &gcd[k-1]; |
| 3189 |
|
| 3190 |
sprintf( dbuffer, "%d", mv->dpi ); |
| 3191 |
label[k].text = (unichar_t *) dbuffer; |
| 3192 |
label[k].text_is_1byte = true; |
| 3193 |
gcd[k].gd.label = &label[k]; |
| 3194 |
gcd[k].gd.flags = gg_visible|gg_enabled; |
| 3195 |
gcd[k].gd.cid = CID_DPI; |
| 3196 |
gcd[k++].creator = GTextFieldCreate; |
| 3197 |
hvarray[i][1] = &gcd[k-1]; hvarray[i++][2] = NULL; |
| 3198 |
|
| 3199 |
label[k].text = (unichar_t *) _("_OK"); |
| 3200 |
label[k].text_is_1byte = true; |
| 3201 |
label[k].text_in_resource = true; |
| 3202 |
gcd[k].gd.label = &label[k]; |
| 3203 |
gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_default; |
| 3204 |
gcd[k].gd.handle_controlevent = PXSZ_OK; |
| 3205 |
gcd[k++].creator = GButtonCreate; |
| 3206 |
|
| 3207 |
label[k].text = (unichar_t *) _("_Cancel"); |
| 3208 |
label[k].text_is_1byte = true; |
| 3209 |
label[k].text_in_resource = true; |
| 3210 |
gcd[k].gd.label = &label[k]; |
| 3211 |
gcd[k].gd.flags = gg_visible|gg_enabled | gg_but_cancel; |
| 3212 |
gcd[k].gd.handle_controlevent = PXSZ_Cancel; |
| 3213 |
gcd[k++].creator = GButtonCreate; |
| 3214 |
|
| 3215 |
barray[0] = barray[2] = barray[3] = barray[4] = barray[6] = GCD_Glue; barray[7] = NULL; |
| 3216 |
barray[1] = &gcd[k-2]; barray[5] = &gcd[k-1]; |
| 3217 |
hvarray[i][0] = &boxes[2]; hvarray[i][1] = GCD_ColSpan; hvarray[i++][2] = NULL; |
| 3218 |
hvarray[i][0] = NULL; |
| 3219 |
|
| 3220 |
memset(boxes,0,sizeof(boxes)); |
| 3221 |
boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; |
| 3222 |
boxes[0].gd.flags = gg_enabled|gg_visible; |
| 3223 |
boxes[0].gd.u.boxelements = hvarray[0]; |
| 3224 |
boxes[0].creator = GHVGroupCreate; |
| 3225 |
|
| 3226 |
boxes[2].gd.flags = gg_enabled|gg_visible; |
| 3227 |
boxes[2].gd.u.boxelements = barray; |
| 3228 |
boxes[2].creator = GHBoxCreate; |
| 3229 |
|
| 3230 |
GGadgetsCreate(gw,boxes); |
| 3231 |
GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame); |
| 3232 |
GHVBoxSetExpandableRow(boxes[0].ret,gb_expandglue); |
| 3233 |
|
| 3234 |
GHVBoxFitWindow(boxes[0].ret); |
| 3235 |
|
| 3236 |
GDrawSetVisible(gw,true); |
| 3237 |
while ( !pxsz.done ) |
| 3238 |
GDrawProcessOneEvent(NULL); |
| 3239 |
GDrawDestroyWindow(gw); |
| 3240 |
} |
| 3241 |
|
| 3242 |
static void MVMenuSizeWindow(GWindow mgw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3243 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(mgw); |
| 3244 |
mv->pixelsize_set_by_window = true; |
| 3245 |
mv->pixelsize = mv_scales[mv->scale_index]*(mv->vheight - 2); |
| 3246 |
mv->dpi = 72; |
| 3247 |
mv->ptsize = mv->pixelsize; |
| 3248 |
if ( mv->bdf==NULL ) { |
| 3249 |
BDFFontFree(mv->show); |
| 3250 |
mv->show = SplineFontPieceMeal( |
| 3251 |
mv->sf, mv->layer, mv->pixelsize, 72, |
| 3252 |
MVGetSplineFontPieceMealFlags( mv ), |
| 3253 |
NULL); |
| 3254 |
} |
| 3255 |
MVReKern(mv); |
| 3256 |
MVSetVSb(mv); |
| 3257 |
} |
| 3258 |
|
| 3259 |
static void MVMenuChangePointSize(GWindow mgw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3260 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(mgw); |
| 3261 |
|
| 3262 |
if ( mv->pixelsize_set_by_window ) |
| 3263 |
return; |
| 3264 |
if ( mi->mid==MV_MID_Bigger ) |
| 3265 |
++(mv->ptsize); |
| 3266 |
else |
| 3267 |
--(mv->ptsize); |
| 3268 |
mv->pixelsize = rint( (mv->ptsize*mv->dpi)/72.0 ); |
| 3269 |
if ( mv->bdf==NULL ) |
| 3270 |
BDFFontFree(mv->show); |
| 3271 |
mv->bdf = NULL; |
| 3272 |
mv->show = SplineFontPieceMeal(mv->sf, mv->layer, mv->ptsize, mv->dpi, |
| 3273 |
MVGetSplineFontPieceMealFlags( mv ), NULL); |
| 3274 |
|
| 3275 |
MVReKern(mv); |
| 3276 |
MVSetVSb(mv); |
| 3277 |
} |
| 3278 |
|
| 3279 |
static void MVMenuChangeLayer(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3280 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3281 |
|
| 3282 |
mv->layer = mi->mid; |
| 3283 |
BDFFontFree(mv->show); |
| 3284 |
mv->show = SplineFontPieceMeal(mv->sf, mv->layer, mv->ptsize, mv->dpi, |
| 3285 |
MVGetSplineFontPieceMealFlags( mv ), NULL); |
| 3286 |
MVRemetric(mv); |
| 3287 |
GDrawRequestExpose(mv->v,NULL,false); |
| 3288 |
} |
| 3289 |
|
| 3290 |
static void MVMenuCenter(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) |
| 3291 |
{ |
| 3292 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3293 |
int i; |
| 3294 |
DBounds bb; |
| 3295 |
real transform[6]; |
| 3296 |
SplineChar *sc; |
| 3297 |
|
| 3298 |
for ( i=0; i<mv->glyphcnt; ++i ) |
| 3299 |
if ( mv->perchar[i].selected ) |
| 3300 |
break; |
| 3301 |
if ( i!=mv->glyphcnt ) { |
| 3302 |
sc = mv->glyphs[i].sc; |
| 3303 |
transform[0] = transform[3] = 1.0; |
| 3304 |
transform[1] = transform[2] = transform[5] = 0.0; |
| 3305 |
SplineCharFindBounds(sc,&bb); |
| 3306 |
if ( mi->mid==MV_MID_Center ) |
| 3307 |
transform[4] = (sc->width-(bb.maxx-bb.minx))/2 - bb.minx; |
| 3308 |
else |
| 3309 |
transform[4] = (sc->width-(bb.maxx-bb.minx))/3 - bb.minx; |
| 3310 |
if ( transform[4]!=0 ) |
| 3311 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, fvt_dontmovewidth| fvt_alllayers ); |
| 3312 |
} |
| 3313 |
} |
| 3314 |
|
| 3315 |
static void MVMenuKernByClasses(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3316 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3317 |
ShowKernClasses(mv->sf, mv, mv->layer, false); |
| 3318 |
} |
| 3319 |
|
| 3320 |
static void MVMenuVKernByClasses(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3321 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3322 |
ShowKernClasses(mv->sf, mv, mv->layer, true); |
| 3323 |
} |
| 3324 |
|
| 3325 |
static void MVMenuVKernFromHKern(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3326 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3327 |
FVVKernFromHKern((FontViewBase *) mv->fv); |
| 3328 |
} |
| 3329 |
|
| 3330 |
static void MVMenuKPCloseup(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3331 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3332 |
SplineChar *sc1=NULL, *sc2=NULL; |
| 3333 |
int i; |
| 3334 |
|
| 3335 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 3336 |
if ( mv->perchar[i].selected ) { |
| 3337 |
sc1 = mv->glyphs[i].sc; |
| 3338 |
if ( i+1<mv->glyphcnt ) |
| 3339 |
sc2 = mv->glyphs[i+1].sc; |
| 3340 |
break; |
| 3341 |
} |
| 3342 |
} |
| 3343 |
KernPairD(mv->sf,sc1,sc2,mv->layer,mv->vertical); |
| 3344 |
} |
| 3345 |
|
| 3346 |
static GMenuItem2 wnmenu[] = { |
| 3347 |
{ { (unichar_t *) N_("New O_utline Window"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'u' }, H_("New Outline Window|No Shortcut"), NULL, NULL, MVMenuOpenOutline, MV_MID_OpenOutline }, |
| 3348 |
{ { (unichar_t *) N_("New _Bitmap Window"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("New Bitmap Window|No Shortcut"), NULL, NULL, MVMenuOpenBitmap, MV_MID_OpenBitmap }, |
| 3349 |
{ { (unichar_t *) N_("New _Metrics Window"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 1, 1, 0, 0, 0, 0, 1, 1, 0, 'M' }, H_("New Metrics Window|No Shortcut"), NULL, NULL, NULL, 0 }, |
| 3350 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3351 |
{ { (unichar_t *) N_("Warnings"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'M' }, H_("Warnings|No Shortcut"), NULL, NULL, _MenuWarnings, MV_MID_Warnings }, |
| 3352 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3353 |
GMENUITEM2_EMPTY |
| 3354 |
}; |
| 3355 |
|
| 3356 |
static void MVWindowMenuBuild(GWindow gw,struct gmenuitem *mi,GEvent *e) { |
| 3357 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3358 |
int i; |
| 3359 |
SplineChar *sc; |
| 3360 |
struct gmenuitem *wmi; |
| 3361 |
|
| 3362 |
WindowMenuBuild(gw,mi,e); |
| 3363 |
|
| 3364 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 3365 |
if ( mv->perchar[i].selected ) |
| 3366 |
break; |
| 3367 |
if ( i==-1 ) sc = NULL; else sc = mv->glyphs[i].sc; |
| 3368 |
|
| 3369 |
for ( wmi = mi->sub; wmi->ti.text!=NULL || wmi->ti.line ; ++wmi ) { |
| 3370 |
switch ( wmi->mid ) { |
| 3371 |
case MV_MID_OpenOutline: |
| 3372 |
wmi->ti.disabled = sc==NULL; |
| 3373 |
break; |
| 3374 |
case MV_MID_OpenBitmap: |
| 3375 |
mi->ti.disabled = mv->sf->bitmaps==NULL || sc==NULL; |
| 3376 |
break; |
| 3377 |
case MV_MID_Warnings: |
| 3378 |
wmi->ti.disabled = ErrorWindowExists(); |
| 3379 |
break; |
| 3380 |
} |
| 3381 |
} |
| 3382 |
} |
| 3383 |
|
| 3384 |
static GMenuItem2 dummyitem[] = { |
| 3385 |
{ { (unichar_t *) N_("Font|_New"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'N' }, NULL, NULL, NULL, NULL, 0 }, |
| 3386 |
GMENUITEM2_EMPTY |
| 3387 |
}; |
| 3388 |
static GMenuItem2 fllist[] = { |
| 3389 |
{ { (unichar_t *) N_("Font|_New"), (GImage *) "filenew.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'N' }, H_("New|No Shortcut"), NULL, NULL, MenuNew, 0 }, |
| 3390 |
{ { (unichar_t *) N_("_Open"), (GImage *) "fileopen.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'O' }, H_("Open|No Shortcut"), NULL, NULL, MVMenuOpen, 0 }, |
| 3391 |
{ { (unichar_t *) N_("Recen_t"), (GImage *) "filerecent.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 't' }, NULL, dummyitem, MenuRecentBuild, NULL, MV_MID_Recent }, |
| 3392 |
{ { (unichar_t *) N_("_Close"), (GImage *) "fileclose.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'C' }, H_("Close|No Shortcut"), NULL, NULL, MVMenuClose, 0 }, |
| 3393 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3394 |
{ { (unichar_t *) N_("_Save"), (GImage *) "filesave.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'S' }, H_("Save|No Shortcut"), NULL, NULL, MVMenuSave, 0 }, |
| 3395 |
{ { (unichar_t *) N_("S_ave as..."), (GImage *) "filesaveas.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'a' }, H_("Save as...|No Shortcut"), NULL, NULL, MVMenuSaveAs, 0 }, |
| 3396 |
{ { (unichar_t *) N_("_Generate Fonts..."), (GImage *) "filegenerate.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'G' }, H_("Generate Fonts...|No Shortcut"), NULL, NULL, MVMenuGenerate, 0 }, |
| 3397 |
{ { (unichar_t *) N_("Generate Mac _Family..."), (GImage *) "filegeneratefamily.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'F' }, H_("Generate Mac Family...|No Shortcut"), NULL, NULL, MVMenuGenerateFamily, 0 }, |
| 3398 |
{ { (unichar_t *) N_("Generate TTC..."), (GImage *) "filegeneratefamily.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'F' }, H_("Generate TTC...|No Shortcut"), NULL, NULL, MVMenuGenerateTTC, 0 }, |
| 3399 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3400 |
{ { (unichar_t *) N_("_Merge Feature Info..."), (GImage *) "filemergefeature.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'M' }, H_("Merge Feature Info...|No Shortcut"), NULL, NULL, MVMenuMergeKern, 0 }, |
| 3401 |
{ { (unichar_t *) N_("Load _Word List..."), (GImage *) 0, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'M' }, H_("Load Word List...|No Shortcut"), NULL, NULL, MVMenuAddWordList, 0 }, |
| 3402 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3403 |
{ { (unichar_t *) N_("_Print..."), (GImage *) "fileprint.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'P' }, H_("Print...|No Shortcut"), NULL, NULL, MVMenuPrint, 0 }, |
| 3404 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3405 |
{ { (unichar_t *) N_("Pr_eferences..."), (GImage *) "fileprefs.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'e' }, H_("Preferences...|No Shortcut"), NULL, NULL, MenuPrefs, 0 }, |
| 3406 |
{ { (unichar_t *) N_("Appea_rance Editor..."), (GImage *) "menuempty.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'e' }, H_("Appearance Editor...|No Shortcut"), NULL, NULL, MenuXRes, 0 }, |
| 3407 |
#ifndef _NO_PYTHON |
| 3408 |
{ { (unichar_t *) N_("Config_ure Plugins..."), (GImage *) "menuempty.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'u' }, H_("Configure Plugins...|No Shortcut"), NULL, NULL, MenuPlug, 0 }, |
| 3409 |
#endif |
| 3410 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3411 |
{ { (unichar_t *) N_("_Quit"), (GImage *) "filequit.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'Q' }, H_("Quit|No Shortcut"), NULL, NULL, MenuExit, 0 }, |
| 3412 |
GMENUITEM2_EMPTY |
| 3413 |
}; |
| 3414 |
|
| 3415 |
static GMenuItem2 edlist[] = { |
| 3416 |
{ { (unichar_t *) N_("_Undo"), (GImage *) "editundo.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'U' }, H_("Undo|No Shortcut"), NULL, NULL, MVUndo, MV_MID_Undo }, |
| 3417 |
{ { (unichar_t *) N_("_Redo"), (GImage *) "editredo.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'R' }, H_("Redo|No Shortcut"), NULL, NULL, MVRedo, MV_MID_Redo }, |
| 3418 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3419 |
{ { (unichar_t *) N_("Cu_t"), (GImage *) "editcut.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 't' }, H_("Cut|No Shortcut"), NULL, NULL, MVCut, MV_MID_Cut }, |
| 3420 |
{ { (unichar_t *) N_("_Copy"), (GImage *) "editcopy.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'C' }, H_("Copy|No Shortcut"), NULL, NULL, MVCopy, MV_MID_Copy }, |
| 3421 |
{ { (unichar_t *) N_("C_opy Reference"), (GImage *) "editcopyref.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'o' }, H_("Copy Reference|No Shortcut"), NULL, NULL, MVMenuCopyRef, MV_MID_CopyRef }, |
| 3422 |
{ { (unichar_t *) N_("Copy _Width"), (GImage *) "editcopywidth.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'W' }, H_("Copy Width|No Shortcut"), NULL, NULL, MVMenuCopyWidth, MV_MID_CopyWidth }, |
| 3423 |
{ { (unichar_t *) N_("Copy _VWidth"), (GImage *) "editcopyvwidth.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'V' }, H_("Copy VWidth|No Shortcut"), NULL, NULL, MVMenuCopyWidth, MV_MID_CopyVWidth }, |
| 3424 |
{ { (unichar_t *) N_("Co_py LBearing"), (GImage *) "editcopylbearing.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'p' }, H_("Copy LBearing|No Shortcut"), NULL, NULL, MVMenuCopyWidth, MV_MID_CopyLBearing }, |
| 3425 |
{ { (unichar_t *) N_("Copy RBearin_g"), (GImage *) "editcopyrbearing.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'g' }, H_("Copy RBearing|No Shortcut"), NULL, NULL, MVMenuCopyWidth, MV_MID_CopyRBearing }, |
| 3426 |
{ { (unichar_t *) N_("_Paste"), (GImage *) "editpaste.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'P' }, H_("Paste|No Shortcut"), NULL, NULL, MVPaste, MV_MID_Paste }, |
| 3427 |
{ { (unichar_t *) N_("C_lear"), (GImage *) "editclear.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 1, 1, 0, 0, 0, 0, 1, 1, 0, 'l' }, H_("Clear|No Shortcut"), NULL, NULL, MVClear, MV_MID_Clear }, |
| 3428 |
{ { (unichar_t *) N_("_Join"), (GImage *) "editjoin.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'J' }, H_("Join|No Shortcut"), NULL, NULL, MVMenuJoin, MV_MID_Join }, |
| 3429 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3430 |
{ { (unichar_t *) N_("Select _All"), (GImage *) "editselect.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 1, 1, 0, 0, 0, 0, 1, 1, 0, 'A' }, H_("Select All|No Shortcut"), NULL, NULL, MVSelectAll, MV_MID_SelAll }, |
| 3431 |
{ { (unichar_t *) N_("_Deselect All"), (GImage *) "menuempty.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'D' }, H_("Deselect All|Escape"), NULL, NULL, MVClearSelection, MV_MID_ClearSel }, |
| 3432 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3433 |
{ { (unichar_t *) N_("U_nlink Reference"), (GImage *) "editunlink.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'U' }, H_("Unlink Reference|No Shortcut"), NULL, NULL, MVUnlinkRef, MV_MID_UnlinkRef }, |
| 3434 |
GMENUITEM2_EMPTY |
| 3435 |
}; |
| 3436 |
|
| 3437 |
static GMenuItem2 smlist[] = { |
| 3438 |
{ { (unichar_t *) N_("_Simplify"), (GImage *) "elementsimplify.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'S' }, H_("Simplify|No Shortcut"), NULL, NULL, MVMenuSimplify, MV_MID_Simplify }, |
| 3439 |
{ { (unichar_t *) N_("Simplify More..."), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'S' }, H_("Simplify More...|No Shortcut"), NULL, NULL, MVMenuSimplifyMore, MV_MID_SimplifyMore }, |
| 3440 |
{ { (unichar_t *) N_("Clea_nup Glyph"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'n' }, H_("Cleanup Glyph|No Shortcut"), NULL, NULL, MVMenuCleanup, MV_MID_CleanupGlyph }, |
| 3441 |
GMENUITEM2_EMPTY |
| 3442 |
}; |
| 3443 |
|
| 3444 |
static GMenuItem2 rmlist[] = { |
| 3445 |
{ { (unichar_t *) N_("_Remove Overlap"), (GImage *) "overlaprm.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'O' }, H_("Remove Overlap|No Shortcut"), NULL, NULL, MVMenuOverlap, MV_MID_RmOverlap }, |
| 3446 |
{ { (unichar_t *) N_("_Intersect"), (GImage *) "overlapintersection.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'I' }, H_("Intersect|No Shortcut"), NULL, NULL, MVMenuOverlap, MV_MID_Intersection }, |
| 3447 |
{ { (unichar_t *) N_("_Find Intersections"), (GImage *) "overlapfindinter.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'O' }, H_("Find Intersections|No Shortcut"), NULL, NULL, MVMenuOverlap, MV_MID_FindInter }, |
| 3448 |
GMENUITEM2_EMPTY |
| 3449 |
}; |
| 3450 |
|
| 3451 |
static GMenuItem2 eflist[] = { |
| 3452 |
{ { (unichar_t *) N_("_Inline"), (GImage *) "stylesinline.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'O' }, H_("Inline|No Shortcut"), NULL, NULL, MVMenuInline, 0 }, |
| 3453 |
{ { (unichar_t *) N_("_Outline"), (GImage *) "stylesoutline.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'I' }, H_("Outline|No Shortcut"), NULL, NULL, MVMenuOutline, 0 }, |
| 3454 |
{ { (unichar_t *) N_("_Shadow"), (GImage *) "stylesshadow.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'S' }, H_("Shadow|No Shortcut"), NULL, NULL, MVMenuShadow, 0 }, |
| 3455 |
{ { (unichar_t *) N_("_Wireframe"), (GImage *) "styleswireframe.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, true, 0, 0, 0, 0, 1, 1, 0, 'W' }, H_("Wireframe|No Shortcut"), NULL, NULL, MVMenuWireframe, 0 }, |
| 3456 |
GMENUITEM2_EMPTY |
| 3457 |
}; |
| 3458 |
|
| 3459 |
static GMenuItem2 balist[] = { |
| 3460 |
{ { (unichar_t *) N_("_Build Accented Glyph"), (GImage *) "elementbuildaccent.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("Build Accented Glyph|No Shortcut"), NULL, NULL, MVMenuBuildAccent, MV_MID_BuildAccent }, |
| 3461 |
{ { (unichar_t *) N_("Build _Composite Glyph"), (GImage *) "elementbuildcomposite.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("Build Composite Glyph|No Shortcut"), NULL, NULL, MVMenuBuildComposite, MV_MID_BuildComposite }, |
| 3462 |
GMENUITEM2_EMPTY |
| 3463 |
}; |
| 3464 |
|
| 3465 |
static void balistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3466 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3467 |
int i; |
| 3468 |
SplineChar *sc; |
| 3469 |
|
| 3470 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 3471 |
if ( mv->perchar[i].selected ) |
| 3472 |
break; |
| 3473 |
if ( i==-1 ) sc = NULL; else sc = mv->glyphs[i].sc; |
| 3474 |
|
| 3475 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3476 |
switch ( mi->mid ) { |
| 3477 |
case MV_MID_BuildAccent: |
| 3478 |
mi->ti.disabled = sc==NULL || !SFIsSomethingBuildable(sc->parent, sc, mv->layer, true); |
| 3479 |
break; |
| 3480 |
case MV_MID_BuildComposite: |
| 3481 |
mi->ti.disabled = sc==NULL || !SFIsSomethingBuildable(sc->parent, sc, mv->layer, false); |
| 3482 |
break; |
| 3483 |
} |
| 3484 |
} |
| 3485 |
} |
| 3486 |
|
| 3487 |
static GMenuItem2 ellist[] = { |
| 3488 |
{ { (unichar_t *) N_("_Font Info..."), (GImage *) "elementfontinfo.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'F' }, H_("Font Info...|No Shortcut"), NULL, NULL, MVMenuFontInfo, 0 }, |
| 3489 |
{ { (unichar_t *) N_("Glyph _Info..."), (GImage *) "elementglyphinfo.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'I' }, H_("Glyph Info...|No Shortcut"), NULL, NULL, MVMenuCharInfo, MV_MID_CharInfo }, |
| 3490 |
{ { (unichar_t *) N_("S_how Dependent"), (GImage *) "elementshowdep.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'D' }, H_("Show Dependent|No Shortcut"), NULL, NULL, MVMenuShowDependents, MV_MID_ShowDependents }, |
| 3491 |
{ { (unichar_t *) N_("Find Pr_oblems..."), (GImage *) "elementfindprobs.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'o' }, H_("Find Problems...|No Shortcut"), NULL, NULL, MVMenuFindProblems, MV_MID_FindProblems }, |
| 3492 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3493 |
{ { (unichar_t *) N_("Bitm_ap Strikes Available..."), (GImage *) "elementbitmapsavail.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'A' }, H_("Bitmap Strikes Available...|No Shortcut"), NULL, NULL, MVMenuBitmaps, MV_MID_AvailBitmaps }, |
| 3494 |
{ { (unichar_t *) N_("Regenerate _Bitmap Glyphs..."), (GImage *) "elementregenbitmaps.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("Regenerate Bitmap Glyphs...|No Shortcut"), NULL, NULL, MVMenuBitmaps, MV_MID_RegenBitmaps }, |
| 3495 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3496 |
{ { (unichar_t *) N_("_Transform..."), (GImage *) "elementtransform.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("Transform...|No Shortcut"), NULL, NULL, MVMenuTransform, MV_MID_Transform }, |
| 3497 |
#ifdef FONTFORGE_CONFIG_TILEPATH |
| 3498 |
{ { (unichar_t *) N_("Tile _Path..."), (GImage *) "elementtilepath.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'P' }, H_("Tile Path...|No Shortcut"), NULL, NULL, MVMenuTilePath, MV_MID_TilePath }, |
| 3499 |
#endif |
| 3500 |
{ { (unichar_t *) N_("_Remove Overlap"), (GImage *) "rmoverlap.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'O' }, H_("Remove Overlap|No Shortcut"), rmlist, NULL, NULL, MV_MID_RmOverlap }, |
| 3501 |
{ { (unichar_t *) N_("_Simplify"), (GImage *) "elementsimplify.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'S' }, H_("Simplify|No Shortcut"), smlist, NULL, NULL, MV_MID_Simplify }, |
| 3502 |
{ { (unichar_t *) N_("Add E_xtrema"), (GImage *) "elementaddextrema.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'x' }, H_("Add Extrema|No Shortcut"), NULL, NULL, MVMenuAddExtrema, MV_MID_AddExtrema }, |
| 3503 |
{ { (unichar_t *) N_("Add Points Of I_nflection"), (GImage *) "elementaddinflections.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'n' }, H_("Add Points Of Inflection|No Shortcut"), NULL, NULL, MVMenuAddInflections, MV_MID_AddInflections }, |
| 3504 |
{ { (unichar_t *) N_("To _Int"), (GImage *) "elementround.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'I' }, H_("To Int|No Shortcut"), NULL, NULL, MVMenuRound2Int, MV_MID_Round }, |
| 3505 |
{ { (unichar_t *) N_("Effects"), (GImage *) "elementstyles.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, '\0' }, H_("Effects|No Shortcut"), eflist, NULL, NULL, MV_MID_Effects }, |
| 3506 |
{ { (unichar_t *) N_("Autot_race"), (GImage *) "elementautotrace.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'r' }, H_("Autotrace|No Shortcut"), NULL, NULL, MVMenuAutotrace, MV_MID_Autotrace }, |
| 3507 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3508 |
{ { (unichar_t *) N_("_Correct Direction"), (GImage *) "elementcorrectdir.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'D' }, H_("Correct Direction|No Shortcut"), NULL, NULL, MVMenuCorrectDir, MV_MID_Correct }, |
| 3509 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3510 |
{ { (unichar_t *) N_("B_uild"), (GImage *) "elementbuildaccent.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("Build|No Shortcut"), balist, balistcheck, NULL, MV_MID_BuildAccent }, |
| 3511 |
GMENUITEM2_EMPTY |
| 3512 |
}; |
| 3513 |
|
| 3514 |
static GMenuItem2 dummyall[] = { |
| 3515 |
{ { (unichar_t *) N_("All"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 1, 1, 0, 0, 0, 0, 1, 1, 0, 'K' }, H_("All|No Shortcut"), NULL, NULL, NULL, 0 }, |
| 3516 |
GMENUITEM2_EMPTY |
| 3517 |
}; |
| 3518 |
|
| 3519 |
|
| 3520 |
static void aplistbuild(GWindow base, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3521 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(base); |
| 3522 |
|
| 3523 |
GMenuItemArrayFree(mi->sub); |
| 3524 |
mi->sub = NULL; |
| 3525 |
|
| 3526 |
_aplistbuild(mi, mv->sf, MVMenuAnchorPairs); |
| 3527 |
} |
| 3528 |
|
| 3529 |
static GMenuItem2 cblist[] = { |
| 3530 |
{ { (unichar_t *) N_("_Kern Pairs"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'K' }, H_("Kern Pairs|No Shortcut"), NULL, NULL, MVMenuKernPairs, MV_MID_KernPairs }, |
| 3531 |
{ { (unichar_t *) N_("_Anchored Pairs"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'K' }, H_("Anchored Pairs|No Shortcut"), dummyall, aplistbuild, MVMenuAnchorPairs, MV_MID_AnchorPairs }, |
| 3532 |
{ { (unichar_t *) N_("_Ligatures"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'L' }, H_("Ligatures|No Shortcut"), NULL, NULL, MVMenuLigatures, MV_MID_Ligatures }, |
| 3533 |
GMENUITEM2_EMPTY |
| 3534 |
}; |
| 3535 |
|
| 3536 |
static void cblistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3537 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3538 |
SplineFont *sf = mv->sf; |
| 3539 |
int i, anyligs=0, anykerns=0; |
| 3540 |
PST *pst; |
| 3541 |
|
| 3542 |
for ( i=0; i<sf->glyphcnt; ++i ) if ( sf->glyphs[i]!=NULL ) { |
| 3543 |
for ( pst=sf->glyphs[i]->possub; pst!=NULL; pst=pst->next ) { |
| 3544 |
if ( pst->type==pst_ligature ) { |
| 3545 |
anyligs = true; |
| 3546 |
if ( anykerns ) |
| 3547 |
break; |
| 3548 |
} |
| 3549 |
} |
| 3550 |
if ( (mv->vertical ? sf->glyphs[i]->vkerns : sf->glyphs[i]->kerns)!=NULL ) { |
| 3551 |
anykerns = true; |
| 3552 |
if ( anyligs ) |
| 3553 |
break; |
| 3554 |
} |
| 3555 |
} |
| 3556 |
|
| 3557 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3558 |
switch ( mi->mid ) { |
| 3559 |
case MV_MID_Ligatures: |
| 3560 |
mi->ti.disabled = !anyligs; |
| 3561 |
break; |
| 3562 |
case MV_MID_KernPairs: |
| 3563 |
mi->ti.disabled = !anykerns; |
| 3564 |
break; |
| 3565 |
case MV_MID_AnchorPairs: |
| 3566 |
mi->ti.disabled = sf->anchor==NULL; |
| 3567 |
break; |
| 3568 |
} |
| 3569 |
} |
| 3570 |
} |
| 3571 |
|
| 3572 |
static GMenuItem2 lylist[] = { |
| 3573 |
{ { (unichar_t *) N_("Layer|Foreground"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, '\0' }, NULL, NULL, NULL, MVMenuChangeLayer, ly_fore }, |
| 3574 |
GMENUITEM2_EMPTY |
| 3575 |
}; |
| 3576 |
|
| 3577 |
static void lylistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3578 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3579 |
SplineFont *sf = mv->fv->b.sf; |
| 3580 |
int ly; |
| 3581 |
GMenuItem *sub; |
| 3582 |
|
| 3583 |
sub = calloc(sf->layer_cnt+1,sizeof(GMenuItem)); |
| 3584 |
for ( ly=ly_fore; ly<sf->layer_cnt; ++ly ) { |
| 3585 |
sub[ly-1].ti.text = utf82u_copy(sf->layers[ly].name); |
| 3586 |
sub[ly-1].ti.checkable = true; |
| 3587 |
sub[ly-1].ti.checked = ly == mv->layer; |
| 3588 |
sub[ly-1].invoke = MVMenuChangeLayer; |
| 3589 |
sub[ly-1].mid = ly; |
| 3590 |
sub[ly-1].ti.fg = sub[ly-1].ti.bg = COLOR_DEFAULT; |
| 3591 |
} |
| 3592 |
GMenuItemArrayFree(mi->sub); |
| 3593 |
mi->sub = sub; |
| 3594 |
} |
| 3595 |
|
| 3596 |
static GMenuItem2 gdlist[] = { |
| 3597 |
{ { (unichar_t *) N_("_Show"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Show|No Shortcut"), NULL, NULL, MVMenuShowGrid, MV_MID_ShowGrid }, |
| 3598 |
{ { (unichar_t *) N_("_Partial"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Partial|No Shortcut"), NULL, NULL, MVMenuShowGrid, MV_MID_PartialGrid }, |
| 3599 |
{ { (unichar_t *) N_("Hide when _Moving"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Hide when Moving|No Shortcut"), NULL, NULL, MVMenuShowGrid, MV_MID_HideGridWhenMoving }, |
| 3600 |
{ { (unichar_t *) N_("_Hide"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Hide|No Shortcut"), NULL, NULL, MVMenuShowGrid, MV_MID_HideGrid }, |
| 3601 |
GMENUITEM2_EMPTY |
| 3602 |
}; |
| 3603 |
|
| 3604 |
static void gdlistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3605 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3606 |
|
| 3607 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3608 |
switch ( mi->mid ) { |
| 3609 |
case MV_MID_ShowGrid: |
| 3610 |
mi->ti.checked = mv->showgrid == mv_showgrid; |
| 3611 |
break; |
| 3612 |
case MV_MID_HideGrid: |
| 3613 |
mi->ti.checked = mv->showgrid == mv_hidegrid; |
| 3614 |
break; |
| 3615 |
case MV_MID_PartialGrid: |
| 3616 |
mi->ti.checked = mv->showgrid == mv_partialgrid; |
| 3617 |
break; |
| 3618 |
case MV_MID_HideGridWhenMoving: |
| 3619 |
mi->ti.checked = mv->showgrid == mv_hidemovinggrid; |
| 3620 |
break; |
| 3621 |
} |
| 3622 |
} |
| 3623 |
} |
| 3624 |
|
| 3625 |
static GMenuItem2 vwlist[] = { |
| 3626 |
{ { (unichar_t *) N_("Z_oom out"), (GImage *) "viewzoomout.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'o' }, H_("Zoom out|No Shortcut"), NULL, NULL, MVMenuScale, MV_MID_ZoomOut }, |
| 3627 |
{ { (unichar_t *) N_("Zoom _in"), (GImage *) "viewzoomin.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'i' }, H_("Zoom in|No Shortcut"), NULL, NULL, MVMenuScale, MV_MID_ZoomIn }, |
| 3628 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3629 |
{ { (unichar_t *) N_("Insert Glyph _After..."), (GImage *) "viewinsertafter.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'C' }, H_("Insert Glyph After...|No Shortcut"), NULL, NULL, MVMenuInsertChar, MV_MID_InsertCharA }, |
| 3630 |
{ { (unichar_t *) N_("Insert Glyph _Before..."), (GImage *) "viewinsertbefore.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("Insert Glyph Before...|No Shortcut"), NULL, NULL, MVMenuInsertChar, MV_MID_InsertCharB }, |
| 3631 |
{ { (unichar_t *) N_("_Replace Glyph..."), (GImage *) "viewreplace.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'R' }, H_("Replace Glyph...|No Shortcut"), NULL, NULL, MVMenuChangeChar, MV_MID_ReplaceChar }, |
| 3632 |
{ { (unichar_t *) N_("_Next Glyph"), (GImage *) "viewnext.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'N' }, H_("Next Glyph|No Shortcut"), NULL, NULL, MVMenuChangeChar, MV_MID_Next }, |
| 3633 |
{ { (unichar_t *) N_("_Prev Glyph"), (GImage *) "viewprev.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'P' }, H_("Prev Glyph|No Shortcut"), NULL, NULL, MVMenuChangeChar, MV_MID_Prev }, |
| 3634 |
{ { (unichar_t *) N_("Next _Defined Glyph"), (GImage *) "viewnextdef.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'D' }, H_("Next Defined Glyph|No Shortcut"), NULL, NULL, MVMenuChangeChar, MV_MID_NextDef }, |
| 3635 |
{ { (unichar_t *) N_("Prev Defined Gl_yph"), (GImage *) "viewprevdef.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'a' }, H_("Prev Defined Glyph|No Shortcut"), NULL, NULL, MVMenuChangeChar, MV_MID_PrevDef }, |
| 3636 |
{ { (unichar_t *) N_("Find In Font _View"), (GImage *) "viewfindinfont.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'V' }, H_("Find In Font View|No Shortcut"), NULL, NULL, MVMenuFindInFontView, MV_MID_FindInFontView }, |
| 3637 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3638 |
{ { (unichar_t *) N_("_Layers"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, '\0' }, H_("Layers|No Shortcut"), lylist, lylistcheck, NULL, 0 }, |
| 3639 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3640 |
{ { (unichar_t *) N_("Com_binations"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'b' }, H_("Combinations|No Shortcut"), cblist, cblistcheck, NULL, 0 }, |
| 3641 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3642 |
{ { (unichar_t *) N_("Show _Grid"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'G' }, H_("Show Grid|No Shortcut"), gdlist, gdlistcheck, MVMenuShowGrid, MV_MID_ShowGrid }, |
| 3643 |
{ { (unichar_t *) N_("_Anti Alias"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'A' }, H_("Anti Alias|No Shortcut"), NULL, NULL, MVMenuAA, MV_MID_AntiAlias }, |
| 3644 |
{ { (unichar_t *) N_("Render using Hinting"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'A' }, H_("Render using Hinting|No Shortcut"), NULL, NULL, MVMenuRenderUsingHinting, MV_MID_RenderUsingHinting }, |
| 3645 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3646 |
{ { (unichar_t *) N_("_Vertical"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, '\0' }, H_("Vertical|No Shortcut"), NULL, NULL, MVMenuVertical, MV_MID_Vertical }, |
| 3647 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3648 |
{ { (unichar_t *) N_("Size set from _Window"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'O' }, H_("Size set from Window|No Shortcut"), NULL, NULL, MVMenuSizeWindow, MV_MID_SizeWindow }, |
| 3649 |
{ { (unichar_t *) N_("Set Point _Size"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'O' }, H_("Set Point Size|No Shortcut"), NULL, NULL, MVMenuPointSize, MV_MID_PointSize }, |
| 3650 |
{ { (unichar_t *) N_("_Bigger Point Size"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'B' }, H_("Bigger Point Size|No Shortcut"), NULL, NULL, MVMenuChangePointSize, MV_MID_Bigger }, |
| 3651 |
{ { (unichar_t *) N_("_Smaller Point Size"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'S' }, H_("Smaller Point Size|No Shortcut"), NULL, NULL, MVMenuChangePointSize, MV_MID_Smaller }, |
| 3652 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3653 |
{ { (unichar_t *) N_("Next _Line in Word List"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'O' }, H_("Next Line in Word List|No Shortcut"), NULL, NULL, MVMenuNextLineInWordList, MV_MID_NextLineInWordList }, |
| 3654 |
{ { (unichar_t *) N_("Previous Line in _Word List"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'O' }, H_("Previous Line in Word List|No Shortcut"), NULL, NULL, MVMenuPrevLineInWordList, MV_MID_PrevLineInWordList }, |
| 3655 |
|
| 3656 |
{ { NULL, NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 1, 0, 0, 0, '\0' }, NULL, NULL, NULL, NULL, 0 }, |
| 3657 |
{ { (unichar_t *) N_("_Outline"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'O' }, H_("Outline|No Shortcut"), NULL, NULL, MVMenuShowBitmap, MV_MID_Outline }, |
| 3658 |
GMENUITEM2_EMPTY, |
| 3659 |
|
| 3660 |
GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, |
| 3661 |
GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, |
| 3662 |
GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, |
| 3663 |
GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY, GMENUITEM2_EMPTY |
| 3664 |
}; |
| 3665 |
|
| 3666 |
static void MVMenuContextualHelp(GWindow UNUSED(base), struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3667 |
help("ui/mainviews/metricsview.html", NULL); |
| 3668 |
} |
| 3669 |
|
| 3670 |
static GMenuItem2 tylist[] = { |
| 3671 |
{ { (unichar_t *) N_("_Kerning only"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'C' }, H_("Kerning only|No Shortcut"), NULL, NULL, MVMenuWindowType, MV_MID_KernOnly }, |
| 3672 |
{ { (unichar_t *) N_("_Advance Width only"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Advance Width only|No Shortcut"), NULL, NULL, MVMenuWindowType, MV_MID_WidthOnly }, |
| 3673 |
{ { (unichar_t *) N_("_Both"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 1, 0, 0, 0, 1, 1, 0, 'T' }, H_("Both|No Shortcut"), NULL, NULL, MVMenuWindowType, MV_MID_BothKernWidth }, |
| 3674 |
GMENUITEM2_EMPTY |
| 3675 |
}; |
| 3676 |
|
| 3677 |
static void tylistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3678 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3679 |
|
| 3680 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3681 |
switch ( mi->mid ) { |
| 3682 |
case MV_MID_KernOnly: |
| 3683 |
mi->ti.checked = mv->type == mv_kernonly; |
| 3684 |
break; |
| 3685 |
case MV_MID_WidthOnly: |
| 3686 |
mi->ti.checked = mv->type == mv_widthonly; |
| 3687 |
break; |
| 3688 |
case MV_MID_BothKernWidth: |
| 3689 |
mi->ti.checked = mv->type == mv_kernwidth; |
| 3690 |
break; |
| 3691 |
} |
| 3692 |
} |
| 3693 |
} |
| 3694 |
|
| 3695 |
|
| 3696 |
|
| 3697 |
static void MVMenuSetWidth(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3698 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3699 |
if ( mi->mid == MV_MID_SetVWidth && !mv->sf->hasvmetrics ) |
| 3700 |
return; |
| 3701 |
SplineChar* sc = getSelectedChar(mv); |
| 3702 |
|
| 3703 |
if(!sc) |
| 3704 |
return; |
| 3705 |
|
| 3706 |
GenericVSetWidth(mv->fv,sc, |
| 3707 |
mi->mid==MV_MID_SetWidth?wt_width: |
| 3708 |
mi->mid==MV_MID_SetLBearing?wt_lbearing: |
| 3709 |
mi->mid==MV_MID_SetRBearing?wt_rbearing: |
| 3710 |
mi->mid==MV_MID_SetBearings?wt_bearings: |
| 3711 |
wt_vwidth); |
| 3712 |
} |
| 3713 |
|
| 3714 |
static void MVMenuRemoveKern(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3715 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3716 |
SplineChar* sc = getSelectedChar(mv); |
| 3717 |
if(!sc) |
| 3718 |
return; |
| 3719 |
SCRemoveKern(sc); |
| 3720 |
} |
| 3721 |
static void MVMenuRemoveVKern(GWindow gw, struct gmenuitem *UNUSED(mi), GEvent *UNUSED(e)) { |
| 3722 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3723 |
SplineChar* sc = getSelectedChar(mv); |
| 3724 |
if(!sc) |
| 3725 |
return; |
| 3726 |
SCRemoveVKern(sc); |
| 3727 |
} |
| 3728 |
|
| 3729 |
static GMenuItem2 mtlist[] = { |
| 3730 |
{ { (unichar_t *) N_("_Center in Width"), (GImage *) "metricscenter.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'C' }, H_("Center in Width|No Shortcut"), NULL, NULL, MVMenuCenter, MV_MID_Center }, |
| 3731 |
{ { (unichar_t *) N_("_Thirds in Width"), (GImage *) "menuempty.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("Thirds in Width|No Shortcut"), NULL, NULL, MVMenuCenter, MV_MID_Thirds }, |
| 3732 |
{ { (unichar_t *) N_("Set _Width..."), (GImage *) "metricssetwidth.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'W' }, H_("Set Width...|No Shortcut"), NULL, NULL, MVMenuSetWidth, MV_MID_SetWidth }, |
| 3733 |
{ { (unichar_t *) N_("Set _LBearing..."), (GImage *) "metricssetlbearing.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'L' }, H_("Set LBearing...|No Shortcut"), NULL, NULL, MVMenuSetWidth, MV_MID_SetLBearing }, |
| 3734 |
{ { (unichar_t *) N_("Set _RBearing..."), (GImage *) "metricssetrbearing.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'R' }, H_("Set RBearing...|No Shortcut"), NULL, NULL, MVMenuSetWidth, MV_MID_SetRBearing }, |
| 3735 |
{ { (unichar_t *) N_("Set Both Bearings..."), (GImage *) "menuempty.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'R' }, H_("Set Both Bearings...|No Shortcut"), NULL, NULL, MVMenuSetWidth, MV_MID_SetBearings }, |
| 3736 |
GMENUITEM2_LINE, |
| 3737 |
{ { (unichar_t *) N_("Set _Vertical Advance..."), (GImage *) "metricssetvwidth.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'V' }, H_("Set Vertical Advance...|No Shortcut"), NULL, NULL, MVMenuSetWidth, MV_MID_SetVWidth }, |
| 3738 |
GMENUITEM2_LINE, |
| 3739 |
{ { (unichar_t *) N_("_Window Type"), (GImage *) "menuempty.png", COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("Window Type|No Shortcut"), tylist, tylistcheck, NULL, 0 }, |
| 3740 |
GMENUITEM2_LINE, |
| 3741 |
{ { (unichar_t *) N_("Ker_n By Classes..."), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("Kern By Classes...|No Shortcut"), NULL, NULL, MVMenuKernByClasses, 0 }, |
| 3742 |
{ { (unichar_t *) N_("VKern By Classes..."), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("VKern By Classes...|No Shortcut"), NULL, NULL, MVMenuVKernByClasses, MV_MID_VKernClass }, |
| 3743 |
{ { (unichar_t *) N_("VKern From HKern"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("VKern From HKern|No Shortcut"), NULL, NULL, MVMenuVKernFromHKern, MV_MID_VKernFromHKern }, |
| 3744 |
{ { (unichar_t *) N_("Remove Kern _Pairs"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'P' }, H_("Remove Kern Pairs|No Shortcut"), NULL, NULL, MVMenuRemoveKern, MV_MID_RemoveKerns }, |
| 3745 |
{ { (unichar_t *) N_("Remove VKern Pairs"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'P' }, H_("Remove VKern Pairs|No Shortcut"), NULL, NULL, MVMenuRemoveVKern, MV_MID_RemoveVKerns }, |
| 3746 |
{ { (unichar_t *) N_("Kern Pair Closeup..."), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'T' }, H_("Kern Pair Closeup...|No Shortcut"), NULL, NULL, MVMenuKPCloseup, 0 }, |
| 3747 |
GMENUITEM2_EMPTY |
| 3748 |
}; |
| 3749 |
|
| 3750 |
static void fllistcheck(GWindow UNUSED(gw), struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3751 |
|
| 3752 |
|
| 3753 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3754 |
switch ( mi->mid ) { |
| 3755 |
case MV_MID_Recent: |
| 3756 |
mi->ti.disabled = !RecentFilesAny(); |
| 3757 |
break; |
| 3758 |
} |
| 3759 |
} |
| 3760 |
} |
| 3761 |
|
| 3762 |
static void edlistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3763 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3764 |
int i; |
| 3765 |
|
| 3766 |
if ( GWindowGetFocusGadgetOfWindow(gw)!=NULL ) |
| 3767 |
i = -1; |
| 3768 |
else |
| 3769 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 3770 |
if ( mv->perchar[i].selected ) |
| 3771 |
break; |
| 3772 |
|
| 3773 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3774 |
switch ( mi->mid ) { |
| 3775 |
case MV_MID_Cut: case MV_MID_Copy: |
| 3776 |
break; |
| 3777 |
case MV_MID_Join: |
| 3778 |
case MV_MID_CopyRef: case MV_MID_CopyWidth: |
| 3779 |
case MV_MID_CopyLBearing: case MV_MID_CopyRBearing: |
| 3780 |
case MV_MID_Clear: |
| 3781 |
mi->ti.disabled = i==-1; |
| 3782 |
break; |
| 3783 |
case MV_MID_CopyVWidth: |
| 3784 |
mi->ti.disabled = i==-1 || !mv->sf->hasvmetrics; |
| 3785 |
break; |
| 3786 |
case MV_MID_UnlinkRef: |
| 3787 |
mi->ti.disabled = i==-1 || mv->glyphs[i].sc->layers[mv->layer].refs==NULL; |
| 3788 |
break; |
| 3789 |
case MV_MID_Paste: |
| 3790 |
break; |
| 3791 |
} |
| 3792 |
} |
| 3793 |
} |
| 3794 |
|
| 3795 |
static void ellistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3796 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3797 |
int i, anybuildable; |
| 3798 |
SplineChar *sc; |
| 3799 |
int order2 = mv->sf->layers[mv->layer].order2; |
| 3800 |
|
| 3801 |
for ( i=mv->glyphcnt-1; i>=0; --i ) |
| 3802 |
if ( mv->perchar[i].selected ) |
| 3803 |
break; |
| 3804 |
if ( i==-1 ) sc = NULL; else sc = mv->glyphs[i].sc; |
| 3805 |
|
| 3806 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 3807 |
switch ( mi->mid ) { |
| 3808 |
case MV_MID_RegenBitmaps: |
| 3809 |
mi->ti.disabled = mv->sf->bitmaps==NULL; |
| 3810 |
break; |
| 3811 |
case MV_MID_CharInfo: |
| 3812 |
mi->ti.disabled = sc==NULL ; |
| 3813 |
break; |
| 3814 |
case MV_MID_ShowDependents: |
| 3815 |
mi->ti.disabled = sc==NULL || sc->dependents == NULL; |
| 3816 |
break; |
| 3817 |
case MV_MID_FindProblems: |
| 3818 |
case MV_MID_Transform: |
| 3819 |
mi->ti.disabled = sc==NULL; |
| 3820 |
break; |
| 3821 |
case MV_MID_Effects: |
| 3822 |
mi->ti.disabled = sc==NULL || mv->sf->onlybitmaps || order2; |
| 3823 |
break; |
| 3824 |
case MV_MID_RmOverlap: case MV_MID_Stroke: |
| 3825 |
mi->ti.disabled = sc==NULL || mv->sf->onlybitmaps; |
| 3826 |
break; |
| 3827 |
case MV_MID_AddExtrema: case MV_MID_AddInflections: case MV_MID_Round: case MV_MID_Correct: |
| 3828 |
mi->ti.disabled = sc==NULL || mv->sf->onlybitmaps; |
| 3829 |
break; |
| 3830 |
#ifdef FONTFORGE_CONFIG_TILEPATH |
| 3831 |
case MV_MID_TilePath: |
| 3832 |
mi->ti.disabled = sc==NULL || mv->sf->onlybitmaps || ClipBoardToSplineSet()==NULL || order2; |
| 3833 |
break; |
| 3834 |
#endif |
| 3835 |
case MV_MID_Simplify: |
| 3836 |
mi->ti.disabled = sc==NULL || mv->sf->onlybitmaps; |
| 3837 |
break; |
| 3838 |
case MV_MID_BuildAccent: |
| 3839 |
anybuildable = false; |
| 3840 |
if ( sc!=NULL && SFIsSomethingBuildable(mv->sf,sc,mv->layer,false) ) |
| 3841 |
anybuildable = true; |
| 3842 |
mi->ti.disabled = !anybuildable; |
| 3843 |
break; |
| 3844 |
case MV_MID_Autotrace: |
| 3845 |
mi->ti.disabled = !(FindAutoTraceName()!=NULL && sc!=NULL && |
| 3846 |
sc->layers[ly_back].images!=NULL ); |
| 3847 |
break; |
| 3848 |
} |
| 3849 |
} |
| 3850 |
} |
| 3851 |
|
| 3852 |
static ShaperContext* MVMakeShaperContext(MetricsView* mv) { |
| 3853 |
ShaperContext* context = calloc(1, sizeof(ShaperContext)); |
| 3854 |
context->sf = mv->sf; |
| 3855 |
context->mv = mv; |
| 3856 |
context->apply_ticked_features = ApplyTickedFeatures; |
| 3857 |
context->get_char_metrics = MVCharMetrics; |
| 3858 |
context->get_kern_offset = MVGetKernOffset; |
| 3859 |
context->script_is_rtl = ScriptIsRightToLeft; |
| 3860 |
context->get_or_make_char = SFGetOrMakeChar; |
| 3861 |
context->write_font_into_memory = WriteTTFFontForShaper; |
| 3862 |
context->get_name = SCGetName; |
| 3863 |
context->get_encoding = SCGetEncoding; |
| 3864 |
|
| 3865 |
return context; |
| 3866 |
} |
| 3867 |
|
| 3868 |
static void SetShaper(MetricsView *mv, const char* shaper_name) { |
| 3869 |
GCursor ct = GDrawGetCursor(mv->gw); |
| 3870 |
|
| 3871 |
|
| 3872 |
GDrawProcessPendingEvents(NULL); |
| 3873 |
|
| 3874 |
|
| 3875 |
GDrawSetCursor(mv->gw,ct_watch); |
| 3876 |
|
| 3877 |
|
| 3878 |
|
| 3879 |
GDrawSync(NULL); |
| 3880 |
|
| 3881 |
shaper_free(&(mv->shaper)); |
| 3882 |
mv->shaper = shaper_factory(shaper_name, MVMakeShaperContext(mv)); |
| 3883 |
MVSetFeatures(mv); |
| 3884 |
MVRefreshAll(mv); |
| 3885 |
|
| 3886 |
GDrawSetCursor(mv->gw,ct); |
| 3887 |
} |
| 3888 |
|
| 3889 |
static void MVSetShaper(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3890 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3891 |
const char* new_shaper_name = mi->ti.userdata; |
| 3892 |
|
| 3893 |
|
| 3894 |
if (mv->shaper && (strcmp(shaper_name(mv->shaper), new_shaper_name) == 0)) { |
| 3895 |
return; |
| 3896 |
} |
| 3897 |
|
| 3898 |
SetShaper(mv, new_shaper_name); |
| 3899 |
} |
| 3900 |
|
| 3901 |
static void MVRefreshShaper(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3902 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3903 |
const char* current_shaper_name = shaper_name(mv->shaper); |
| 3904 |
|
| 3905 |
SetShaper(mv, current_shaper_name); |
| 3906 |
} |
| 3907 |
|
| 3908 |
static void vwlistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 3909 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 3910 |
int i, j, base, aselection; |
| 3911 |
BDFFont *bdf; |
| 3912 |
char buffer[60]; |
| 3913 |
int n_shapers = 0; |
| 3914 |
const ShaperDef *sh_def, *shaper_defs = get_shaper_defs(); |
| 3915 |
|
| 3916 |
aselection = false; |
| 3917 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 3918 |
if ( mv->perchar[j].selected ) { |
| 3919 |
aselection = true; |
| 3920 |
break; |
| 3921 |
} |
| 3922 |
|
| 3923 |
for ( i=0; vwlist[i].mid!=MV_MID_Outline; ++i ) |
| 3924 |
switch ( vwlist[i].mid ) { |
| 3925 |
case MV_MID_ZoomIn: |
| 3926 |
vwlist[i].ti.disabled = mv->scale_index==0; |
| 3927 |
break; |
| 3928 |
case MV_MID_ZoomOut: |
| 3929 |
vwlist[i].ti.disabled = mv->scale_index>=sizeof(mv_scales)/sizeof(mv_scales[0])-1; |
| 3930 |
break; |
| 3931 |
case MV_MID_AntiAlias: |
| 3932 |
vwlist[i].ti.checked = mv->antialias; |
| 3933 |
vwlist[i].ti.disabled = mv->bdf!=NULL; |
| 3934 |
break; |
| 3935 |
case MV_MID_RenderUsingHinting: |
| 3936 |
vwlist[i].ti.checked = mv->usehinting; |
| 3937 |
vwlist[i].ti.disabled = mv->bdf!=NULL; |
| 3938 |
break; |
| 3939 |
case MV_MID_SizeWindow: |
| 3940 |
vwlist[i].ti.disabled = mv->pixelsize_set_by_window; |
| 3941 |
vwlist[i].ti.checked = mv->pixelsize_set_by_window; |
| 3942 |
break; |
| 3943 |
case MV_MID_Bigger: |
| 3944 |
case MV_MID_Smaller: |
| 3945 |
vwlist[i].ti.disabled = mv->pixelsize_set_by_window; |
| 3946 |
break; |
| 3947 |
case MV_MID_ReplaceChar: |
| 3948 |
case MV_MID_FindInFontView: |
| 3949 |
case MV_MID_Next: |
| 3950 |
case MV_MID_Prev: |
| 3951 |
case MV_MID_NextDef: |
| 3952 |
case MV_MID_PrevDef: |
| 3953 |
vwlist[i].ti.disabled = !aselection; |
| 3954 |
break; |
| 3955 |
case MV_MID_Vertical: |
| 3956 |
vwlist[i].ti.checked = mv->vertical; |
| 3957 |
vwlist[i].ti.disabled = !mv->sf->hasvmetrics; |
| 3958 |
break; |
| 3959 |
case MV_MID_Layers: |
| 3960 |
vwlist[i].ti.disabled = mv->sf->layer_cnt<=2 || mv->sf->multilayer; |
| 3961 |
break; |
| 3962 |
} |
| 3963 |
vwlist[i].ti.checked = mv->bdf==NULL; |
| 3964 |
base = i+1; |
| 3965 |
|
| 3966 |
for ( i=base; i<sizeof(vwlist)/sizeof(vwlist[0]); ++i ) { |
| 3967 |
free( vwlist[i].ti.text); |
| 3968 |
vwlist[i].ti.text = NULL; |
| 3969 |
vwlist[i].ti.line = false; |
| 3970 |
} |
| 3971 |
i = base; |
| 3972 |
|
| 3973 |
if ( mv->sf->bitmaps!=NULL ) { |
| 3974 |
for ( bdf = mv->sf->bitmaps, i=base; |
| 3975 |
i<sizeof(vwlist)/sizeof(vwlist[0])-1 && bdf!=NULL; |
| 3976 |
++i, bdf = bdf->next ) { |
| 3977 |
if ( BDFDepth(bdf)==1 ) |
| 3978 |
sprintf( buffer, _("%d pixel bitmap"), bdf->pixelsize ); |
| 3979 |
else |
| 3980 |
sprintf( buffer, _("%d@%d pixel bitmap"), |
| 3981 |
bdf->pixelsize, BDFDepth(bdf) ); |
| 3982 |
vwlist[i].ti.text = utf82u_copy(buffer); |
| 3983 |
vwlist[i].ti.checkable = true; |
| 3984 |
vwlist[i].ti.checked = bdf==mv->bdf; |
| 3985 |
vwlist[i].ti.userdata = bdf; |
| 3986 |
vwlist[i].invoke = MVMenuShowBitmap; |
| 3987 |
vwlist[i].ti.fg = vwlist[i].ti.bg = COLOR_DEFAULT; |
| 3988 |
} |
| 3989 |
} |
| 3990 |
|
| 3991 |
|
| 3992 |
for (sh_def = shaper_defs; sh_def->name != NULL; ++sh_def) ++n_shapers; |
| 3993 |
|
| 3994 |
|
| 3995 |
if (n_shapers > 1) { |
| 3996 |
vwlist[i++].ti.line = true; |
| 3997 |
for (sh_def = shaper_defs; |
| 3998 |
i<sizeof(vwlist)/sizeof(vwlist[0])-1 && sh_def->name != NULL; ++sh_def) { |
| 3999 |
vwlist[i].ti.text = utf82u_copy(sh_def->label); |
| 4000 |
vwlist[i].ti.checkable = true; |
| 4001 |
vwlist[i].ti.checked = (strcmp(shaper_name(mv->shaper), sh_def->name)==0); |
| 4002 |
vwlist[i].ti.userdata = (void*) sh_def->name; |
| 4003 |
vwlist[i].invoke = MVSetShaper; |
| 4004 |
vwlist[i].ti.fg = vwlist[i].ti.bg = COLOR_DEFAULT; |
| 4005 |
i++; |
| 4006 |
} |
| 4007 |
|
| 4008 |
vwlist[i].ti.text = utf82u_copy(_("Refresh Shaper")); |
| 4009 |
vwlist[i].ti.checkable = false; |
| 4010 |
vwlist[i].invoke = MVRefreshShaper; |
| 4011 |
vwlist[i].ti.fg = vwlist[i].ti.bg = COLOR_DEFAULT; |
| 4012 |
} |
| 4013 |
GMenuItemArrayFree(mi->sub); |
| 4014 |
mi->sub = GMenuItem2ArrayCopy(vwlist,NULL); |
| 4015 |
} |
| 4016 |
|
| 4017 |
GTextInfo *GetShaperList(int* p_default) { |
| 4018 |
GTextInfo *ti; |
| 4019 |
int i, cnt; |
| 4020 |
const ShaperDef *sh_def, *shaper_defs = get_shaper_defs(); |
| 4021 |
const char* default_shaper = get_default_shaper(); |
| 4022 |
|
| 4023 |
if (p_default) *p_default = 0; |
| 4024 |
|
| 4025 |
cnt = 0; |
| 4026 |
for ( sh_def=shaper_defs; sh_def->name!=NULL ; ++sh_def ) |
| 4027 |
++cnt; |
| 4028 |
|
| 4029 |
ti = calloc(cnt+1,sizeof(GTextInfo)); |
| 4030 |
for ( i=0; i<cnt; ++i ) { |
| 4031 |
ti[i].text = uc_copy(shaper_defs[i].label); |
| 4032 |
ti[i].selected = (strcmp(shaper_defs[i].name, default_shaper) == 0); |
| 4033 |
if (ti[i].selected && p_default) { |
| 4034 |
*p_default = i; |
| 4035 |
} |
| 4036 |
ti[i].userdata = (void *) shaper_defs[i].name; |
| 4037 |
} |
| 4038 |
return( ti ); |
| 4039 |
} |
| 4040 |
|
| 4041 |
static void mtlistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) { |
| 4042 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 4043 |
SplineChar* sc = getSelectedChar(mv); |
| 4044 |
|
| 4045 |
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) { |
| 4046 |
switch ( mi->mid ) { |
| 4047 |
case MV_MID_VKernClass: |
| 4048 |
case MV_MID_VKernFromHKern: |
| 4049 |
case MV_MID_SetVWidth: |
| 4050 |
mi->ti.disabled = !mv->sf->hasvmetrics; |
| 4051 |
break; |
| 4052 |
case MV_MID_RemoveKerns: |
| 4053 |
mi->ti.disabled = sc ? sc->kerns==NULL : 1; |
| 4054 |
break; |
| 4055 |
case MV_MID_RemoveVKerns: |
| 4056 |
mi->ti.disabled = sc ? sc->vkerns==NULL : 1; |
| 4057 |
break; |
| 4058 |
|
| 4059 |
} |
| 4060 |
} |
| 4061 |
} |
| 4062 |
|
| 4063 |
static GMenuItem2 mblist[] = { |
| 4064 |
{ { (unichar_t *) N_("_File"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'F' }, H_("File|No Shortcut"), fllist, fllistcheck, NULL, 0 }, |
| 4065 |
{ { (unichar_t *) N_("_Edit"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'E' }, H_("Edit|No Shortcut"), edlist, edlistcheck, NULL, 0 }, |
| 4066 |
{ { (unichar_t *) N_("E_lement"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'l' }, H_("Element|No Shortcut"), ellist, ellistcheck, NULL, 0 }, |
| 4067 |
{ { (unichar_t *) N_("_View"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'V' }, H_("View|No Shortcut"), vwlist, vwlistcheck, NULL, 0 }, |
| 4068 |
{ { (unichar_t *) N_("_Metrics"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'M' }, H_("Metrics|No Shortcut"), mtlist, mtlistcheck, NULL, 0 }, |
| 4069 |
{ { (unichar_t *) N_("_Window"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'W' }, H_("Window|No Shortcut"), wnmenu, MVWindowMenuBuild, NULL, 0 }, |
| 4070 |
{ { (unichar_t *) N_("_Help"), NULL, COLOR_DEFAULT, COLOR_DEFAULT, NULL, NULL, 0, 1, 0, 0, 0, 0, 1, 1, 0, 'H' }, H_("Help|No Shortcut"), helplist, NULL, NULL, 0 }, |
| 4071 |
GMENUITEM2_EMPTY |
| 4072 |
}; |
| 4073 |
|
| 4074 |
static void MVResize(MetricsView *mv) { |
| 4075 |
GRect pos, wsize; |
| 4076 |
int i; |
| 4077 |
int size; |
| 4078 |
|
| 4079 |
GDrawGetSize(mv->gw,&wsize); |
| 4080 |
if ( wsize.height < mv->topend+20 + mv->height-mv->displayend || |
| 4081 |
wsize.width < 30 ) { |
| 4082 |
int width= wsize.width < 30 ? 30 : wsize.width; |
| 4083 |
int height; |
| 4084 |
|
| 4085 |
if ( wsize.height < mv->topend+20 + mv->height-mv->displayend ) |
| 4086 |
height = mv->topend+20 + mv->height-mv->displayend; |
| 4087 |
else |
| 4088 |
height = wsize.height; |
| 4089 |
GDrawResize(mv->gw,width,height); |
| 4090 |
return; |
| 4091 |
} |
| 4092 |
|
| 4093 |
mv->width = wsize.width; |
| 4094 |
mv->displayend = wsize.height - (mv->height-mv->displayend); |
| 4095 |
mv->height = wsize.height; |
| 4096 |
|
| 4097 |
mv_width = wsize.width; mv_height = wsize.height; |
| 4098 |
SavePrefs(true); |
| 4099 |
|
| 4100 |
pos.width = wsize.width; |
| 4101 |
pos.height = mv->sbh; |
| 4102 |
pos.y = wsize.height - pos.height; pos.x = 0; |
| 4103 |
GGadgetResize(mv->hsb,pos.width,pos.height); |
| 4104 |
GGadgetMove(mv->hsb,pos.x,pos.y); |
| 4105 |
|
| 4106 |
mv->dwidth = mv->width - mv->sbh; |
| 4107 |
GGadgetResize(mv->vsb,mv->sbh,mv->displayend-mv->topend); |
| 4108 |
GGadgetMove(mv->vsb,wsize.width-mv->sbh,mv->topend); |
| 4109 |
|
| 4110 |
GGadgetResize(mv->features,mv->xstart,mv->displayend - mv->topend); |
| 4111 |
|
| 4112 |
size = (mv->displayend - mv->topend - 4); |
| 4113 |
if ( mv->dwidth-20<size ) |
| 4114 |
size = mv->dwidth-20; |
| 4115 |
if ( mv->pixelsize_set_by_window ) { |
| 4116 |
mv->ptsize = mv->pixelsize = mv_scales[mv->scale_index]*size; |
| 4117 |
mv->dpi = 72; |
| 4118 |
if ( mv->bdf==NULL ) { |
| 4119 |
BDFFontFree(mv->show); |
| 4120 |
mv->show = SplineFontPieceMeal(mv->sf,mv->layer,mv->ptsize,mv->dpi, |
| 4121 |
MVGetSplineFontPieceMealFlags( mv ), NULL ); |
| 4122 |
} |
| 4123 |
} |
| 4124 |
|
| 4125 |
for ( i=0; i<mv->max; ++i ) if ( mv->perchar[i].width!=NULL ) { |
| 4126 |
GGadgetMove(mv->perchar[i].name,mv->perchar[i].mx,mv->displayend+2); |
| 4127 |
GGadgetMove(mv->perchar[i].width,mv->perchar[i].mx,mv->displayend+2+mv->fh+4); |
| 4128 |
GGadgetMove(mv->perchar[i].lbearing,mv->perchar[i].mx,mv->displayend+2+2*(mv->fh+4)); |
| 4129 |
GGadgetMove(mv->perchar[i].rbearing,mv->perchar[i].mx,mv->displayend+2+3*(mv->fh+4)); |
| 4130 |
if ( mv->perchar[i].kern!=NULL ) |
| 4131 |
GGadgetMove(mv->perchar[i].kern,mv->perchar[i].mx-mv->perchar[i].mwidth/2,mv->displayend+2+4*(mv->fh+4)); |
| 4132 |
} |
| 4133 |
GGadgetMove(mv->namelab,2,mv->displayend+2); |
| 4134 |
GGadgetMove(mv->widthlab,2,mv->displayend+2+mv->fh+4); |
| 4135 |
GGadgetMove(mv->lbearinglab,2,mv->displayend+2+2*(mv->fh+4)); |
| 4136 |
GGadgetMove(mv->rbearinglab,2,mv->displayend+2+3*(mv->fh+4)); |
| 4137 |
GGadgetMove(mv->kernlab,2,mv->displayend+2+4*(mv->fh+4)); |
| 4138 |
|
| 4139 |
{ |
| 4140 |
int newwidth = mv->width; |
| 4141 |
GRect scriptselector_size; |
| 4142 |
GRect charselector_size; |
| 4143 |
GRect charselectorNext_size; |
| 4144 |
GRect charselectorPrev_size; |
| 4145 |
GRect subtable_list_size; |
| 4146 |
GGadgetGetSize(mv->script, &scriptselector_size); |
| 4147 |
GGadgetGetSize(mv->text, &charselector_size); |
| 4148 |
GGadgetGetSize(mv->textPrev, &charselectorPrev_size); |
| 4149 |
GGadgetGetSize(mv->textNext, &charselectorNext_size); |
| 4150 |
GGadgetGetSize(mv->subtable_list, &subtable_list_size); |
| 4151 |
int new_charselector_width = newwidth - charselector_size.x - charselectorNext_size.width - 2 - charselectorPrev_size.width - 2 - subtable_list_size.width - 10 - 10; |
| 4152 |
if (new_charselector_width < GDrawPointsToPixels(mv->gw,100)) |
| 4153 |
new_charselector_width = GDrawPointsToPixels(mv->gw,100); |
| 4154 |
int new_charselectorPrev_x = charselector_size.x + new_charselector_width + 4; |
| 4155 |
int new_charselectorNext_x = new_charselectorPrev_x + charselectorPrev_size.width + 4; |
| 4156 |
int new_subtableselector_x = new_charselectorNext_x + charselectorNext_size.width + 10; |
| 4157 |
|
| 4158 |
GGadgetResize(mv->text, new_charselector_width, charselector_size.height); |
| 4159 |
GGadgetMove(mv->textPrev, new_charselectorPrev_x, charselectorPrev_size.y); |
| 4160 |
GGadgetMove(mv->textNext, new_charselectorNext_x, charselectorNext_size.y); |
| 4161 |
GGadgetMove(mv->subtable_list, new_subtableselector_x, subtable_list_size.y); |
| 4162 |
} |
| 4163 |
|
| 4164 |
mv->vwidth = mv->dwidth-mv->xstart; |
| 4165 |
mv->vheight = mv->displayend-mv->topend-2; |
| 4166 |
GDrawResize(mv->v,mv->vwidth, mv->vheight); |
| 4167 |
MVRemetric(mv); |
| 4168 |
GDrawRequestExpose(mv->gw,NULL,true); |
| 4169 |
GDrawRequestExpose(mv->v,NULL,true); |
| 4170 |
} |
| 4171 |
|
| 4172 |
static void MVChar(MetricsView *mv,GEvent *event) |
| 4173 |
{ |
| 4174 |
if ( event->u.chr.keysym=='s' && |
| 4175 |
(event->u.chr.state&ksm_control) && |
| 4176 |
(event->u.chr.state&ksm_meta) ) |
| 4177 |
MenuSaveAll(NULL,NULL,NULL); |
| 4178 |
else if ( event->u.chr.keysym=='I' && |
| 4179 |
(event->u.chr.state&ksm_shift) && |
| 4180 |
(event->u.chr.state&ksm_meta) ) |
| 4181 |
MVMenuCharInfo(mv->gw,NULL,NULL); |
| 4182 |
else if ( event->u.chr.keysym == GK_Help ) { |
| 4183 |
MenuHelp(NULL,NULL,NULL); |
| 4184 |
} |
| 4185 |
if ( event->u.chr.keysym == GK_Up || event->u.chr.keysym==GK_KP_Up |
| 4186 |
|| event->u.chr.keysym == GK_Down || event->u.chr.keysym==GK_KP_Down |
| 4187 |
|| event->u.chr.keysym == GK_Left || event->u.chr.keysym==GK_KP_Left |
| 4188 |
|| event->u.chr.keysym == GK_Right || event->u.chr.keysym==GK_KP_Right ) { |
| 4189 |
if( event->u.chr.state&ksm_meta ) { |
| 4190 |
int dir = ( event->u.chr.keysym == GK_Up || event->u.chr.keysym==GK_KP_Up ) ? -1 |
| 4191 |
: ( ( event->u.chr.keysym == GK_Down || event->u.chr.keysym==GK_KP_Down ) ? 1 : 0); |
| 4192 |
GGadget *active = GWindowGetFocusGadgetOfWindow(mv->gw); |
| 4193 |
GGadget *toSelect = 0; |
| 4194 |
|
| 4195 |
if( active ) { |
| 4196 |
int i=0, j=0; |
| 4197 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 4198 |
|
| 4199 |
|
| 4200 |
for ( j=1; j<10 && mv->perchar[i].updownkparray[j]; ++j ) { |
| 4201 |
if ( active == mv->perchar[i].updownkparray[j] ) { |
| 4202 |
if( dir != 0 ) { |
| 4203 |
toSelect = mv->perchar[i].updownkparray[j+dir]; |
| 4204 |
} else { |
| 4205 |
int newidx = i; |
| 4206 |
if( event->u.chr.keysym == GK_Left || event->u.chr.keysym==GK_KP_Left ) |
| 4207 |
newidx--; |
| 4208 |
if( event->u.chr.keysym == GK_Right || event->u.chr.keysym==GK_KP_Right ) |
| 4209 |
newidx++; |
| 4210 |
if( newidx < 0 || newidx >= mv->glyphcnt ) |
| 4211 |
return; |
| 4212 |
toSelect = mv->perchar[newidx].updownkparray[j]; |
| 4213 |
} |
| 4214 |
} |
| 4215 |
} |
| 4216 |
} |
| 4217 |
} |
| 4218 |
if( toSelect ) { |
| 4219 |
GWidgetIndicateFocusGadget(toSelect); |
| 4220 |
} |
| 4221 |
return; |
| 4222 |
} |
| 4223 |
} |
| 4224 |
if ( event->u.chr.keysym == GK_Up || event->u.chr.keysym==GK_KP_Up || |
| 4225 |
event->u.chr.keysym == GK_Down || event->u.chr.keysym==GK_KP_Down ) { |
| 4226 |
GGadget *active = GWindowGetFocusGadgetOfWindow(mv->gw); |
| 4227 |
if(!active) |
| 4228 |
return; |
| 4229 |
|
| 4230 |
|
| 4231 |
|
| 4232 |
|
| 4233 |
if( active != mv->text ) |
| 4234 |
{ |
| 4235 |
const unichar_t *title = _GGadgetGetTitle(active); |
| 4236 |
if (!title) |
| 4237 |
return; |
| 4238 |
|
| 4239 |
unichar_t *end; |
| 4240 |
double val = u_strtod(title,&end); |
| 4241 |
if (isValidInt(end)) { |
| 4242 |
int dir = ( event->u.chr.keysym == GK_Up || event->u.chr.keysym==GK_KP_Up ) ? 1 : -1; |
| 4243 |
if( event->u.chr.state&ksm_control && event->u.chr.state&ksm_shift ) { |
| 4244 |
dir *= pref_mv_control_shift_and_arrow_skip; |
| 4245 |
} |
| 4246 |
else if( event->u.chr.state&ksm_shift ) { |
| 4247 |
dir *= pref_mv_shift_and_arrow_skip; |
| 4248 |
} |
| 4249 |
val += dir; |
| 4250 |
char buf[100]; |
| 4251 |
snprintf(buf,99,"%.0f",val); |
| 4252 |
GGadgetSetTitle8(active, buf); |
| 4253 |
|
| 4254 |
event->u.control.u.tf_changed.from_pulldown=-1; |
| 4255 |
event->type=et_controlevent; |
| 4256 |
event->u.control.subtype = et_textchanged; |
| 4257 |
GGadgetDispatchEvent(active,event); |
| 4258 |
|
| 4259 |
if( haveClassBasedKerningInView(mv) ) |
| 4260 |
{ |
| 4261 |
MVRemetric(mv); |
| 4262 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4263 |
} |
| 4264 |
} |
| 4265 |
} |
| 4266 |
} |
| 4267 |
if ( event->u.chr.keysym == GK_Up || event->u.chr.keysym==GK_KP_Up || |
| 4268 |
event->u.chr.keysym == GK_Down || event->u.chr.keysym==GK_KP_Down ) |
| 4269 |
{ |
| 4270 |
int dir = ( event->u.chr.keysym == GK_Up || event->u.chr.keysym==GK_KP_Up ) ? -1 : 1; |
| 4271 |
MVMoveInWordListByOffset( mv, dir ); |
| 4272 |
} |
| 4273 |
} |
| 4274 |
|
| 4275 |
static int hitsbit(BDFChar *bc, int x, int y) { |
| 4276 |
if ( bc->byte_data ) |
| 4277 |
return( bc->bitmap[y*bc->bytes_per_line+x] ); |
| 4278 |
else |
| 4279 |
return( bc->bitmap[y*bc->bytes_per_line+(x>>3)]&(1<<(7-(x&7))) ); |
| 4280 |
} |
| 4281 |
|
| 4282 |
static void _MVSubVMouse(MetricsView *mv,GEvent *event) { |
| 4283 |
int i, x, y, j, within, xbase; |
| 4284 |
SplineChar *sc; |
| 4285 |
int diff; |
| 4286 |
int onwidth, onkern; |
| 4287 |
SplineFont *sf = mv->sf; |
| 4288 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 4289 |
double scale = iscale*mv->pixelsize/(double) (sf->ascent+sf->descent); |
| 4290 |
int as = rint(sf->ascent*scale); |
| 4291 |
|
| 4292 |
xbase = mv->vwidth/2; |
| 4293 |
within = -1; |
| 4294 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 4295 |
y = mv->metrics[i].dy + mv->metrics[i].yoff; |
| 4296 |
x = xbase - mv->pixelsize*iscale/2 - mv->metrics[i].xoff; |
| 4297 |
if ( mv->bdf==NULL ) { |
| 4298 |
BDFChar *bdfc = BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos); |
| 4299 |
if ( event->u.mouse.x >= x+bdfc->xmin && |
| 4300 |
event->u.mouse.x <= x+bdfc->xmax && |
| 4301 |
event->u.mouse.y <= (y+as)-bdfc->ymin && |
| 4302 |
event->u.mouse.y >= (y+as)-bdfc->ymax && |
| 4303 |
hitsbit(bdfc,rint(iscale*(event->u.mouse.x-x-bdfc->xmin)), |
| 4304 |
rint(iscale*(event->u.mouse.y-(y+as-bdfc->ymax)))) ) |
| 4305 |
break; |
| 4306 |
} |
| 4307 |
y += -mv->metrics[i].yoff; |
| 4308 |
if ( event->u.mouse.y >= y && event->u.mouse.y < y+mv->metrics[i].dheight+ mv->metrics[i].kernafter ) |
| 4309 |
within = i; |
| 4310 |
} |
| 4311 |
if ( i==mv->glyphcnt ) |
| 4312 |
sc = NULL; |
| 4313 |
else |
| 4314 |
sc = mv->glyphs[i].sc; |
| 4315 |
|
| 4316 |
diff = event->u.mouse.y-mv->pressed_y; |
| 4317 |
onwidth = onkern = false; |
| 4318 |
if ( sc==NULL ) { |
| 4319 |
if ( mv->type == mv_kernonly ) { |
| 4320 |
if ( within!=-1 && within+1<mv->glyphcnt && |
| 4321 |
event->u.mouse.y>mv->metrics[within+1].dy-3 ) { |
| 4322 |
onkern = true; |
| 4323 |
++within; |
| 4324 |
} else if ( within>0 && |
| 4325 |
event->u.mouse.y<mv->metrics[within].dy+3 ) |
| 4326 |
onkern = true; |
| 4327 |
} else if ( mv->type == mv_widthonly ) { |
| 4328 |
if ( within!=-1 && within+1<mv->glyphcnt && |
| 4329 |
event->u.mouse.y>mv->metrics[within+1].dy-3 ) |
| 4330 |
onwidth = true; |
| 4331 |
else if ( within>=0 && |
| 4332 |
event->u.mouse.y>mv->metrics[within].dy+mv->metrics[within].dheight+mv->metrics[within].kernafter-3 ) { |
| 4333 |
onwidth = true; |
| 4334 |
} |
| 4335 |
} else { |
| 4336 |
if ( within>0 && mv->perchar[within-1].selected && |
| 4337 |
event->u.mouse.y<mv->metrics[within].dy+3 ) |
| 4338 |
onwidth = true; |
| 4339 |
else if ( within!=-1 && within+1<mv->glyphcnt && |
| 4340 |
mv->perchar[within+1].selected && |
| 4341 |
event->u.mouse.y>mv->metrics[within+1].dy-3 ) { |
| 4342 |
onkern = true; |
| 4343 |
++within; |
| 4344 |
} else if ( within>0 && mv->perchar[within].selected && |
| 4345 |
event->u.mouse.y<mv->metrics[within].dy+3 ) |
| 4346 |
onkern = true; |
| 4347 |
else if ( within>=0 && |
| 4348 |
event->u.mouse.y>mv->metrics[within].dy+mv->metrics[within].dheight+mv->metrics[within].kernafter-3 ) { |
| 4349 |
onwidth = true; |
| 4350 |
} |
| 4351 |
} |
| 4352 |
} |
| 4353 |
|
| 4354 |
if ( event->type != et_mousemove || !mv->pressed ) { |
| 4355 |
int ct = -1; |
| 4356 |
if ( mv->bdf!=NULL || |
| 4357 |
( mv->type==mv_kernonly && !onkern ) || |
| 4358 |
( mv->type==mv_widthonly && !onwidth )) { |
| 4359 |
if ( mv->cursor!=ct_mypointer ) |
| 4360 |
ct = ct_mypointer; |
| 4361 |
} else if ( sc!=NULL ) { |
| 4362 |
if ( mv->cursor!=ct_lbearing ) |
| 4363 |
ct = ct_lbearing; |
| 4364 |
} else if ( onwidth ) { |
| 4365 |
if ( mv->cursor!=ct_rbearing ) |
| 4366 |
ct = ct_rbearing; |
| 4367 |
} else if ( onkern ) { |
| 4368 |
if ( mv->cursor!=ct_kerning ) |
| 4369 |
ct = ct_kerning; |
| 4370 |
} else { |
| 4371 |
if ( mv->cursor!=ct_mypointer ) |
| 4372 |
ct = ct_mypointer; |
| 4373 |
} |
| 4374 |
if ( ct!=-1 ) { |
| 4375 |
GDrawSetCursor(mv->gw,ct); |
| 4376 |
mv->cursor = ct; |
| 4377 |
} |
| 4378 |
} |
| 4379 |
|
| 4380 |
if ( event->type == et_mousemove && !mv->pressed ) { |
| 4381 |
if ( sc==NULL && within!=-1 ) |
| 4382 |
sc = mv->glyphs[within].sc; |
| 4383 |
if ( sc!=NULL ) |
| 4384 |
SCPreparePopup(mv->gw,sc,mv->fv->b.map->remap,mv->fv->b.map->backmap[sc->orig_pos],sc->unicodeenc); |
| 4385 |
|
| 4386 |
} else if ( event->type == et_mousedown && mv->bdf==NULL ) { |
| 4387 |
CVPaletteDeactivate(); |
| 4388 |
if ( sc!=NULL ) { |
| 4389 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 4390 |
if ( j!=i && mv->perchar[j].selected ) |
| 4391 |
MVDeselectChar(mv,j); |
| 4392 |
MVSelectChar(mv,i); |
| 4393 |
GWindowClearFocusGadgetOfWindow(mv->gw); |
| 4394 |
mv->pressed = true; |
| 4395 |
} else if ( within!=-1 ) { |
| 4396 |
mv->pressedwidth = onwidth; |
| 4397 |
mv->pressedkern = onkern; |
| 4398 |
if ( mv->pressedwidth || mv->pressedkern ) { |
| 4399 |
mv->pressed = true; |
| 4400 |
if ( !mv->perchar[within].selected ) { |
| 4401 |
MVDoSelect(mv,within); |
| 4402 |
} |
| 4403 |
} |
| 4404 |
} |
| 4405 |
mv->pressed_y = event->u.mouse.y; |
| 4406 |
} else if ( event->type == et_mousemove && mv->pressed ) { |
| 4407 |
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i ); |
| 4408 |
if ( mv->pressedwidth ) { |
| 4409 |
int ow = mv->metrics[i].dwidth; |
| 4410 |
mv->metrics[i].dwidth = rint(mv->glyphs[i].sc->vwidth*scale) + diff; |
| 4411 |
if ( ow!=mv->metrics[i].dwidth ) { |
| 4412 |
for ( j=i+1; j<mv->glyphcnt; ++j ) |
| 4413 |
mv->metrics[j].dy = mv->metrics[j-1].dy+mv->metrics[j-1].dheight+ |
| 4414 |
mv->metrics[j-1].kernafter; |
| 4415 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4416 |
} |
| 4417 |
} else if ( mv->pressedkern ) { |
| 4418 |
int ow = mv->metrics[i-1].kernafter; |
| 4419 |
KernPair *kp; |
| 4420 |
int kpoff; |
| 4421 |
KernClass *kc; |
| 4422 |
kp = mv->glyphs[i-1].kp; |
| 4423 |
if ( kp!=NULL ) |
| 4424 |
kpoff = kp->off; |
| 4425 |
else if ((kc=mv->glyphs[i-1].kc)!=NULL ) |
| 4426 |
kpoff = kc->offsets[mv->glyphs[i-1].kc_index]; |
| 4427 |
else |
| 4428 |
kpoff = 0; |
| 4429 |
kpoff = kpoff * mv->pixelsize*iscale / |
| 4430 |
(mv->sf->descent+mv->sf->ascent); |
| 4431 |
mv->metrics[i-1].kernafter = kpoff + diff; |
| 4432 |
if ( ow!=mv->metrics[i-1].kernafter ) { |
| 4433 |
for ( j=i; j<mv->glyphcnt; ++j ) |
| 4434 |
mv->metrics[j].dy = mv->metrics[j-1].dy+mv->metrics[j-1].dheight+ |
| 4435 |
mv->metrics[j-1].kernafter; |
| 4436 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4437 |
} |
| 4438 |
} else if ( mv->type!=mv_kernonly ) { |
| 4439 |
int olda = mv->activeoff; |
| 4440 |
BDFChar *bdfc = BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos); |
| 4441 |
mv->activeoff = diff; |
| 4442 |
MVRedrawI(mv,i,bdfc->xmin+olda,bdfc->xmax+olda); |
| 4443 |
} |
| 4444 |
} else if ( event->type == et_mouseup && event->u.mouse.clicks>1 && |
| 4445 |
(within!=-1 || sc!=NULL)) { |
| 4446 |
mv->pressed = false; mv->activeoff = 0; |
| 4447 |
mv->pressedwidth = mv->pressedkern = false; |
| 4448 |
if ( within==-1 ) within = i; |
| 4449 |
if ( mv->bdf==NULL ) |
| 4450 |
CharViewCreate(mv->glyphs[within].sc,mv->fv,-1); |
| 4451 |
else |
| 4452 |
BitmapViewCreate(mv->bdf->glyphs[mv->glyphs[within].sc->orig_pos],mv->bdf,mv->fv,-1); |
| 4453 |
if ( mv->showgrid==mv_hidemovinggrid ) |
| 4454 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4455 |
} else if ( event->type == et_mouseup && mv->pressed ) { |
| 4456 |
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i ); |
| 4457 |
mv->pressed = false; |
| 4458 |
mv->activeoff = 0; |
| 4459 |
sc = mv->glyphs[i].sc; |
| 4460 |
if ( mv->pressedwidth ) { |
| 4461 |
mv->pressedwidth = false; |
| 4462 |
diff = diff*(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale); |
| 4463 |
if ( diff!=0 ) { |
| 4464 |
SCPreserveWidth(sc); |
| 4465 |
sc->vwidth += diff; |
| 4466 |
SCCharChangedUpdate(sc,ly_none); |
| 4467 |
for ( ; i<mv->glyphcnt; ++i ) |
| 4468 |
mv->metrics[i].dy = mv->metrics[i-1].dy+mv->metrics[i-1].dheight + |
| 4469 |
mv->metrics[i-1].kernafter ; |
| 4470 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4471 |
} else if ( mv->showgrid==mv_hidemovinggrid ) |
| 4472 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4473 |
} else if ( mv->pressedkern ) { |
| 4474 |
mv->pressedkern = false; |
| 4475 |
diff = diff*(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale); |
| 4476 |
if ( diff!=0 ) |
| 4477 |
MV_ChangeKerning(mv, i, diff, true); |
| 4478 |
MVRefreshValues(mv,i-1); |
| 4479 |
} else if ( mv->type!=mv_kernonly ) { |
| 4480 |
real transform[6]; |
| 4481 |
DBounds bb; |
| 4482 |
SplineCharFindBounds(sc,&bb); |
| 4483 |
transform[0] = transform[3] = 1.0; |
| 4484 |
transform[1] = transform[2] = transform[4] = 0; |
| 4485 |
transform[5] = -diff* |
| 4486 |
(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale); |
| 4487 |
if ( transform[5]!=0 ) |
| 4488 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL,false); |
| 4489 |
} |
| 4490 |
mv->pressedwidth = false; |
| 4491 |
mv->pressedkern = false; |
| 4492 |
} else if ( event->type == et_mouseup && mv->bdf!=NULL && within!=-1 ) { |
| 4493 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 4494 |
if ( j!=within && mv->perchar[j].selected ) |
| 4495 |
MVDeselectChar(mv,j); |
| 4496 |
MVSelectChar(mv,within); |
| 4497 |
if ( mv->showgrid==mv_hidemovinggrid ) |
| 4498 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4499 |
} |
| 4500 |
} |
| 4501 |
|
| 4502 |
static void MVSubMouse(MetricsView *mv,GEvent *event) { |
| 4503 |
|
| 4504 |
int i, x, y, j, within, ybase; |
| 4505 |
SplineChar *sc; |
| 4506 |
int diff; |
| 4507 |
int onwidth, onkern; |
| 4508 |
BDFChar *bdfc; |
| 4509 |
double iscale = mv->pixelsize_set_by_window ? 1.0 : mv_scales[mv->scale_index]; |
| 4510 |
|
| 4511 |
GGadgetEndPopup(); |
| 4512 |
|
| 4513 |
if ( event->type==et_mouseup ) { |
| 4514 |
event->type = et_mousemove; |
| 4515 |
MVSubMouse(mv,event); |
| 4516 |
event->u.mouse.x -= mv->xoff; |
| 4517 |
event->u.mouse.y -= mv->yoff; |
| 4518 |
event->type = et_mouseup; |
| 4519 |
} |
| 4520 |
|
| 4521 |
event->u.mouse.x += mv->xoff; |
| 4522 |
event->u.mouse.y += mv->yoff; |
| 4523 |
if ( mv->vertical ) { |
| 4524 |
_MVSubVMouse(mv,event); |
| 4525 |
return; |
| 4526 |
} |
| 4527 |
|
| 4528 |
ybase = mv->ybaseline - mv->yoff; |
| 4529 |
within = -1; |
| 4530 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 4531 |
x = mv->metrics[i].dx + mv->metrics[i].xoff; |
| 4532 |
if ( mv->right_to_left ) |
| 4533 |
x = mv->vwidth - x - mv->metrics[i].dwidth - mv->metrics[i].kernafter; |
| 4534 |
y = ybase - mv->metrics[i].yoff; |
| 4535 |
if ( mv->bdf==NULL ) { |
| 4536 |
bdfc = BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos); |
| 4537 |
if ( event->u.mouse.x >= x+bdfc->xmin && |
| 4538 |
event->u.mouse.x <= x+bdfc->xmax && |
| 4539 |
event->u.mouse.y <= y-bdfc->ymin && |
| 4540 |
event->u.mouse.y >= y-bdfc->ymax && |
| 4541 |
hitsbit(bdfc,rint(iscale*(event->u.mouse.x-x-bdfc->xmin)), |
| 4542 |
rint(iscale*(bdfc->ymax-(y-event->u.mouse.y)))) ) |
| 4543 |
break; |
| 4544 |
} |
| 4545 |
x += mv->right_to_left ? mv->metrics[i].xoff : -mv->metrics[i].xoff; |
| 4546 |
if ( event->u.mouse.x >= x && event->u.mouse.x < x+mv->metrics[i].dwidth+ mv->metrics[i].kernafter ) |
| 4547 |
within = i; |
| 4548 |
} |
| 4549 |
if ( i==mv->glyphcnt ) |
| 4550 |
sc = NULL; |
| 4551 |
else |
| 4552 |
sc = mv->glyphs[i].sc; |
| 4553 |
|
| 4554 |
diff = event->u.mouse.x-mv->pressed_x; |
| 4555 |
|
| 4556 |
onwidth = onkern = false; |
| 4557 |
if ( sc==NULL ) { |
| 4558 |
if ( !mv->right_to_left ) { |
| 4559 |
if ( mv->type == mv_kernonly ) { |
| 4560 |
if ( within>=0 && within+1<mv->glyphcnt && |
| 4561 |
event->u.mouse.x>mv->metrics[within+1].dx-3 ) { |
| 4562 |
onkern = true; |
| 4563 |
++within; |
| 4564 |
} else if ( within>0 && |
| 4565 |
event->u.mouse.x<mv->metrics[within].dx+3 ) |
| 4566 |
onkern = true; |
| 4567 |
} else if ( mv->type == mv_widthonly ) { |
| 4568 |
if ( within>=0 && within+1<mv->glyphcnt && |
| 4569 |
event->u.mouse.x>mv->metrics[within+1].dx-3 ) |
| 4570 |
onwidth = true; |
| 4571 |
else if ( within>=0 && |
| 4572 |
event->u.mouse.x>mv->metrics[within].dx+mv->metrics[within].dwidth+mv->metrics[within].kernafter-3 ) { |
| 4573 |
onwidth = true; |
| 4574 |
} |
| 4575 |
} else { |
| 4576 |
if ( within>0 && mv->perchar[within-1].selected && |
| 4577 |
event->u.mouse.x<mv->metrics[within].dx+3 ) |
| 4578 |
onwidth = true; |
| 4579 |
else if ( within!=-1 && within+1<mv->glyphcnt && |
| 4580 |
mv->perchar[within+1].selected && |
| 4581 |
event->u.mouse.x>mv->metrics[within+1].dx-3 ) { |
| 4582 |
onkern = true; |
| 4583 |
++within; |
| 4584 |
} else if ( within>0 && mv->perchar[within].selected && |
| 4585 |
event->u.mouse.x<mv->metrics[within].dx+3 ) |
| 4586 |
onkern = true; |
| 4587 |
else if ( within>=0 && |
| 4588 |
event->u.mouse.x>mv->metrics[within].dx+mv->metrics[within].dwidth+mv->metrics[within].kernafter-3 ) { |
| 4589 |
onwidth = true; |
| 4590 |
} |
| 4591 |
} |
| 4592 |
} else { |
| 4593 |
if ( mv->type == mv_kernonly ) { |
| 4594 |
if ( within>=0 && within+1<mv->glyphcnt && |
| 4595 |
event->u.mouse.x<mv->dwidth-(mv->metrics[within+1].dx-3) ) { |
| 4596 |
onkern = true; |
| 4597 |
++within; |
| 4598 |
} else if ( within>0 && |
| 4599 |
event->u.mouse.x>mv->dwidth-(mv->metrics[within].dx+3) ) |
| 4600 |
onkern = true; |
| 4601 |
} else if ( mv->type == mv_widthonly ) { |
| 4602 |
if ( within>=0 && within+1<mv->glyphcnt && |
| 4603 |
event->u.mouse.x<mv->dwidth-(mv->metrics[within+1].dx-3) ) |
| 4604 |
onwidth = true; |
| 4605 |
else if ( within>=0 && |
| 4606 |
event->u.mouse.x<mv->dwidth-(mv->metrics[within].dx+mv->metrics[within].dwidth+mv->metrics[within].kernafter-3) ) { |
| 4607 |
onwidth = true; |
| 4608 |
} |
| 4609 |
} else { |
| 4610 |
if ( within>0 && mv->perchar[within-1].selected && |
| 4611 |
event->u.mouse.x>mv->dwidth-(mv->metrics[within].dx+3) ) |
| 4612 |
onwidth = true; |
| 4613 |
else if ( within!=-1 && within+1<mv->glyphcnt && |
| 4614 |
mv->perchar[within+1].selected && |
| 4615 |
event->u.mouse.x<mv->dwidth-(mv->metrics[within+1].dx-3) ) { |
| 4616 |
onkern = true; |
| 4617 |
++within; |
| 4618 |
} else if ( within>0 && mv->perchar[within].selected && |
| 4619 |
event->u.mouse.x>mv->dwidth-(mv->metrics[within].dx+3) ) |
| 4620 |
onkern = true; |
| 4621 |
else if ( within>=0 && |
| 4622 |
event->u.mouse.x<mv->dwidth-(mv->metrics[within].dx+mv->metrics[within].dwidth+mv->metrics[within].kernafter-3) ) { |
| 4623 |
onwidth = true; |
| 4624 |
} |
| 4625 |
} |
| 4626 |
} |
| 4627 |
} |
| 4628 |
|
| 4629 |
if ( event->type != et_mousemove || !mv->pressed ) { |
| 4630 |
int ct = -1; |
| 4631 |
if ( mv->bdf!=NULL || |
| 4632 |
( mv->type==mv_kernonly && !onkern ) || |
| 4633 |
( mv->type==mv_widthonly && !onwidth )) { |
| 4634 |
if ( mv->cursor!=ct_mypointer ) |
| 4635 |
ct = ct_mypointer; |
| 4636 |
} else if ( sc!=NULL ) { |
| 4637 |
if ( mv->cursor!=ct_lbearing ) |
| 4638 |
ct = ct_lbearing; |
| 4639 |
} else if ( onwidth ) { |
| 4640 |
if ( mv->cursor!=ct_rbearing ) |
| 4641 |
ct = ct_rbearing; |
| 4642 |
} else if ( onkern ) { |
| 4643 |
if ( mv->cursor!=ct_kerning ) |
| 4644 |
ct = ct_kerning; |
| 4645 |
} else { |
| 4646 |
if ( mv->cursor!=ct_mypointer ) |
| 4647 |
ct = ct_mypointer; |
| 4648 |
} |
| 4649 |
if ( ct!=-1 ) { |
| 4650 |
GDrawSetCursor(mv->gw,ct); |
| 4651 |
mv->cursor = ct; |
| 4652 |
} |
| 4653 |
} |
| 4654 |
|
| 4655 |
if ( event->type == et_mousemove && !mv->pressed ) { |
| 4656 |
if ( sc==NULL && within!=-1 ) |
| 4657 |
sc = mv->glyphs[within].sc; |
| 4658 |
if ( sc!=NULL ) |
| 4659 |
SCPreparePopup(mv->gw,sc,mv->fv->b.map->remap,mv->fv->b.map->backmap[sc->orig_pos],sc->unicodeenc); |
| 4660 |
|
| 4661 |
} else if ( event->type == et_mousedown && mv->bdf==NULL ) { |
| 4662 |
CVPaletteDeactivate(); |
| 4663 |
if ( sc!=NULL ) { |
| 4664 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 4665 |
if ( j!=i && mv->perchar[j].selected ) |
| 4666 |
MVDeselectChar(mv,j); |
| 4667 |
MVSelectChar(mv,i); |
| 4668 |
GWindowClearFocusGadgetOfWindow(mv->gw); |
| 4669 |
mv->pressed = true; |
| 4670 |
} else if ( within!=-1 ) { |
| 4671 |
mv->pressedwidth = onwidth; |
| 4672 |
mv->pressedkern = onkern; |
| 4673 |
if ( mv->pressedwidth || mv->pressedkern ) { |
| 4674 |
mv->pressed = true; |
| 4675 |
if ( !mv->perchar[within].selected ) { |
| 4676 |
MVDoSelect(mv,within); |
| 4677 |
} |
| 4678 |
} |
| 4679 |
} |
| 4680 |
mv->pressed_x = event->u.mouse.x; |
| 4681 |
} else if ( event->type == et_mousemove && mv->pressed ) { |
| 4682 |
|
| 4683 |
|
| 4684 |
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i ) |
| 4685 |
{ |
| 4686 |
|
| 4687 |
} |
| 4688 |
|
| 4689 |
if ( mv->pressedwidth ) { |
| 4690 |
int ow = mv->metrics[i].dwidth; |
| 4691 |
if ( mv->right_to_left ) diff = -diff; |
| 4692 |
bdfc = BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos); |
| 4693 |
mv->metrics[i].dwidth = bdfc->width + diff; |
| 4694 |
if ( ow!=mv->metrics[i].dwidth ) { |
| 4695 |
for ( j=i+1; j<mv->glyphcnt; ++j ) |
| 4696 |
mv->metrics[j].dx = mv->metrics[j-1].dx+mv->metrics[j-1].dwidth+ mv->metrics[j-1].kernafter; |
| 4697 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4698 |
} |
| 4699 |
} else if ( mv->pressedkern ) { |
| 4700 |
int ow = mv->metrics[i-1].kernafter; |
| 4701 |
KernPair *kp; |
| 4702 |
int kpoff; |
| 4703 |
KernClass *kc; |
| 4704 |
int index; |
| 4705 |
for ( kp = mv->glyphs[i-1].sc->kerns; kp!=NULL && kp->sc!=mv->glyphs[i].sc; kp = kp->next ); |
| 4706 |
if ( kp!=NULL ) |
| 4707 |
kpoff = kp->off; |
| 4708 |
else if ((kc=SFFindKernClass(mv->sf,mv->glyphs[i-1].sc,mv->glyphs[i].sc,&index,false))!=NULL ) |
| 4709 |
kpoff = kc->offsets[index]; |
| 4710 |
else |
| 4711 |
kpoff = 0; |
| 4712 |
kpoff = kpoff * mv->pixelsize*iscale / |
| 4713 |
(mv->sf->descent+mv->sf->ascent); |
| 4714 |
if ( mv->right_to_left ) diff = -diff; |
| 4715 |
mv->metrics[i-1].kernafter = kpoff + diff; |
| 4716 |
if ( ow!=mv->metrics[i-1].kernafter ) { |
| 4717 |
for ( j=i; j<mv->glyphcnt; ++j ) |
| 4718 |
mv->metrics[j].dx = mv->metrics[j-1].dx+mv->metrics[j-1].dwidth+ mv->metrics[j-1].kernafter; |
| 4719 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4720 |
} |
| 4721 |
} else if ( mv->type!=mv_kernonly ) { |
| 4722 |
int olda = mv->activeoff; |
| 4723 |
bdfc = BDFPieceMealCheck(mv->show,mv->glyphs[i].sc->orig_pos); |
| 4724 |
mv->activeoff = diff; |
| 4725 |
MVRedrawI(mv,i,bdfc->xmin+olda,bdfc->xmax+olda); |
| 4726 |
} |
| 4727 |
} else if ( event->type == et_mouseup && event->u.mouse.clicks>1 && |
| 4728 |
(within!=-1 || sc!=NULL)) { |
| 4729 |
mv->pressed = false; mv->activeoff = 0; |
| 4730 |
mv->pressedwidth = mv->pressedkern = false; |
| 4731 |
if ( within==-1 ) within = i; |
| 4732 |
if ( mv->bdf==NULL ) |
| 4733 |
CharViewCreate(mv->glyphs[within].sc,mv->fv,-1); |
| 4734 |
else |
| 4735 |
BitmapViewCreate(mv->bdf->glyphs[mv->glyphs[within].sc->orig_pos],mv->bdf,mv->fv,-1); |
| 4736 |
if ( mv->showgrid==mv_hidemovinggrid ) |
| 4737 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4738 |
} else if ( event->type == et_mouseup && mv->pressed ) { |
| 4739 |
for ( i=0; i<mv->glyphcnt && !mv->perchar[i].selected; ++i ) |
| 4740 |
{ |
| 4741 |
|
| 4742 |
} |
| 4743 |
|
| 4744 |
|
| 4745 |
mv->pressed = false; |
| 4746 |
mv->activeoff = 0; |
| 4747 |
sc = mv->glyphs[i].sc; |
| 4748 |
if ( mv->pressedwidth ) { |
| 4749 |
mv->pressedwidth = false; |
| 4750 |
if ( mv->right_to_left ) diff = -diff; |
| 4751 |
diff = diff*(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale); |
| 4752 |
|
| 4753 |
if ( diff!=0 ) { |
| 4754 |
SCPreserveWidth(sc); |
| 4755 |
SCSynchronizeWidth(sc,sc->width+diff,sc->width,NULL); |
| 4756 |
SCCharChangedUpdate(sc,ly_none); |
| 4757 |
} |
| 4758 |
} else if ( mv->pressedkern ) { |
| 4759 |
mv->pressedkern = false; |
| 4760 |
diff = diff*(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale); |
| 4761 |
if ( diff!=0 ) { |
| 4762 |
if ( mv->right_to_left ) diff = -diff; |
| 4763 |
MV_ChangeKerning(mv, i, diff, true); |
| 4764 |
MVRefreshValues(mv,i-1); |
| 4765 |
} |
| 4766 |
} else if ( mv->type!=mv_kernonly ) { |
| 4767 |
real transform[6]; |
| 4768 |
transform[0] = transform[3] = 1.0; |
| 4769 |
transform[1] = transform[2] = transform[5] = 0; |
| 4770 |
transform[4] = diff* |
| 4771 |
(mv->sf->ascent+mv->sf->descent)/(mv->pixelsize*iscale); |
| 4772 |
if ( transform[4]!=0 ) |
| 4773 |
FVTrans( (FontViewBase *)mv->fv,sc,transform,NULL, 0 | fvt_alllayers ); |
| 4774 |
} |
| 4775 |
mv->pressedwidth = false; |
| 4776 |
mv->pressedkern = false; |
| 4777 |
if ( mv->showgrid==mv_hidemovinggrid ) |
| 4778 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4779 |
} else if ( event->type == et_mouseup && mv->bdf!=NULL && within!=-1 ) { |
| 4780 |
for ( j=0; j<mv->glyphcnt; ++j ) |
| 4781 |
if ( j!=within && mv->perchar[j].selected ) |
| 4782 |
MVDeselectChar(mv,j); |
| 4783 |
MVSelectChar(mv,within); |
| 4784 |
if ( mv->showgrid==mv_hidemovinggrid ) |
| 4785 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4786 |
} |
| 4787 |
} |
| 4788 |
|
| 4789 |
static void MVMouse(MetricsView *mv,GEvent *event) { |
| 4790 |
int i; |
| 4791 |
|
| 4792 |
if ( event->u.mouse.y< mv->topend || event->u.mouse.y >= mv->displayend ) { |
| 4793 |
|
| 4794 |
|
| 4795 |
if ( event->u.mouse.y >= mv->displayend && |
| 4796 |
event->u.mouse.y<mv->height-mv->sbh ) { |
| 4797 |
|
| 4798 |
event->u.mouse.x += (mv->coff*mv->mwidth); |
| 4799 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 4800 |
if ( event->u.mouse.x >= mv->perchar[i].mx && |
| 4801 |
event->u.mouse.x < mv->perchar[i].mx+mv->perchar[i].mwidth ) |
| 4802 |
break; |
| 4803 |
} |
| 4804 |
if ( i<mv->glyphcnt ) |
| 4805 |
SCPreparePopup(mv->gw,mv->glyphs[i].sc,mv->fv->b.map->remap, |
| 4806 |
mv->fv->b.map->backmap[mv->glyphs[i].sc->orig_pos], |
| 4807 |
mv->glyphs[i].sc->unicodeenc); |
| 4808 |
} |
| 4809 |
if ( mv->cursor!=ct_mypointer ) { |
| 4810 |
GDrawSetCursor(mv->gw,ct_mypointer); |
| 4811 |
mv->cursor = ct_mypointer; |
| 4812 |
} |
| 4813 |
return; |
| 4814 |
} |
| 4815 |
} |
| 4816 |
|
| 4817 |
static void MVDrop(MetricsView *mv,GEvent *event) { |
| 4818 |
int x,ex = event->u.drag_drop.x + mv->xoff; |
| 4819 |
int y,ey = event->u.drag_drop.y + mv->yoff; |
| 4820 |
int within, i, cnt, ch; |
| 4821 |
int32_t len; |
| 4822 |
char *cnames, *start, *pt; |
| 4823 |
unichar_t *newtext; |
| 4824 |
const unichar_t *oldtext; |
| 4825 |
SplineChar **founds; |
| 4826 |
|
| 4827 |
|
| 4828 |
|
| 4829 |
if ( !GDrawSelectionHasType(mv->gw,sn_drag_and_drop,"STRING")) |
| 4830 |
return; |
| 4831 |
cnames = GDrawRequestSelection(mv->gw,sn_drag_and_drop,"STRING",&len); |
| 4832 |
if ( cnames==NULL ) |
| 4833 |
return; |
| 4834 |
|
| 4835 |
within = mv->glyphcnt; |
| 4836 |
if ( !mv->vertical ) { |
| 4837 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 4838 |
x = mv->metrics[i].dx; |
| 4839 |
if ( mv->right_to_left ) |
| 4840 |
x = mv->dwidth - x - mv->metrics[i].dwidth - mv->metrics[i].kernafter ; |
| 4841 |
if ( ex >= x && ex < x+mv->metrics[i].dwidth+ mv->metrics[i].kernafter ) { |
| 4842 |
within = i; |
| 4843 |
break; |
| 4844 |
} |
| 4845 |
} |
| 4846 |
} else { |
| 4847 |
for ( i=0; i<mv->glyphcnt; ++i ) { |
| 4848 |
y = mv->metrics[i].dy; |
| 4849 |
if ( ey >= y && ey < y+mv->metrics[i].dheight+ |
| 4850 |
mv->metrics[i].kernafter ) { |
| 4851 |
within = i; |
| 4852 |
break; |
| 4853 |
} |
| 4854 |
} |
| 4855 |
} |
| 4856 |
|
| 4857 |
founds = malloc(len*sizeof(SplineChar *)); |
| 4858 |
start = cnames; |
| 4859 |
for ( i=0; *start; ) { |
| 4860 |
while ( *start==' ' ) ++start; |
| 4861 |
if ( *start=='\0' ) |
| 4862 |
break; |
| 4863 |
for ( pt=start; *pt && *pt!=' '; ++pt ); |
| 4864 |
ch = *pt; *pt = '\0'; |
| 4865 |
if ( (founds[i]=SFGetChar(mv->sf,-1,start))!=NULL ) |
| 4866 |
++i; |
| 4867 |
*pt = ch; |
| 4868 |
start = pt; |
| 4869 |
} |
| 4870 |
cnt = i; |
| 4871 |
free( cnames ); |
| 4872 |
if ( cnt==0 ) { |
| 4873 |
free(founds); |
| 4874 |
return; |
| 4875 |
} |
| 4876 |
if ( within<mv->glyphcnt ) |
| 4877 |
within = mv->glyphs[within].orig_index; |
| 4878 |
else |
| 4879 |
within = mv->clen; |
| 4880 |
|
| 4881 |
if ( mv->clen+cnt+1>=mv->cmax ) { |
| 4882 |
mv->cmax = mv->clen+cnt+10; |
| 4883 |
mv->chars = realloc(mv->chars,mv->cmax*sizeof(SplineChar *)); |
| 4884 |
} |
| 4885 |
oldtext = _GGadgetGetTitle(mv->text); |
| 4886 |
newtext = malloc((mv->clen+cnt+1)*sizeof(unichar_t)); |
| 4887 |
u_strcpy(newtext,oldtext); |
| 4888 |
newtext[mv->clen+cnt]='\0'; |
| 4889 |
for ( i=mv->clen+cnt; i>=within+cnt; --i ) { |
| 4890 |
newtext[i] = newtext[i-cnt]; |
| 4891 |
mv->chars[i] = mv->chars[i-cnt]; |
| 4892 |
} |
| 4893 |
for ( i=within; i<within+cnt; ++i ) { |
| 4894 |
mv->chars[i] = founds[i-within]; |
| 4895 |
newtext[i] = founds[i-within]->unicodeenc>=0 ? |
| 4896 |
founds[i-within]->unicodeenc : MVFakeUnicodeOfSc(mv,founds[i-within]); |
| 4897 |
} |
| 4898 |
mv->clen += cnt; |
| 4899 |
MVRemetric(mv); |
| 4900 |
free(founds); |
| 4901 |
|
| 4902 |
GGadgetSetTitle(mv->text,newtext); |
| 4903 |
free(newtext); |
| 4904 |
|
| 4905 |
GDrawRequestExpose(mv->v,NULL,false); |
| 4906 |
} |
| 4907 |
|
| 4908 |
static int mv_v_e_h(GWindow gw, GEvent *event) { |
| 4909 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 4910 |
|
| 4911 |
switch ( event->type ) { |
| 4912 |
case et_expose: |
| 4913 |
GDrawSetLineWidth(gw,0); |
| 4914 |
MVSubExpose(mv,gw,event); |
| 4915 |
break; |
| 4916 |
case et_char: |
| 4917 |
MVChar(mv,event); |
| 4918 |
break; |
| 4919 |
case et_charup: |
| 4920 |
if ( event->u.chr.keysym == GK_Left || event->u.chr.keysym==GK_KP_Left |
| 4921 |
|| event->u.chr.keysym == GK_Right || event->u.chr.keysym==GK_KP_Right ) { |
| 4922 |
if( event->u.chr.state&ksm_meta ) { |
| 4923 |
MVChar(mv,event); |
| 4924 |
} |
| 4925 |
} |
| 4926 |
break; |
| 4927 |
case et_mouseup: case et_mousemove: case et_mousedown: |
| 4928 |
if (( event->type==et_mouseup || event->type==et_mousedown ) && |
| 4929 |
(event->u.mouse.button>=4 && event->u.mouse.button<=7) ) { |
| 4930 |
int ish = event->u.mouse.button>5; |
| 4931 |
if ( event->u.mouse.state&ksm_shift ) ish = !ish; |
| 4932 |
if ( event->u.mouse.state&ksm_control ) { |
| 4933 |
if ( event->type==et_mousedown ) { |
| 4934 |
if ( event->u.mouse.button==4 || event->u.mouse.button==6 ) |
| 4935 |
_MVMenuScale(mv,MV_MID_ZoomIn); |
| 4936 |
else |
| 4937 |
_MVMenuScale(mv,MV_MID_ZoomOut); |
| 4938 |
} |
| 4939 |
} else if ( ish ) { |
| 4940 |
return( GGadgetDispatchEvent(mv->hsb,event)); |
| 4941 |
} else { |
| 4942 |
return( GGadgetDispatchEvent(mv->vsb,event)); |
| 4943 |
} |
| 4944 |
return( true ); |
| 4945 |
} |
| 4946 |
if ( mv->gwgic!=NULL && event->type==et_mousedown) |
| 4947 |
GDrawSetGIC(mv->gw,mv->gwgic,0,20); |
| 4948 |
MVSubMouse(mv,event); |
| 4949 |
break; |
| 4950 |
case et_drop: |
| 4951 |
MVDrop(mv,event); |
| 4952 |
break; |
| 4953 |
default: break; |
| 4954 |
} |
| 4955 |
return( true ); |
| 4956 |
} |
| 4957 |
|
| 4958 |
static int mv_e_h(GWindow gw, GEvent *event) { |
| 4959 |
MetricsView *mv = (MetricsView *) GDrawGetUserData(gw); |
| 4960 |
SplineFont *sf; |
| 4961 |
|
| 4962 |
|
| 4963 |
switch ( event->type ) { |
| 4964 |
case et_selclear: |
| 4965 |
ClipboardClear(); |
| 4966 |
break; |
| 4967 |
case et_expose: |
| 4968 |
GDrawSetLineWidth(gw,0); |
| 4969 |
MVExpose(mv,gw,event); |
| 4970 |
break; |
| 4971 |
case et_resize: |
| 4972 |
if ( event->u.resize.sized ) |
| 4973 |
MVResize(mv); |
| 4974 |
break; |
| 4975 |
case et_char: |
| 4976 |
if ((event->u.chr.keysym == GK_Tab || event->u.chr.keysym == GK_BackTab) && (!(event->u.chr.state&ksm_meta))) { |
| 4977 |
|
| 4978 |
|
| 4979 |
|
| 4980 |
|
| 4981 |
return 0; |
| 4982 |
} |
| 4983 |
|
| 4984 |
break; |
| 4985 |
case et_charup: |
| 4986 |
if ((event->u.chr.keysym == GK_Tab || event->u.chr.keysym == GK_BackTab) && (!(event->u.chr.state&ksm_meta))) { |
| 4987 |
|
| 4988 |
|
| 4989 |
|
| 4990 |
|
| 4991 |
return 0; |
| 4992 |
} else if ((event->u.chr.keysym == GK_Return) && (!(event->u.chr.state&ksm_meta))) { |
| 4993 |
MVMoveInTableByColumnByOffset(mv, (event->u.chr.state&ksm_shift) ? -1 : 1); |
| 4994 |
} else { |
| 4995 |
MVChar(mv,event); |
| 4996 |
} |
| 4997 |
#if 0 |
| 4998 |
|
| 4999 |
if ( event->u.chr.keysym == GK_Left || event->u.chr.keysym==GK_KP_Left |
| 5000 |
|| event->u.chr.keysym == GK_Right || event->u.chr.keysym==GK_KP_Right ) { |
| 5001 |
if( event->u.chr.state&ksm_meta ) { |
| 5002 |
MVChar(mv,event); |
| 5003 |
} |
| 5004 |
} |
| 5005 |
#endif |
| 5006 |
break; |
| 5007 |
case et_mouseup: case et_mousemove: case et_mousedown: |
| 5008 |
if( GGadgetContainsEventLocation( mv->textPrev, event )) |
| 5009 |
{ |
| 5010 |
GGadgetPreparePopup(mv->gw,c_to_u("Show the previous word in the current word list\n" |
| 5011 |
"Select the menu File / Load Word List... to load a wordlist.")); |
| 5012 |
} |
| 5013 |
else if( GGadgetContainsEventLocation( mv->textNext, event )) |
| 5014 |
{ |
| 5015 |
GGadgetPreparePopup(mv->gw,c_to_u("Show the next word in the current word list\n" |
| 5016 |
"Select the menu File / Load Word List... to load a wordlist.")); |
| 5017 |
} |
| 5018 |
else if( GGadgetContainsEventLocation( mv->text, event )) |
| 5019 |
{ |
| 5020 |
GGadgetPreparePopup(mv->gw,c_to_u("This is a word list that you can step through to quickly see your glyphs in context\n" |
| 5021 |
"Select the menu File / Load Word List... to load a wordlist.")); |
| 5022 |
} |
| 5023 |
else |
| 5024 |
{ |
| 5025 |
GGadgetPreparePopup(mv->gw, 0); |
| 5026 |
} |
| 5027 |
|
| 5028 |
|
| 5029 |
if (( event->type==et_mouseup || event->type==et_mousedown ) && |
| 5030 |
(event->u.mouse.button>=4 && event->u.mouse.button<=7) ) { |
| 5031 |
int ish = event->u.mouse.button>5; |
| 5032 |
if ( event->u.mouse.state&ksm_shift ) ish = !ish; |
| 5033 |
if ( event->u.mouse.state&ksm_control ) { |
| 5034 |
if ( event->type==et_mousedown ) { |
| 5035 |
if ( event->u.mouse.button==4 || event->u.mouse.button==6 ) |
| 5036 |
_MVMenuScale(mv,MV_MID_ZoomIn); |
| 5037 |
else |
| 5038 |
_MVMenuScale(mv,MV_MID_ZoomOut); |
| 5039 |
} |
| 5040 |
} else if ( ish ) { |
| 5041 |
return( GGadgetDispatchEvent(mv->hsb,event)); |
| 5042 |
} else { |
| 5043 |
return( GGadgetDispatchEvent(mv->vsb,event)); |
| 5044 |
} |
| 5045 |
return( true ); |
| 5046 |
} |
| 5047 |
if ( mv->gwgic!=NULL && event->type==et_mousedown) |
| 5048 |
GDrawSetGIC(mv->gw,mv->gwgic,0,20); |
| 5049 |
MVMouse(mv,event); |
| 5050 |
break; |
| 5051 |
case et_drop: |
| 5052 |
MVDrop(mv,event); |
| 5053 |
break; |
| 5054 |
case et_controlevent: |
| 5055 |
switch ( event->u.control.subtype ) { |
| 5056 |
case et_scrollbarchange: |
| 5057 |
if ( event->u.control.g==mv->hsb ) |
| 5058 |
MVHScroll(mv,&event->u.control.u.sb); |
| 5059 |
else |
| 5060 |
MVVScroll(mv,&event->u.control.u.sb); |
| 5061 |
break; |
| 5062 |
default: break; |
| 5063 |
} |
| 5064 |
break; |
| 5065 |
case et_map: |
| 5066 |
if (event->u.map.is_visible) { |
| 5067 |
SetShaper(mv, get_default_shaper()); |
| 5068 |
} |
| 5069 |
break; |
| 5070 |
case et_close: |
| 5071 |
MVMenuClose(gw,NULL,NULL); |
| 5072 |
break; |
| 5073 |
case et_destroy: |
| 5074 |
sf = mv->sf; |
| 5075 |
if ( sf->cidmaster ) sf = sf->cidmaster; |
| 5076 |
if ( sf->metrics==mv ) |
| 5077 |
sf->metrics = mv->next; |
| 5078 |
else { |
| 5079 |
MetricsView *n; |
| 5080 |
for ( n=sf->metrics; n->next!=mv; n=n->next ); |
| 5081 |
n->next = mv->next; |
| 5082 |
} |
| 5083 |
KCLD_MvDetach(sf->kcld,mv); |
| 5084 |
MetricsViewFree(mv); |
| 5085 |
break; |
| 5086 |
case et_focus: |
| 5087 |
break; |
| 5088 |
default: break; |
| 5089 |
} |
| 5090 |
return( true ); |
| 5091 |
} |
| 5092 |
|
| 5093 |
GTextInfo *SLOfFont(SplineFont *sf) { |
| 5094 |
uint32_t *scripttags, *langtags; |
| 5095 |
int s, l, i, k, cnt; |
| 5096 |
extern GTextInfo scripts[], languages[]; |
| 5097 |
GTextInfo *ret = NULL; |
| 5098 |
char *sname=NULL, *lname, *temp; |
| 5099 |
char sbuf[8], lbuf[8]; |
| 5100 |
|
| 5101 |
LookupUIInit(); |
| 5102 |
scripttags = SFScriptsInLookups(sf); |
| 5103 |
if ( scripttags==NULL ) |
| 5104 |
return( NULL ); |
| 5105 |
|
| 5106 |
for ( k=0; k<2; ++k ) { |
| 5107 |
cnt = 0; |
| 5108 |
for ( s=0; scripttags[s]!=0; ++s ) { |
| 5109 |
if ( k ) { |
| 5110 |
for ( i=0; scripts[i].text!=NULL; ++i ) |
| 5111 |
if ( scripttags[s] == (intptr_t) (scripts[i].userdata)) |
| 5112 |
break; |
| 5113 |
sname = (char *) (scripts[i].text); |
| 5114 |
sbuf[0] = scripttags[s]>>24; |
| 5115 |
sbuf[1] = scripttags[s]>>16; |
| 5116 |
sbuf[2] = scripttags[s]>>8; |
| 5117 |
sbuf[3] = scripttags[s]; |
| 5118 |
sbuf[4] = 0; |
| 5119 |
if ( sname==NULL ) |
| 5120 |
sname = sbuf; |
| 5121 |
} |
| 5122 |
langtags = SFLangsInScript(sf,-1,scripttags[s]); |
| 5123 |
|
| 5124 |
for ( l=0; langtags[l]!=0; ++l ) { |
| 5125 |
if ( k ) { |
| 5126 |
for ( i=0; languages[i].text!=NULL; ++i ) |
| 5127 |
if ( langtags[l] == (intptr_t) (languages[i].userdata)) |
| 5128 |
break; |
| 5129 |
lname = (char *) (languages[i].text); |
| 5130 |
lbuf[0] = langtags[l]>>24; |
| 5131 |
lbuf[1] = langtags[l]>>16; |
| 5132 |
lbuf[2] = langtags[l]>>8; |
| 5133 |
lbuf[3] = langtags[l]; |
| 5134 |
lbuf[4] = 0; |
| 5135 |
if ( lname==NULL ) |
| 5136 |
lname = lbuf; |
| 5137 |
temp = malloc(strlen(sname)+strlen(lname)+3); |
| 5138 |
strcpy(temp,sname); strcat(temp,"{"); strcat(temp,lname); strcat(temp,"}"); |
| 5139 |
ret[cnt].text = (unichar_t *) temp; |
| 5140 |
ret[cnt].text_is_1byte = true; |
| 5141 |
temp = malloc(11); |
| 5142 |
strcpy(temp,sbuf); temp[4] = '{'; strcpy(temp+5,lbuf); temp[9]='}'; temp[10] = 0; |
| 5143 |
ret[cnt].userdata = temp; |
| 5144 |
} |
| 5145 |
++cnt; |
| 5146 |
} |
| 5147 |
free(langtags); |
| 5148 |
} |
| 5149 |
if ( !k ) |
| 5150 |
ret = calloc((cnt+1),sizeof(GTextInfo)); |
| 5151 |
} |
| 5152 |
free(scripttags); |
| 5153 |
return( ret ); |
| 5154 |
} |
| 5155 |
|
| 5156 |
#define metricsicon_width 16 |
| 5157 |
#define metricsicon_height 16 |
| 5158 |
static unsigned char metricsicon_bits[] = { |
| 5159 |
0x04, 0x10, 0xf0, 0x03, 0x24, 0x12, 0x20, 0x00, 0x24, 0x10, 0xe0, 0x00, |
| 5160 |
0x24, 0x10, 0x20, 0x00, 0x24, 0x10, 0x20, 0x00, 0x74, 0x10, 0x00, 0x00, |
| 5161 |
0x55, 0x55, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00}; |
| 5162 |
|
| 5163 |
static int metricsview_ready = false; |
| 5164 |
|
| 5165 |
static void MetricsViewFinish() { |
| 5166 |
if (!metricsview_ready) return; |
| 5167 |
mb2FreeGetText(mblist); |
| 5168 |
} |
| 5169 |
|
| 5170 |
void MetricsViewFinishNonStatic() { |
| 5171 |
MetricsViewFinish(); |
| 5172 |
} |
| 5173 |
|
| 5174 |
static void MetricsViewInit(void ) { |
| 5175 |
|
| 5176 |
if (metricsview_ready) return; |
| 5177 |
mv_text_init[2].text = (unichar_t *) _((char *) mv_text_init[2].text); |
| 5178 |
mb2DoGetText(mblist); |
| 5179 |
MVColInit(); |
| 5180 |
atexit(&MetricsViewFinishNonStatic); |
| 5181 |
} |
| 5182 |
|
| 5183 |
MetricsView *MetricsViewCreate(FontView *fv,SplineChar *sc,BDFFont *bdf) { |
| 5184 |
GRect pos; |
| 5185 |
GWindow gw; |
| 5186 |
GWindowAttrs wattrs; |
| 5187 |
GGadgetData gd; |
| 5188 |
GRect gsize; |
| 5189 |
MetricsView *mv = calloc(1,sizeof(MetricsView)); |
| 5190 |
static GWindow icon = NULL; |
| 5191 |
extern int _GScrollBar_Width; |
| 5192 |
|
| 5193 |
|
| 5194 |
#define MAXGLYPHNAME_LEN 31 |
| 5195 |
unsigned int selectmax = fvmv_selectmax < 0 ? fv->b.sf->glyphcnt : fvmv_selectmax; |
| 5196 |
char *buf = malloc(selectmax * (MAXGLYPHNAME_LEN + 1) + 1); |
| 5197 |
char *pt; |
| 5198 |
GTextInfo label; |
| 5199 |
int i,j,cnt; |
| 5200 |
int as,ds,ld; |
| 5201 |
SplineFont *master = fv->b.sf->cidmaster ? fv->b.sf->cidmaster : fv->b.sf; |
| 5202 |
|
| 5203 |
MetricsViewInit(); |
| 5204 |
|
| 5205 |
if ( icon==NULL ) |
| 5206 |
icon = GDrawCreateBitmap(NULL,metricsicon_width,metricsicon_height,metricsicon_bits); |
| 5207 |
|
| 5208 |
mv->fv = fv; |
| 5209 |
mv->sf = fv->b.sf; |
| 5210 |
mv->bdf = bdf; |
| 5211 |
mv->showgrid = mvshowgrid; |
| 5212 |
mv->antialias = mv_antialias; |
| 5213 |
mv->scale_index = SCALE_INDEX_NORMAL; |
| 5214 |
mv->next = master->metrics; |
| 5215 |
master->metrics = mv; |
| 5216 |
mv->layer = fv->b.active_layer; |
| 5217 |
mv->type = mv_type; |
| 5218 |
mv->pixelsize_set_by_window = true; |
| 5219 |
mv->dpi = 72; |
| 5220 |
|
| 5221 |
|
| 5222 |
|
| 5223 |
mv->shaper = shaper_factory("builtin", MVMakeShaperContext(mv)); |
| 5224 |
|
| 5225 |
memset(&wattrs,0,sizeof(wattrs)); |
| 5226 |
wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_icon; |
| 5227 |
wattrs.event_masks = ~(0); |
| 5228 |
wattrs.cursor = ct_mypointer; |
| 5229 |
char* titlebuf = MVWindowTitle(mv); |
| 5230 |
wattrs.utf8_window_title = titlebuf; |
| 5231 |
wattrs.icon = icon; |
| 5232 |
pos.x = pos.y = 0; |
| 5233 |
pos.width = mv_width; |
| 5234 |
pos.height = mv_height; |
| 5235 |
mv->gw = gw = GDrawCreateTopWindow(NULL,&pos,mv_e_h,mv,&wattrs); |
| 5236 |
free(titlebuf); |
| 5237 |
mv->width = pos.width; mv->height = pos.height; |
| 5238 |
mv->gwgic = GDrawCreateInputContext(mv->gw,gic_root|gic_orlesser); |
| 5239 |
GDrawSetGIC(gw,mv->gwgic,0,20); |
| 5240 |
GDrawSetWindowTypeName(mv->gw, "MetricsView"); |
| 5241 |
|
| 5242 |
memset(&gd,0,sizeof(gd)); |
| 5243 |
gd.flags = gg_visible | gg_enabled; |
| 5244 |
helplist[0].invoke = MVMenuContextualHelp; |
| 5245 |
gd.u.menu2 = mblist; |
| 5246 |
mv->mb = GMenu2BarCreate( gw, &gd, NULL); |
| 5247 |
GGadgetGetSize(mv->mb,&gsize); |
| 5248 |
mv->mbh = gsize.height; |
| 5249 |
|
| 5250 |
gd.pos.height = GDrawPointsToPixels(gw,_GScrollBar_Width); |
| 5251 |
gd.pos.y = pos.height-gd.pos.height; |
| 5252 |
gd.pos.x = 0; gd.pos.width = pos.width; |
| 5253 |
gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels; |
| 5254 |
mv->hsb = GScrollBarCreate(gw,&gd,mv); |
| 5255 |
GGadgetGetSize(mv->hsb,&gsize); |
| 5256 |
mv->sbh = gsize.height; |
| 5257 |
mv->dwidth = mv->width-mv->sbh; |
| 5258 |
|
| 5259 |
gd.pos.width = mv->sbh; |
| 5260 |
gd.pos.y = 0; gd.pos.height = pos.height; |
| 5261 |
gd.pos.x = pos.width-gd.pos.width; |
| 5262 |
gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_sb_vert; |
| 5263 |
mv->vsb = GScrollBarCreate(gw,&gd,mv); |
| 5264 |
|
| 5265 |
mv->font = mv_font.fi; |
| 5266 |
GDrawWindowFontMetrics(gw,mv->font,&as,&ds,&ld); |
| 5267 |
mv->fh = as+ds; mv->as = as; |
| 5268 |
|
| 5269 |
pt = buf; |
| 5270 |
|
| 5271 |
mv->chars = calloc(mv->cmax=selectmax+1,sizeof(SplineChar *)); |
| 5272 |
if ( sc!=NULL ) { |
| 5273 |
mv->chars[mv->clen++] = sc; |
| 5274 |
} else { |
| 5275 |
EncMap *map = fv->b.map; |
| 5276 |
for ( j=1; (j<=fv->sel_index || j<1) && mv->clen<selectmax; ++j ) { |
| 5277 |
for ( i=0; i<map->enccount && mv->clen<selectmax; ++i ) { |
| 5278 |
int gid = map->map[i]; |
| 5279 |
if ( gid!=-1 && fv->b.selected[i]==j && fv->b.sf->glyphs[gid]!=NULL ) { |
| 5280 |
mv->chars[mv->clen++] = fv->b.sf->glyphs[gid]; |
| 5281 |
} |
| 5282 |
} |
| 5283 |
} |
| 5284 |
} |
| 5285 |
mv->chars[mv->clen] = NULL; |
| 5286 |
|
| 5287 |
for ( cnt=0; cnt<mv->clen; ++cnt ) { |
| 5288 |
int cp = mv->chars[cnt]->unicodeenc; |
| 5289 |
static const unichar_t metricsview_tokens[] = {'#', '[', ']', '/', '\\', '\0'}; |
| 5290 |
if ( cp != -1 && u_strchr(metricsview_tokens, cp) == NULL ) |
| 5291 |
pt = utf8_idpb(pt,cp,0); |
| 5292 |
else { |
| 5293 |
*pt = '/'; pt++; |
| 5294 |
strcpy(pt, mv->chars[cnt]->name); |
| 5295 |
pt += strlen(mv->chars[cnt]->name); |
| 5296 |
} |
| 5297 |
} |
| 5298 |
*pt = '\0'; |
| 5299 |
|
| 5300 |
memset(&gd,0,sizeof(gd)); |
| 5301 |
memset(&label,0,sizeof(label)); |
| 5302 |
gd.pos.y = mv->mbh+2; gd.pos.x = 10; |
| 5303 |
gd.pos.width = GDrawPointsToPixels(mv->gw,100); |
| 5304 |
gd.label = &label; |
| 5305 |
label.text = (unichar_t *) "DFLT{dflt}"; |
| 5306 |
label.text_is_1byte = true; |
| 5307 |
gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels; |
| 5308 |
gd.u.list = mv->scriptlangs = SLOfFont(mv->sf); |
| 5309 |
gd.handle_controlevent = MV_ScriptLangChanged; |
| 5310 |
mv->script = GListFieldCreate(gw,&gd,mv); |
| 5311 |
GGadgetGetSize(mv->script,&gsize); |
| 5312 |
mv->topend = gsize.y + gsize.height + 2; |
| 5313 |
|
| 5314 |
gd.pos.x = gd.pos.x+gd.pos.width+10; |
| 5315 |
gd.pos.width = GDrawPointsToPixels(mv->gw,200); |
| 5316 |
gd.pos.height = gsize.height; |
| 5317 |
label.text = (unichar_t *) buf; |
| 5318 |
gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_text_xim; |
| 5319 |
gd.handle_controlevent = MV_TextChanged; |
| 5320 |
gd.u.list = mv_text_init; |
| 5321 |
mv->text = GListFieldCreate(gw,&gd,mv); |
| 5322 |
|
| 5323 |
|
| 5324 |
{ |
| 5325 |
GTextInfo label[9]; |
| 5326 |
GGadgetData xgd = gd; |
| 5327 |
gd.pos.width += 2 * xgd.pos.height + 4; |
| 5328 |
memset(label, '\0', sizeof(GTextInfo)); |
| 5329 |
xgd.pos.x += xgd.pos.width + 2; |
| 5330 |
xgd.pos.width = xgd.pos.height; |
| 5331 |
xgd.flags = gg_visible|gg_enabled|gg_pos_in_pixels; |
| 5332 |
xgd.handle_controlevent = MVMoveToPrevInWordList; |
| 5333 |
xgd.label = &label[0]; |
| 5334 |
label[0].text = (unichar_t *) "⇞"; |
| 5335 |
label[0].text_is_1byte = true; |
| 5336 |
mv->textPrev = GButtonCreate(mv->gw,&xgd,mv); |
| 5337 |
memset(label, '\0', sizeof(GTextInfo)); |
| 5338 |
xgd.pos.x += xgd.pos.width + 2; |
| 5339 |
xgd.pos.width = xgd.pos.height; |
| 5340 |
xgd.flags = gg_visible|gg_enabled|gg_pos_in_pixels; |
| 5341 |
xgd.handle_controlevent = MVMoveToNextInWordList; |
| 5342 |
xgd.label = &label[0]; |
| 5343 |
label[0].text = (unichar_t *) "⇟"; |
| 5344 |
label[0].text_is_1byte = true; |
| 5345 |
mv->textNext = GButtonCreate(mv->gw,&xgd,mv); |
| 5346 |
} |
| 5347 |
|
| 5348 |
|
| 5349 |
gd.pos.x = gd.pos.x+gd.pos.width+10; --gd.pos.y; |
| 5350 |
gd.pos.width += 30; |
| 5351 |
gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels; |
| 5352 |
gd.handle_controlevent = MV_SubtableChanged; |
| 5353 |
gd.label = NULL; |
| 5354 |
gd.u.list = NULL; |
| 5355 |
mv->subtable_list = GListButtonCreate(gw,&gd,mv); |
| 5356 |
MVSetSubtables(master); |
| 5357 |
|
| 5358 |
gd.pos.y = mv->topend; gd.pos.x = 0; |
| 5359 |
gd.flags = gg_visible|gg_enabled|gg_pos_in_pixels|gg_pos_use0|gg_list_multiplesel|gg_list_alphabetic; |
| 5360 |
gd.pos.width = GDrawPointsToPixels(mv->gw,50); |
| 5361 |
gd.handle_controlevent = MV_FeaturesChanged; |
| 5362 |
mv->features = GListCreate(gw,&gd,mv); |
| 5363 |
GListSetSBAlwaysVisible(mv->features,true); |
| 5364 |
GListSetPopupCallback(mv->features,MV_FriendlyFeatures); |
| 5365 |
mv->xstart = gd.pos.width; |
| 5366 |
|
| 5367 |
pos.x = mv->xstart; pos.width = mv->dwidth - mv->xstart; |
| 5368 |
pos.y = mv->topend+2; pos.height = mv->displayend - mv->topend - 2; |
| 5369 |
memset(&wattrs,0,sizeof(wattrs)); |
| 5370 |
wattrs.mask = wam_events|wam_backcol; |
| 5371 |
wattrs.background_color = view_bgcol; |
| 5372 |
wattrs.event_masks = -1; |
| 5373 |
wattrs.cursor = ct_mypointer; |
| 5374 |
mv->v = GWidgetCreateSubWindow(mv->gw,&pos,mv_v_e_h,mv,&wattrs); |
| 5375 |
GDrawSetWindowTypeName(mv->v, "MetricsView"); |
| 5376 |
|
| 5377 |
MVSetFeatures(mv); |
| 5378 |
MVMakeLabels(mv); |
| 5379 |
MVResize(mv); |
| 5380 |
GWidgetIndicateFocusGadget(mv->text); |
| 5381 |
|
| 5382 |
GDrawSetVisible(mv->v,true); |
| 5383 |
GDrawSetVisible(gw,true); |
| 5384 |
free(buf); |
| 5385 |
return( mv ); |
| 5386 |
} |
| 5387 |
|
| 5388 |
void MetricsViewFree(MetricsView *mv) { |
| 5389 |
|
| 5390 |
if ( mv->scriptlangs!=NULL ) { |
| 5391 |
int i; |
| 5392 |
for ( i=0; mv->scriptlangs[i].text!=NULL ; ++i ) |
| 5393 |
free(mv->scriptlangs[i].userdata ); |
| 5394 |
GTextInfoListFree(mv->scriptlangs); |
| 5395 |
} |
| 5396 |
BDFFontFree(mv->show); |
| 5397 |
|
| 5398 |
free(mv->chars); |
| 5399 |
free(mv->glyphs); |
| 5400 |
free(mv->metrics); |
| 5401 |
free(mv->perchar); |
| 5402 |
shaper_free(&(mv->shaper)); |
| 5403 |
free(mv); |
| 5404 |
} |
| 5405 |
|
| 5406 |
void MVRefreshAll(MetricsView *mv) { |
| 5407 |
|
| 5408 |
if ( mv!=NULL ) { |
| 5409 |
MVRemetric(mv); |
| 5410 |
GDrawRequestExpose(mv->v,NULL,false); |
| 5411 |
} |
| 5412 |
} |
| 5413 |
|
| 5414 |
|
| 5415 |
static int MV_GlyphCnt(struct metricsview *mv) { |
| 5416 |
return( mv->glyphcnt ); |
| 5417 |
} |
| 5418 |
|
| 5419 |
static SplineChar *MV_Glyph(struct metricsview *mv,int i) { |
| 5420 |
if ( i<0 || i>=mv->glyphcnt ) |
| 5421 |
return( NULL ); |
| 5422 |
|
| 5423 |
return( mv->glyphs[i].sc ); |
| 5424 |
} |
| 5425 |
|
| 5426 |
static void MV_ReKernAll(struct splinefont *sf) { |
| 5427 |
MetricsView *mv; |
| 5428 |
|
| 5429 |
for ( mv=sf->metrics; mv!=NULL; mv=mv->next ) |
| 5430 |
MVReKern(mv); |
| 5431 |
} |
| 5432 |
|
| 5433 |
static void MV_ReFeatureAll(struct splinefont *sf) { |
| 5434 |
MetricsView *mv; |
| 5435 |
|
| 5436 |
MVSetSubtables(sf); |
| 5437 |
for ( mv=sf->metrics; mv!=NULL; mv=mv->next ) |
| 5438 |
MVSetFeatures(mv); |
| 5439 |
} |
| 5440 |
|
| 5441 |
static void MV_CloseAll(struct splinefont *sf) { |
| 5442 |
MetricsView *mv, *mvnext; |
| 5443 |
for ( mv=sf->metrics; mv!=NULL; mv=mvnext ) { |
| 5444 |
mvnext = mv->next; |
| 5445 |
GDrawDestroyWindow(mv->gw); |
| 5446 |
} |
| 5447 |
GDrawSync(NULL); |
| 5448 |
GDrawProcessPendingEvents(NULL); |
| 5449 |
} |
| 5450 |
|
| 5451 |
struct mv_interface gdraw_mv_interface = { |
| 5452 |
MV_GlyphCnt, |
| 5453 |
MV_Glyph, |
| 5454 |
MV_ReKernAll, |
| 5455 |
MV_ReFeatureAll, |
| 5456 |
MV_CloseAll |
| 5457 |
}; |
| 5458 |
|
| 5459 |
static int MetricsViewRIInit(GResInfo *ri) { |
| 5460 |
extern GResInfo fontview_ri; |
| 5461 |
extern Color fvfgcol; |
| 5462 |
if ( ri->is_initialized ) |
| 5463 |
return false; |
| 5464 |
GResEditDoInit(&fontview_ri); |
| 5465 |
glyphcol = fvfgcol; |
| 5466 |
dividercol = GDrawGetDefaultForeground(NULL); |
| 5467 |
return _GResEditInitialize(ri); |
| 5468 |
} |
| 5469 |
|
| 5470 |
static struct resed metricsview_re[] = { |
| 5471 |
{N_("Glyph Color"), "GlyphColor", rt_color, &glyphcol, N_("Foreground color of glyph area"), NULL, { 0 }, 0, 0 }, |
| 5472 |
{N_("Selected Glyph Col"), "SelectedGlyphColor", rt_color, &selglyphcol, N_("Color used to mark the selected glyph"), NULL, { 0 }, 0, 0 }, |
| 5473 |
{N_("Divider Color"), "DividerColor", rt_color, ÷rcol, N_("Color of field divider lines"), NULL, { 0 }, 0, 0 }, |
| 5474 |
{N_("Advance Width Col"), "AdvanceWidthColor", rt_color, &widthcol, N_("Color used to draw the advance width line of a glyph"), NULL, { 0 }, 0, 0 }, |
| 5475 |
{N_("Italic Advance Col"), "ItalicAdvanceColor", rt_color, &widthcol, N_("Color used to draw the italic advance width line of a glyph"), NULL, { 0 }, 0, 0 }, |
| 5476 |
{N_("Kern Line Color"), "KernLineColor", rt_color, &kernlinecol, N_("Color used to draw the kerning line"), NULL, { 0 }, 0, 0 }, |
| 5477 |
{N_("Side Bearing Color"), "SideBearingLineColor", rt_color, &rbearinglinecol, N_("Color used to draw the left side bearing"), NULL, { 0 }, 0, 0 }, |
| 5478 |
RESED_EMPTY |
| 5479 |
}; |
| 5480 |
extern GResInfo miscwin_ri; |
| 5481 |
GResInfo metricsview_ri = { |
| 5482 |
&miscwin_ri, NULL,NULL, NULL, |
| 5483 |
NULL, |
| 5484 |
&mv_font, |
| 5485 |
NULL, |
| 5486 |
metricsview_re, |
| 5487 |
N_("Metrics View"), |
| 5488 |
N_("This window displays metrics information about a font"), |
| 5489 |
"MetricsView", |
| 5490 |
"fontforge", |
| 5491 |
false, |
| 5492 |
false, |
| 5493 |
0, |
| 5494 |
GBOX_EMPTY, |
| 5495 |
GBOX_EMPTY, |
| 5496 |
NULL, |
| 5497 |
MetricsViewRIInit, |
| 5498 |
NULL |
| 5499 |
}; |
| 5500 |
|
| 5501 |
|
| 5502 |
void MVSelectFirstKerningTable(struct metricsview *mv) |
| 5503 |
{ |
| 5504 |
|
| 5505 |
|
| 5506 |
|
| 5507 |
|
| 5508 |
|
| 5509 |
|
| 5510 |
|
| 5511 |
|
| 5512 |
|
| 5513 |
|
| 5514 |
|
| 5515 |
if( GGadgetGetFirstListSelectedItem(mv->features) >= 0 ) |
| 5516 |
{ |
| 5517 |
return; |
| 5518 |
} |
| 5519 |
|
| 5520 |
GGadgetSelectOneListItem(mv->features,0); |
| 5521 |
MVRemetric(mv); |
| 5522 |
GDrawRequestExpose(mv->v,NULL,false); |
| 5523 |
} |
| 5524 |
|
| 5525 |
|