This library processes TrueType files:
Some important concepts to understand to use this library:
Characters are defined by unicode codepoints, e.g. 65 is uppercase A, 231 is lowercase c with a cedilla, 0x7e30 is the hiragana for "ma".
A visual character shape (every codepoint is rendered as some glyph)
A font-specific integer ID representing a glyph
Glyph shapes are defined relative to a baseline, which is the bottom of uppercase characters. Characters extend both above and below the baseline.
As you draw text to the screen, you keep track of a "current point" which is the origin of each character. The current point's vertical position is the baseline. Even "baked fonts" use this model.
The vertical qualities of the font, used to vertically position and space the characters. See docs for GetFontVMetrics.
The preferred interface for specifying font sizes in stb_truetype is to specify how tall the font's vertical extent should be in pixels. If that sounds good enough, skip the next paragraph.
Most font APIs instead use "points", which are a common typographic measurement for describing font size, defined as 72 points per inch. stb_truetype provides a point API for compatibility. However, true "per inch" conventions don't make much sense on computer displays since different monitors have different number of pixels per inch. For example, Windows traditionally uses a convention that there are 96 pixels per inch, thus making 'inch' measurements have nothing to do with inches, and thus effectively defining a point to be 1.333 pixels. Additionally, the TrueType font data provides an explicit scale factor to scale a given font's glyphs to points, but the author has observed that this scale factor is often wrong for non-commercial fonts, thus making fonts scaled in points according to the TrueType spec incoherently sized in practice.
Select how high you want the font to be, in points or pixels. Call #()ScaleForPixelHeight or ScaleForMappingEmToPixels to compute a scale factor
SF that will be used by all other functions.
You need to select a y-coordinate that is the baseline of where your text will appear. Call GetFontBoundingBox to get the baseline-relative bounding
box for all characters. SF*-y0 will be the distance in pixels that the worst-case character could extend above the baseline, so if you want the
top edge of characters to appear at the top of the screen where y=0, then you would set the baseline to SF*-y0.
Set the current point where the first character will appear. The first character could extend left of the current point; this is font dependent. You can either choose a current point that is the leftmost point and hope, or add some padding, or check the bounding box or left-side-bearing of the first character to be displayed and set the current point based on that.
Compute the bounding box of the character. It will contain signed values relative to <current_point, baseline>. I.e. if it returns
x0,y0,x1,y1, then the character should be displayed in the rectangle from <current_point+SF*x0, baseline+SF*y0> to
<current_point+SF*x1,baseline+SF*y1).
Call GetGlyphHMetrics, and compute current_point += SF * advance.
Quality:
Performance:
The system uses the raw data found in the .ttf file without changing it and without building auxiliary data structures. This is a bit inefficient on little-endian systems (the data is big-endian), but assuming you're caching the bitmaps or glyph shapes this shouldn't be a big deal.
It appears to be very hard to programmatically determine what font a given file is in a general way. I provide an API for this, but I don't recommend it.
Incomplete text-in-3d-api example, which draws quads properly aligned to be lossless:
unsigned char ttf_buffer[1<<20];
unsigned char temp_bitmap[512*512];
stbtt_bakedchar cdata[96]; // ASCII 32..126 is 95 glyphs
GLuint ftex;
void my_stbtt_initfont(void)
{
fread(ttf_buffer, 1, 1<<20, fopen("c:/windows/fonts/times.ttf", "rb"));
stbtt_BakeFontBitmap(ttf_buffer,0, 32.0, temp_bitmap,512,512, 32,96, cdata); // no guarantee this fits!
// can free ttf_buffer at this point
glGenTextures(1, &ftex);
glBindTexture(GL_TEXTURE_2D, ftex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, 512,512, 0, GL_ALPHA, GL_UNSIGNED_BYTE, temp_bitmap);
// can free temp_bitmap at this point
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
void my_stbtt_print(float x, float y, char *text)
{
// assume orthographic projection with units = screen pixels, origin at top left
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ftex);
glBegin(GL_QUADS);
while (*text) {
if (*text ≥ 32 && *text < 128) {
stbtt_aligned_quad q;
stbtt_GetBakedQuad(cdata, 512,512, *text-32, &x,&y,&q,1);//1=opengl & d3d10+,0=d3d9
glTexCoord2f(q.s0,q.t1); glVertex2f(q.x0,q.y0);
glTexCoord2f(q.s1,q.t1); glVertex2f(q.x1,q.y0);
glTexCoord2f(q.s1,q.t0); glVertex2f(q.x1,q.y1);
glTexCoord2f(q.s0,q.t0); glVertex2f(q.x0,q.y1);
}
++text;
}
glEnd();
}
Complete program (this compiles): get a single bitmap, print as ASCII art:
char ttf_buffer[1<<25];
int main(int argc, char **argv)
{
stbtt_fontinfo font;
unsigned char *bitmap;
int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 'a'), s = (argc > 2 ? atoi(argv[2]) : 20);
fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/arialbd.ttf", "rb"));
stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0));
bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, s), c, &w, &h, 0,0);
for (j=0; j < h; ++j) {
for (i=0; i < w; ++i)
putchar(" .:ioVM@"[bitmap[j*w+i]>>5]);
putchar('\n');
}
return 0;
}
Complete program: print "Hello World!" banner, with bugs:
char buffer[24<<20];
unsigned char screen[20][79];
int main(int arg, char **argv)
{
stbtt_fontinfo font;
int i,j,ascent,baseline,ch=0;
float scale, xpos=2; // leave a little padding in case the character extends left
char *text = "Heljo World!";
fread(buffer, 1, 1000000, fopen("c:/windows/fonts/arialbd.ttf", "rb"));
stbtt_InitFont(&font, buffer, 0);
scale = stbtt_ScaleForPixelHeight(&font, 15);
stbtt_GetFontVMetrics(&font, &ascent,0,0);
baseline = (int) (ascent*scale);
while (text[ch]) {
int advance,lsb,x0,y0,x1,y1;
float x_shift = xpos - (float) floor(xpos);
stbtt_GetCodepointHMetrics(&font, text[ch], &advance, &lsb);
stbtt_GetCodepointBitmapBoxSubpixel(&font, text[ch], scale,scale,x_shift,0, &x0,&y0,&x1,&y1);
stbtt_MakeCodepointBitmapSubpixel(&font, &screen[baseline + y0][(int) xpos + x0], x1-x0,y1-y0, 79, scale,scale,x_shift,0, text[ch]);
// note that this stomps the old data, so where character boxes overlap (e.g. 'lj') it's wrong
// because this API is really for baking character bitmaps into textures. if you want to render
// a sequence of characters, you really need to render each bitmap to a temp buffer, then
// "alpha blend" that into the working buffer
xpos += (advance * scale);
if (text[ch+1])
xpos += scale*stbtt_GetCodepointKernAdvance(&font, text[ch],text[ch+1]);
++ch;
}
for (j=0; j < 20; ++j) {
for (i=0; i < 78; ++i)
putchar(" .:ioVM@"[screen[j][i]>>5]);
putchar('\n');
}
return 0;
}
You should really just solve this offline, keep your own tables of what font is what, and don't try to get it out of the .ttf file. That's because getting it out of the .ttf file is really hard, because the names in the file can appear in many possible encodings, in many possible languages, and e.g. if you need a case-insensitive comparison, the details of that depend on the encoding & language in a complex way (actually underspecified in truetype, but also gigantic).
But you can use the provided functions in two possible ways:
FindMatchingFont will use *case-sensitive* comparisons on unicode-encoded names to try to find the font you want; you can run this before
calling InitFontGetFontNameString lets you get any of the various strings from the file yourself and do your own comparisons on them. You have to have called
InitFont first.| Modifier and Type | Field and Description |
|---|---|
| public static final int | STBTT_MAC_EID_ARABIC
Encoding IDs for |
| public static final int | STBTT_MAC_EID_CHINESE_TRAD
Encoding IDs for |
| public static final int | STBTT_MAC_EID_GREEK
Encoding IDs for |
| public static final int | STBTT_MAC_EID_HEBREW
Encoding IDs for |
| public static final int | STBTT_MAC_EID_JAPANESE
Encoding IDs for |
| public static final int | STBTT_MAC_EID_KOREAN
Encoding IDs for |
| public static final int | STBTT_MAC_EID_ROMAN
Encoding IDs for |
| public static final int | STBTT_MAC_EID_RUSSIAN
Encoding IDs for |
| public static final int | STBTT_MAC_LANG_ARABIC
Language ID for |
| public static final int | STBTT_MAC_LANG_CHINESE_SIMPLIFIED
Language ID for |
| public static final int | STBTT_MAC_LANG_CHINESE_TRAD
Language ID for |
| public static final int | STBTT_MAC_LANG_DUTCH
Language ID for |
| public static final int | STBTT_MAC_LANG_ENGLISH
Language ID for |
| public static final int | STBTT_MAC_LANG_FRENCH
Language ID for |
| public static final int | STBTT_MAC_LANG_GERMAN
Language ID for |
| public static final int | STBTT_MAC_LANG_HEBREW
Language ID for |
| public static final int | STBTT_MAC_LANG_ITALIAN
Language ID for |
| public static final int | STBTT_MAC_LANG_JAPANESE
Language ID for |
| public static final int | STBTT_MAC_LANG_KOREAN
Language ID for |
| public static final int | STBTT_MAC_LANG_RUSSIAN
Language ID for |
| public static final int | STBTT_MAC_LANG_SPANISH
Language ID for |
| public static final int | STBTT_MAC_LANG_SWEDISH
Language ID for |
| public static final int | STBTT_MACSTYLE_BOLD
Style flags, use in |
| public static final int | STBTT_MACSTYLE_DONTCARE
Style flags, use in |
| public static final int | STBTT_MACSTYLE_ITALIC
Style flags, use in |
| public static final int | STBTT_MACSTYLE_NONE
Style flags, use in |
| public static final int | STBTT_MACSTYLE_UNDERSCORE
Style flags, use in |
| public static final int | STBTT_MS_EID_SHIFTJIS
Encoding IDs for |
| public static final int | STBTT_MS_EID_SYMBOL
Encoding IDs for |
| public static final int | STBTT_MS_EID_UNICODE_BMP
Encoding IDs for |
| public static final int | STBTT_MS_EID_UNICODE_FULL
Encoding IDs for |
| public static final int | STBTT_MS_LANG_CHINESE
Language ID for |
| public static final int | STBTT_MS_LANG_DUTCH
Language ID for |
| public static final int | STBTT_MS_LANG_ENGLISH
Language ID for |
| public static final int | STBTT_MS_LANG_FRENCH
Language ID for |
| public static final int | STBTT_MS_LANG_GERMAN
Language ID for |
| public static final int | STBTT_MS_LANG_HEBREW
Language ID for |
| public static final int | STBTT_MS_LANG_ITALIAN
Language ID for |
| public static final int | STBTT_MS_LANG_JAPANESE
Language ID for |
| public static final int | STBTT_MS_LANG_KOREAN
Language ID for |
| public static final int | STBTT_MS_LANG_RUSSIAN
Language ID for |
| public static final int | STBTT_MS_LANG_SPANISH
Language ID for |
| public static final int | STBTT_MS_LANG_SWEDISH
Language ID for |
| public static final int | STBTT_PLATFORM_ID_ISO
Platform IDs. |
| public static final int | STBTT_PLATFORM_ID_MAC
Platform IDs. |
| public static final int | STBTT_PLATFORM_ID_MICROSOFT
Platform IDs. |
| public static final int | STBTT_PLATFORM_ID_UNICODE
Platform IDs. |
| public static final int | STBTT_UNICODE_EID_ISO_10646
Encoding IDs for |
| public static final int | STBTT_UNICODE_EID_UNICODE_1_0
Encoding IDs for |
| public static final int | STBTT_UNICODE_EID_UNICODE_1_1
Encoding IDs for |
| public static final int | STBTT_UNICODE_EID_UNICODE_2_0_BMP
Encoding IDs for |
| public static final int | STBTT_UNICODE_EID_UNICODE_2_0_FULL
Encoding IDs for |
| public static final byte | STBTT_vcubic
Vertex type. |
| public static final byte | STBTT_vcurve
Vertex type. |
| public static final byte | STBTT_vline
Vertex type. |
| public static final byte | STBTT_vmove
Vertex type. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description | |||||
|---|---|---|---|---|---|---|
| public static native int | nstbtt_BakeFontBitmap(long data, int offset, float pixel_height, long pixels, int pw, int ph, int first_char, int
the number of characters to bake, starting at num_chars, long chardata)first_charUnsafe version of: | |||||
| public static native int | nstbtt_CompareUTF8toUTF16_bigendian(long s1, int
the length of the first string, in bytes len1, long s2, int the length of the second string, in bytes len2)Unsafe version of: | |||||
| public static native int | ||||||
| public static native int | ||||||
| public static native long | ||||||
| public static native void | ||||||
| public static native void | ||||||
| public static native void | ||||||
| public static native void | nstbtt_GetBakedQuad(long chardata, int pw, int ph, int char_index, long xpos, long ypos, long q, int opengl_fillrule)
Unsafe version of: | |||||
| public static native void | nstbtt_GetBakedQuad(long chardata, int pw, int ph, int char_index, float[] xpos, float[] ypos, long q, int opengl_fillrule)
Array version of: | |||||
| public static native long | nstbtt_GetCodepointBitmap(long info, float scale_x, float scale_y, int codepoint, long width, long height, long xoff, long yoff)
Unsafe version of: | |||||
| public static native long | nstbtt_GetCodepointBitmap(long info, float scale_x, float scale_y, int codepoint, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static native void | nstbtt_GetCodepointBitmapBox(long font, int codepoint, float scale_x, float scale_y, long ix0, long iy0, long ix1, long iy1)
Unsafe version of: | |||||
| public static native void | nstbtt_GetCodepointBitmapBox(long font, int codepoint, float scale_x, float scale_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static native void | nstbtt_GetCodepointBitmapBoxSubpixel(long font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, long ix0, long iy0, long ix1, long iy1)
Unsafe version of: | |||||
| public static native void | nstbtt_GetCodepointBitmapBoxSubpixel(long font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static native long | nstbtt_GetCodepointBitmapSubpixel(long info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, long width, long height, long xoff, long yoff)
Unsafe version of: | |||||
| public static native long | nstbtt_GetCodepointBitmapSubpixel(long info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static native int | nstbtt_GetCodepointBox(long info, int codepoint, long x0, long y0, long x1, long y1)
Unsafe version of: | |||||
| public static native int | nstbtt_GetCodepointBox(long info, int codepoint, int[] x0, int[] y0, int[] x1, int[] y1)
Array version of: | |||||
| public static native void | nstbtt_GetCodepointHMetrics(long info, int codepoint, long advanceWidth, long leftSideBearing)
Unsafe version of: | |||||
| public static native void | nstbtt_GetCodepointHMetrics(long info, int codepoint, int[] advanceWidth, int[] leftSideBearing)
Array version of: | |||||
| public static native int | nstbtt_GetCodepointKernAdvance(long info, int ch1, int ch2)
Unsafe version of: | |||||
| public static native long | nstbtt_GetCodepointSDF(long font, float scale, int codepoint, int padding, byte onedge_value, float pixel_dist_scale, long width, long height, long xoff, long yoff)
Unsafe version of: | |||||
| public static native long | nstbtt_GetCodepointSDF(long font, float scale, int codepoint, int padding, byte onedge_value, float pixel_dist_scale, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static native int | nstbtt_GetCodepointShape(long info, int unicode_codepoint, long vertices)
Unsafe version of: | |||||
| public static native int | nstbtt_GetCodepointSVG(long info, int unicode_codepoint, long svg)
Unsafe version of: | |||||
| public static native void | nstbtt_GetFontBoundingBox(long info, long x0, long y0, long x1, long y1)
Unsafe version of: | |||||
| public static native void | nstbtt_GetFontBoundingBox(long info, int[] x0, int[] y0, int[] x1, int[] y1)
Array version of: | |||||
| public static native long | nstbtt_GetFontNameString(long font, long
returns the string length, in bytes length, int platformID, int encodingID, int languageID, int nameID)Unsafe version of: | |||||
| public static native int | ||||||
| public static native void | nstbtt_GetFontVMetrics(long info, long ascent, long descent, long lineGap)
Unsafe version of: | |||||
| public static native void | nstbtt_GetFontVMetrics(long info, int[] ascent, int[] descent, int[] lineGap)
Array version of: | |||||
| public static native int | nstbtt_GetFontVMetricsOS2(long info, long typoAscent, long typoDescent, long typoLineGap)
Unsafe version of: | |||||
| public static native int | nstbtt_GetFontVMetricsOS2(long info, int[] typoAscent, int[] typoDescent, int[] typoLineGap)
Array version of: | |||||
| public static native long | nstbtt_GetGlyphBitmap(long info, float scale_x, float scale_y, int glyph, long width, long height, long xoff, long yoff)
Unsafe version of: | |||||
| public static native long | nstbtt_GetGlyphBitmap(long info, float scale_x, float scale_y, int glyph, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static native void | nstbtt_GetGlyphBitmapBox(long font, int glyph, float scale_x, float scale_y, long ix0, long iy0, long ix1, long iy1)
Unsafe version of: | |||||
| public static native void | nstbtt_GetGlyphBitmapBox(long font, int glyph, float scale_x, float scale_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static native void | nstbtt_GetGlyphBitmapBoxSubpixel(long font, int glyph, float scale_x, float scale_y, float shift_x, float shift_y, long ix0, long iy0, long ix1, long iy1)
Unsafe version of: | |||||
| public static native void | nstbtt_GetGlyphBitmapBoxSubpixel(long font, int glyph, float scale_x, float scale_y, float shift_x, float shift_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static native long | nstbtt_GetGlyphBitmapSubpixel(long info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, long width, long height, long xoff, long yoff)
Unsafe version of: | |||||
| public static native long | nstbtt_GetGlyphBitmapSubpixel(long info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static native int | nstbtt_GetGlyphBox(long info, int glyph_index, long x0, long y0, long x1, long y1)
Unsafe version of: | |||||
| public static native int | nstbtt_GetGlyphBox(long info, int glyph_index, int[] x0, int[] y0, int[] x1, int[] y1)
Array version of: | |||||
| public static native void | nstbtt_GetGlyphHMetrics(long info, int glyph_index, long advanceWidth, long leftSideBearing)
Unsafe version of: | |||||
| public static native void | nstbtt_GetGlyphHMetrics(long info, int glyph_index, int[] advanceWidth, int[] leftSideBearing)
Array version of: | |||||
| public static native int | ||||||
| public static native long | nstbtt_GetGlyphSDF(long font, float scale, int glyph, int padding, byte onedge_value, float pixel_dist_scale, long width, long height, long xoff, long yoff)
Unsafe version of: | |||||
| public static native long | nstbtt_GetGlyphSDF(long font, float scale, int glyph, int padding, byte onedge_value, float pixel_dist_scale, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static native int | ||||||
| public static native int | ||||||
| public static native int | ||||||
| public static native int | ||||||
| public static native int | ||||||
| public static native void | nstbtt_GetPackedQuad(long chardata, int pw, int ph, int char_index, long xpos, long ypos, long q, int align_to_integer)
Unsafe version of: | |||||
| public static native void | nstbtt_GetPackedQuad(long chardata, int pw, int ph, int char_index, float[] xpos, float[] ypos, long q, int align_to_integer)
Array version of: | |||||
| public static native void | nstbtt_GetScaledFontVMetrics(long fontdata, int index, float size, long ascent, long descent, long lineGap)
Unsafe version of: | |||||
| public static native void | nstbtt_GetScaledFontVMetrics(long fontdata, int index, float size, float[] ascent, float[] descent, float[] lineGap)
Array version of: | |||||
| public static native int | ||||||
| public static native int | ||||||
| public static native void | nstbtt_MakeCodepointBitmap(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
Unsafe version of: | |||||
| public static native void | nstbtt_MakeCodepointBitmapSubpixel(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
Unsafe version of: | |||||
| public static native void | nstbtt_MakeCodepointBitmapSubpixelPrefilter(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, long sub_x, long sub_y, int codepoint)
Unsafe version of: | |||||
| public static native void | nstbtt_MakeCodepointBitmapSubpixelPrefilter(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float[] sub_x, float[] sub_y, int codepoint)
Array version of: | |||||
| public static native void | nstbtt_MakeGlyphBitmap(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
Unsafe version of: | |||||
| public static native void | nstbtt_MakeGlyphBitmapSubpixel(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
Unsafe version of: | |||||
| public static native void | nstbtt_MakeGlyphBitmapSubpixelPrefilter(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, long sub_x, long sub_y, int glyph)
Unsafe version of: | |||||
| public static native void | nstbtt_MakeGlyphBitmapSubpixelPrefilter(long info, long output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float[] sub_x, float[] sub_y, int glyph)
Array version of: | |||||
| public static native int | nstbtt_PackBegin(long spc, long pixels, int width, int height, int stride_in_bytes, int padding, long alloc_context)
Unsafe version of: | |||||
| public static native void | ||||||
| public static native int | nstbtt_PackFontRange(long spc, long fontdata, int font_index, float font_size, int first_unicode_char_in_range, int
the number of unicode code points in the range num_chars_in_range, long chardata_for_range)Unsafe version of: | |||||
| public static native int | nstbtt_PackFontRanges(long spc, long fontdata, int font_index, long ranges, int
the number of num_ranges)STBTTPackRange structs in rangesUnsafe version of: | |||||
| public static native int | nstbtt_PackFontRangesGatherRects(long spc, long info, long ranges, int
the number of num_ranges, long rects)STBTTPackRange structs in rangesUnsafe version of: | |||||
| public static native void | nstbtt_PackFontRangesPackRects(long spc, long rects, int
the number of structs in num_rects)rectsUnsafe version of: | |||||
| public static native int | nstbtt_PackFontRangesRenderIntoRects(long spc, long info, long ranges, int
the number of num_ranges, long rects)STBTTPackRange structs in rangesUnsafe version of: | |||||
| public static native void | nstbtt_PackSetOversampling(long spc, int h_oversample, int v_oversample)
Unsafe version of: | |||||
| public static native void | nstbtt_PackSetSkipMissingCodepoints(long spc, int skip)
Unsafe version of: | |||||
| public static native void | nstbtt_Rasterize(long result, float flatness_in_pixels, long vertices, int
number of vertices in above array num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, long alloc_context)Unsafe version of: | |||||
| public static native float | nstbtt_ScaleForMappingEmToPixels(long info, float pixels)
Unsafe version of: | |||||
| public static native float | ||||||
| public static int | Returns: if positive, the first unused row of the bitmap. If negative, returns the negative of the number of characters that fit. If 0, no characters fit and no rows were used.the font data data, float the font height, in pixels pixel_height, ByteBuffer a buffer in which to write the font bitmap pixels, int the bitmap width, in pixels pw, int the bitmap height, in pixels ph, int the first character to bake first_char, STBTTBakedChar.an array of chardataSTBTTBakedChar structs, it's num_chars longBakes a font to a bitmap for use as texture. | |||||
| public static boolean | stbtt_CompareUTF8toUTF16_bigendian(ByteBuffer
the first string s1, ByteBuffer the second string s2)Returns 1/0 whether the first string interpreted as utf8 is identical to the second string interpreted as big-endian utf16... | |||||
| public static int | Returns: the glyph index or 0 if the character codepoint is not defined in the fontan info, int STBTTFontinfo structthe unicode code point unicode_codepoint)If you're going to perform multiple operations on the same character and you want a speed-up, call this function with the character you're going to process, then use glyph-based functions instead of the codepoint-based functions. | |||||
| public static int | stbtt_FindMatchingFont(ByteBuffer
the font data fontdata, ByteBuffer the font name name, int the style flags. One of: flags)
Returns the offset (not index) of the font that matches, or -1 if none. | |||||
| public static int | stbtt_FindMatchingFont(ByteBuffer
the font data fontdata, CharSequence the font name name, int the style flags. One of: flags)
Returns the offset (not index) of the font that matches, or -1 if none. | |||||
| public static long | ||||||
| public static void | stbtt_FreeBitmap(ByteBuffer
the bitmap to free bitmap, long a pointer to an allocation context userdata)Frees a bitmap allocated by | |||||
| public static void | stbtt_FreeBitmap(ByteBuffer
the bitmap to free bitmap)Frees a bitmap allocated by | |||||
| public static void | stbtt_FreeSDF(ByteBuffer
the SDF bitmap to free bitmap, long a pointer to an allocation context userdata)Frees an SDF bitmap. | |||||
| public static void | ||||||
| public static void | stbtt_FreeShape(STBTTFontinfo
an info, STBTTVertex.STBTTFontinfo structthe array of verticesSTBTTVertex structs to freeFrees the data allocated by | |||||
| public static void | stbtt_GetBakedQuad(STBTTBakedChar.
an array of chardata,STBTTBakedChar structsthe bitmap width, in pixels pw, int the bitmap height, in pixels ph, int the character index in the char_index, FloatBuffer chardata arraythe current x position, in screen pixel space xpos, FloatBuffer the current y position, in screen pixel space ypos, STBTTAlignedQuad an q, boolean STBTTAlignedQuad struct in which to return the quad to draw1 if opengl fill rule; 0 if DX9 or earlier opengl_fillrule)Computes quad to draw for a given char and advances the current position. | |||||
| public static void | stbtt_GetBakedQuad(STBTTBakedChar.
Array version of: | |||||
| public static ByteBuffer | stbtt_GetCodepointBitmap(STBTTFontinfo
an info, float STBTTFontinfo structthe horizontal scale scale_x, float the vertical scale scale_y, int the unicode codepoint to render codepoint, IntBuffer returns the bitmap width width, IntBuffer returns the bitmap height height, IntBuffer returns the horizontal offset in pixel space from the glyph origin to the left of the bitmap xoff, IntBuffer returns the vertical offset in pixel space from the glyph origin to the top of the bitmap yoff)Allocates a large-enough single-channel 8bpp bitmap and renders the specified character/glyph at the specified scale into it, with antialiasing. | |||||
| public static ByteBuffer | stbtt_GetCodepointBitmap(STBTTFontinfo info, float scale_x, float scale_y, int codepoint, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static void | stbtt_GetCodepointBitmapBox(STBTTFontinfo
an font, int STBTTFontinfo structthe unicode codepoint codepoint, float the horizontal scale scale_x, float the vertical scale scale_y, IntBuffer returns the left coordinate ix0, IntBuffer returns the bottom coordinate iy0, IntBuffer returns the right coordinate ix1, IntBuffer returns the top coordinate iy1)Get the bbox of the bitmap centered around the glyph origin; so the bitmap width is | |||||
| public static void | stbtt_GetCodepointBitmapBox(STBTTFontinfo font, int codepoint, float scale_x, float scale_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static void | stbtt_GetCodepointBitmapBoxSubpixel(STBTTFontinfo
an font, int STBTTFontinfo structthe unicode codepoint codepoint, float the horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, IntBuffer returns the left coordinate ix0, IntBuffer returns the bottom coordinate iy0, IntBuffer returns the right coordinate ix1, IntBuffer returns the top coordinate iy1)Same as | |||||
| public static void | stbtt_GetCodepointBitmapBoxSubpixel(STBTTFontinfo font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static ByteBuffer | stbtt_GetCodepointBitmapSubpixel(STBTTFontinfo
an info, float STBTTFontinfo structthe horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, int the unicode codepoint to render codepoint, IntBuffer returns the bitmap width width, IntBuffer returns the bitmap height height, IntBuffer returns the horizontal offset in pixel space from the glyph origin to the left of the bitmap xoff, IntBuffer returns the vertical offset in pixel space from the glyph origin to the top of the bitmap yoff)Same as | |||||
| public static ByteBuffer | stbtt_GetCodepointBitmapSubpixel(STBTTFontinfo info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static boolean | stbtt_GetCodepointBox(STBTTFontinfo
an info, int STBTTFontinfo structthe unicode codepoint codepoint, IntBuffer returns the left coordinate x0, IntBuffer returns the bottom coordinate y0, IntBuffer returns the right coordinate x1, IntBuffer returns the top coordinate y1)Gets the bounding box of the visible part of the glyph, in unscaled coordinates. | |||||
| public static boolean | stbtt_GetCodepointBox(STBTTFontinfo info, int codepoint, int[] x0, int[] y0, int[] x1, int[] y1)
Array version of: | |||||
| public static void | stbtt_GetCodepointHMetrics(STBTTFontinfo
an info, int STBTTFontinfo structthe unicode codepoint codepoint, IntBuffer the offset from the current horizontal position to the next horizontal position advanceWidth, IntBuffer the offset from the current horizontal position to the left edge of the character leftSideBearing)Returns horizontal metrics for the specified codepoint. | |||||
| public static void | stbtt_GetCodepointHMetrics(STBTTFontinfo info, int codepoint, int[] advanceWidth, int[] leftSideBearing)
Array version of: | |||||
| public static int | stbtt_GetCodepointKernAdvance(STBTTFontinfo
an info, int STBTTFontinfo structthe first unicode codepoint ch1, int the second unicode codepoint ch2)Returns the additional amount to add to the | |||||
| public static ByteBuffer | stbtt_GetCodepointSDF(STBTTFontinfo
an font, float STBTTFontinfo structcontrols the size of the resulting SDF bitmap, same as it would be creating a regular bitmap scale, int the codepoint to generate the SDF for codepoint, int extra "pixels" around the character which are filled with the distance to the character (not 0), which allows effects like bit outlines padding, byte value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) onedge_value, float what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale). If positive, > pixel_dist_scale, IntBuffer onedge_value
is inside; if negative, < onedge_value is inside.output width of the SDF bitmap (including padding) width, IntBuffer output height of the SDF bitmap (including padding) height, IntBuffer output horizontal origin of the character xoff, IntBuffer output vertical origin of the character yoff)Codepoint version of | |||||
| public static ByteBuffer | stbtt_GetCodepointSDF(STBTTFontinfo font, float scale, int codepoint, int padding, byte onedge_value, float pixel_dist_scale, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static int | stbtt_GetCodepointShape(STBTTFontinfo
an info, int STBTTFontinfo structthe unicode codepoint unicode_codepoint, PointerBuffer returns a pointer to an array of vertices)STBTTVertex structsReturns number of vertices and fills The shape is a series of contours. | |||||
| public static STBTTVertex. | stbtt_GetCodepointShape(STBTTFontinfo
an info, int STBTTFontinfo structthe unicode codepoint unicode_codepoint)Returns number of vertices and fills The shape is a series of contours. | |||||
| public static int | Returns: data size or 0 if SVG not foundFills | |||||
| public static void | stbtt_GetFontBoundingBox(STBTTFontinfo
an info, IntBuffer STBTTFontinfo structthe left coordinate x0, IntBuffer the bottom coordinate y0, IntBuffer the right coordinate x1, IntBuffer the top coordinate y1)Returns the bounding box around all possible characters. | |||||
| public static void | stbtt_GetFontBoundingBox(STBTTFontinfo info, int[] x0, int[] y0, int[] x1, int[] y1)
Array version of: | |||||
| public static ByteBuffer | stbtt_GetFontNameString(STBTTFontinfo
an font, int STBTTFontinfo structthe platform ID. One of: platformID, int
the encoding ID. One of: encodingID, int the language ID. One of: languageID, int the name ID nameID)Returns the string (which may be big-endian double byte, e.g. for unicode) and puts the length in bytes in | |||||
| public static int | stbtt_GetFontOffsetForIndex(ByteBuffer
the font data data, int the font index index)Each .ttf/.ttc file may have more than one font. | |||||
| public static void | stbtt_GetFontVMetrics(STBTTFontinfo
an info, IntBuffer STBTTFontinfo structreturns the coordinate above the baseline the font extends ascent, IntBuffer returns the coordinate below the baseline the font extends (i.e. it is typically negative) descent, IntBuffer returns the spacing between one row's descent and the next row's ascent lineGap)Returns vertical metrics for the specified font. | |||||
| public static void | stbtt_GetFontVMetrics(STBTTFontinfo info, int[] ascent, int[] descent, int[] lineGap)
Array version of: | |||||
| public static boolean | Returns: 1 on success (table present), 0 on failurean info, IntBuffer STBTTFontinfo structreturns the coordinate above the baseline the font extends typoAscent, IntBuffer returns the coordinate below the baseline the font extends (i.e. it is typically negative) typoDescent, IntBuffer returns the spacing between one row's descent and the next row's ascent typoLineGap)Analogous to | |||||
| public static boolean | stbtt_GetFontVMetricsOS2(STBTTFontinfo info, int[] typoAscent, int[] typoDescent, int[] typoLineGap)
Array version of: | |||||
| public static ByteBuffer | stbtt_GetGlyphBitmap(STBTTFontinfo
an info, float STBTTFontinfo structthe horizontal scale scale_x, float the vertical scale scale_y, int the glyph index to render glyph, IntBuffer returns the bitmap width width, IntBuffer returns the bitmap height height, IntBuffer returns the horizontal offset in pixel space from the glyph origin to the left of the bitmap xoff, IntBuffer returns the vertical offset in pixel space from the glyph origin to the top of the bitmap yoff)Allocates a large-enough single-channel 8bpp bitmap and renders the specified character/glyph at the specified scale into it, with antialiasing. | |||||
| public static ByteBuffer | stbtt_GetGlyphBitmap(STBTTFontinfo info, float scale_x, float scale_y, int glyph, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static void | stbtt_GetGlyphBitmapBox(STBTTFontinfo
an font, int STBTTFontinfo structthe glyph index glyph, float the horizontal scale scale_x, float the vertical scale scale_y, IntBuffer returns the left coordinate ix0, IntBuffer returns the bottom coordinate iy0, IntBuffer returns the right coordinate ix1, IntBuffer returns the top coordinate iy1)Get the bbox of the bitmap centered around the glyph origin; so the bitmap width is | |||||
| public static void | stbtt_GetGlyphBitmapBox(STBTTFontinfo font, int glyph, float scale_x, float scale_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static void | stbtt_GetGlyphBitmapBoxSubpixel(STBTTFontinfo
an font, int STBTTFontinfo structthe glyph index glyph, float the horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, IntBuffer returns the left coordinate ix0, IntBuffer returns the bottom coordinate iy0, IntBuffer returns the right coordinate ix1, IntBuffer returns the top coordinate iy1)Same as | |||||
| public static void | stbtt_GetGlyphBitmapBoxSubpixel(STBTTFontinfo font, int glyph, float scale_x, float scale_y, float shift_x, float shift_y, int[] ix0, int[] iy0, int[] ix1, int[] iy1)
Array version of: | |||||
| public static ByteBuffer | stbtt_GetGlyphBitmapSubpixel(STBTTFontinfo
an info, float STBTTFontinfo structthe horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, int the glyph index to render glyph, IntBuffer returns the bitmap width width, IntBuffer returns the bitmap height height, IntBuffer returns the horizontal offset in pixel space from the glyph origin to the left of the bitmap xoff, IntBuffer returns the vertical offset in pixel space from the glyph origin to the top of the bitmap yoff)Same as | |||||
| public static ByteBuffer | stbtt_GetGlyphBitmapSubpixel(STBTTFontinfo info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static boolean | stbtt_GetGlyphBox(STBTTFontinfo
an info, int STBTTFontinfo structthe glyph index glyph_index, IntBuffer returns the left coordinate x0, IntBuffer returns the bottom coordinate y0, IntBuffer returns the right coordinate x1, IntBuffer returns the top coordinate y1)Glyph version of | |||||
| public static boolean | stbtt_GetGlyphBox(STBTTFontinfo info, int glyph_index, int[] x0, int[] y0, int[] x1, int[] y1)
Array version of: | |||||
| public static void | stbtt_GetGlyphHMetrics(STBTTFontinfo
an info, int STBTTFontinfo structthe glyph index glyph_index, IntBuffer the offset from the current horizontal position to the next horizontal position advanceWidth, IntBuffer the offset from the current horizontal position to the left edge of the character leftSideBearing)Glyph version of | |||||
| public static void | stbtt_GetGlyphHMetrics(STBTTFontinfo info, int glyph_index, int[] advanceWidth, int[] leftSideBearing)
Array version of: | |||||
| public static int | stbtt_GetGlyphKernAdvance(STBTTFontinfo
an info, int STBTTFontinfo structthe first glyph index glyph1, int the second glyph index glyph2)Glyph version of | |||||
| public static ByteBuffer | stbtt_GetGlyphSDF(STBTTFontinfo
an font, float STBTTFontinfo structcontrols the size of the resulting SDF bitmap, same as it would be creating a regular bitmap scale, int the glyph to generate the SDF for glyph, int extra "pixels" around the character which are filled with the distance to the character (not 0), which allows effects like bit outlines padding, byte value 0-255 to test the SDF against to reconstruct the character (i.e. the isocontour of the character) onedge_value, float what value the SDF should increase by when moving one SDF "pixel" away from the edge (on the 0..255 scale). If positive, > pixel_dist_scale, IntBuffer onedge_value
is inside; if negative, < onedge_value is inside.output width of the SDF bitmap (including padding) width, IntBuffer output height of the SDF bitmap (including padding) height, IntBuffer output horizontal origin of the character xoff, IntBuffer output vertical origin of the character yoff)Computes a discretized SDF field for a single character, suitable for storing in a single-channel texture, sampling with bilinear filtering, and testing against larger than some threshold to produce scalable fonts. | |||||
| public static ByteBuffer | stbtt_GetGlyphSDF(STBTTFontinfo font, float scale, int glyph, int padding, byte onedge_value, float pixel_dist_scale, int[] width, int[] height, int[] xoff, int[] yoff)
Array version of: | |||||
| public static int | stbtt_GetGlyphShape(STBTTFontinfo
an info, int STBTTFontinfo structthe unicode codepoint glyph_index, PointerBuffer returns a pointer to an array of vertices)STBTTVertex structsGlyph version of | |||||
| public static STBTTVertex. | stbtt_GetGlyphShape(STBTTFontinfo
an info, int STBTTFontinfo structthe unicode codepoint glyph_index)Glyph version of | |||||
| public static int | Returns: data size or 0 if SVG not foundFills | |||||
| public static int | stbtt_GetKerningTable(STBTTFontinfo info, STBTTKerningentry.
Retrieves a complete list of all of the kerning pairs provided by the font. | |||||
| public static int | ||||||
| public static int | ||||||
| public static void | stbtt_GetPackedQuad(STBTTPackedchar.
an array of chardata,STBTTPackedchar structsthe bitmap width, in pixels pw, int the bitmap height, in pixels ph, int the character index in the char_index, FloatBuffer chardata arraythe current x position, in screen pixel space xpos, FloatBuffer the current y position, in screen pixel space ypos, STBTTAlignedQuad an q, boolean STBTTAlignedQuad struct in which to return the quad to draw1 to align the quad to integer coordinates align_to_integer)Computes quad to draw for a given char and advances the current position. | |||||
| public static void | stbtt_GetPackedQuad(STBTTPackedchar.
Array version of: | |||||
| public static void | stbtt_GetScaledFontVMetrics(ByteBuffer fontdata, int
the font index (use 0 if you don't know what that is) index, float the font height, in pixels size, FloatBuffer returns the coordinate above the baseline the font extends ascent, FloatBuffer returns the coordinate below the baseline the font extends (i.e. it is typically negative) descent, FloatBuffer returns the spacing between one row's descent and the next row's ascent lineGap)Query the font vertical metrics without having to create a font first. | |||||
| public static void | stbtt_GetScaledFontVMetrics(ByteBuffer fontdata, int index, float size, float[] ascent, float[] descent, float[] lineGap)
Array version of: | |||||
| public static boolean | Returns: 1 on success, 0 on failurean info, ByteBuffer STBTTFontinfo structthe font data data, int the font data offset offset)Given an offset into the file that defines a font, this function builds the necessary cached info for the rest of the system. | |||||
| public static boolean | Returns: 1 on success, 0 on failurean info, ByteBuffer STBTTFontinfo structthe font data data)Given an offset into the file that defines a font, this function builds the necessary cached info for the rest of the system. | |||||
| public static boolean | stbtt_IsGlyphEmpty(STBTTFontinfo
an info, int STBTTFontinfo structthe glyph index glyph_index)Returns non-zero if nothing is drawn for this glyph. | |||||
| public static void | stbtt_MakeCodepointBitmap(STBTTFontinfo
an info, ByteBuffer STBTTFontinfo structthe bitmap storage output, int the bitmap width out_w, int the bitmap height out_h, int the row stride, in bytes out_stride, float the horizontal scale scale_x, float the vertical scale scale_y, int the unicode codepoint to render codepoint)Same as | |||||
| public static void | stbtt_MakeCodepointBitmapSubpixel(STBTTFontinfo
an info, ByteBuffer STBTTFontinfo structthe bitmap storage output, int the bitmap width out_w, int the bitmap height out_h, int the row stride, in bytes out_stride, float the horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, int the unicode codepoint to render codepoint)Same as | |||||
| public static void | stbtt_MakeCodepointBitmapSubpixelPrefilter(STBTTFontinfo
an info, ByteBuffer STBTTFontinfo structthe bitmap storage output, int the bitmap width out_w, int the bitmap height out_h, int the row stride, in bytes out_stride, float the horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, int the horizontal oversampling amount oversample_x, int the vertical oversampling amount oversample_y, FloatBuffer returns the horizontal oversample shift sub_x, FloatBuffer returns the vertical oversample shift sub_y, int the unicode codepoint to render codepoint)Same as | |||||
| public static void | stbtt_MakeCodepointBitmapSubpixelPrefilter(STBTTFontinfo info, ByteBuffer output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float[] sub_x, float[] sub_y, int codepoint)
Array version of: | |||||
| public static void | stbtt_MakeGlyphBitmap(STBTTFontinfo
an info, ByteBuffer STBTTFontinfo structthe bitmap storage output, int the bitmap width out_w, int the bitmap height out_h, int the row stride, in bytes out_stride, float the horizontal scale scale_x, float the vertical scale scale_y, int the glyph index to render glyph)Same as | |||||
| public static void | stbtt_MakeGlyphBitmapSubpixel(STBTTFontinfo
an info, ByteBuffer STBTTFontinfo structthe bitmap storage output, int the bitmap width out_w, int the bitmap height out_h, int the row stride, in bytes out_stride, float the horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, int the glyph index to render glyph)Same as | |||||
| public static void | stbtt_MakeGlyphBitmapSubpixelPrefilter(STBTTFontinfo
an info, ByteBuffer STBTTFontinfo structthe bitmap storage output, int the bitmap width out_w, int the bitmap height out_h, int the row stride, in bytes out_stride, float the horizontal scale scale_x, float the vertical scale scale_y, float the horizontal subpixel shift shift_x, float the vertical subpixel shift shift_y, int the horizontal oversampling amount oversample_x, int the vertical oversampling amount oversample_y, FloatBuffer returns the horizontal oversample shift sub_x, FloatBuffer returns the vertical oversample shift sub_y, int the glyph index to render glyph)Same as | |||||
| public static void | stbtt_MakeGlyphBitmapSubpixelPrefilter(STBTTFontinfo info, ByteBuffer output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int oversample_x, int oversample_y, float[] sub_x, float[] sub_y, int glyph)
Array version of: | |||||
| public static boolean | Returns: 1 on success, 0 on failurean spc, ByteBuffer STBTTPackContext structa buffer in which to store the bitmap data pixels, int the bitmap width, in pixels width, int the bitmap height, in pixels height, int the distance from one row to the next (or 0 to mean they are packed tightly together) stride_in_bytes, int the amount of padding to leave between each character (normally you want '1' for bitmaps you'll use as textures with bilinear filtering) padding, long a pointer to an allocation context alloc_context)Initializes a packing context stored in the passed-in | |||||
| public static boolean | Returns: 1 on success, 0 on failurean spc, ByteBuffer STBTTPackContext structa buffer in which to store the bitmap data pixels, int the bitmap width, in pixels width, int the bitmap height, in pixels height, int the distance from one row to the next (or 0 to mean they are packed tightly together) stride_in_bytes, int the amount of padding to leave between each character (normally you want '1' for bitmaps you'll use as textures with bilinear filtering) padding)Initializes a packing context stored in the passed-in | |||||
| public static void | stbtt_PackEnd(STBTTPackContext
an spc)STBTTPackContext structCleans up the packing context and frees all memory. | |||||
| public static boolean | Returns: 1 on success, 0 on failurean spc, ByteBuffer STBTTPackContext structthe font data fontdata, int the font index (use 0 if you don't know what that is font_index, float the full height of the character from ascender to descender, as computed by font_size, int ScaleForPixelHeight. To use a point size as computed by
ScaleForMappingEmToPixels, wrap the font size in STBTT_POINT_SIZE and pass the result, i.e.:
the first unicode code point in the range first_unicode_char_in_range, STBTTPackedchar.an array of chardata_for_rangeSTBTTPackedchar structsCreates character bitmaps from the | |||||
| public static boolean | Returns: 1 on success, 0 on failurean spc, ByteBuffer STBTTPackContext structthe font data fontdata, int the font index (use 0 if you don't know what that is) font_index, STBTTPackRange.an array of rangesSTBTTPackRange structsCreates character bitmaps from multiple ranges of characters stored in ranges. | |||||
| public static int | Returns: the number of structs written inrectsan spc, STBTTFontinfo STBTTPackContext structan info, STBTTPackRange.STBTTFontinfo structan array of ranges,STBTTPackRange structsan array of rectsSTBRPRect structs. It must be big enough to accommodate all characters in the given ranges.Calling these functions in sequence is roughly equivalent to calling | |||||
| public static void | stbtt_PackFontRangesPackRects(STBTTPackContext
an spc, STBRPRect.STBTTPackContext structan array of rectsSTBRPRect structs | |||||
| public static boolean | Returns: 1 on success, 0 on failurean spc, STBTTFontinfo STBTTPackContext structan info, STBTTPackRange.STBTTFontinfo structan array of ranges,STBTTPackRange structsan array of rectsSTBRPRect structs. It must be big enough to accommodate all characters in the given ranges. | |||||
| public static void | stbtt_PackSetOversampling(STBTTPackContext
an spc, int STBTTPackContext structthe horizontal oversampling amount h_oversample, int the vertical oversampling amount v_oversample)Oversampling a font increases the quality by allowing higher-quality subpixel positioning, and is especially valuable at smaller text sizes. | |||||
| public static void | stbtt_PackSetSkipMissingCodepoints(STBTTPackContext
an spc, boolean STBTTPackContext structthe skip flag skip)If | |||||
| public static int | Returns: the point size of the characterthe full height of a character font_size)Converts the full height of a character from ascender to descender, as computed by | |||||
| public static void | stbtt_Rasterize(STBTTBitmap
1-channel bitmap to draw into result, float allowable error of curve in pixels flatness_in_pixels, STBTTVertex.array of vertices defining shape vertices,horizontal scale applied to input vertices scale_x, float vertical scale applied to input vertices scale_y, float horizontal translation applied to input vertices shift_x, float vertical translation applied to input vertices shift_y, int another horizontal translation applied to input x_off, int another vertical translation applied to input y_off, boolean if non-zero, vertically flip shape invert)Rasterize a shape with quadratic beziers into a bitmap. | |||||
| public static float | Returns: the scale factoran info, float STBTTFontinfo structthe font height, in pixels pixels)Computes a scale factor to produce a font whose EM size is mapped to | |||||
| public static float | Returns: the scale factoran info, float STBTTFontinfo structthe font height, in pixels pixels)Computes a scale factor to produce a font whose "height" is |