From 4a90d14283e6ecfeaf43e59d374653d52d7d0336 Mon Sep 17 00:00:00 2001 From: Alexey Kryukov Date: Sun, 20 Feb 2011 11:36:26 +0300 Subject: Still problems with function indicators in matix edit controls. --- gdraw/gmatrixedit.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/gdraw/gmatrixedit.c b/gdraw/gmatrixedit.c index be982b6e..31edc25b 100644 --- a/gdraw/gmatrixedit.c +++ b/gdraw/gmatrixedit.c @@ -757,13 +757,13 @@ static void GME_PositionEdit(GMatrixEdit *gme) { GDrawGetSize(gme->nested,&wsize); if ( end>wsize.width ) end = wsize.width - x; + if ( gme->col_data[c].me_type==me_stringchoice || + gme->col_data[c].me_type==me_stringchoicetrans || + gme->col_data[c].me_type==me_stringchoicetag || + gme->col_data[c].me_type==me_onlyfuncedit || + gme->col_data[c].me_type==me_funcedit ) + end -= gme->mark_size+gme->mark_skip; } - if ( gme->col_data[c].me_type==me_stringchoice || - gme->col_data[c].me_type==me_stringchoicetrans || - gme->col_data[c].me_type==me_stringchoicetag || - gme->col_data[c].me_type==me_onlyfuncedit || - gme->col_data[c].me_type==me_funcedit ) - end -= gme->mark_size+gme->mark_skip; GGadgetResize(gme->tf,end-x,gme->fh); GGadgetMove(gme->tf,x,y); @@ -1349,6 +1349,7 @@ return; markpos = ( c == lastc && gme->col_data[c].x + gme->col_data[c].width > size.width ) ? size.width - gme->col_data[c].x : gme->col_data[c].width; markpos -= (gme->mark_size+gme->mark_skip); + if ( markpos < 0 ) markpos = 0; if ( event->type==et_mousedown && event->u.mouse.button==3 ) { if ( gme->popupmenu!=NULL ) (gme->popupmenu)(&gme->g,event,r,c); @@ -1542,15 +1543,22 @@ static void GMatrixEdit_SubExpose(GMatrixEdit *gme,GWindow pixmap,GEvent *event) GDrawFillRect(pixmap,&clip,gme->g.box->main_background!=COLOR_DEFAULT?gme->g.box->main_background: GDrawGetDefaultBackground(GDrawGetDisplayOfWindow(pixmap))); #endif - if ( c == lastc && clip.x+gme->col_data[c].width > size.width ) - clip.width = size.width - clip.x; - if ( gme->col_data[c].me_type == me_stringchoice || gme->col_data[c].me_type == me_stringchoicetrans || gme->col_data[c].me_type == me_stringchoicetag || gme->col_data[c].me_type == me_onlyfuncedit || gme->col_data[c].me_type == me_funcedit ) { - clip.width -= (gme->mark_size+gme->mark_skip); + + if ( c == lastc ) { + if ( clip.x < size.width && clip.x + clip.width > size.width ) + clip.width = size.width - clip.x; + else if ( clip.x >= size.width ) + clip.width = 0; + } + if ( clip.width >= (gme->mark_size+gme->mark_skip) ) + clip.width -= (gme->mark_size+gme->mark_skip); + else + clip.width = 0; } if ( clip.width>0 ) { GDrawPushClip(pixmap,&clip,&old); @@ -1778,8 +1786,14 @@ static void GME_HScroll(GMatrixEdit *gme,struct sbevent *sb) { gme->col_data[lastc].me_type == me_stringchoicetrans || gme->col_data[lastc].me_type == me_stringchoicetag || gme->col_data[lastc].me_type == me_onlyfuncedit || - gme->col_data[lastc].me_type == me_funcedit) && - gme->col_data[lastc].x + gme->col_data[lastc].width > clip.width ) { + gme->col_data[lastc].me_type == me_funcedit ) && + gme->col_data[lastc].x <= gme->off_left + size.width - (gme->mark_size + gme->mark_skip) ) { + int xdiff = gme->off_left + size.width - (gme->mark_size + gme->mark_skip) - gme->col_data[lastc].x; + /* Catch the moment when we should stop scrolling the list mark area */ + if ( xdiff + diff < 0 ) { + GDrawScroll( gme->nested,&clip,xdiff + diff,0 ); + diff = -xdiff; + } clip.width -= (gme->mark_size + gme->mark_skip); } GDrawScroll( gme->nested,&clip,diff,0 ); -- cgit v1.2.3 From 6fe88d8f68e43520420e54613a4a7f2c75221871 Mon Sep 17 00:00:00 2001 From: Alexey Kryukov Date: Sun, 20 Feb 2011 11:39:55 +0300 Subject: Make ligature carets accessible from python scripts. --- fontforge/python.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ htdocs/python.html | 6 +++++ 2 files changed, 78 insertions(+) diff --git a/fontforge/python.c b/fontforge/python.c index bd5d5c5b..39e50f5c 100644 --- a/fontforge/python.c +++ b/fontforge/python.c @@ -5734,6 +5734,75 @@ return( -1 ); return( 0 ); } +static PyObject *PyFF_Glyph_get_lcarets(PyFF_Glyph *self,void *closure) { + + SplineChar *sc = ((PyFF_Glyph *) self)->sc; + int cnt=0, i; + PST *pst, *lcar = NULL; + PyObject *tuple; + + for ( pst = sc->possub; pst!=NULL; pst=pst->next ) { + if ( pst->type==pst_lcaret ) { + lcar = pst; + cnt = lcar->u.lcaret.cnt; + break; + } + } + tuple = PyTuple_New(cnt); + + if ( lcar != NULL ) { + for ( i=0; iu.lcaret.carets[i]) ); + } + } +return( tuple ); +} + +static int PyFF_Glyph_set_lcarets(PyFF_Glyph *self,PyObject *value,void *closure) { + SplineChar *sc = self->sc; + int i, cnt, lig_comp_max = 0, lc; + char *pt; + int16 *carets; + PST *pst, *lcar = NULL; + + cnt = PySequence_Size(value); + if ( cnt==-1 ) +return( -1 ); + + if ( cnt > 0 ) + carets = galloc( cnt*sizeof(int16) ); + for ( i=0; ipossub; pst!=NULL; pst=pst->next ) { + if ( pst->type==pst_lcaret ) { + lcar = pst; + free( lcar->u.lcaret.carets ); + } else if ( pst->type==pst_ligature ) { + for ( lc=0, pt=pst->u.lig.components; *pt; ++pt ) + if ( *pt==' ' ) ++lc; + if ( lc>lig_comp_max ) + lig_comp_max = lc; + } + } + + if ( lcar == NULL && cnt > 0 ) { + lcar = chunkalloc(sizeof(PST)); + lcar->type = pst_lcaret; + lcar->next = sc->possub; + sc->possub = lcar; + } + if ( lcar != NULL ) { + lcar->u.lcaret.cnt = cnt; + lcar->u.lcaret.carets = cnt > 0 ? carets : NULL; + sc->lig_caret_cnt_fixed = ( cnt != lig_comp_max ) ? true : false; + } +return( 0 ); +} + static PyObject *PyFF_Glyph_get_font(PyFF_Glyph *self,void *closure) { return( PyFV_From_FV_I(self->sc->parent->fv)); @@ -6614,6 +6683,9 @@ static PyGetSetDef PyFF_Glyph_getset[] = { {"manualHints", (getter)PyFF_Glyph_get_manualhints, (setter)PyFF_Glyph_set_manualhints, "The hints have been set manually, and the glyph should not be autohinted by default" }, + {"lcarets", + (getter)PyFF_Glyph_get_lcarets, (setter)PyFF_Glyph_set_lcarets, + "The ligature caret locations, defined for this glyph, as a tuple.", NULL}, {"validation_state", (getter)PyFF_Glyph_get_validation_state, (setter)PyFF_cant_set, "glyph's validation state (readonly)", NULL}, diff --git a/htdocs/python.html b/htdocs/python.html index e277d468..f199a78c 100644 --- a/htdocs/python.html +++ b/htdocs/python.html @@ -1779,6 +1779,12 @@ pen = None; # Finalize the pen. This tells FontForge reference tuple object. Layer 0 is the background layer. Layer 1 is the foreground layer. + + lcarets + A tuple containing the glyph's ligature caret locations. Setting + this will also either enable or disable the "Default Ligature Caret Count" + flag depending from the number of elements in the tuple. + left_side_bearing The left side bearing of the glyph -- cgit v1.2.3 From 2b62efebd4bd0f4f9f4d598cfab518eaea1029ca Mon Sep 17 00:00:00 2001 From: Alexey Kryukov Date: Sun, 20 Feb 2011 11:43:35 +0300 Subject: Sort human-readable stylistic set names (first by feature tag, then by language) both in the FontInfo dialog and in SFD output. --- fontforge/fontinfo.c | 18 +++++++++++++++++- fontforge/sfd.c | 4 ++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fontforge/fontinfo.c b/fontforge/fontinfo.c index eec058c2..c9fb3cf2 100644 --- a/fontforge/fontinfo.c +++ b/fontforge/fontinfo.c @@ -3487,6 +3487,20 @@ static int GFI_AddOFL(GGadget *g, GEvent *e) { return( true ); } +static int ss_cmp(const void *_md1, const void *_md2) { + const struct matrix_data *md1 = _md1, *md2 = _md2; + + char buf1[20], buf2[20]; + const char *l1, *l2; + + if ( md1[1].u.md_ival == md2[1].u.md_ival ) { + l1 = langname(md1[0].u.md_ival,buf1); + l2 = langname(md2[0].u.md_ival,buf2); +return( strcoll(l1,l2)); + } +return( md1[1].u.md_ival - md2[1].u.md_ival ); +} + static void SSMatrixInit(struct matrixinit *mi,struct gfi_data *d) { SplineFont *sf = d->sf; struct matrix_data *md; @@ -3509,6 +3523,7 @@ static void SSMatrixInit(struct matrixinit *mi,struct gfi_data *d) { md[3*cnt+2].u.md_str = copy(on->name); } } + qsort( md, cnt, 3*sizeof(struct matrix_data), ss_cmp ); mi->matrix_data = md; mi->initial_row_cnt = cnt; } @@ -3935,7 +3950,8 @@ static void StoreSSNames(struct gfi_data *d) { OtfFeatNameListFree(sf->feat_names); sf->feat_names = NULL; - for ( i=0; i=0; --i ) { if ( strings[3*i+2].u.md_str == NULL ) continue; tag = strings[3*i+1].u.md_ival; diff --git a/fontforge/sfd.c b/fontforge/sfd.c index dde1fd15..25c15d72 100644 --- a/fontforge/sfd.c +++ b/fontforge/sfd.c @@ -1626,10 +1626,10 @@ static void SFDDumpOtfFeatNames(FILE *sfd, SplineFont *sf) { fprintf( sfd, "OtfFeatName: '%c%c%c%c' ", fn->tag>>24, fn->tag>>16, fn->tag>>8, fn->tag ); for ( on=fn->names; on!=NULL; on=on->next ) { - fprintf( sfd, " %d ", on->lang ); + fprintf( sfd, "%d ", on->lang ); SFDDumpUTF7Str(sfd, on->name); - putc('\n',sfd); } + putc('\n',sfd); } } -- cgit v1.2.3