Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
fixStems is always false
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Aug 24, 2018
1 parent 2b5bdf6 commit fd5e47f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 200 deletions.
7 changes: 2 additions & 5 deletions libpsautohint/src/ac.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define MAXSTEMDIST 150 /* initial maximum stem width allowed for hints */

PathElt *gPathStart, *gPathEnd;
bool gUseV, gUseH, gAutoVFix, gAutoHFix, gAutoLinearCurveFix, gEditGlyph;
bool gUseV, gUseH, gAutoLinearCurveFix, gEditGlyph;
bool gHasFlex, gFlexOK, gFlexStrict, gBandError;
Fixed gHBigDist, gVBigDist, gInitBigDist, gMinDist, gGhostWidth, gGhostLength,
gBendLength, gBandMargin, gMaxFlare, gMaxBendMerge, gMaxMerge,
Expand Down Expand Up @@ -98,7 +98,6 @@ InitData(const ACFontInfo* fontinfo, int32_t reason)
gSCurveTan = 25;
gMaxVal = 8000000.0;
gMinVal = 1.0 / (float)(FixOne);
gAutoHFix = gAutoVFix = false;
gEditGlyph = true;
gRoundToInt = true;
/* Default is to change a curve with collinear points into a line.
Expand Down Expand Up @@ -135,7 +134,7 @@ InitData(const ACFontInfo* fontinfo, int32_t reason)

/* Returns whether hinting was successful. */
bool
AutoHint(const ACFontInfo* fontinfo, const char* srcbezdata, bool fixStems,
AutoHint(const ACFontInfo* fontinfo, const char* srcbezdata,
bool extrahint, bool changeGlyph, bool roundCoords)
{
InitAll(fontinfo, STARTUP);
Expand All @@ -146,8 +145,6 @@ AutoHint(const ACFontInfo* fontinfo, const char* srcbezdata, bool fixStems,
gEditGlyph = changeGlyph;
gRoundToInt = roundCoords;
gAutoLinearCurveFix = gEditGlyph;
if (gEditGlyph && fixStems)
gAutoVFix = gAutoHFix = fixStems;

return AutoHintGlyph(fontinfo, srcbezdata, extrahint);
}
Expand Down
7 changes: 2 additions & 5 deletions libpsautohint/src/ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ typedef struct {
extern ACBuffer* gBezOutput;

extern PathElt* gPathStart, *gPathEnd;
extern bool gUseV, gUseH, gAutoVFix, gAutoHFix, gAutoLinearCurveFix;
extern bool gUseV, gUseH, gAutoLinearCurveFix;
extern bool gEditGlyph; /* whether glyph can be modified when adding hints */
extern bool gBandError;
extern bool gHasFlex, gFlexOK, gFlexStrict;
Expand Down Expand Up @@ -302,10 +302,8 @@ bool AutoHintGlyph(const ACFontInfo* fontinfo, const char* srcglyph,
void EvalV(void);
void EvalH(void);
void GenVPts(int32_t specialGlyphType);
void CheckVal(HintVal* val, bool vert);
void CheckTfmVal(HintSeg* hSegList, Fixed* bandList, int32_t length);
void CheckVals(HintVal* vlst, bool vert);
bool DoFixes(void);
bool FindLineSeg(Fixed loc, HintSeg* sL);
void FltnCurve(Cd c0, Cd c1, Cd c2, Cd c3, FltnRec* pfr);
bool InBlueBand(Fixed loc, int32_t n, Fixed* p);
Expand Down Expand Up @@ -414,8 +412,7 @@ void AddHStem(Fixed right, Fixed left, bool curved);
void AddGlyphExtremes(Fixed bot, Fixed top);

bool AutoHint(const ACFontInfo* fontinfo, const char* srcbezdata,
bool fixStems, bool extrahint, bool changeGlyph,
bool roundCoords);
bool extrahint, bool changeGlyph, bool roundCoords);

bool MergeGlyphPaths(const ACFontInfo* fontinfo, const char** srcglyphs,
int nmasters, const char** masters, char** outbuffers,
Expand Down
3 changes: 0 additions & 3 deletions libpsautohint/src/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,6 @@ AddHintsInnerLoop(const ACFontInfo* fontinfo, const char* srcglyph,
if (CounterFailed && retryHinting == 1) {
goto retry;
}
if (!DoFixes()) {
break;
}
if (retryHinting > 1) {
break;
}
Expand Down
187 changes: 1 addition & 186 deletions libpsautohint/src/fix.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

#include "ac.h"

#define maxFixes (100)
static Fixed HFixYs[maxFixes], HFixDYs[maxFixes];
static Fixed VFixXs[maxFixes], VFixDXs[maxFixes];
static int32_t HFixCount, VFixCount;
static Fixed bPrev, tPrev;

void
Expand All @@ -21,65 +17,10 @@ InitFix(int32_t reason)
switch (reason) {
case STARTUP:
case RESTART:
HFixCount = VFixCount = 0;
bPrev = tPrev = FixedPosInf;
}
}

static void
RecordHFix(Fixed y, Fixed dy)
{
HFixYs[HFixCount] = y;
HFixDYs[HFixCount] = dy;
HFixCount++;
}

static void
RecordVFix(Fixed x, Fixed dx)
{
VFixXs[VFixCount] = x;
VFixDXs[VFixCount] = dx;
VFixCount++;
}

static void
RecordForFix(bool vert, Fixed w, Fixed minW, Fixed b, Fixed t)
{
Fixed mn, mx, delta;
if (b < t) {
mn = b;
mx = t;
} else {
mn = t;
mx = b;
}
if (!vert && HFixCount + 4 < maxFixes && gAutoHFix) {
Fixed fixdy = w - minW;
if (abs(fixdy) <= FixOne) {
RecordHFix(mn, fixdy);
RecordHFix(mx - fixdy, fixdy);
} else {
delta = FixHalfMul(fixdy);
RecordHFix(mn, delta);
RecordHFix(mn + fixdy, -delta);
RecordHFix(mx, -delta);
RecordHFix(mx - fixdy, delta);
}
} else if (vert && VFixCount + 4 < maxFixes && gAutoVFix) {
Fixed fixdx = w - minW;
if (abs(fixdx) <= FixOne) {
RecordVFix(mn, fixdx);
RecordVFix(mx - fixdx, fixdx);
} else {
delta = FixHalfMul(fixdx);
RecordVFix(mn, delta);
RecordVFix(mn + fixdx, -delta);
RecordVFix(mx, -delta);
RecordVFix(mx - fixdx, delta);
}
}
}

static bool
CheckForInsideBands(Fixed loc, Fixed* blues, int32_t numblues)
{
Expand Down Expand Up @@ -155,7 +96,7 @@ CheckTfmVal(Fixed b, Fixed t, bool vert)
}
#endif

void
static void
CheckVal(HintVal* val, bool vert)
{
Fixed* stems;
Expand Down Expand Up @@ -199,8 +140,6 @@ CheckVal(HintVal* val, bool vert)
}
bPrev = b;
tPrev = t;
if ((vert && gAutoVFix) || (!vert && gAutoHFix))
RecordForFix(vert, w, minW, b, t);
}

void
Expand All @@ -211,127 +150,3 @@ CheckVals(HintVal* vlst, bool vert)
vlst = vlst->vNxt;
}
}

static void
FixH(PathElt* e, Fixed fixy, Fixed fixdy)
{
PathElt *prev, *nxt;
RMovePoint(0, fixdy, cpStart, e);
RMovePoint(0, fixdy, cpEnd, e);
prev = e->prev;
if (prev != NULL && prev->type == CURVETO && prev->y2 == fixy)
RMovePoint(0, fixdy, cpCurve2, prev);
if (e->type == CLOSEPATH)
e = GetDest(e);
nxt = e->next;
if (nxt != NULL && nxt->type == CURVETO && nxt->y1 == fixy)
RMovePoint(0, fixdy, cpCurve1, nxt);
}

static void
FixHs(Fixed fixy, Fixed fixdy)
{ /* y dy in user space */
PathElt* e;
Fixed xlst = 0, ylst = 0, xinit = 0, yinit = 0;
fixy = -fixy;
fixdy = -fixdy;
e = gPathStart;
while (e != NULL) {
switch (e->type) {
case MOVETO:
xlst = xinit = e->x;
ylst = yinit = e->y;
break;
case LINETO:
if (e->y == fixy && ylst == fixy)
FixH(e, fixy, fixdy);
xlst = e->x;
ylst = e->y;
break;
case CURVETO:
xlst = e->x3;
ylst = e->y3;
break;
case CLOSEPATH:
if (yinit == fixy && ylst == fixy && xinit != xlst)
FixH(e, fixy, fixdy);
break;
default: {
LogMsg(LOGERROR, NONFATALERROR,
"Illegal operator in path list.");
}
}
e = e->next;
}
}

static void
FixV(PathElt* e, Fixed fixx, Fixed fixdx)
{
PathElt *prev, *nxt;
RMovePoint(fixdx, 0, cpStart, e);
RMovePoint(fixdx, 0, cpEnd, e);
prev = e->prev;
if (prev != NULL && prev->type == CURVETO && prev->x2 == fixx)
RMovePoint(fixdx, 0, cpCurve2, prev);
if (e->type == CLOSEPATH)
e = GetDest(e);
nxt = e->next;
if (nxt != NULL && nxt->type == CURVETO && nxt->x1 == fixx)
RMovePoint(fixdx, 0, cpCurve1, nxt);
}

static void
FixVs(Fixed fixx, Fixed fixdx)
{ /* x dx in user space */
PathElt* e;
Fixed xlst = 0, ylst = 0, xinit = 0, yinit = 0;
e = gPathStart;
while (e != NULL) {
switch (e->type) {
case MOVETO:
xlst = xinit = e->x;
ylst = yinit = e->y;
break;
case LINETO:
if (e->x == fixx && xlst == fixx)
FixV(e, fixx, fixdx);
xlst = e->x;
ylst = e->y;
break;
case CURVETO:
xlst = e->x3;
ylst = e->y3;
break;
case CLOSEPATH:
if (xinit == fixx && xlst == fixx && yinit != ylst)
FixV(e, fixx, fixdx);
break;
default: {
LogMsg(LOGERROR, NONFATALERROR,
"Illegal operator in point list.");
}
}
e = e->next;
}
}

bool
DoFixes(void)
{
bool didfixes = false;
int32_t i;
if (HFixCount > 0 && gAutoHFix) {
LogMsg(INFO, OK, "Fixing horizontal near misses.");
didfixes = true;
for (i = 0; i < HFixCount; i++)
FixHs(HFixYs[i], HFixDYs[i]);
}
if (VFixCount > 0 && gAutoVFix) {
LogMsg(INFO, OK, "Fixing vertical near misses.");
didfixes = true;
for (i = 0; i < VFixCount; i++)
FixVs(VFixXs[i], VFixDXs[i]);
}
return didfixes;
}
1 change: 0 additions & 1 deletion libpsautohint/src/psautohint.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ AutoHintString(const char* srcbezdata, const char* fontinfodata,

result = AutoHint(fontinfo, /* font info */
srcbezdata, /* input glyph */
false, /* fixStems */
allowHintSub, /* extrahint */
allowEdit, /* changeGlyphs */
roundCoords);
Expand Down

0 comments on commit fd5e47f

Please sign in to comment.