summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Williams <pfaedit@users.sourceforge.net>2011-02-20 07:28:42 -0800
committerGeorge Williams <pfaedit@users.sourceforge.net>2011-02-20 07:28:42 -0800
commit34149bb8d4f90dad40a3cf84d4ef274fbfc33f73 (patch)
tree911f1e1d3e941eca9ad4b7b17f60e4fd820e3195
parentb29c42603fb65c2d9a403ba7b9d4739d7a1762a8 (diff)
parent2b62efebd4bd0f4f9f4d598cfab518eaea1029ca (diff)
Merge branch 'master' of ssh://fontforge.git.sourceforge.net/gitroot/fontforge/fontforge
-rw-r--r--fontforge/fontinfo.c18
-rw-r--r--fontforge/python.c72
-rw-r--r--fontforge/sfd.c4
-rw-r--r--gdraw/gmatrixedit.c38
-rw-r--r--htdocs/python.html6
5 files changed, 123 insertions, 15 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<rows; ++i ) {
+ qsort( strings, rows, 3*sizeof(struct matrix_data), ss_cmp );
+ for ( i=rows-1; 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/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; i<cnt; ++i ) {
+ PyTuple_SetItem( tuple,i,Py_BuildValue("i",lcar->u.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; i<cnt; ++i ) {
+ carets[i] = PyInt_AsLong( PySequence_GetItem(value,i) );
+ if ( PyErr_Occurred())
+return( -1 );
+ }
+
+ for ( pst = sc->possub; 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/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);
}
}
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 );
diff --git a/htdocs/python.html b/htdocs/python.html
index 522b0a08..eec8bdde 100644
--- a/htdocs/python.html
+++ b/htdocs/python.html
@@ -1780,6 +1780,12 @@ pen = None; # Finalize the pen. This tells FontForge
layer. Layer 1 is the foreground layer.</TD>
</TR>
<TR>
+ <TD><CODE>lcarets</CODE></TD>
+ <TD colspan=2>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.</TD>
+ </TR>
+ <TR>
<TD><CODE>left_side_bearing</CODE></TD>
<TD colspan=2>The left side bearing of the glyph</TD>
</TR>