vidstige / NRasterizer

OpenType parser in pure c#
Apache License 2.0
38 stars 11 forks source link

Measure text #43

Closed tocsoft closed 7 years ago

tocsoft commented 7 years ago

Added a new method to measure the text.

Fixes #42

While I was in here I tried to refactor, what owns the output resolution, and how we pass rendering options in to try and simplify the API.

tocsoft commented 7 years ago

I've updated based on your feedback... I renamed RenderOptions to TextOptions as I felt that made more sense when its being passed into Render(..) / Measure(..) methods.

I also renamed the private 'Render' method to ProcessText to be a bit more generic.

tocsoft commented 7 years ago

@vidstige I've had a pass of cleaning up the unit tests in relation to measuring strings, the changes are https://github.com/tocsoft/NRasterizer/commit/e0a14073851ba50841afc493c04ddd20a026a997 do you want me to add that changes to this PR or would you rather I sent you this over as a separate PR? after/if you accept this one.

vidstige commented 7 years ago

@tocsoft ah, back from vaccation. :-) Sorry for letting you hang. I guess it's easiest for you to pull these changes + the cleanup commit into a new branch and make a new pull request against master?

Also I feel we need a refactor. It feels to quirky to have the bool renderGlyph argument to ProcessText, but rather there should a function returning iterator that iterates over glyph coordinates. You see where I am going with this? Then the measure text and draw text functions could both use this iterator. Sample signature IEnumerable<Point2D> GlyphPositions(Point2D position, string text, int size, TextOptions options = DefaultTextOptions) or something like that.

vidstige commented 7 years ago

Perhaps start with creating the new pr as this branch has merge conflicts? You can also merge and resolve conflicts in here if it easier for you :+1:

vidstige commented 7 years ago

Let's get this baby in anyway :)

tocsoft commented 7 years ago

superseded by #48