Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlaps and anisotropic filtering #22

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a80c04f
Geometry code to check for arc (and segment) intersections. Runs, but…
May 9, 2012
cbde181
Revised arc interesection detection functions. Does not always work i…
May 11, 2012
77654e9
Intersection check of segment interior with endpoints should work.
May 16, 2012
9167fce
Changed intersect functions to return intersection points, rather tha…
May 17, 2012
a7051bd
Removed glyph-overlap attempt; will have to restart with new approach.
May 18, 2012
9ff48ee
Added a check for arc endpoint/segment intersection.
May 18, 2012
46429c4
Updated "segment contains point" method. Updated check for parallel l…
May 22, 2012
a2e13ad
Lots of work on rearrange_endpoints, which should change order that c…
May 22, 2012
8c789d9
Rearrange contours works, sorts contours by some intersection rule.
May 23, 2012
9ba70e2
Moved code around; rearranging endpoints now done in glyphy-blob. Con…
May 24, 2012
6290a3e
Started work on processing intersecting contours in stages. Not compl…
May 29, 2012
87ab802
Intersecting contours work! Kind of. Outlines on overlap regions are …
May 30, 2012
a023ecd
Outlines work properly in intersecting contours!!! Just need to fix a…
May 31, 2012
e3e08b2
Simple code cleanup. No major change
Jun 1, 2012
fce3ed7
Fixed outline seam glitch, as in DroidSans.ttf glyph (a+cedilla) ą.
Jun 4, 2012
d57d973
Began work on graph method for grouping contours. Set up vertex struc…
Jun 4, 2012
8e7da16
Added support for solid edges between vertices. The same framework ca…
Jun 5, 2012
d42b6fb
Dotted edges are now formed between contours that surround/contain ea…
Jun 6, 2012
a6f26c7
No functional change, but started setting up for collapsed dotted edges.
Jun 8, 2012
e0af0fb
Dotted edges are collapsed and the relevant vertices are merged in th…
Jun 8, 2012
68ece9c
Handled cases where a cell is completely within one contour group, bu…
Jun 12, 2012
aed4e4a
Partition now chosen using the graph algorithm. Edges are repeated af…
Jun 13, 2012
44eb644
Edges in the new graph are no longer repeated.
Jun 14, 2012
3b353f2
Small floating point fix to help coincident outlines keep working.
Jun 14, 2012
3838582
Fixed missing edge bug (very rare - need coincident points), and gene…
Jun 15, 2012
a7a6d90
Minor. Some light code cleanup; added some comments.
Jun 19, 2012
5e946bb
Modified glyphy_sdf to keep track of vector to nearest contour. Still…
Jun 20, 2012
b051088
Subpixel rendering - Some progress on min_dist_vector returned by gly…
Jun 25, 2012
d61590b
SDF now has min_dist_vector with some nice shading, and functions now…
Jun 26, 2012
27b20fa
Merged repeated code into a single "find_min_dist" function in glyphy…
Jun 27, 2012
309f59c
The sdf vector now points in the correct direction... but seams still…
Jun 28, 2012
4e78597
Minor fix.. but SEAMS ARE GONE. Smooth outlines, yessir.
Jun 29, 2012
8cbc8da
Added TestFont with some bad examples; some colour revamp for sdf.
Jul 4, 2012
d8f10c3
Some work on anisotrpic antialias
Jul 4, 2012
7c7575c
Enable anisotropic antialiasing: apply P_inverse to shortest vector w…
Jul 9, 2012
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
Binary file added TestFont.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion demo/demo-font.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ encode_ft_glyph (demo_font_t *font,

assert (glyphy_arc_accumulator_get_error (font->acc) <= tolerance);

#if 0
#if 1
/* Technically speaking, we want the following code,
* however, crappy fonts have crappy flags. So we just
* fixup unconditionally... */
Expand Down
42 changes: 35 additions & 7 deletions demo/demo-fshader.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,27 @@ main()
/* isotropic antialiasing */
vec2 dpdx = dFdx (p);
vec2 dpdy = dFdy (p);
float m = length (vec2 (length (dpdx), length (dpdy))) * SQRT2_2;
float w = abs (normalize (dpdx).x) + abs (normalize (dpdy).x);

vec4 color = vec4 (0,0,0,1);

float det = dpdx.x * dpdy.y - dpdx.y * dpdy.x;
mat2 P_inv = mat2(dpdy.y, -dpdx.y, -dpdy.x, dpdx.x) * (1. / det);
vec2 sdf_vector;

/* gdist is signed distance to nearest contour; sdf_vector is the shortest vector version. */
float gsdist = glyphy_sdf (p, gi.nominal_size, sdf_vector GLYPHY_DEMO_EXTRA_ARGS);




if (glyphy_iszero (det)) {
gl_FragColor = vec4(1,0,0,1);
return;
}

float m = 1.;//SQRT2;//length (vec2 (length (dpdx), length (dpdy))); //1.0;
gsdist = sign (gsdist) * length (P_inv * sdf_vector);

float gsdist = glyphy_sdf (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);
float w = abs (normalize (dpdx).x) + abs (normalize (dpdy).x);
vec4 color = vec4 (0,0,0,1);
float sdist = gsdist / m * u_contrast;

if (!u_debug) {
Expand All @@ -84,19 +99,32 @@ main()

float udist = abs (sdist);
float gudist = abs (gsdist);
// Color the outline red
float pdist = glyphy_point_dist (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);
/* // Color the outline red
color += vec4 (1,0,0,1) * smoothstep (2., 1., udist);
// Color the distance field in green
if (!glyphy_isinf (udist))
color += vec4 (0,.3,0,(1. + sin (sdist)) * abs(1. - gsdist * 3.) / 3.);

float pdist = glyphy_point_dist (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);

// Color points green
color = mix (vec4 (0,1,0,.5), color, smoothstep (.05, .06, pdist));

glyphy_arc_list_t arc_list = glyphy_arc_list (p, gi.nominal_size GLYPHY_DEMO_EXTRA_ARGS);
// Color the number of endpoints per cell blue
color += vec4 (0,0,1,.1) * float(arc_list.num_endpoints) * 32./255.;
*/
if (glyphy_isinf (sdf_vector.x) || glyphy_isinf (sdf_vector.y))
color = vec4 (0, 0, 0, 1);

else
color = vec4 (0.5*(sdf_vector.x)+0.5, 0.5*(sdf_vector.y)+0.5, 0.4, 1);


color += vec4 (1,1,1,1) * smoothstep (1.6, 1.4, udist);
color = mix (vec4 (0,0.2,0.2,.5), color, smoothstep (.04, .06, pdist));
// else
// color = vec4 (0,0,0,1);
}

gl_FragColor = color;
Expand Down
2 changes: 1 addition & 1 deletion demo/jabberwocky.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ static const char *jabberwocky =
" And the mome raths outgrabe.\n"
"\n"
"\"Beware the Jabberwock, my son!\n"
" The jaws that bite, the claws that catch!\n"
" The jaws ţhąt bite, thę çląwş that ©atch!\n"
"Beware the Jubjub bird, and shun\n"
" The frumious Bandersnatch!\"\n"
"He took his vorpal sword in hand:\n"
Expand Down
Loading