Revert float '=' cond and oversample default font

I previously used a conditional style so I don't have to compare
floats directly with eachother because of warning. This caused some
bugs and I now reverted back all conditions back to normal.
In addition I oversampled the default font to make it look better.
This commit is contained in:
vurtun 2016-04-20 18:20:33 +02:00
parent 18b93fcc8a
commit 1d7f0244f9

View File

@ -1104,7 +1104,7 @@ NK_API void nk_textedit_redo(struct nk_text_edit*);
While the first approach works fine if you don't want to use the optional While the first approach works fine if you don't want to use the optional
vertex buffer output it is not enough if you do. To get font handling working vertex buffer output it is not enough if you do. To get font handling working
for these cases you have to provide to additional parameter inside the for these cases you have to provide two additional parameter inside the
`nk_user_font`. First a texture atlas handle used to draw text as subimages `nk_user_font`. First a texture atlas handle used to draw text as subimages
of a bigger font atlas texture and a callback to query a characters glyph of a bigger font atlas texture and a callback to query a characters glyph
information (offset, size, ...). So it is still possible to provide your own information (offset, size, ...). So it is still possible to provide your own
@ -6945,7 +6945,7 @@ nk_rp_pack_rects(struct nk_rp_context *context, struct nk_rp_rect *rects, int nu
} }
/* sort according to heuristic */ /* sort according to heuristic */
nk_rp_qsort(rects, (unsigned)num_rects, nk_rect_height_compare); qsort(rects, (unsigned)num_rects, sizeof(rects[0]), nk_rect_height_compare);
for (i=0; i < num_rects; ++i) { for (i=0; i < num_rects; ++i) {
struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); struct nk_rp__findresult fr = nk_rp__skyline_pack_rectangle(context, rects[i].w, rects[i].h);
@ -6958,7 +6958,8 @@ nk_rp_pack_rects(struct nk_rp_context *context, struct nk_rp_rect *rects, int nu
} }
/* unsort */ /* unsort */
nk_rp_qsort(rects, (unsigned)num_rects, nk_rect_original_order); /*nk_rp_qsort(rects, (unsigned)num_rects, nk_rect_original_order);*/
qsort(rects, (unsigned)num_rects, sizeof(rects[0]), nk_rect_original_order);
/* set was_packed flags */ /* set was_packed flags */
for (i=0; i < num_rects; ++i) for (i=0; i < num_rects; ++i)
@ -7731,7 +7732,7 @@ NK_INTERN void
nk_tt__handle_clipped_edge(float *scanline, int x, struct nk_tt__active_edge *e, nk_tt__handle_clipped_edge(float *scanline, int x, struct nk_tt__active_edge *e,
float x0, float y0, float x1, float y1) float x0, float y0, float x1, float y1)
{ {
if (!(y0>y1) && !(y0<y1)) return; if (y0 == y1) return;
NK_ASSERT(y0 < y1); NK_ASSERT(y0 < y1);
NK_ASSERT(e->sy <= e->ey); NK_ASSERT(e->sy <= e->ey);
if (y0 > e->ey) return; if (y0 > e->ey) return;
@ -7745,8 +7746,8 @@ nk_tt__handle_clipped_edge(float *scanline, int x, struct nk_tt__active_edge *e,
y1 = e->ey; y1 = e->ey;
} }
if (!(x0 > x) && !(x0 < x)) NK_ASSERT(x1 <= x+1); if (x0 == x) NK_ASSERT(x1 <= x+1);
else if (!(x0 > x+1) && !(x0 < x+1)) NK_ASSERT(x1 >= x); else if (x0 == x+1) NK_ASSERT(x1 >= x);
else if (x0 <= x) NK_ASSERT(x1 <= x); else if (x0 <= x) NK_ASSERT(x1 <= x);
else if (x0 >= x+1) NK_ASSERT(x1 >= x+1); else if (x0 >= x+1) NK_ASSERT(x1 >= x+1);
else NK_ASSERT(x1 >= x && x1 <= x+1); else NK_ASSERT(x1 >= x && x1 <= x+1);
@ -7771,7 +7772,7 @@ nk_tt__fill_active_edges_new(float *scanline, float *scanline_fill, int len,
/* brute force every pixel */ /* brute force every pixel */
/* compute intersection points with top & bottom */ /* compute intersection points with top & bottom */
NK_ASSERT(e->ey >= y_top); NK_ASSERT(e->ey >= y_top);
if (!(e->fdx > 0) && !(e->fdx < 0)) { if (e->fdx == 0) {
float x0 = e->fx; float x0 = e->fx;
if (x0 < len) { if (x0 < len) {
if (x0 >= 0) { if (x0 >= 0) {
@ -7970,11 +7971,15 @@ nk_tt__rasterize_sorted_edges(struct nk_tt__bitmap *result, struct nk_tt__edge *
/* insert all edges that start before the bottom of this scanline */ /* insert all edges that start before the bottom of this scanline */
while (e->y0 <= scan_y_bottom) { while (e->y0 <= scan_y_bottom) {
if (e->y0 != e->y1) {
struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top); struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
if (z != 0) {
NK_ASSERT(z->ey >= scan_y_top); NK_ASSERT(z->ey >= scan_y_top);
/* insert at front */ /* insert at front */
z->next = active; z->next = active;
active = z; active = z;
}
}
++e; ++e;
} }
@ -8136,7 +8141,7 @@ nk_tt__rasterize(struct nk_tt__bitmap *result, struct nk_tt__point *pts,
for (k=0; k < wcount[i]; j=k++) { for (k=0; k < wcount[i]; j=k++) {
int a=k,b=j; int a=k,b=j;
/* skip the edge if horizontal */ /* skip the edge if horizontal */
if (!(p[j].y > p[k].y) && !(p[j].y < p[k].y)) if (p[j].y == p[k].y)
continue; continue;
/* add edge from j to k to the list */ /* add edge from j to k to the list */
@ -8345,7 +8350,7 @@ nk_tt_PackBegin(struct nk_tt_pack_context *spc, unsigned char *pixels,
spc->pack_info = context; spc->pack_info = context;
spc->nodes = nodes; spc->nodes = nodes;
spc->padding = padding; spc->padding = padding;
spc->stride_in_bytes = stride_in_bytes != 0 ? stride_in_bytes : pw; spc->stride_in_bytes = (stride_in_bytes != 0) ? stride_in_bytes : pw;
spc->h_oversample = 1; spc->h_oversample = 1;
spc->v_oversample = 1; spc->v_oversample = 1;
@ -9479,7 +9484,7 @@ nk_font_config(float pixel_height)
cfg.ttf_size = 0; cfg.ttf_size = 0;
cfg.ttf_data_owned_by_atlas = 0; cfg.ttf_data_owned_by_atlas = 0;
cfg.size = pixel_height; cfg.size = pixel_height;
cfg.oversample_h = 1; cfg.oversample_h = 3;
cfg.oversample_v = 1; cfg.oversample_v = 1;
cfg.pixel_snap = 0; cfg.pixel_snap = 0;
cfg.coord_type = NK_COORD_UV; cfg.coord_type = NK_COORD_UV;
@ -9741,7 +9746,7 @@ nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,
#ifdef NK_INCLUDE_DEFAULT_FONT #ifdef NK_INCLUDE_DEFAULT_FONT
/* no font added so just use default font */ /* no font added so just use default font */
if (!atlas->font_num) if (!atlas->font_num)
atlas->default_font = nk_font_atlas_add_default(atlas, 14.0f, 0); atlas->default_font = nk_font_atlas_add_default(atlas, 13.0f, 0);
#endif #endif
NK_ASSERT(atlas->font_num); NK_ASSERT(atlas->font_num);
if (!atlas->font_num) return 0; if (!atlas->font_num) return 0;