rotated.RotatePoints(rotationAngle, IPoint(rotationCenter.x(), rotationCenter.y()));
else if (tool == TOOLRotatePoly)
{
- uint16 poly = rotated.GetPolyForPointNumber(ptHighlight);
+ uint16_t poly = rotated.GetPolyForPointNumber(ptHighlight);
rotated.RotatePolyAroundCentroid(poly, rotationAngle);
}
{
for(int poly=0; poly<glyph.GetNumPolys(); poly++)
{
+#if 0
if (glyph.GetNumPoints(poly) < 3)
continue;
pt = pt2;
}
}
+#else
+ DrawGlyphPoly(p, glyph, poly);
+#endif
}
}
-void EditWindow::DrawGlyphPoly(QPainter & p, GlyphPoints & glyph, uint16 poly)
+void EditWindow::DrawGlyphPoly(QPainter & p, GlyphPoints & glyph, uint16_t poly)
{
// Sanity check
if (glyph.GetNumPoints(poly) < 3)
for(int i=0; i<pts.GetNumPoints(); i++)
{
- int32 p1x = pts.GetX(i), p1y = pts.GetY(i),
+ int32_t p1x = pts.GetX(i), p1y = pts.GetY(i),
p2x = pts.GetX(pts.GetNext(i)), p2y = pts.GetY(pts.GetNext(i));
Vector ls(p2x, p2y, 0, p1x, p1y, 0), v1(pt2.x(), pt2.y(), 0, p1x, p1y, 0),
pts.RotatePoints(rotationAngle, IPoint(rotationCenter.x(), rotationCenter.y()));
else
{
- uint16 poly = pts.GetPolyForPointNumber(ptHighlight);
+ uint16_t poly = pts.GetPolyForPointNumber(ptHighlight);
pts.RotatePolyAroundCentroid(poly, rotationAngle);
}
void EditWindow::keyPressEvent(QKeyEvent * event)
{
+ // Sanity checking...
+ if (ptHighlight == -1)
+ return;
+
+ if (event->key() == Qt::Key_Up)
+ {
+ pts.SetXY(ptHighlight, pts.GetX(ptHighlight), pts.GetY(ptHighlight) + 1);
+ }
+ else if (event->key() == Qt::Key_Down)
+ pts.SetXY(ptHighlight, pts.GetX(ptHighlight), pts.GetY(ptHighlight) - 1);
+ else if (event->key() == Qt::Key_Right)
+ pts.SetXY(ptHighlight, pts.GetX(ptHighlight) + 1, pts.GetY(ptHighlight));
+ else if (event->key() == Qt::Key_Left)
+ pts.SetXY(ptHighlight, pts.GetX(ptHighlight) - 1, pts.GetY(ptHighlight));
+ else
+ return;
+
+ event->accept();
+ update();
+ ((TTEdit *)qApp)->charWnd->MakePathFromPoints(&pts);
+ ((TTEdit *)qApp)->charWnd->update();
}
-void EditWindow::keyReleaseEvent(QKeyEvent * event)
+void EditWindow::keyReleaseEvent(QKeyEvent * /*event*/)
{
}
#define __EDITWINDOW_H__
#include <QtWidgets>
-#include "types.h"
+#include <stdint.h>
#include "toolwindow.h" // For ToolType enum
#include "glyphpoints.h"
QSize sizeHint() const;
protected:
- void paintEvent(QPaintEvent * event);
- void mousePressEvent(QMouseEvent * event);
- void mouseMoveEvent(QMouseEvent * event);
- void mouseReleaseEvent(QMouseEvent * event);
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
private:
void CreateCursors(void);
- QPoint GetAdjustedMousePosition(QMouseEvent * event);
+ QPoint GetAdjustedMousePosition(QMouseEvent *);
QPoint GetAdjustedClientPosition(int x, int y);
void DrawGlyph(QPainter & p, GlyphPoints & glyph);
- void DrawGlyphPoly(QPainter & p, GlyphPoints & glyph, uint16 poly);
+ void DrawGlyphPoly(QPainter & p, GlyphPoints & glyph, uint16_t poly);
public:
QImage image;
QPoint pt, ptOffset, ptPrevious;
double scale; // Window scaling factor
- int32 offsetX, offsetY; // Window offsets
+ int32_t offsetX, offsetY; // Window offsets
ToolType tool; // Current tool
GlyphPoints pts; // Glyph point structure
- int32 ptHighlight, oldPtHighlight, ptNextHighlight, oldPtNextHighlight;
- int16 polyHighlight, oldPolyHighlight;
+ int32_t ptHighlight, oldPtHighlight, ptNextHighlight, oldPtNextHighlight;
+ int16_t polyHighlight, oldPolyHighlight;
bool polyFirstPoint;
bool showRotationCenter, haveZeroPoint;
QPoint rotationCenter, rotationZeroPoint, rotationCurrentPoint;
}*/
GlyphPoints::GlyphPoints(int nPts/*=0*/, int nPlys/*=0*/, int * xa/*=null*/, int * ya/*=null*/,
- bool * oca/*=null*/, uint16 * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL)
+ bool * oca/*=null*/, uint16_t * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL)
//GlyphPoints::GlyphPoints(int nPts, int nPlys/*=0*/, int * xa/*=null*/, int * ya/*=null*/,
-// bool * oca/*=null*/, uint16 * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL)
+// bool * oca/*=null*/, uint16_t * pa/*=null*/): x(NULL), y(NULL), onCurve(NULL), polyEnd(NULL)
{
AllocateAndCopy(nPts, nPlys, xa, ya, oca, pa);
if (nPlys == 0)
{
numPolys = 1;
- polyEnd = new uint16[numPolys];
+ polyEnd = new uint16_t[numPolys];
polyEnd[0] = numPoints - 1;
}
#ifdef DEBUG
}
-void GlyphPoints::AllocateAndCopy(int nPts, int nPlys, int * xa, int * ya, bool * oca, uint16 * pa)
+void GlyphPoints::AllocateAndCopy(int nPts, int nPlys, int * xa, int * ya, bool * oca, uint16_t * pa)
{
numPoints = nPts, numPolys = nPlys;
if (numPolys)
{
- polyEnd = new uint16[numPolys];
+ polyEnd = new uint16_t[numPolys];
if (pa) // Copy poly ends in if they're passed in...
for(int i=0; i<nPlys; i++)
int * totX = new int[totPoints];
int * totY = new int[totPoints];
bool * totOnCurve = new bool[totPoints];
- uint16 * totPolyEnd = new uint16[totPolys];
+ uint16_t * totPolyEnd = new uint16_t[totPolys];
for(int i=0; i<numPoints; i++)
{
int * totX = new int[numPoints + 1];
int * totY = new int[numPoints + 1];
bool * totOnCurve = new bool[numPoints + 1];
- uint16 * totPolyEnd = new uint16[numPolys];
+ uint16_t * totPolyEnd = new uint16_t[numPolys];
for(int i=0; i<numPoints; i++)
totX[i] = x[i], totY[i] = y[i], totOnCurve[i] = onCurve[i];
numPoints = numPolys = pointsAllocated = polysAllocated = 0;
numPolys = 1;
- polyEnd = new uint16[numPolys];
+ polyEnd = new uint16_t[numPolys];
polyEnd[0] = numPoints - 1;
}
-void GlyphPoints::InsertPoint(uint16 pt, int xx, int yy, bool oc)
+void GlyphPoints::InsertPoint(uint16_t pt, int xx, int yy, bool oc)
{
if (pt > numPoints) // > because we can insert at end...!
throw GP_OUT_OF_RANGE;
}
-void GlyphPoints::InsertPoint(uint16 pt, const IPoint &p)
+void GlyphPoints::InsertPoint(uint16_t pt, const IPoint &p)
{
InsertPoint(pt, p.x, p.y, p.onCurve);
}
// size counters down as needed. In the future, we'll keep track so we
// don't have to reallocate *every* damn time a point is added...
//
-void GlyphPoints::DeletePoint(uint16 pt)
+void GlyphPoints::DeletePoint(uint16_t pt)
{
// Adjust polygon ends appropriately
- uint16 poly = GetPoly(pt);
+ uint16_t poly = GetPoly(pt);
for(int i=poly; i<numPolys; i++)
polyEnd[i]--;
}
-uint16 GlyphPoints::GetNumPoints(void)
+uint16_t GlyphPoints::GetNumPoints(void)
{
return numPoints;
}
-uint16 GlyphPoints::GetNumPoints(uint16 poly)
+uint16_t GlyphPoints::GetNumPoints(uint16_t poly)
{
if (poly >= numPolys)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetNumPoints(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
+WriteLogMsg("Exception: GetNumPoints(uint16_t). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-uint16 GlyphPoints::GetNumPolys(void)
+uint16_t GlyphPoints::GetNumPolys(void)
{
return numPolys;
}
-int GlyphPoints::GetX(uint16 pt)
+int GlyphPoints::GetX(uint16_t pt)
{
if (pt >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetX(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+WriteLogMsg("Exception: GetX(uint16_t). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-int GlyphPoints::GetY(uint16 pt)
+int GlyphPoints::GetY(uint16_t pt)
{
if (pt >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetY(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+WriteLogMsg("Exception: GetY(uint16_t). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-bool GlyphPoints::GetOnCurve(uint16 pt)
+bool GlyphPoints::GetOnCurve(uint16_t pt)
{
if (pt >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetOnCurve(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+WriteLogMsg("Exception: GetOnCurve(uint16_t). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-int GlyphPoints::GetX(uint16 poly, uint16 pt)
+int GlyphPoints::GetX(uint16_t poly, uint16_t pt)
{
if (pt >= GetNumPoints(poly))
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetX(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints);
+WriteLogMsg("Exception: GetX(uint16_t, uint16_t). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-int GlyphPoints::GetNextX(uint16 poly, uint16 pt)
+int GlyphPoints::GetNextX(uint16_t poly, uint16_t pt)
{
return GetX(poly, GetNext(poly, pt));
}
-int GlyphPoints::GetY(uint16 poly, uint16 pt)
+int GlyphPoints::GetY(uint16_t poly, uint16_t pt)
{
if (pt >= GetNumPoints(poly))
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetY(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints);
+WriteLogMsg("Exception: GetY(uint16_t, uint16_t). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-int GlyphPoints::GetNextY(uint16 poly, uint16 pt)
+int GlyphPoints::GetNextY(uint16_t poly, uint16_t pt)
{
return GetY(poly, GetNext(poly, pt));
}
-IPoint GlyphPoints::GetPoint(uint16 poly, uint16 pt)
+IPoint GlyphPoints::GetPoint(uint16_t poly, uint16_t pt)
{
return IPoint(GetX(poly, pt), GetY(poly, pt), GetOnCurve(poly, pt));
}
-IPoint GlyphPoints::GetPoint(uint16 pointNumber)
+IPoint GlyphPoints::GetPoint(uint16_t pointNumber)
{
if (pointNumber > numPoints)
throw GP_OUT_OF_RANGE;
}
-bool GlyphPoints::GetOnCurve(uint16 poly, uint16 pt)
+bool GlyphPoints::GetOnCurve(uint16_t poly, uint16_t pt)
{
if (pt >= GetNumPoints(poly))
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetOnCurve(uint16, uint16). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints);
+WriteLogMsg("Exception: GetOnCurve(uint16_t, uint16_t). poly= %u, pt=%u, numPoints=%u\xD\xA", poly, pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-bool GlyphPoints::GetPrevOnCurve(uint16 poly, uint16 pt)
+bool GlyphPoints::GetPrevOnCurve(uint16_t poly, uint16_t pt)
{
return GetOnCurve(poly, GetPrev(poly, pt));
}
-bool GlyphPoints::GetNextOnCurve(uint16 poly, uint16 pt)
+bool GlyphPoints::GetNextOnCurve(uint16_t poly, uint16_t pt)
{
return GetOnCurve(poly, GetNext(poly, pt));
}
-uint16 GlyphPoints::GetPolyStart(uint16 poly)
+uint16_t GlyphPoints::GetPolyStart(uint16_t poly)
{
if (poly >= numPolys)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
+WriteLogMsg("Exception: GetPolyEnd(uint16_t). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-uint16 GlyphPoints::GetPolyEnd(uint16 poly)
+uint16_t GlyphPoints::GetPolyEnd(uint16_t poly)
{
if (poly >= numPolys)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
+WriteLogMsg("Exception: GetPolyEnd(uint16_t). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
//
// Offset only a specific polygon in the glyph
//
-void GlyphPoints::OffsetPoly(uint16 poly, int32 xOff, int32 yOff)
+void GlyphPoints::OffsetPoly(uint16_t poly, int32_t xOff, int32_t yOff)
{
if (poly >= numPolys)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
+WriteLogMsg("Exception: GetPolyEnd(uint16_t). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
#endif
- uint16 polyStart = (poly == 0 ? 0 : polyEnd[poly - 1] + 1);
+ uint16_t polyStart = (poly == 0 ? 0 : polyEnd[poly - 1] + 1);
for(int i=0; i<GetNumPoints(poly); i++)
x[polyStart + i] += xOff, y[polyStart + i] += yOff;
}
-void GlyphPoints::SetXY(uint16 pt, int xx, int yy)
+void GlyphPoints::SetXY(uint16_t pt, int xx, int yy)
{
if (pt >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: SetXY(uint16, int, int). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+WriteLogMsg("Exception: SetXY(uint16_t, int, int). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-void GlyphPoints::SetOnCurve(uint16 pt, bool oc)
+void GlyphPoints::SetOnCurve(uint16_t pt, bool oc)
{
if (pt >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: SetOnCurve(uint16, bool). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+WriteLogMsg("Exception: SetOnCurve(uint16_t, bool). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-void GlyphPoints::SetPoint(const uint16 pointNum, const IPoint point)
+void GlyphPoints::SetPoint(const uint16_t pointNum, const IPoint point)
{
if (pointNum >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: SetPoint(uint16, IPoint). pt=%u, numPoints=%u\xD\xA", pointNum, numPoints);
+WriteLogMsg("Exception: SetPoint(uint16_t, IPoint). pt=%u, numPoints=%u\xD\xA", pointNum, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
}
-uint16 GlyphPoints::GetPrev(uint16 pt)
+uint16_t GlyphPoints::GetPrev(uint16_t pt)
{
// pt = 7, polyEnd = 4, 9, 15
- uint16 min = 0, max = numPoints - 1;
+ uint16_t min = 0, max = numPoints - 1;
for(int i=0; i<numPolys; i++)
{
}
}
- uint16 retVal = pt - 1;
+ uint16_t retVal = pt - 1;
if (pt == min)
retVal = max;
}
-uint16 GlyphPoints::GetNext(uint16 pt)
+uint16_t GlyphPoints::GetNext(uint16_t pt)
{
- uint16 min = 0, max = numPoints - 1;
+ uint16_t min = 0, max = numPoints - 1;
for(int i=0; i<numPolys; i++)
{
}
}
- uint16 retVal = pt + 1;
+ uint16_t retVal = pt + 1;
if (pt == max)
retVal = min;
// Get previous point for this polygon using wraparound.
// Note that pt is a zero-based index!
//
-uint16 GlyphPoints::GetPrev(uint16 poly, uint16 pt)
+uint16_t GlyphPoints::GetPrev(uint16_t poly, uint16_t pt)
{
return (pt == 0 ? GetNumPoints(poly) - 1 : pt - 1);
}
// Get next point for this polygon using wraparound.
// Note that pt is a zero-based index!
//
-uint16 GlyphPoints::GetNext(uint16 poly, uint16 pt)
+uint16_t GlyphPoints::GetNext(uint16_t poly, uint16_t pt)
{
return (pt == GetNumPoints(poly) - 1 ? 0 : pt + 1);
}
#warning "!!! This function returns incorrect results !!!"
-uint16 GlyphPoints::GetPoly(uint16 pt)
+uint16_t GlyphPoints::GetPoly(uint16_t pt)
{
if (pt >= numPoints)
#ifdef DEBUG
{
-WriteLogMsg("Exception: GetPoly(uint16). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
+WriteLogMsg("Exception: GetPoly(uint16_t). pt=%u, numPoints=%u\xD\xA", pt, numPoints);
#endif
throw GP_OUT_OF_RANGE;
#ifdef DEBUG
if (pt <= polyEnd[i])
return i;
- return (uint16)-1;
+ return (uint16_t)-1;
}
if (numPoints == 0) // By default, we already *have* a poly
return;
- uint16 * newPolyEnd = new uint16[numPolys + 1];
+ uint16_t * newPolyEnd = new uint16_t[numPolys + 1];
- for(uint16 i=0; i<numPolys; i++)
+ for(uint16_t i=0; i<numPolys; i++)
newPolyEnd[i] = polyEnd[i];
newPolyEnd[numPolys] = newPolyEnd[numPolys - 1];
}
-IPoint GlyphPoints::GetMidpointToPrev(uint16 poly, uint16 pt)
+IPoint GlyphPoints::GetMidpointToPrev(uint16_t poly, uint16_t pt)
{
- uint16 prev = GetPrev(poly, pt);
+ uint16_t prev = GetPrev(poly, pt);
- int32 x1 = GetX(poly, pt), y1 = GetY(poly, pt);
- int32 x2 = GetX(poly, prev), y2 = GetY(poly, prev);
+ int32_t x1 = GetX(poly, pt), y1 = GetY(poly, pt);
+ int32_t x2 = GetX(poly, prev), y2 = GetY(poly, prev);
return IPoint((x1 + x2) / 2.0f, (y1 + y2) / 2.0f);
}
-IPoint GlyphPoints::GetMidpointToNext(uint16 poly, uint16 pt)
+IPoint GlyphPoints::GetMidpointToNext(uint16_t poly, uint16_t pt)
{
- uint16 next = GetNext(poly, pt);
+ uint16_t next = GetNext(poly, pt);
- int32 x1 = GetX(poly, pt), y1 = GetY(poly, pt);
- int32 x2 = GetX(poly, next), y2 = GetY(poly, next);
+ int32_t x1 = GetX(poly, pt), y1 = GetY(poly, pt);
+ int32_t x2 = GetX(poly, next), y2 = GetY(poly, next);
return IPoint((x1 + x2) / 2.0f, (y1 + y2) / 2.0f);
}
-IPoint GlyphPoints::GetPrevPoint(uint16 poly, uint16 pt)
+IPoint GlyphPoints::GetPrevPoint(uint16_t poly, uint16_t pt)
{
- uint16 prevPt = GetPrev(poly, pt);
+ uint16_t prevPt = GetPrev(poly, pt);
return IPoint(GetX(poly, prevPt), GetY(poly, prevPt));
}
-IPoint GlyphPoints::GetNextPoint(uint16 poly, uint16 pt)
+IPoint GlyphPoints::GetNextPoint(uint16_t poly, uint16_t pt)
{
- uint16 nextPt = GetNext(poly, pt);
+ uint16_t nextPt = GetNext(poly, pt);
return IPoint(GetX(poly, nextPt), GetY(poly, nextPt));
}
-uint16 GlyphPoints::GetPolyForPoint(IPoint point)
+uint16_t GlyphPoints::GetPolyForPoint(IPoint point)
{
- uint16 poly = 0;
+ uint16_t poly = 0;
- for(uint16 i=0; i<numPoints; i++)
+ for(uint16_t i=0; i<numPoints; i++)
{
if (i > polyEnd[poly])
poly++;
}
-uint16 GlyphPoints::GetPolyForPointNumber(uint16 pointNumber)
+uint16_t GlyphPoints::GetPolyForPointNumber(uint16_t pointNumber)
{
// If there's only one poly, we know where the point is...
if (numPolys <= 1)
return 0;
// Otherwise, do a linear search through the polys to find the right one
- for(uint16 i=0; i<numPolys; i++)
+ for(uint16_t i=0; i<numPolys; i++)
{
if (pointNumber >= GetPolyStart(i) && pointNumber <= polyEnd[i])
return i;
}
-IPoint GlyphPoints::GetPolyCentroid(const int16 poly)
+IPoint GlyphPoints::GetPolyCentroid(const int16_t poly)
{
// We should throw an exception here, but meh
// (this actually short circuits the exception handling in all the GetPolyXXX() functions)
// if (poly >= numPolys)
//#ifdef DEBUG
//{
-//WriteLogMsg("Exception: GetPolyEnd(uint16). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
+//WriteLogMsg("Exception: GetPolyEnd(uint16_t). poly=%u, numPolys=%u\xD\xA", poly, numPolys);
//#endif
// throw GP_OUT_OF_RANGE;
//#ifdef DEBUG
//#endif
IPoint centroid; // Initializes to (0, 0)
- uint16 numPointsInPoly = GetNumPoints(poly);
+ uint16_t numPointsInPoly = GetNumPoints(poly);
- for(uint16 i=GetPolyStart(poly); i<=GetPolyEnd(poly); i++)
+ for(uint16_t i=GetPolyStart(poly); i<=GetPolyEnd(poly); i++)
{
centroid.x += x[i];
centroid.y += y[i];
}
-void GlyphPoints::RotatePolyAroundCentroid(const int16 poly, const double angle)
+void GlyphPoints::RotatePolyAroundCentroid(const int16_t poly, const double angle)
{
if (poly >= numPolys)
return;
IPoint centroid = GetPolyCentroid(poly);
- for(uint16 i=GetPolyStart(poly); i<=GetPolyEnd(poly); i++)
+ for(uint16_t i=GetPolyStart(poly); i<=GetPolyEnd(poly); i++)
{
IPoint rotated = RotatePoint(angle, IPoint(x[i], y[i]), centroid);
x[i] = rotated.x;
}
-void GlyphPoints::InvertPolyDrawSequence(const uint16 poly)
+void GlyphPoints::InvertPolyDrawSequence(const uint16_t poly)
{
if (poly >= numPolys)
throw GP_OUT_OF_RANGE;
- uint16 pointNum1 = GetPolyStart(poly);
- uint16 pointNum2 = GetPolyEnd(poly);
+ uint16_t pointNum1 = GetPolyStart(poly);
+ uint16_t pointNum2 = GetPolyEnd(poly);
// Algorithm: Step through points in the polygon, swapping 1st and last, then
// 2nd and (last - 1), 3rd and (last - 2), etc. We only do this for half the
// points, as doing it for all would undo the swapping we did in the 1st half.
- for(uint16 i=0; i<GetNumPoints(poly)/2; i++)
+ for(uint16_t i=0; i<GetNumPoints(poly)/2; i++)
{
IPoint point1 = GetPoint(pointNum1 + i);
IPoint point2 = GetPoint(pointNum2 - i);
}
fscanf(file, "%s %u", line, &numPolys);
- polyEnd = new uint16[numPolys];
+ polyEnd = new uint16_t[numPolys];
for(int i=0; i<numPolys; i++)
{
#ifndef __GLYPHPOINTS_H__
#define __GLYPHPOINTS_H__
-#include "types.h"
+#include <stdint.h>
#include <stdio.h>
// "IPoint" is an Integer based Point
struct IPoint
{
- int32 x, y;
+ int32_t x, y;
bool onCurve;
- IPoint(int32 xx=0, int32 yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}
+ IPoint(int32_t xx=0, int32_t yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}
bool operator==(const IPoint & p) { return (p.x == x && p.y == y ? true: false); };
};
struct GuideLine
{
- int32 x, y;
+ int32_t x, y;
double angle;
};
//Turns out the compiler barfs regardless...
//Turns out the problem was that the copy ctor wasn't declared as CONST...
GlyphPoints(int nPts = 0, int nPlys = 0, int * xa = NULL, int * ya = NULL,
- bool * oca = NULL, uint16 * pa = NULL);
+ bool * oca = NULL, uint16_t * pa = NULL);
// GlyphPoints(void);// And now *this* is needed... Bleah!
// GlyphPoints(int nPts, int nPlys = 0, int * xa = NULL, int * ya = NULL,
-// bool * oca = NULL, uint16 * pa = NULL);
+// bool * oca = NULL, uint16_t * pa = NULL);
GlyphPoints(int xx, int yy, bool oc);
// GlyphPoints(GlyphPoints &); // Copy constructor
GlyphPoints(const GlyphPoints &); // Copy constructor
GlyphPoints operator+(const IPoint &);
GlyphPoints& operator+=(const IPoint &);
void Clear(void);
- void InsertPoint(uint16, int, int, bool);
- void InsertPoint(uint16, const IPoint &);
- void DeletePoint(uint16);
- uint16 GetNumPoints(void);
- uint16 GetNumPoints(uint16 poly);
- uint16 GetNumPolys(void);
- int GetX(uint16);
- int GetY(uint16);
- bool GetOnCurve(uint16);
- int GetX(uint16, uint16);
- int GetNextX(uint16, uint16);
- int GetY(uint16, uint16);
- int GetNextY(uint16, uint16);
- IPoint GetPoint(uint16, uint16);
- IPoint GetPoint(uint16);
- bool GetOnCurve(uint16, uint16);
- bool GetPrevOnCurve(uint16, uint16);
- bool GetNextOnCurve(uint16, uint16);
- uint16 GetPolyStart(uint16);
- uint16 GetPolyEnd(uint16);
+ void InsertPoint(uint16_t, int, int, bool);
+ void InsertPoint(uint16_t, const IPoint &);
+ void DeletePoint(uint16_t);
+ uint16_t GetNumPoints(void);
+ uint16_t GetNumPoints(uint16_t poly);
+ uint16_t GetNumPolys(void);
+ int GetX(uint16_t);
+ int GetY(uint16_t);
+ bool GetOnCurve(uint16_t);
+ int GetX(uint16_t, uint16_t);
+ int GetNextX(uint16_t, uint16_t);
+ int GetY(uint16_t, uint16_t);
+ int GetNextY(uint16_t, uint16_t);
+ IPoint GetPoint(uint16_t, uint16_t);
+ IPoint GetPoint(uint16_t);
+ bool GetOnCurve(uint16_t, uint16_t);
+ bool GetPrevOnCurve(uint16_t, uint16_t);
+ bool GetNextOnCurve(uint16_t, uint16_t);
+ uint16_t GetPolyStart(uint16_t);
+ uint16_t GetPolyEnd(uint16_t);
void OffsetPoints(int, int);
- void OffsetPoly(uint16, int32, int32);
+ void OffsetPoly(uint16_t, int32_t, int32_t);
void ScalePoints(float);
- void SetXY(uint16, int, int);
- void SetOnCurve(uint16, bool);
- void SetPoint(const uint16 pointNum, const IPoint point);
- uint16 GetPrev(uint16);
- uint16 GetNext(uint16);
- uint16 GetPrev(uint16, uint16);
- uint16 GetNext(uint16, uint16);
- uint16 GetPoly(uint16);
+ void SetXY(uint16_t, int, int);
+ void SetOnCurve(uint16_t, bool);
+ void SetPoint(const uint16_t pointNum, const IPoint point);
+ uint16_t GetPrev(uint16_t);
+ uint16_t GetNext(uint16_t);
+ uint16_t GetPrev(uint16_t, uint16_t);
+ uint16_t GetNext(uint16_t, uint16_t);
+ uint16_t GetPoly(uint16_t);
void AddNewPolyAtEnd(void);
- IPoint GetMidpointToPrev(uint16, uint16);
- IPoint GetMidpointToNext(uint16, uint16);
- IPoint GetPrevPoint(uint16, uint16);
- IPoint GetNextPoint(uint16, uint16);
- uint16 GetPolyForPoint(IPoint point);
- uint16 GetPolyForPointNumber(uint16 pointNumber);
+ IPoint GetMidpointToPrev(uint16_t, uint16_t);
+ IPoint GetMidpointToNext(uint16_t, uint16_t);
+ IPoint GetPrevPoint(uint16_t, uint16_t);
+ IPoint GetNextPoint(uint16_t, uint16_t);
+ uint16_t GetPolyForPoint(IPoint point);
+ uint16_t GetPolyForPointNumber(uint16_t pointNumber);
IPoint RotatePoint(const double angle, const IPoint point, const IPoint center);
void RotatePoints(const double angle, const IPoint point);
- IPoint GetPolyCentroid(const int16 poly);
- void RotatePolyAroundCentroid(const int16 poly, const double angle);
- void InvertPolyDrawSequence(const uint16 poly);
+ IPoint GetPolyCentroid(const int16_t poly);
+ void RotatePolyAroundCentroid(const int16_t poly, const double angle);
+ void InvertPolyDrawSequence(const uint16_t poly);
bool LoadGlyphFromFile(FILE *);
bool SaveGlyphToFile(FILE *);
private:
- void AllocateAndCopy(int, int, int *, int *, bool *, uint16 *);
+ void AllocateAndCopy(int, int, int *, int *, bool *, uint16_t *);
void FreeAllocatedMemory(void);
private:
int numPoints, numPolys;
int * x, * y;
bool * onCurve;
- uint16 * polyEnd;
- uint16 pointsAllocated, polysAllocated;
+ uint16_t * polyEnd;
+ uint16_t pointsAllocated, polysAllocated;
};
#endif // __GLYPHPOINTS_H__
//
// Draw a round dot (5x5, centered on [x, y])
//
-void DrawRoundDot(QPainter &p, int32 x, int32 y)
+void DrawRoundDot(QPainter &p, int32_t x, int32_t y)
{
QPoint pt[8];
//
// Draw a sqaure dot (5x5, centered on [x, y])
//
-void DrawSquareDot(QPainter &p, int32 x, int32 y)
+void DrawSquareDot(QPainter &p, int32_t x, int32_t y)
{
QPoint pt[4];
//
// Draw a sqaure dot (nxn, centered on [x, y])
//
-void DrawSquareDotN(QPainter &p, int32 x, int32 y, uint32 n)
+void DrawSquareDotN(QPainter &p, int32_t x, int32_t y, uint32_t n)
{
QPoint pt[4];
- uint32 offset = (n - 1) / 2;
+ uint32_t offset = (n - 1) / 2;
pt[0] = QPoint(x - offset, y - offset);
pt[1] = QPoint(x + offset, y - offset);
//
// Draw a round dot (nxn, centered on [x, y])
//
-void DrawRoundDotN(QPainter &p, int32 x, int32 y, uint32 n)
+void DrawRoundDotN(QPainter &p, int32_t x, int32_t y, uint32_t n)
{
int radius = (n / 2) + 1;
p.drawEllipse(x - radius, y - radius, n, n);
#ifndef __GRAPHICPRIMITIVES_H__
#define __GRAPHICPRIMITIVES_H__
+#include <stdint.h>
#include <QtGui> // For QPainter
-#include "types.h" // For int32
#include "glyphpoints.h" // For IPoint
struct point
void Bezier(QPainter &, point, point, point);
void Bezier(QPainter &, IPoint, IPoint, IPoint);
-void DrawRoundDot(QPainter &, int32, int32);
-void DrawSquareDot(QPainter &, int32, int32);
-void DrawRoundDotN(QPainter &, int32, int32, uint32);
-void DrawSquareDotN(QPainter &, int32, int32, uint32);
+void DrawRoundDot(QPainter &, int32_t, int32_t);
+void DrawSquareDot(QPainter &, int32_t, int32_t);
+void DrawRoundDotN(QPainter &, int32_t, int32_t, uint32_t);
+void DrawSquareDotN(QPainter &, int32_t, int32_t, uint32_t);
#endif // __GRAPHICPRIMITIVES_H__
((TTEdit *)qApp)->charWnd = new CharWindow(this);
editWnd = new EditWindow(this);
setCentralWidget(editWnd);
+ editWnd->setFocus();
setWindowIcon(QIcon(":/res/ttedit.png"));
setWindowTitle("TTEdit!");
};
#endif // __MAINWINDOW_H__
+
#define DEBUGTP // Toolpalette debugging...
#include "toolwindow.h"
-#include "types.h"
ToolWindow::ToolWindow(void): QWidget(NULL, Qt::Window | Qt::FramelessWindowHint),
//printf("pt = %u, %u\n", pt.x(), pt.y());
// Divide mouse coords by the bitmap stamp size to find which one is pointed to
- uint32 x = (uint32)pt.x() / sizeStamp.x(), y = (uint32)pt.y() / sizeStamp.y();
+ uint32_t x = (uint32_t)pt.x() / sizeStamp.x(), y = (uint32_t)pt.y() / sizeStamp.y();
// Preset failure into newTool, in case no new tool is selected
ToolType newTool = TOOLNone;
};
#endif // __TOOLWINDOW_H__
+
// - Eliminate ALL references to BYTE, WORD, SBYTE, SWORD, etc.
//
-#include <stdio.h> // For file handling, etc. //
+#include <stdio.h> // For file handling, etc.
#include <stdlib.h>
#include <string.h>
#include "charnames.h"
#define NUMTABS 24 // Number of distinct tables
-/*void fskip(HANDLE file, uint32 bytesToSkip)
+/*void fskip(HANDLE file, uint32_t bytesToSkip)
{
SetFilePointer(file, (LONG)bytesToSkip, NULL, FILE_CURRENT);
}*/
//
// Get a BYTE from the current file...
//
-uint8 ReadByte(FILE * file)
+uint8_t ReadByte(FILE * file)
{
- return (uint8)fgetc(file);
+ return (uint8_t)fgetc(file);
}
// The following routines get and put WORDs and DWORDs in little endian
//
// Get a WORD from the current file...
//
-uint16 ReadWord(FILE * file)
+uint16_t ReadWord(FILE * file)
{
- uint16 word = (uint16)fgetc(file) << 8;
- word |= (uint16)fgetc(file);
+ uint16_t word = (uint16_t)fgetc(file) << 8;
+ word |= (uint16_t)fgetc(file);
return word;
}
//
// Get a double WORD from the current file...
//
-uint32 ReadDWord(FILE * file)
+uint32_t ReadDWord(FILE * file)
{
- uint32 dword = 0;
+ uint32_t dword = 0;
for(int i=0; i<4; i++)
{
dword <<= 8;
- dword |= (uint8)fgetc(file);
+ dword |= (uint8_t)fgetc(file);
}
return dword;
//
// Write a WORD to the current file...
//
-void WriteWord(FILE * file, uint16 word)
+void WriteWord(FILE * file, uint16_t word)
{
fputc(word >> 8, file); // Hi byte
fputc(word & 0xFF, file); // Lo byte
//
// Write a double WORD to the current file...
//
-void WriteDWord(FILE * file, uint32 dword)
+void WriteDWord(FILE * file, uint32_t dword)
{
for(int i=0; i<4; i++)
{
//
// Return a BYTE from a BYTE based table
//
-uint8 GetByte(uint8 * table, uint32 &ptr)
+uint8_t GetByte(uint8_t * table, uint32_t &ptr)
{
return table[ptr++];
}
//
// Return a WORD from a BYTE based table
//
-uint16 GetWord(uint8 * table, uint32 &ptr)
+uint16_t GetWord(uint8_t * table, uint32_t &ptr)
{
- uint16 hi = table[ptr++];
- uint16 lo = table[ptr++];
+ uint16_t hi = table[ptr++];
+ uint16_t lo = table[ptr++];
- return (uint16)((hi<<8) | lo);
+ return (uint16_t)((hi<<8) | lo);
}
//
// Return a double WORD from a BYTE based table
//
-uint32 GetDWord(uint8 * table, uint32 &ptr)
+uint32_t GetDWord(uint8_t * table, uint32_t &ptr)
{
- uint32 hi1 = table[ptr++];
- uint32 lo1 = table[ptr++];
- uint32 hi2 = table[ptr++];
- uint32 lo2 = table[ptr++];
+ uint32_t hi1 = table[ptr++];
+ uint32_t lo1 = table[ptr++];
+ uint32_t hi2 = table[ptr++];
+ uint32_t lo2 = table[ptr++];
- return (uint32)((hi1 << 24) | (lo1 << 16) | (hi2 << 8) | lo2);
+ return (uint32_t)((hi1 << 24) | (lo1 << 16) | (hi2 << 8) | lo2);
}
/////////////////////////////////////////////////////////////////////////////
//
// Store a BYTE in a BYTE based table
//
-void SetByte(uint8 * table, uint32 &ptr, uint8 data)
+void SetByte(uint8_t * table, uint32_t &ptr, uint8_t data)
{
table[ptr++] = data;
}
//
// Store a WORD in a BYTE based table
//
-void SetWord(uint8 * table, uint32 &ptr, uint16 data)
+void SetWord(uint8_t * table, uint32_t &ptr, uint16_t data)
{
table[ptr++] = data>>8; table[ptr++] = data&0xFF;
}
//
// Store a DWORD in a BYTE based table
//
-void SetDWord(uint8 * table, uint32 &ptr, uint32 data)
+void SetDWord(uint8_t * table, uint32_t &ptr, uint32_t data)
{
- table[ptr++] = (uint8)(data >> 24); table[ptr++] = (uint8)(data >> 16);
- table[ptr++] = (uint8)(data >> 8); table[ptr++] = (uint8)(data & 0xFF);
+ table[ptr++] = (uint8_t)(data >> 24); table[ptr++] = (uint8_t)(data >> 16);
+ table[ptr++] = (uint8_t)(data >> 8); table[ptr++] = (uint8_t)(data & 0xFF);
}
/////////////////////////////////////////////////////////////////////////////
// Fixed point to float (& vice versa) conversions
/////////////////////////////////////////////////////////////////////////////
-float FixedToFloat(int16 fixed)
+float FixedToFloat(int16_t fixed)
{
return (float)fixed / 16384.0f;
}
larray[18] = &maxp_len; larray[19] = &name_len; larray[20] = &post_len;
larray[21] = &prep_len; larray[22] = &vhea_len; larray[23] = &vmtx_len;
- for(uint32 i=0; i<NUMTABS; i++)
+ for(uint32_t i=0; i<NUMTABS; i++)
*parray[i] = NULL; // Init pointers...
- for(uint32 i=0; i<MAXGLYPHS; i++)
+ for(uint32_t i=0; i<MAXGLYPHS; i++)
glyph[i] = NULL;
}
/////////////////////////////////////////////////////////////////////////////
void TTF::ClearTables(void)
{
- for(uint32 i=0; i<NUMTABS; i++)
+ for(uint32_t i=0; i<NUMTABS; i++)
{
if ((*parray[i]) != NULL)
{
}
}
- for(uint32 i=0; i<MAXGLYPHS; i++)
+ for(uint32_t i=0; i<MAXGLYPHS; i++)
{
if (glyph[i] != NULL)
{
{
// unsigned char ch; // Temp variable
// UINT num_tabs; // Number of tables
- uint32 offset[NUMTABS], length[NUMTABS]; // Temporary storage...
+ uint32_t offset[NUMTABS], length[NUMTABS]; // Temporary storage...
char names[NUMTABS][5];
char narray[NUMTABS][5] = { "EBDT", "EBLC", "EBSC", "LTSH", "OS/2", "PCLT",
"VDMX", "cmap", "cvt ", "fpgm", "gasp", "glyf", "hdmx", "head", "hhea",
}
#endif
- uint32 num_tabs = ReadWord(file); // Get # of tables
+ uint32_t num_tabs = ReadWord(file); // Get # of tables
#ifdef TTFDEBUG
WriteLogMsg("Number of tables is %u...\n", num_tabs);
#endif
#ifdef TTFDEBUG
WriteLogMsg("Reading names of tables...\n");
#endif
- for(uint32 i=0; i<num_tabs; i++)
+ for(uint32_t i=0; i<num_tabs; i++)
{
// ReadFile(file, names[i], 4, &bytesRead, NULL);
fread(names[i], 1, 4, file);
#ifdef TTFDEBUG
WriteLogMsg("Reading tables...\n");
#endif
- for(uint32 i=0; i<num_tabs; i++)
+ for(uint32_t i=0; i<num_tabs; i++)
{
- for(uint32 j=0; j<NUMTABS; j++)
+ for(uint32_t j=0; j<NUMTABS; j++)
{
if ((strcmp(names[i], narray[j])) == 0) // Found a match...
{
-// *parray[j] = (uint8 *)GlobalAlloc(GMEM_FIXED, length[i]); // Allocate space
- *parray[j] = (uint8 *)malloc(length[i]); // Alloc space
+// *parray[j] = (uint8_t *)GlobalAlloc(GMEM_FIXED, length[i]); // Allocate space
+ *parray[j] = (uint8_t *)malloc(length[i]); // Alloc space
if (*parray[j] == NULL)
return false; // Bail out if nothing allocated
{
// fstream file;
// ULONG offset = 12;
- uint32 numtabs = 0;
+ uint32_t numtabs = 0;
char padding[3] = { 0, 0, 0 };
// Convert this to a table of ULONGs to decrease complexity...
//wouldn't be endian safe then...
BuildTables(); // Ignore return value...
- for(uint32 i=0; i<NUMTABS; i++) // Figure out how many tables there are
+ for(uint32_t i=0; i<NUMTABS; i++) // Figure out how many tables there are
if ((*parray[i]) != NULL)
numtabs++;
- uint32 offset = 12 + (numtabs * 16); // Calc correct offset to start of data
+ uint32_t offset = 12 + (numtabs * 16); // Calc correct offset to start of data
// HANDLE file = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
// NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteWord(file, 0); // entrySelector Log2(max power of 2 <= numTables).
WriteWord(file, 0); // NumTables x 16 - searchRange.
- for(uint32 i=0; i<NUMTABS; i++) // Write out table directory...
+ for(uint32_t i=0; i<NUMTABS; i++) // Write out table directory...
{
if ((*parray[i]) != NULL)
{
WriteDWord(file, offset); // Offset
WriteDWord(file, (*larray[i])); // Length
- offset += (((*larray[i]) + 3) & ~3); // Pad out to 4-uint8 boundary...
+ offset += (((*larray[i]) + 3) & ~3); // Pad out to 4-uint8_t boundary...
}
}
- for(uint32 i=0; i<NUMTABS; i++) // Write out the tables...
+ for(uint32_t i=0; i<NUMTABS; i++) // Write out the tables...
{
if ((*parray[i]) != NULL)
{
-// for(uint32 j=0; j<(*larray[i]); j++)
+// for(uint32_t j=0; j<(*larray[i]); j++)
// file.put((*parray[i])[j]);
// WriteFile(file, *parray[i], *larray[i], &bytesWritten, NULL);
fwrite(*parray[i], 1, *larray[i], file);
- uint32 remainder = ((*larray[i]) & 0x3);
+ uint32_t remainder = ((*larray[i]) & 0x3);
if (remainder) // i.e., it's not evenly div by 4
// for(j=remainder; j<4; j++)
// file.put((char)0); // pad it!
//
// This function encodes the glyph data and stores it to the 'glyf' table.
/////////////////////////////////////////////////////////////////////////////
-bool TTF::EncodeGlyph(uint16 glyphnum)
+bool TTF::EncodeGlyph(uint16_t glyphnum)
{
bool retval = false; // Assume failure
- uint8 flag, xbuf[4000], ybuf[4000], fbuf[2000];
- uint32 xp = 0, yp = 0, fp = 0; // Table pointers
+ uint8_t flag, xbuf[4000], ybuf[4000], fbuf[2000];
+ uint32_t xp = 0, yp = 0, fp = 0; // Table pointers
if (glyphnum < myMaxp.numGlyphs) // numofgls is 1 based ind, glyph# 0 based
{
// need to add composite encoding...
int lastx = 0, lasty = 0;
- for(uint32 i=0; i<numberOfPoints; i++)
+ for(uint32_t i=0; i<numberOfPoints; i++)
{
flag = 0;
int curx = gx[i] - lastx, cury = gy[i] - lasty;
if (curx)
{
- if ((curx > 255) || (curx < -255)) // I.e., it's 2 uint8 value
+ if ((curx > 255) || (curx < -255)) // I.e., it's 2 uint8_t value
SetWord(xbuf, xp, curx);
else
{
if (cury)
{
- if ((cury > 255) || (cury < -255)) // I.e., it's 2 uint8 value
+ if ((cury > 255) || (cury < -255)) // I.e., it's 2 uint8_t value
SetWord(ybuf, yp, cury);
else
{
{
if (fbuf[i] == fbuf[i+1]) //
{
- uint8 count = 0; // Sentinel takes care of check for end of flags...
+ uint8_t count = 0; // Sentinel takes care of check for end of flags...
while (fbuf[i] == fbuf[++i]) count++; // Count number of repeats
i--;
fbuf[fp++] = fbuf[i] | 0x08; // Set repeat flag
fp = numberOfPoints;
// Find length of glyph and reallocate space if necessary
- uint32 newLength = 12 + numberOfPolys*2 + numberOfHints + fp + xp + yp;
+ uint32_t newLength = 12 + numberOfPolys*2 + numberOfHints + fp + xp + yp;
if (newLength & 0x03)
newLength += (4 - newLength & 0x03);
if (glyphLen[glyphnum] != newLength)
{
- glyph[glyphnum] = (uint8 *)realloc(glyph[glyphnum], newLength);
+ glyph[glyphnum] = (uint8_t *)realloc(glyph[glyphnum], newLength);
glyphLen[glyphnum] = newLength;
}
// And finally, store it!
- uint32 gp = 0; // Glyph pointer...
+ uint32_t gp = 0; // Glyph pointer...
SetWord(glyph[glyphnum], gp, numberOfPolys);
SetWord(glyph[glyphnum], gp, llx);
SetWord(glyph[glyphnum], gp, lly);
SetWord(glyph[glyphnum], gp, urx);
SetWord(glyph[glyphnum], gp, ury);
- for(uint32 i=0; i<numberOfPolys; i++)
+ for(uint32_t i=0; i<numberOfPolys; i++)
SetWord(glyph[glyphnum], gp, poly[i]);
SetWord(glyph[glyphnum], gp, numberOfHints);
- for(uint32 i=0; i<numberOfHints; i++)
+ for(uint32_t i=0; i<numberOfHints; i++)
SetByte(glyph[glyphnum], gp, hint[i]);
- for(uint32 i=0; i<fp; i++)
+ for(uint32_t i=0; i<fp; i++)
SetByte(glyph[glyphnum], gp, fbuf[i]);
- for(uint32 i=0; i<xp; i++)
+ for(uint32_t i=0; i<xp; i++)
SetByte(glyph[glyphnum], gp, xbuf[i]);
- for(uint32 i=0; i<yp; i++)
+ for(uint32_t i=0; i<yp; i++)
SetByte(glyph[glyphnum], gp, ybuf[i]);
retval = true; // Successfully encoded!
// This function decodes the glyph data and stores it to the object's
// internal array.
/////////////////////////////////////////////////////////////////////////////
-bool TTF::DecodeGlyph(uint16 glyphnum)
+bool TTF::DecodeGlyph(uint16_t glyphnum)
{
bool retval = false;
- uint32 i, dp;
+ uint32_t i, dp;
// glyphnum is 0 based index, while numGlyphs is 1 based
if (glyphnum >= myMaxp.numGlyphs)
isCompositeGlyph = false; // Default is no
numberOfPolys = GetWord(glyph[glyphnum], dp); // # of polygons
- llx = (int16)GetWord(glyph[glyphnum], dp); // Lower left X
- lly = (int16)GetWord(glyph[glyphnum], dp); // Lower left Y
- urx = (int16)GetWord(glyph[glyphnum], dp); // Upper right X
- ury = (int16)GetWord(glyph[glyphnum], dp); // Upper right Y
+ llx = (int16_t)GetWord(glyph[glyphnum], dp); // Lower left X
+ lly = (int16_t)GetWord(glyph[glyphnum], dp); // Lower left Y
+ urx = (int16_t)GetWord(glyph[glyphnum], dp); // Upper right X
+ ury = (int16_t)GetWord(glyph[glyphnum], dp); // Upper right Y
// Need to handle composite glyphs better here. The ways things
// are set now is a recipe for disaster...
{
cmpst.flags = GetWord(glyph[glyphnum], dp);
cmpst.glyphIndex = GetWord(glyph[glyphnum], dp);
- cmpst.arg1 = (cmpst.flags & 0x01 ? (int16)GetWord(glyph[glyphnum], dp) : (int8)GetByte(glyph[glyphnum], dp));
- cmpst.arg2 = (cmpst.flags & 0x01 ? (int16)GetWord(glyph[glyphnum], dp) : (int8)GetByte(glyph[glyphnum], dp));
+ cmpst.arg1 = (cmpst.flags & 0x01 ? (int16_t)GetWord(glyph[glyphnum], dp) : (int8_t)GetByte(glyph[glyphnum], dp));
+ cmpst.arg2 = (cmpst.flags & 0x01 ? (int16_t)GetWord(glyph[glyphnum], dp) : (int8_t)GetByte(glyph[glyphnum], dp));
if (cmpst.flags & 0x08)
- cmpst.xScale = cmpst.yScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp));
+ cmpst.xScale = cmpst.yScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp));
else if (cmpst.flags & 0x40)
- cmpst.xScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.yScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp));
+ cmpst.xScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.yScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp));
else if (cmpst.flags & 0x80)
- cmpst.xScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.scale01 = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.scale10 = FixedToFloat((int16)GetWord(glyph[glyphnum], dp)),
- cmpst.yScale = FixedToFloat((int16)GetWord(glyph[glyphnum], dp));
+ cmpst.xScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.scale01 = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.scale10 = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp)),
+ cmpst.yScale = FixedToFloat((int16_t)GetWord(glyph[glyphnum], dp));
compositeList.AddAtRear(cmpst);
}
//do {
// USHORT flags;
// USHORT glyphIndex;
-// if ( flags & ARG_1_AND_2_ARE_uint16S) {
-// (SHORT or Fuint16) argument1;
-// (SHORT or Fuint16) argument2;
+// if ( flags & ARG_1_AND_2_ARE_uint16_tS) {
+// (SHORT or Fuint16_t) argument1;
+// (SHORT or Fuint16_t) argument2;
// } else {
// USHORT arg1and2; /* (arg1 << 8) | arg2 */
// }
//} while ( flags & MORE_COMPONENTS )
//if (flags & WE_HAVE_INSTR){
// USHORT numInstr
-// uint8 instr[numInstr]
+// uint8_t instr[numInstr]
//
//Flags Bit Description
-//ARG_1_AND_2_ARE_uint16S 0 If this is set, the arguments are uint16s;
-// otherwise, they are uint8s.
+//ARG_1_AND_2_ARE_uint16_tS 0 If this is set, the arguments are uint16_ts;
+// otherwise, they are uint8_ts.
//ARGS_ARE_XY_VALUES 1 If this is set, the arguments are xy values;
// otherwise, they are points.
//ROUND_XY_TO_GRID 2 For the xy values if the preceding is true.
// Decode the dots...
- uint32 num_pts = poly[numberOfPolys-1] + 1;
+ uint32_t num_pts = poly[numberOfPolys-1] + 1;
numberOfPoints = num_pts; // necessary??
- uint32 xptr, yptr; // pointers to beginning of coord data
- uint32 numXs = 0;
+ uint32_t xptr, yptr; // pointers to beginning of coord data
+ uint32_t numXs = 0;
int xx = 0, yy = 0, repeat;
- uint32 numTokens = num_pts, k, numRep;
+ uint32_t numTokens = num_pts, k, numRep;
// We make an educated guess that num_pts = num_tokens; but if there
// is repeated data in the tokens, then we need to adjust the # of
// tokens down appropriately.
- for(uint32 i=0; i<numTokens; i++)
+ for(uint32_t i=0; i<numTokens; i++)
{
- uint8 token = glyph[glyphnum][dp+i]; uint32 rpts = 1;
+ uint8_t token = glyph[glyphnum][dp+i]; uint32_t rpts = 1;
if (token & 0x08) // Repeated token?
{
numTokens -= (numRep - 1); // Yes, adjust.
}
- // 10 = same x(0uint8s), 00 = 2uint8s, 02&12 = 1uint8
+ // 10 = same x(0uint8_ts), 00 = 2uint8_ts, 02&12 = 1uint8_t
if ((token & 0x02) == 0x02)
numXs += rpts;
k = 0; // Index to the point array
- for(uint32 i=0; i<numTokens; i++)
+ for(uint32_t i=0; i<numTokens; i++)
{
- uint8 token = glyph[glyphnum][dp+i];
+ uint8_t token = glyph[glyphnum][dp+i];
repeat = 1;
if (token & 0x08)
xx -= GetByte(glyph[glyphnum], xptr);
if ((token & 0x12) == 0x00)
- xx += (int16)GetWord(glyph[glyphnum], xptr);
+ xx += (int16_t)GetWord(glyph[glyphnum], xptr);
gx[k] = xx; // Store x-coordinate
yy -= GetByte(glyph[glyphnum], yptr);
if ((token & 0x24) == 0x00)
- yy += (int16)GetWord(glyph[glyphnum], yptr);
+ yy += (int16_t)GetWord(glyph[glyphnum], yptr);
gy[k] = yy; // Store y-coordinate
This function decodes the 'glyf' data for a non-composite (atomic) glyph and
returns it as a GlyphPoints object. Helper function.
*****************************************************************************/
-GlyphPoints TTF::GetGlyphPoints(uint16 glyphNum)
+GlyphPoints TTF::GetGlyphPoints(uint16_t glyphNum)
{
if (DecodeGlyph(glyphNum))
return GlyphPoints(numberOfPoints, numberOfPolys, gx, gy, onCurve, poly);
This function decodes the 'glyf' data for a composite glyph and returns
it as a GlyphPoints object.
*****************************************************************************/
-GlyphPoints TTF::GetAllCompositePoints(uint16 glyphNum)
+GlyphPoints TTF::GetAllCompositePoints(uint16_t glyphNum)
{
// int tmpGlyph = currentGlyph;
}
/////////////////////////////////////////////////////////////////////////////
-// Member function: void GetCharName(int cNum, uint8 * buf)
+// Member function: void GetCharName(int cNum, uint8_t * buf)
//
// This function returns the character name of the glyph number passed in.
/////////////////////////////////////////////////////////////////////////////
-void TTF::GetCharName(int cNum, uint8 * buf)
+void TTF::GetCharName(int cNum, uint8_t * buf)
{
buf[0] = 0; // Set failure as default condition
if (post[1] != 0x02 || post[2] != 0x00) // i.e., it's NOT a V2.0 table
return;
- uint8 * pTab = NULL;
- uint32 tabOff = 34, numGlyphs = (uint32)((post[32] << 8) | post[33]);
- uint32 index = (uint32)((post[tabOff + cNum * 2] << 8) | post[tabOff + cNum * 2 + 1]);
- uint32 nInd2;
+ uint8_t * pTab = NULL;
+ uint32_t tabOff = 34, numGlyphs = (uint32_t)((post[32] << 8) | post[33]);
+ uint32_t index = (uint32_t)((post[tabOff + cNum * 2] << 8) | post[tabOff + cNum * 2 + 1]);
+ uint32_t nInd2;
if (index > 257)
{
pTab = macStdNames;
}
- for(uint32 i=0; i<index; i++)
- nInd2 = nInd2 + pTab[nInd2] + 1; // 1st uint8 is length of string + that uint8
+ for(uint32_t i=0; i<index; i++)
+ nInd2 = nInd2 + pTab[nInd2] + 1; // 1st uint8_t is length of string + that uint8_t
- uint8 len = pTab[nInd2];
+ uint8_t len = pTab[nInd2];
nInd2++;
- for(uint8 i=0; i<len; i++)
+ for(uint8_t i=0; i<len; i++)
buf[i] = pTab[nInd2 + i];
buf[len] = 0;
return false; // Corrupt data?
}
- uint32 tp = 0;
+ uint32_t tp = 0;
myHead.version = GetDWord(head, tp);
myHead.fontRevision = GetDWord(head, tp);
myHead.checkSumAdjustment = GetDWord(head, tp);
myHead.yMax = GetWord(head, tp);
myHead.macStyle = GetWord(head, tp);
myHead.lowestRecPPEM = GetWord(head, tp);
- myHead.fontDirectionHint = (int16)GetWord(head, tp);
- myHead.indexToLocFormat = (int16)GetWord(head, tp);
- myHead.glyphDataFormat = (int16)GetWord(head, tp);
+ myHead.fontDirectionHint = (int16_t)GetWord(head, tp);
+ myHead.indexToLocFormat = (int16_t)GetWord(head, tp);
+ myHead.glyphDataFormat = (int16_t)GetWord(head, tp);
if (maxp_len != 32)
{
myMaxp.maxComponentDepth = GetWord(maxp, tp);
tp = 0; // Reset table pointer
- uint32 start = (myHead.indexToLocFormat ? GetDWord(loca, tp) : GetWord(loca, tp) << 1);
+ uint32_t start = (myHead.indexToLocFormat ? GetDWord(loca, tp) : GetWord(loca, tp) << 1);
- for(uint32 i=0; i<myMaxp.numGlyphs; i++)
+ for(uint32_t i=0; i<myMaxp.numGlyphs; i++)
{
- uint32 end = (myHead.indexToLocFormat ? GetDWord(loca, tp) : GetWord(loca, tp) << 1);
- uint32 length = end - start;
+ uint32_t end = (myHead.indexToLocFormat ? GetDWord(loca, tp) : GetWord(loca, tp) << 1);
+ uint32_t length = end - start;
glyphLen[i] = length; // Lengths are saved 'cause malloc is sloppy
if (length) // loca+start? pointer arithmetic?
{
- glyph[i] = (uint8 *)malloc(length); // Allocate space,
+ glyph[i] = (uint8_t *)malloc(length); // Allocate space,
memcpy(glyph[i], glyf+start, length); // and move it!
}
else
/////////////////////////////////////////////////////////////////////////////
bool TTF::BuildTables(void)
{
- uint32 i, tp, start;
+ uint32_t i, tp, start;
- myHead.indexToLocFormat = 1; // We don't bother with [uint16s*2] format...
+ myHead.indexToLocFormat = 1; // We don't bother with [uint16_ts*2] format...
// Build HEAD table
SetWord(head, tp, myHead.yMax);// = GetWord(head, tp);
SetWord(head, tp, myHead.macStyle);// = GetWord(head, tp);
SetWord(head, tp, myHead.lowestRecPPEM);// = GetWord(head, tp);
- SetWord(head, tp, myHead.fontDirectionHint);// = (int16)GetWord(head, tp);
- SetWord(head, tp, myHead.indexToLocFormat);// = (int16)GetWord(head, tp);
- SetWord(head, tp, myHead.glyphDataFormat);// = (int16)GetWord(head, tp);
+ SetWord(head, tp, myHead.fontDirectionHint);// = (int16_t)GetWord(head, tp);
+ SetWord(head, tp, myHead.indexToLocFormat);// = (int16_t)GetWord(head, tp);
+ SetWord(head, tp, myHead.glyphDataFormat);// = (int16_t)GetWord(head, tp);
// Build MAXP table
if (loca)
free(loca); // And create/reallocate it...
- loca = (uint8 *) malloc(loca_len);
+ loca = (uint8_t *) malloc(loca_len);
glyf_len = 0; // Refigure glyf table length
if (glyf)
free(glyf);
- glyf = (uint8 *) malloc(glyf_len);
+ glyf = (uint8_t *) malloc(glyf_len);
start = tp = 0; // Reset table pointer
// internal array. If the flag isDirty is set, it also encodes the internal
// array and stores it to the 'glyf' table.
/////////////////////////////////////////////////////////////////////////////
-bool TTF::SetGlyph(uint16 glyphnum)
+bool TTF::SetGlyph(uint16_t glyphnum)
{
bool retval = false; // Set failure as default
// is greater than the number of glyphs, glyph is added at end of list. This
// glyph then becomes the current glyph.
/////////////////////////////////////////////////////////////////////////////
-bool TTF::AddGlyph(uint16 glyphnum)
+bool TTF::AddGlyph(uint16_t glyphnum)
{
// incomplete: JLH
bool retval = false;
// This function deletes the glyph at position glyphnum. All glyphs after
// this glyph are moved down in position.
/////////////////////////////////////////////////////////////////////////////
-bool TTF::DeleteGlyph(uint16 glyphnum)
+bool TTF::DeleteGlyph(uint16_t glyphnum)
{
// incomplete: JLH
bool retval = false;
return Box(llx, lly, urx, ury);
}
-GlyphPt TTF::GetPoint(uint16 pointno)
+GlyphPt TTF::GetPoint(uint16_t pointno)
{
GlyphPt p;
return p;
}
-uint16 TTF::GetNumberOfPolys(void)
+uint16_t TTF::GetNumberOfPolys(void)
{
return numberOfPolys;
}
-uint16 TTF::GetPolyEnd(uint16 polynum)
+uint16_t TTF::GetPolyEnd(uint16_t polynum)
{
if (polynum >= numberOfPolys)
return 0;
return poly[polynum];
}
-int TTF::GetPointX(uint16 pointno)
+int TTF::GetPointX(uint16_t pointno)
{
if (pointno >= MAXPOINTS)
return 0;
return gx[pointno];
}
-int TTF::GetPointY(uint16 pointno)
+int TTF::GetPointY(uint16_t pointno)
{
if (pointno >= MAXPOINTS)
return 0;
return gy[pointno];
}
-bool TTF::GetOnCurve(uint16 pointno)
+bool TTF::GetOnCurve(uint16_t pointno)
{
if (pointno >= MAXPOINTS)
return true;
return onCurve[pointno];
}
-bool TTF::SetOnCurve(uint16 pointno, bool state)
+bool TTF::SetOnCurve(uint16_t pointno, bool state)
{
if (pointno >= numberOfPoints)
return false;
return true;
}
-bool TTF::MovePoint(uint16 pointno, int x, int y)
+bool TTF::MovePoint(uint16_t pointno, int x, int y)
{
if (pointno >= numberOfPoints)
return false;
return true;
}
-bool TTF::MovePoint(uint16 pointno, GlyphPt p)
+bool TTF::MovePoint(uint16_t pointno, GlyphPt p)
{
if (pointno >= numberOfPoints)
return false;
// TTF database.
//
-// These really shouldn't be included here, but are for now...
-//#include <string.h>
-////#include <afxwin.h> // This is needed only for things like BOOL, etc.
-//#include <fstream.h>
-//#include <stdlib.h>
-//#include <malloc.h> // Both for malloc, free, _msize, realloc
-
#ifndef __TTF_H__
#define __TTF_H__
+#include <stdint.h>
#include "list.h"
-#include "types.h"
#include "glyphpoints.h"
#define MAXGLYPHS 4096 // Number of glyphs in object
#define MAXPOINTS 2000 // Number of points in a glyph
-#define MAXHINTS 2000 // Number of hint uint8s in glyph
+#define MAXHINTS 2000 // Number of hint uint8_ts in glyph
//
// "head" struct
//
struct Head
{
- uint32 version; // Fixed - Table version number (0x00010000 for version 1.0.)
- uint32 fontRevision; // Fixed - fontRevision (Set by font manufacturer.)
- uint32 checkSumAdjustment; // To compute: Set it to 0, sum the entire font
+ uint32_t version; // Fixed - Table version number (0x00010000 for version 1.0.)
+ uint32_t fontRevision; // Fixed - fontRevision (Set by font manufacturer.)
+ uint32_t checkSumAdjustment; // To compute: Set it to 0, sum the entire font
// as ULONG, then store 0xB1B0AFBA - sum.
- uint32 magicNumber; // Set to 0x5F0F3CF5.
- uint16 flags; /* Bit 0 - baseline for font at y=0;
+ uint32_t magicNumber; // Set to 0x5F0F3CF5.
+ uint16_t flags; /* Bit 0 - baseline for font at y=0;
Bit 1 - left sidebearing at x=0;
Bit 2 - instructions may depend on point size;
Bit 3 - force ppem to integer values for all
Bit 4 - instructions may alter advance width
(the advance widths might not scale linearly);
Note: All other bits must be zero.*/
- uint16 unitsPerEm; // Valid range is from 16 to 16384
- uint32 /*longDateTime*/ createdh, createdl; // International date (8-uint8 field).
- uint32 /*longDateTime*/ modifiedh, modifiedl; // International date (8-uint8 field).
- uint16 xMin; // For all glyph bounding boxes.
- uint16 yMin; // For all glyph bounding boxes.
- uint16 xMax; // For all glyph bounding boxes.
- uint16 yMax; // For all glyph bounding boxes.
- uint16 macStyle; /* Bit 0 bold (if set to 1); Bit 1 italic (if set to 1)
+ uint16_t unitsPerEm; // Valid range is from 16 to 16384
+ uint32_t /*longDateTime*/ createdh, createdl; // International date (8-uint8_t field).
+ uint32_t /*longDateTime*/ modifiedh, modifiedl; // International date (8-uint8_t field).
+ uint16_t xMin; // For all glyph bounding boxes.
+ uint16_t yMin; // For all glyph bounding boxes.
+ uint16_t xMax; // For all glyph bounding boxes.
+ uint16_t yMax; // For all glyph bounding boxes.
+ uint16_t macStyle; /* Bit 0 bold (if set to 1); Bit 1 italic (if set to 1)
Bits 2-15 reserved (set to 0).*/
- uint16 lowestRecPPEM; // Smallest readable size in pixels.
- int16 fontDirectionHint; /* 0 Fully mixed directional glyphs;
+ uint16_t lowestRecPPEM; // Smallest readable size in pixels.
+ int16_t fontDirectionHint; /* 0 Fully mixed directional glyphs;
1 Only strongly left to right;
2 Like 1 but also contains neutrals;
-1 Only strongly right to left;
-2 Like -1 but also contains neutrals.*/
- int16 indexToLocFormat; // 0 for short offsets, 1 for long.
- int16 glyphDataFormat; // 0 for current format.
+ int16_t indexToLocFormat; // 0 for short offsets, 1 for long.
+ int16_t glyphDataFormat; // 0 for current format.
};
//
//
struct Maxp
{
- uint32 version; // Table version number 0x00010000 for version 1.0.
- uint16 numGlyphs; // The number of glyphs in the font.
- uint16 maxPoints; // Maximum points in a non-composite glyph.
- uint16 maxContours; // Maximum contours in a non-composite glyph.
- uint16 maxCompositePoints; // Maximum points in a composite glyph.
- uint16 maxCompositeContours; // Maximum contours in a composite glyph.
- uint16 maxZones; // 1 if instructions do not use the twilight
+ uint32_t version; // Table version number 0x00010000 for version 1.0.
+ uint16_t numGlyphs; // The number of glyphs in the font.
+ uint16_t maxPoints; // Maximum points in a non-composite glyph.
+ uint16_t maxContours; // Maximum contours in a non-composite glyph.
+ uint16_t maxCompositePoints; // Maximum points in a composite glyph.
+ uint16_t maxCompositeContours; // Maximum contours in a composite glyph.
+ uint16_t maxZones; // 1 if instructions do not use the twilight
// zone (Z0), or 2 if instructions do use Z0;
// should be set to 2 in most cases.
- uint16 maxTwilightPoints; // Maximum points used in Z0.
- uint16 maxStorage; // Number of Storage Area locations.
- uint16 maxFunctionDefs; // Number of FDEFs.
- uint16 maxInstructionDefs; // Number of IDEFs.
- uint16 maxStackElements; // Maximum stack depth.
- uint16 maxSizeOfInstructions; // Maximum uint8 count for glyph instructions.
- uint16 maxComponentElements; // Maximum number of components referenced at
+ uint16_t maxTwilightPoints; // Maximum points used in Z0.
+ uint16_t maxStorage; // Number of Storage Area locations.
+ uint16_t maxFunctionDefs; // Number of FDEFs.
+ uint16_t maxInstructionDefs; // Number of IDEFs.
+ uint16_t maxStackElements; // Maximum stack depth.
+ uint16_t maxSizeOfInstructions; // Maximum uint8_t count for glyph instructions.
+ uint16_t maxComponentElements; // Maximum number of components referenced at
// "top level" for any composite glyph.
- uint16 maxComponentDepth; // Maximum levels of recursion; 1 for simple components.
+ uint16_t maxComponentDepth; // Maximum levels of recursion; 1 for simple components.
};
//
Type Description
USHORT Platform ID.
USHORT Platform-specific encoding ID.
-ULONG uint8 offset from beginning of table to the subtable for this encoding.
+ULONG uint8_t offset from beginning of table to the subtable for this encoding.
USHORT format Format number is set to 4.
-USHORT length Length in uint8s.
+USHORT length Length in uint8_ts.
USHORT version Version number (starts at 0).
USHORT segCountX2 2 x segCount.
USHORT searchRange 2 x (2**floor(log2(segCount)))
struct Box
{
- int16 llx, lly, urx, ury;
+ int16_t llx, lly, urx, ury;
// Default constructor
- Box(int16 lx = 0, int16 ly = 0, int16 rx = 0, int16 ry = 0):
+ Box(int16_t lx = 0, int16_t ly = 0, int16_t rx = 0, int16_t ry = 0):
llx(lx), lly(ly), urx(rx), ury(ry) {}
};
struct NameRec
{
- uint16 platformID, platformSpecID, languageID, nameID, length;
- uint8 * str;
+ uint16_t platformID, platformSpecID, languageID, nameID, length;
+ uint8_t * str;
NameRec(): str(NULL) {}
languageID = c.languageID;
nameID = c.nameID;
length = c.length;
-//Fix this str = (uint8 *)strdup((char *)c.str);
+//Fix this str = (uint8_t *)strdup((char *)c.str);
}
};
struct Composite
{
- uint16 flags, glyphIndex;
- int16 arg1, arg2;
+ uint16_t flags, glyphIndex;
+ int16_t arg1, arg2;
float xScale, yScale, scale01, scale10;
- Composite(uint16 fl = 0, uint16 gl = 0, int16 a1 = 0, int16 a2 = 0,
+ Composite(uint16_t fl = 0, uint16_t gl = 0, int16_t a1 = 0, int16_t a2 = 0,
float xs = 1.0f, float ys = 1.0f, float s01 = 1.0f, float s10 = 1.0f):
flags(fl), glyphIndex(gl), arg1(a1), arg2(a2), xScale(xs), yScale(ys),
scale01(s01), scale10(s10) {}
class TTF
{
private:
- bool EncodeGlyph(uint16);
- bool DecodeGlyph(uint16);
+ bool EncodeGlyph(uint16_t);
+ bool DecodeGlyph(uint16_t);
bool ExtractTables(void);
bool BuildTables(void);
bool Load(const char *); // Load font database
bool Save(const char *); // Save font database
void ClearTables(void); // Deallocate memory...
- bool SetGlyph(uint16 glyphnum); // Set internal pointer/encode/decode
- bool AddGlyph(uint16 glyphnum);
- bool DeleteGlyph(uint16 glyphnum);
+ bool SetGlyph(uint16_t glyphnum); // Set internal pointer/encode/decode
+ bool AddGlyph(uint16_t glyphnum);
+ bool DeleteGlyph(uint16_t glyphnum);
Box GetBoundingBox(void);
- GlyphPt GetPoint(uint16 pointno);
- uint16 GetNumberOfPolys(void);
- uint16 GetPolyEnd(uint16 polynum);
- int GetPointX(uint16 pointno);
- int GetPointY(uint16 pointno);
- bool GetOnCurve(uint16 pointno);
- bool SetOnCurve(uint16 pointno, bool state);
- bool MovePoint(uint16 pointno, int x, int y);
- bool MovePoint(uint16 pointno, GlyphPt p);
- bool AddPoint(uint16 pointno, int x, int y, bool state);
- bool DeletePoint(uint16 pointno);
+ GlyphPt GetPoint(uint16_t pointno);
+ uint16_t GetNumberOfPolys(void);
+ uint16_t GetPolyEnd(uint16_t polynum);
+ int GetPointX(uint16_t pointno);
+ int GetPointY(uint16_t pointno);
+ bool GetOnCurve(uint16_t pointno);
+ bool SetOnCurve(uint16_t pointno, bool state);
+ bool MovePoint(uint16_t pointno, int x, int y);
+ bool MovePoint(uint16_t pointno, GlyphPt p);
+ bool AddPoint(uint16_t pointno, int x, int y, bool state);
+ bool DeletePoint(uint16_t pointno);
bool IsCompositeGlyph(void);
- GlyphPoints GetGlyphPoints(uint16);
- GlyphPoints GetAllCompositePoints(uint16);
- void GetCharName(int, uint8 *);
+ GlyphPoints GetGlyphPoints(uint16_t);
+ GlyphPoints GetAllCompositePoints(uint16_t);
+ void GetCharName(int, uint8_t *);
private:
bool isDirty; // Has glyph been modified?
bool isCompositeGlyph; // Is it a composite? (need structs to store composite info...)
- uint16 currentGlyph; // The glyph currently decoded
- uint16 numberOfPoints;
+ uint16_t currentGlyph; // The glyph currently decoded
+ uint16_t numberOfPoints;
int gx[MAXPOINTS]; // Internal point arrays...
int gy[MAXPOINTS]; // These could be dynamically allocated in the
bool onCurve[MAXPOINTS]; // constructor, with default values being set
- uint16 numberOfHints;
- uint8 hint[MAXHINTS]; // Hints storage
- uint16 numberOfPolys; // Number of polygons in glyph
- uint16 poly[200]; // End points of polygons
- int16 llx, lly, urx, ury; // Lower left/Upper right X/Y
+ uint16_t numberOfHints;
+ uint8_t hint[MAXHINTS]; // Hints storage
+ uint16_t numberOfPolys; // Number of polygons in glyph
+ uint16_t poly[200]; // End points of polygons
+ int16_t llx, lly, urx, ury; // Lower left/Upper right X/Y
// public://remove after debugging...
- uint8 * glyph[MAXGLYPHS]; // Placeholders for glyphs
- uint32 glyphLen[MAXGLYPHS]; // Glyph lengths are stored since malloc() is sloppy
+ uint8_t * glyph[MAXGLYPHS]; // Placeholders for glyphs
+ uint32_t glyphLen[MAXGLYPHS]; // Glyph lengths are stored since malloc() is sloppy
Maxp myMaxp; // Internal placeholders for this shiat
Head myHead;
// public: //private: later...
List<Composite> compositeList; // Composite glyph list
- uint8 * EBDT, * EBLC, * EBSC, * LTSH, * OS_2, * PCLT, * VDMX, * cmap, * cvt, * fpgm,
+ uint8_t * EBDT, * EBLC, * EBSC, * LTSH, * OS_2, * PCLT, * VDMX, * cmap, * cvt, * fpgm,
* gasp, * glyf, * hdmx, * head, * hhea, * hmtx, * kern, * loca, * maxp, * name,
* post, * prep, * vhea, * vmtx;
- uint32 EBDT_len, EBLC_len, EBSC_len, LTSH_len, OS_2_len, PCLT_len, VDMX_len, cmap_len,
+ uint32_t EBDT_len, EBLC_len, EBSC_len, LTSH_len, OS_2_len, PCLT_len, VDMX_len, cmap_len,
cvt_len, fpgm_len, gasp_len, glyf_len, hdmx_len, head_len, hhea_len, hmtx_len,
kern_len, loca_len, maxp_len, name_len, post_len, prep_len, vhea_len, vmtx_len;
- uint8 * * parray[24]; // Pointer array
- uint32 * larray[24]; // Length array
+ uint8_t * * parray[24]; // Pointer array
+ uint32_t * larray[24]; // Length array
bool loaded; // Font loaded/init'ed?
};
+++ /dev/null
-//
-// Basic types for platform independent code
-//
-
-#ifndef __TYPES_H__
-#define __TYPES_H__
-
-// This should be portable, since it's part of the C99 standard...!
-
-#include <stdint.h>
-
-typedef uint8_t uint8;
-typedef int8_t int8;
-typedef uint16_t uint16;
-typedef int16_t int16;
-typedef uint32_t uint32;
-typedef int32_t int32;
-typedef uint64_t uint64;
-typedef int64_t int64;
-
-/*#ifndef _WINDOWS_
-#define NULL 0
-// This is for non-compliant compilers that don't follow proper scoping rules (and suck). ;-)
-#define for if(false);else for
-#endif*/
-#ifndef NULL
-#define NULL 0
-#endif
-
-#endif // __TYPES_H__
// Check for equality
bool Vector::operator==(Vector const v)
{
- return (x == v.x && y == v.y && z == v.z ? true : false);
+ return ((x == v.x) && (y == v.y) && (z == v.z) ? true : false);
}
// Check for inequality
bool Vector::operator!=(Vector const v)
{
- return (x != v.x || y != v.y || z != v.z ? true : false);
+ return ((x != v.x) || (y != v.y) || (z != v.z) ? true : false);
}
double Vector::Magnitude(void)
{
- return sqrt(x * x + y * y + z * z);
+ return sqrt((x * x) + (y * y) + (z * z));
}
//
-// Angle between these two vectors
+// Returns the smallest angle between these two vectors
//
double Vector::Angle(Vector v)
{
+// seems that something relies on this bad behavior... :-P
+#if 0
+ // Discard the sign from the subtraction
+ double angle = fabs(Angle() - v.Angle());
+
+ // Return the complementary angle if greater than 180⁰
+ return (angle <= 180.0 ? angle : 360.0 - angle);
+#else
return Angle() - v.Angle();
+#endif
}
bool Vector::isZero(double epsilon/*= 1e-6*/)
{
- return (fabs(x) < epsilon && fabs(y) < epsilon && fabs(z) < epsilon ? true : false);
+ return ((fabs(x) < epsilon) && (fabs(y) < epsilon) && (fabs(z) < epsilon) ? true : false);
}
double xx = v1.x - v2.x;
double yy = v1.y - v2.y;
double zz = v1.z - v2.z;
- return sqrt(xx * xx + yy * yy + zz * zz);
+ return sqrt((xx * xx) + (yy * yy) + (zz * zz));
}
#endif
#endif // __VECTOR_H__
-#endif
\ No newline at end of file
+#endif
+
HEADERS += src/mainwindow.h
HEADERS += src/editwindow.h
HEADERS += src/glyphpoints.h
-HEADERS += src/types.h
HEADERS += src/debug.h
HEADERS += src/toolwindow.h
HEADERS += src/charwindow.h