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:
parent
18b93fcc8a
commit
1d7f0244f9
39
nuklear.h
39
nuklear.h
@ -940,7 +940,7 @@ NK_API void nk_buffer_init(struct nk_buffer*, const struct nk_allocator*, nk_siz
|
||||
NK_API void nk_buffer_init_fixed(struct nk_buffer*, void *memory, nk_size size);
|
||||
NK_API void nk_buffer_info(struct nk_memory_status*, struct nk_buffer*);
|
||||
NK_API void nk_buffer_push(struct nk_buffer*, enum nk_buffer_allocation_type type,
|
||||
void *memory, nk_size size, nk_size align);
|
||||
void *memory, nk_size size, nk_size align);
|
||||
NK_API void nk_buffer_mark(struct nk_buffer*, enum nk_buffer_allocation_type type);
|
||||
NK_API void nk_buffer_reset(struct nk_buffer*, enum nk_buffer_allocation_type type);
|
||||
NK_API void nk_buffer_clear(struct nk_buffer*);
|
||||
@ -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
|
||||
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
|
||||
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
|
||||
@ -6945,7 +6945,7 @@ nk_rp_pack_rects(struct nk_rp_context *context, struct nk_rp_rect *rects, int nu
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
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 */
|
||||
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 */
|
||||
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,
|
||||
float x0, float y0, float x1, float y1)
|
||||
{
|
||||
if (!(y0>y1) && !(y0<y1)) return;
|
||||
if (y0 == y1) return;
|
||||
NK_ASSERT(y0 < y1);
|
||||
NK_ASSERT(e->sy <= e->ey);
|
||||
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;
|
||||
}
|
||||
|
||||
if (!(x0 > x) && !(x0 < x)) NK_ASSERT(x1 <= x+1);
|
||||
else if (!(x0 > x+1) && !(x0 < x+1)) NK_ASSERT(x1 >= x);
|
||||
if (x0 == x) NK_ASSERT(x1 <= x+1);
|
||||
else if (x0 == x+1) NK_ASSERT(x1 >= x);
|
||||
else if (x0 <= x) NK_ASSERT(x1 <= x);
|
||||
else if (x0 >= x+1) NK_ASSERT(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 */
|
||||
/* compute intersection points with top & bottom */
|
||||
NK_ASSERT(e->ey >= y_top);
|
||||
if (!(e->fdx > 0) && !(e->fdx < 0)) {
|
||||
if (e->fdx == 0) {
|
||||
float x0 = e->fx;
|
||||
if (x0 < len) {
|
||||
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 */
|
||||
while (e->y0 <= scan_y_bottom) {
|
||||
struct nk_tt__active_edge *z = nk_tt__new_active(&hh, e, off_x, scan_y_top);
|
||||
NK_ASSERT(z->ey >= scan_y_top);
|
||||
/* insert at front */
|
||||
z->next = active;
|
||||
active = z;
|
||||
if (e->y0 != e->y1) {
|
||||
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);
|
||||
/* insert at front */
|
||||
z->next = active;
|
||||
active = z;
|
||||
}
|
||||
}
|
||||
++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++) {
|
||||
int a=k,b=j;
|
||||
/* 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;
|
||||
|
||||
/* 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->nodes = nodes;
|
||||
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->v_oversample = 1;
|
||||
|
||||
@ -9479,7 +9484,7 @@ nk_font_config(float pixel_height)
|
||||
cfg.ttf_size = 0;
|
||||
cfg.ttf_data_owned_by_atlas = 0;
|
||||
cfg.size = pixel_height;
|
||||
cfg.oversample_h = 1;
|
||||
cfg.oversample_h = 3;
|
||||
cfg.oversample_v = 1;
|
||||
cfg.pixel_snap = 0;
|
||||
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
|
||||
/* no font added so just use default font */
|
||||
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
|
||||
NK_ASSERT(atlas->font_num);
|
||||
if (!atlas->font_num) return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user