Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions NOpenType/CharacterMap.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
//Apache2, 2017, WinterDev
//Apache2, 2014-2016, Samuel Carlsson, WinterDev
using System;

namespace NRasterizer
{
Expand All @@ -20,7 +22,8 @@ internal CharacterMap(int segCount, ushort[] startCode, ushort[] endCode, ushort
_idRangeOffset = idRangeOffset;
_glyphIdArray = glyphIdArray;
}

public ushort PlatformId { get; set; }
public ushort EncodingId { get; set; }
public int CharacterToGlyphIndex(UInt32 character)
{
return (int)RawCharacterToGlyphIndex(character);
Expand Down
77 changes: 67 additions & 10 deletions NOpenType/IGlyphRasterizer.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,78 @@
using System;
//MIT, 2016-2017, WinterDev
//MIT, 2015, Michael Popoloski
//FTL, 3-clauses BSD, FreeType project
//-----------------------------------------------------

namespace NRasterizer
{
//https://en.wikipedia.org/wiki/B%C3%A9zier_curve
//--------------------
//Line, has 2 points..
// (x0,y0) begin point
// (x1,y1) end point
//--------------------
//Curve3 (Quadratic Bézier curves), has 3 points
// (x0,y0) begin point
// (x1,y1) 1st control point
// (x2,y2) end point
//--------------------
//Curve4 (Cubic Bézier curves), has 4 points
// (x0,y0) begin point
// (x1,y1) 1st control point
// (x2,y2) 2nd control point
// (x3,y3) end point
//--------------------
//please note that TrueType font
//compose of Quadractic Bezier
public interface IGlyphRasterizer
{
int Resolution { get; }

/// <summary>
/// begin read a glyph
/// </summary>
/// <param name="contourCount"></param>
void BeginRead(int countourCount);
/// <summary>
/// end read a glyph
/// </summary>
void EndRead();

void LineTo(double x, double y);
void Curve3(double p2x, double p2y, double x, double y);
void Curve4(double p2x, double p2y, double p3x, double p3y, double x, double y);
void MoveTo(double x, double y);
void CloseFigure();

// Called after all letters have been written.
/// <summary>
/// set CURRENT pen position to (x0,y0) And set the position as latest MOVETO position
/// </summary>
/// <param name="x0"></param>
/// <param name="y0"></param>
void MoveTo(double x0, double y0);
/// <summary>
/// add line,begin from CURRENT pen position to (x1,y1) then set (x1,y1) as CURRENT pen position
/// </summary>
/// <param name="x1">end point x</param>
/// <param name="y1">end point y</param>
void LineTo(double x1, double y1);
/// <summary>
/// add Quadratic Bézier curve,begin from CURRENT pen pos, to (x2,y2), then set (x2,y2) as CURRENT pen pos
/// </summary>
/// <param name="x1">x of 1st control point</param>
/// <param name="y1">y of 1st control point</param>
/// <param name="x2">end point x</param>
/// <param name="y2">end point y</param>
void Curve3(double x1, double y1, double x2, double y2);
/// <summary>
/// add Cubic Bézier curve,begin from CURRENT pen pos, to (x3,y3), then set (x3,y3) as CURRENT pen pos
/// </summary>
/// <param name="x1">x of 1st control point</param>
/// <param name="y1">y of 1st control point</param>
/// <param name="x2">x of 2nd control point</param>
/// <param name="y2">y of 2dn control point</param>
/// <param name="x3">end point x</param>
/// <param name="y3">end point y</param>
void Curve4(double x1, double y1, double x2, double y2, double x3, double y3);
/// <summary>
/// close current contour, create line from CURRENT pen position to latest MOVETO position
/// </summary>
void CloseFigure();
/// <summary>
/// Called after all letters have been written.
/// </summary>
void Flush();
}
}
Expand Down
Loading