mirror of
https://github.com/nothings/stb
synced 2024-12-16 12:52:34 +03:00
stb_truetype: tweaks to codepoint-missing packing
This commit is contained in:
parent
f11f1e801a
commit
6244febf5f
@ -643,11 +643,11 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
|||||||
// To use with PackFontRangesGather etc., you must set it before calls
|
// To use with PackFontRangesGather etc., you must set it before calls
|
||||||
// call to PackFontRangesGatherRects.
|
// call to PackFontRangesGatherRects.
|
||||||
|
|
||||||
|
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
|
||||||
// If skip != 0, this tells stb_truetype to skip any codepoints for which
|
// If skip != 0, this tells stb_truetype to skip any codepoints for which
|
||||||
// there is no corresponding glyph. If skip=0, which is the default, then
|
// there is no corresponding glyph. If skip=0, which is the default, then
|
||||||
// codepoints without a glyph recived the font's "missing character" glyph,
|
// codepoints without a glyph recived the font's "missing character" glyph,
|
||||||
// typically an empty box by convention.
|
// typically an empty box by convention.
|
||||||
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip);
|
|
||||||
|
|
||||||
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
||||||
int char_index, // character to display
|
int char_index, // character to display
|
||||||
@ -677,7 +677,7 @@ struct stbtt_pack_context {
|
|||||||
int height;
|
int height;
|
||||||
int stride_in_bytes;
|
int stride_in_bytes;
|
||||||
int padding;
|
int padding;
|
||||||
int skip_empty;
|
int skip_missing;
|
||||||
unsigned int h_oversample, v_oversample;
|
unsigned int h_oversample, v_oversample;
|
||||||
unsigned char *pixels;
|
unsigned char *pixels;
|
||||||
void *nodes;
|
void *nodes;
|
||||||
@ -3806,6 +3806,7 @@ STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, in
|
|||||||
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;
|
||||||
|
spc->skip_missing = 0;
|
||||||
|
|
||||||
stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
|
stbrp_init_target(context, pw-padding, ph-padding, nodes, num_nodes);
|
||||||
|
|
||||||
@ -3833,7 +3834,7 @@ STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h
|
|||||||
|
|
||||||
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
|
STBTT_DEF void stbtt_PackSetSkipMissingCodepoints(stbtt_pack_context *spc, int skip)
|
||||||
{
|
{
|
||||||
spc->skip_empty = skip;
|
spc->skip_missing = skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
#define STBTT__OVER_MASK (STBTT_MAX_OVERSAMPLE-1)
|
||||||
@ -3989,7 +3990,7 @@ STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, const stb
|
|||||||
int x0,y0,x1,y1;
|
int x0,y0,x1,y1;
|
||||||
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
int codepoint = ranges[i].array_of_unicode_codepoints == NULL ? ranges[i].first_unicode_codepoint_in_range + j : ranges[i].array_of_unicode_codepoints[j];
|
||||||
int glyph = stbtt_FindGlyphIndex(info, codepoint);
|
int glyph = stbtt_FindGlyphIndex(info, codepoint);
|
||||||
if (glyph == 0 && spc->skip_empty) {
|
if (glyph == 0 && spc->skip_missing) {
|
||||||
rects[k].w = rects[k].h = 0;
|
rects[k].w = rects[k].h = 0;
|
||||||
} else {
|
} else {
|
||||||
stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
|
stbtt_GetGlyphBitmapBoxSubpixel(info,glyph,
|
||||||
|
Loading…
Reference in New Issue
Block a user