|
@@ -379,6 +379,12 @@ int main(int arg, char **argv)
|
379
|
379
|
typedef char stbtt__check_size32[sizeof(stbtt_int32)==4 ? 1 : -1];
|
380
|
380
|
typedef char stbtt__check_size16[sizeof(stbtt_int16)==2 ? 1 : -1];
|
381
|
381
|
|
|
382
|
+ #ifdef STBTT_STATIC
|
|
383
|
+ #define STBTT_DEF static
|
|
384
|
+ #else
|
|
385
|
+ #define STBTT_DEF extern
|
|
386
|
+ #endif
|
|
387
|
+
|
382
|
388
|
// #define your own STBTT_sort() to override this to avoid qsort
|
383
|
389
|
#ifndef STBTT_sort
|
384
|
390
|
#include <stdlib.h>
|
|
@@ -448,7 +454,7 @@ typedef struct
|
448
|
454
|
float xoff,yoff,xadvance;
|
449
|
455
|
} stbtt_bakedchar;
|
450
|
456
|
|
451
|
|
-extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
|
|
457
|
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
|
452
|
458
|
float pixel_height, // height of font in pixels
|
453
|
459
|
unsigned char *pixels, int pw, int ph, // bitmap to be filled in
|
454
|
460
|
int first_char, int num_chars, // characters to bake
|
|
@@ -464,7 +470,7 @@ typedef struct
|
464
|
470
|
float x1,y1,s1,t1; // bottom-right
|
465
|
471
|
} stbtt_aligned_quad;
|
466
|
472
|
|
467
|
|
-extern void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above
|
|
473
|
+STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, // same data as above
|
468
|
474
|
int char_index, // character to display
|
469
|
475
|
float *xpos, float *ypos, // pointers to current position in screen pixel space
|
470
|
476
|
stbtt_aligned_quad *q, // output: quad to draw
|
|
@@ -497,8 +503,11 @@ typedef struct
|
497
|
503
|
|
498
|
504
|
typedef struct stbtt_pack_context stbtt_pack_context;
|
499
|
505
|
typedef struct stbtt_fontinfo stbtt_fontinfo;
|
|
506
|
+#ifndef STB_RECT_PACK_VERSION
|
|
507
|
+typedef struct stbrp_rect stbrp_rect;
|
|
508
|
+#endif
|
500
|
509
|
|
501
|
|
-extern int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
|
|
510
|
+STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context);
|
502
|
511
|
// Initializes a packing context stored in the passed-in stbtt_pack_context.
|
503
|
512
|
// Future calls using this context will pack characters into the bitmap passed
|
504
|
513
|
// in here: a 1-channel bitmap that is weight x height. stride_in_bytes is
|
|
@@ -509,12 +518,12 @@ extern int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int
|
509
|
518
|
//
|
510
|
519
|
// Returns 0 on failure, 1 on success.
|
511
|
520
|
|
512
|
|
-extern void stbtt_PackEnd (stbtt_pack_context *spc);
|
|
521
|
+STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc);
|
513
|
522
|
// Cleans up the packing context and frees all memory.
|
514
|
523
|
|
515
|
524
|
#define STBTT_POINT_SIZE(x) (-(x))
|
516
|
525
|
|
517
|
|
-extern int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
|
|
526
|
+STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
|
518
|
527
|
int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range);
|
519
|
528
|
// Creates character bitmaps from the font_index'th font found in fontdata (use
|
520
|
529
|
// font_index=0 if you don't know what that is). It creates num_chars_in_range
|
|
@@ -537,19 +546,19 @@ typedef struct
|
537
|
546
|
stbtt_packedchar *chardata_for_range; // output
|
538
|
547
|
} stbtt_pack_range;
|
539
|
548
|
|
540
|
|
-extern int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
|
|
549
|
+STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges);
|
541
|
550
|
// Creates character bitmaps from multiple ranges of characters stored in
|
542
|
551
|
// ranges. This will usually create a better-packed bitmap than multiple
|
543
|
552
|
// calls to stbtt_PackFontRange.
|
544
|
553
|
|
545
|
|
-extern int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
|
546
|
|
-extern int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
|
|
554
|
+STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
|
|
555
|
+STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects);
|
547
|
556
|
// Those functions are called by stbtt_PackFontRanges(). If you want to
|
548
|
557
|
// pack multiple fonts or custom data into a same texture, you may copy
|
549
|
558
|
// the contents of stbtt_PackFontRanges() and create a custom version
|
550
|
559
|
// using those functions.
|
551
|
560
|
|
552
|
|
-extern void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
|
|
561
|
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample);
|
553
|
562
|
// Oversampling a font increases the quality by allowing higher-quality subpixel
|
554
|
563
|
// positioning, and is especially valuable at smaller text sizes.
|
555
|
564
|
//
|
|
@@ -561,7 +570,7 @@ extern void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_ov
|
561
|
570
|
// oversampled textures with bilinear filtering. Look at the readme in
|
562
|
571
|
// stb/tests/oversample for information about oversampled fonts
|
563
|
572
|
|
564
|
|
-extern void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
|
573
|
+STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, // same data as above
|
565
|
574
|
int char_index, // character to display
|
566
|
575
|
float *xpos, float *ypos, // pointers to current position in screen pixel space
|
567
|
576
|
stbtt_aligned_quad *q, // output: quad to draw
|
|
@@ -587,7 +596,7 @@ struct stbtt_pack_context {
|
587
|
596
|
//
|
588
|
597
|
//
|
589
|
598
|
|
590
|
|
-extern int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
|
|
599
|
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index);
|
591
|
600
|
// Each .ttf/.ttc file may have more than one font. Each font has a sequential
|
592
|
601
|
// index number starting from 0. Call this function to get the font offset for
|
593
|
602
|
// a given index; it returns -1 if the index is out of range. A regular .ttf
|
|
@@ -611,7 +620,7 @@ typedef struct stbtt_fontinfo
|
611
|
620
|
int indexToLocFormat; // format needed to map from glyph index to glyph
|
612
|
621
|
} stbtt_fontinfo;
|
613
|
622
|
|
614
|
|
-extern int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
|
|
623
|
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset);
|
615
|
624
|
// Given an offset into the file that defines a font, this function builds
|
616
|
625
|
// the necessary cached info for the rest of the system. You must allocate
|
617
|
626
|
// the stbtt_fontinfo yourself, and stbtt_InitFont will fill it out. You don't
|
|
@@ -623,7 +632,7 @@ extern int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int o
|
623
|
632
|
//
|
624
|
633
|
// CHARACTER TO GLYPH-INDEX CONVERSIOn
|
625
|
634
|
|
626
|
|
-int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
|
|
635
|
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
|
627
|
636
|
// If you're going to perform multiple operations on the same character
|
628
|
637
|
// and you want a speed-up, call this function with the character you're
|
629
|
638
|
// going to process, then use glyph-based functions instead of the
|
|
@@ -635,7 +644,7 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint);
|
635
|
644
|
// CHARACTER PROPERTIES
|
636
|
645
|
//
|
637
|
646
|
|
638
|
|
-extern float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
|
|
647
|
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels);
|
639
|
648
|
// computes a scale factor to produce a font whose "height" is 'pixels' tall.
|
640
|
649
|
// Height is measured as the distance from the highest ascender to the lowest
|
641
|
650
|
// descender; in other words, it's equivalent to calling stbtt_GetFontVMetrics
|
|
@@ -643,12 +652,12 @@ extern float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels)
|
643
|
652
|
// scale = pixels / (ascent - descent)
|
644
|
653
|
// so if you prefer to measure height by the ascent only, use a similar calculation.
|
645
|
654
|
|
646
|
|
-extern float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
|
|
655
|
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels);
|
647
|
656
|
// computes a scale factor to produce a font whose EM size is mapped to
|
648
|
657
|
// 'pixels' tall. This is probably what traditional APIs compute, but
|
649
|
658
|
// I'm not positive.
|
650
|
659
|
|
651
|
|
-extern void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
|
|
660
|
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap);
|
652
|
661
|
// ascent is the coordinate above the baseline the font extends; descent
|
653
|
662
|
// is the coordinate below the baseline the font extends (i.e. it is typically negative)
|
654
|
663
|
// lineGap is the spacing between one row's descent and the next row's ascent...
|
|
@@ -656,23 +665,23 @@ extern void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *
|
656
|
665
|
// these are expressed in unscaled coordinates, so you must multiply by
|
657
|
666
|
// the scale factor for a given size
|
658
|
667
|
|
659
|
|
-extern void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
|
|
668
|
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1);
|
660
|
669
|
// the bounding box around all possible characters
|
661
|
670
|
|
662
|
|
-extern void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
|
|
671
|
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing);
|
663
|
672
|
// leftSideBearing is the offset from the current horizontal position to the left edge of the character
|
664
|
673
|
// advanceWidth is the offset from the current horizontal position to the next horizontal position
|
665
|
674
|
// these are expressed in unscaled coordinates
|
666
|
675
|
|
667
|
|
-extern int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
|
|
676
|
+STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2);
|
668
|
677
|
// an additional amount to add to the 'advance' value between ch1 and ch2
|
669
|
678
|
|
670
|
|
-extern int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
|
|
679
|
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1);
|
671
|
680
|
// Gets the bounding box of the visible part of the glyph, in unscaled coordinates
|
672
|
681
|
|
673
|
|
-extern void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
|
674
|
|
-extern int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
|
675
|
|
-extern int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
|
|
682
|
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing);
|
|
683
|
+STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2);
|
|
684
|
+STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1);
|
676
|
685
|
// as above, but takes one or more glyph indices for greater efficiency
|
677
|
686
|
|
678
|
687
|
|
|
@@ -700,11 +709,11 @@ extern int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *
|
700
|
709
|
} stbtt_vertex;
|
701
|
710
|
#endif
|
702
|
711
|
|
703
|
|
-extern int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
|
|
712
|
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index);
|
704
|
713
|
// returns non-zero if nothing is drawn for this glyph
|
705
|
714
|
|
706
|
|
-extern int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
|
707
|
|
-extern int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
|
|
715
|
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices);
|
|
716
|
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **vertices);
|
708
|
717
|
// returns # of vertices and fills *vertices with the pointer to them
|
709
|
718
|
// these are expressed in "unscaled" coordinates
|
710
|
719
|
//
|
|
@@ -715,7 +724,7 @@ extern int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbt
|
715
|
724
|
// draws a quadratic bezier from previous endpoint to
|
716
|
725
|
// its x,y, using cx,cy as the bezier control point.
|
717
|
726
|
|
718
|
|
-extern void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
|
|
727
|
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
|
719
|
728
|
// frees the data allocated above
|
720
|
729
|
|
721
|
730
|
//////////////////////////////////////////////////////////////////////////////
|
|
@@ -723,10 +732,10 @@ extern void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *vertices);
|
723
|
732
|
// BITMAP RENDERING
|
724
|
733
|
//
|
725
|
734
|
|
726
|
|
-extern void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
|
|
735
|
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata);
|
727
|
736
|
// frees the bitmap allocated below
|
728
|
737
|
|
729
|
|
-extern unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
|
|
738
|
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
|
730
|
739
|
// allocates a large-enough single-channel 8bpp bitmap and renders the
|
731
|
740
|
// specified character/glyph at the specified scale into it, with
|
732
|
741
|
// antialiasing. 0 is no coverage (transparent), 255 is fully covered (opaque).
|
|
@@ -735,39 +744,39 @@ extern unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float
|
735
|
744
|
//
|
736
|
745
|
// xoff/yoff are the offset it pixel space from the glyph origin to the top-left of the bitmap
|
737
|
746
|
|
738
|
|
-extern unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
|
|
747
|
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff);
|
739
|
748
|
// the same as stbtt_GetCodepoitnBitmap, but you can specify a subpixel
|
740
|
749
|
// shift for the character
|
741
|
750
|
|
742
|
|
-extern void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
|
|
751
|
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint);
|
743
|
752
|
// the same as stbtt_GetCodepointBitmap, but you pass in storage for the bitmap
|
744
|
753
|
// in the form of 'output', with row spacing of 'out_stride' bytes. the bitmap
|
745
|
754
|
// is clipped to out_w/out_h bytes. Call stbtt_GetCodepointBitmapBox to get the
|
746
|
755
|
// width and height and positioning info for it first.
|
747
|
756
|
|
748
|
|
-extern void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
|
|
757
|
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint);
|
749
|
758
|
// same as stbtt_MakeCodepointBitmap, but you can specify a subpixel
|
750
|
759
|
// shift for the character
|
751
|
760
|
|
752
|
|
-extern void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
|
761
|
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
753
|
762
|
// get the bbox of the bitmap centered around the glyph origin; so the
|
754
|
763
|
// bitmap width is ix1-ix0, height is iy1-iy0, and location to place
|
755
|
764
|
// the bitmap top left is (leftSideBearing*scale,iy0).
|
756
|
765
|
// (Note that the bitmap uses y-increases-down, but the shape uses
|
757
|
766
|
// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)
|
758
|
767
|
|
759
|
|
-extern void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
|
768
|
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
760
|
769
|
// same as stbtt_GetCodepointBitmapBox, but you can specify a subpixel
|
761
|
770
|
// shift for the character
|
762
|
771
|
|
763
|
772
|
// the following functions are equivalent to the above functions, but operate
|
764
|
773
|
// on glyph indices instead of Unicode codepoints (for efficiency)
|
765
|
|
-extern unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
|
766
|
|
-extern unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
|
767
|
|
-extern void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
|
768
|
|
-extern void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
|
769
|
|
-extern void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
770
|
|
-extern void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
|
774
|
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff);
|
|
775
|
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff);
|
|
776
|
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph);
|
|
777
|
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph);
|
|
778
|
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
|
779
|
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1);
|
771
|
780
|
|
772
|
781
|
|
773
|
782
|
// @TODO: don't expose this structure
|
|
@@ -777,7 +786,7 @@ typedef struct
|
777
|
786
|
unsigned char *pixels;
|
778
|
787
|
} stbtt__bitmap;
|
779
|
788
|
|
780
|
|
-extern void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata);
|
|
789
|
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata);
|
781
|
790
|
|
782
|
791
|
//////////////////////////////////////////////////////////////////////////////
|
783
|
792
|
//
|
|
@@ -801,7 +810,7 @@ extern void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stb
|
801
|
810
|
// You have to have called stbtt_InitFont() first.
|
802
|
811
|
|
803
|
812
|
|
804
|
|
-extern int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
|
|
813
|
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *name, int flags);
|
805
|
814
|
// returns the offset (not index) of the font that matches, or -1 if none
|
806
|
815
|
// if you use STBTT_MACSTYLE_DONTCARE, use a font name like "Arial Bold".
|
807
|
816
|
// if you use any other flag, use a font name like "Arial"; this checks
|
|
@@ -812,11 +821,11 @@ extern int stbtt_FindMatchingFont(const unsigned char *fontdata, const char *nam
|
812
|
821
|
#define STBTT_MACSTYLE_UNDERSCORE 4
|
813
|
822
|
#define STBTT_MACSTYLE_NONE 8 // <= not same as 0, this makes us check the bitfield is 0
|
814
|
823
|
|
815
|
|
-extern int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
|
|
824
|
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2);
|
816
|
825
|
// returns 1/0 whether the first string interpreted as utf8 is identical to
|
817
|
826
|
// the second string interpreted as big-endian utf16... useful for strings from next func
|
818
|
827
|
|
819
|
|
-extern const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
|
|
828
|
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID);
|
820
|
829
|
// returns the string (which may be big-endian double byte, e.g. for unicode)
|
821
|
830
|
// and puts the length in bytes in *length.
|
822
|
831
|
//
|
|
@@ -915,10 +924,10 @@ typedef int stbtt__test_oversample_pow2[(STBTT_MAX_OVERSAMPLE & (STBTT_MAX_OVERS
|
915
|
924
|
|
916
|
925
|
#else
|
917
|
926
|
|
918
|
|
- stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
|
919
|
|
- stbtt_int16 ttSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
|
920
|
|
- stbtt_uint32 ttULONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
|
921
|
|
- stbtt_int32 ttLONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
|
|
927
|
+ static stbtt_uint16 ttUSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
|
|
928
|
+ static stbtt_int16 ttSHORT(const stbtt_uint8 *p) { return p[0]*256 + p[1]; }
|
|
929
|
+ static stbtt_uint32 ttULONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
|
|
930
|
+ static stbtt_int32 ttLONG(const stbtt_uint8 *p) { return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3]; }
|
922
|
931
|
|
923
|
932
|
#endif
|
924
|
933
|
|
|
@@ -949,7 +958,7 @@ static stbtt_uint32 stbtt__find_table(stbtt_uint8 *data, stbtt_uint32 fontstart,
|
949
|
958
|
return 0;
|
950
|
959
|
}
|
951
|
960
|
|
952
|
|
-int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
|
|
961
|
+STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
|
953
|
962
|
{
|
954
|
963
|
// if it's just a font, there's only one valid index
|
955
|
964
|
if (stbtt__isfont(font_collection))
|
|
@@ -968,7 +977,7 @@ int stbtt_GetFontOffsetForIndex(const unsigned char *font_collection, int index)
|
968
|
977
|
return -1;
|
969
|
978
|
}
|
970
|
979
|
|
971
|
|
-int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart)
|
|
980
|
+STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontstart)
|
972
|
981
|
{
|
973
|
982
|
stbtt_uint8 *data = (stbtt_uint8 *) data2;
|
974
|
983
|
stbtt_uint32 cmap, t;
|
|
@@ -1025,7 +1034,7 @@ int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, int fontsta
|
1025
|
1034
|
return 1;
|
1026
|
1035
|
}
|
1027
|
1036
|
|
1028
|
|
-int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
|
|
1037
|
+STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
|
1029
|
1038
|
{
|
1030
|
1039
|
stbtt_uint8 *data = info->data;
|
1031
|
1040
|
stbtt_uint32 index_map = info->index_map;
|
|
@@ -1117,7 +1126,7 @@ int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
|
1117
|
1126
|
return 0;
|
1118
|
1127
|
}
|
1119
|
1128
|
|
1120
|
|
-int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
|
|
1129
|
+STBTT_DEF int stbtt_GetCodepointShape(const stbtt_fontinfo *info, int unicode_codepoint, stbtt_vertex **vertices)
|
1121
|
1130
|
{
|
1122
|
1131
|
return stbtt_GetGlyphShape(info, stbtt_FindGlyphIndex(info, unicode_codepoint), vertices);
|
1123
|
1132
|
}
|
|
@@ -1149,7 +1158,7 @@ static int stbtt__GetGlyfOffset(const stbtt_fontinfo *info, int glyph_index)
|
1149
|
1158
|
return g1==g2 ? -1 : g1; // if length is 0, return -1
|
1150
|
1159
|
}
|
1151
|
1160
|
|
1152
|
|
-int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
|
|
1161
|
+STBTT_DEF int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int *y0, int *x1, int *y1)
|
1153
|
1162
|
{
|
1154
|
1163
|
int g = stbtt__GetGlyfOffset(info, glyph_index);
|
1155
|
1164
|
if (g < 0) return 0;
|
|
@@ -1161,12 +1170,12 @@ int stbtt_GetGlyphBox(const stbtt_fontinfo *info, int glyph_index, int *x0, int
|
1161
|
1170
|
return 1;
|
1162
|
1171
|
}
|
1163
|
1172
|
|
1164
|
|
-int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
|
|
1173
|
+STBTT_DEF int stbtt_GetCodepointBox(const stbtt_fontinfo *info, int codepoint, int *x0, int *y0, int *x1, int *y1)
|
1165
|
1174
|
{
|
1166
|
1175
|
return stbtt_GetGlyphBox(info, stbtt_FindGlyphIndex(info,codepoint), x0,y0,x1,y1);
|
1167
|
1176
|
}
|
1168
|
1177
|
|
1169
|
|
-int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
|
|
1178
|
+STBTT_DEF int stbtt_IsGlyphEmpty(const stbtt_fontinfo *info, int glyph_index)
|
1170
|
1179
|
{
|
1171
|
1180
|
stbtt_int16 numberOfContours;
|
1172
|
1181
|
int g = stbtt__GetGlyfOffset(info, glyph_index);
|
|
@@ -1191,7 +1200,7 @@ static int stbtt__close_shape(stbtt_vertex *vertices, int num_vertices, int was_
|
1191
|
1200
|
return num_vertices;
|
1192
|
1201
|
}
|
1193
|
1202
|
|
1194
|
|
-int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
|
|
1203
|
+STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_vertex **pvertices)
|
1195
|
1204
|
{
|
1196
|
1205
|
stbtt_int16 numberOfContours;
|
1197
|
1206
|
stbtt_uint8 *endPtsOfContours;
|
|
@@ -1417,7 +1426,7 @@ int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, stbtt_verte
|
1417
|
1426
|
return num_vertices;
|
1418
|
1427
|
}
|
1419
|
1428
|
|
1420
|
|
-void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
|
|
1429
|
+STBTT_DEF void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *advanceWidth, int *leftSideBearing)
|
1421
|
1430
|
{
|
1422
|
1431
|
stbtt_uint16 numOfLongHorMetrics = ttUSHORT(info->data+info->hhea + 34);
|
1423
|
1432
|
if (glyph_index < numOfLongHorMetrics) {
|
|
@@ -1429,7 +1438,7 @@ void stbtt_GetGlyphHMetrics(const stbtt_fontinfo *info, int glyph_index, int *ad
|
1429
|
1438
|
}
|
1430
|
1439
|
}
|
1431
|
1440
|
|
1432
|
|
-int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
|
|
1441
|
+STBTT_DEF int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph2)
|
1433
|
1442
|
{
|
1434
|
1443
|
stbtt_uint8 *data = info->data + info->kern;
|
1435
|
1444
|
stbtt_uint32 needle, straw;
|
|
@@ -1459,26 +1468,26 @@ int stbtt_GetGlyphKernAdvance(const stbtt_fontinfo *info, int glyph1, int glyph
|
1459
|
1468
|
return 0;
|
1460
|
1469
|
}
|
1461
|
1470
|
|
1462
|
|
-int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
|
|
1471
|
+STBTT_DEF int stbtt_GetCodepointKernAdvance(const stbtt_fontinfo *info, int ch1, int ch2)
|
1463
|
1472
|
{
|
1464
|
1473
|
if (!info->kern) // if no kerning table, don't waste time looking up both codepoint->glyphs
|
1465
|
1474
|
return 0;
|
1466
|
1475
|
return stbtt_GetGlyphKernAdvance(info, stbtt_FindGlyphIndex(info,ch1), stbtt_FindGlyphIndex(info,ch2));
|
1467
|
1476
|
}
|
1468
|
1477
|
|
1469
|
|
-void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
|
|
1478
|
+STBTT_DEF void stbtt_GetCodepointHMetrics(const stbtt_fontinfo *info, int codepoint, int *advanceWidth, int *leftSideBearing)
|
1470
|
1479
|
{
|
1471
|
1480
|
stbtt_GetGlyphHMetrics(info, stbtt_FindGlyphIndex(info,codepoint), advanceWidth, leftSideBearing);
|
1472
|
1481
|
}
|
1473
|
1482
|
|
1474
|
|
-void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
|
|
1483
|
+STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
|
1475
|
1484
|
{
|
1476
|
1485
|
if (ascent ) *ascent = ttSHORT(info->data+info->hhea + 4);
|
1477
|
1486
|
if (descent) *descent = ttSHORT(info->data+info->hhea + 6);
|
1478
|
1487
|
if (lineGap) *lineGap = ttSHORT(info->data+info->hhea + 8);
|
1479
|
1488
|
}
|
1480
|
1489
|
|
1481
|
|
-void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
|
|
1490
|
+STBTT_DEF void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int *x1, int *y1)
|
1482
|
1491
|
{
|
1483
|
1492
|
*x0 = ttSHORT(info->data + info->head + 36);
|
1484
|
1493
|
*y0 = ttSHORT(info->data + info->head + 38);
|
|
@@ -1486,19 +1495,19 @@ void stbtt_GetFontBoundingBox(const stbtt_fontinfo *info, int *x0, int *y0, int
|
1486
|
1495
|
*y1 = ttSHORT(info->data + info->head + 42);
|
1487
|
1496
|
}
|
1488
|
1497
|
|
1489
|
|
-float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
|
|
1498
|
+STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float height)
|
1490
|
1499
|
{
|
1491
|
1500
|
int fheight = ttSHORT(info->data + info->hhea + 4) - ttSHORT(info->data + info->hhea + 6);
|
1492
|
1501
|
return (float) height / fheight;
|
1493
|
1502
|
}
|
1494
|
1503
|
|
1495
|
|
-float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
|
|
1504
|
+STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
|
1496
|
1505
|
{
|
1497
|
1506
|
int unitsPerEm = ttUSHORT(info->data + info->head + 18);
|
1498
|
1507
|
return pixels / unitsPerEm;
|
1499
|
1508
|
}
|
1500
|
1509
|
|
1501
|
|
-void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
|
|
1510
|
+STBTT_DEF void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
|
1502
|
1511
|
{
|
1503
|
1512
|
STBTT_free(v, info->userdata);
|
1504
|
1513
|
}
|
|
@@ -1508,7 +1517,7 @@ void stbtt_FreeShape(const stbtt_fontinfo *info, stbtt_vertex *v)
|
1508
|
1517
|
// antialiasing software rasterizer
|
1509
|
1518
|
//
|
1510
|
1519
|
|
1511
|
|
-void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
|
1520
|
+STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y,float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
1512
|
1521
|
{
|
1513
|
1522
|
int x0,y0,x1,y1;
|
1514
|
1523
|
if (!stbtt_GetGlyphBox(font, glyph, &x0,&y0,&x1,&y1)) {
|
|
@@ -1526,17 +1535,17 @@ void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, floa
|
1526
|
1535
|
}
|
1527
|
1536
|
}
|
1528
|
1537
|
|
1529
|
|
-void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
|
1538
|
+STBTT_DEF void stbtt_GetGlyphBitmapBox(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
1530
|
1539
|
{
|
1531
|
1540
|
stbtt_GetGlyphBitmapBoxSubpixel(font, glyph, scale_x, scale_y,0.0f,0.0f, ix0, iy0, ix1, iy1);
|
1532
|
1541
|
}
|
1533
|
1542
|
|
1534
|
|
-void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
|
1543
|
+STBTT_DEF void stbtt_GetCodepointBitmapBoxSubpixel(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
1535
|
1544
|
{
|
1536
|
1545
|
stbtt_GetGlyphBitmapBoxSubpixel(font, stbtt_FindGlyphIndex(font,codepoint), scale_x, scale_y,shift_x,shift_y, ix0,iy0,ix1,iy1);
|
1537
|
1546
|
}
|
1538
|
1547
|
|
1539
|
|
-void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
|
1548
|
+STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1)
|
1540
|
1549
|
{
|
1541
|
1550
|
stbtt_GetCodepointBitmapBoxSubpixel(font, codepoint, scale_x, scale_y,0.0f,0.0f, ix0,iy0,ix1,iy1);
|
1542
|
1551
|
}
|
|
@@ -1817,7 +1826,7 @@ static int stbtt__tesselate_curve(stbtt__point *points, int *num_points, float x
|
1817
|
1826
|
}
|
1818
|
1827
|
|
1819
|
1828
|
// returns number of contours
|
1820
|
|
-stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
|
|
1829
|
+static stbtt__point *stbtt_FlattenCurves(stbtt_vertex *vertices, int num_verts, float objspace_flatness, int **contour_lengths, int *num_contours, void *userdata)
|
1821
|
1830
|
{
|
1822
|
1831
|
stbtt__point *points=0;
|
1823
|
1832
|
int num_points=0;
|
|
@@ -1886,7 +1895,7 @@ error:
|
1886
|
1895
|
return NULL;
|
1887
|
1896
|
}
|
1888
|
1897
|
|
1889
|
|
-void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
|
|
1898
|
+STBTT_DEF void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vertex *vertices, int num_verts, float scale_x, float scale_y, float shift_x, float shift_y, int x_off, int y_off, int invert, void *userdata)
|
1890
|
1899
|
{
|
1891
|
1900
|
float scale = scale_x > scale_y ? scale_y : scale_x;
|
1892
|
1901
|
int winding_count, *winding_lengths;
|
|
@@ -1898,12 +1907,12 @@ void stbtt_Rasterize(stbtt__bitmap *result, float flatness_in_pixels, stbtt_vert
|
1898
|
1907
|
}
|
1899
|
1908
|
}
|
1900
|
1909
|
|
1901
|
|
-void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
|
|
1910
|
+STBTT_DEF void stbtt_FreeBitmap(unsigned char *bitmap, void *userdata)
|
1902
|
1911
|
{
|
1903
|
1912
|
STBTT_free(bitmap, userdata);
|
1904
|
1913
|
}
|
1905
|
1914
|
|
1906
|
|
-unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
|
1915
|
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
1907
|
1916
|
{
|
1908
|
1917
|
int ix0,iy0,ix1,iy1;
|
1909
|
1918
|
stbtt__bitmap gbm;
|
|
@@ -1940,12 +1949,12 @@ unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info, float sc
|
1940
|
1949
|
return gbm.pixels;
|
1941
|
1950
|
}
|
1942
|
1951
|
|
1943
|
|
-unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
|
1952
|
+STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff)
|
1944
|
1953
|
{
|
1945
|
1954
|
return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y, 0.0f, 0.0f, glyph, width, height, xoff, yoff);
|
1946
|
1955
|
}
|
1947
|
1956
|
|
1948
|
|
-void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
|
|
1957
|
+STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int glyph)
|
1949
|
1958
|
{
|
1950
|
1959
|
int ix0,iy0;
|
1951
|
1960
|
stbtt_vertex *vertices;
|
|
@@ -1964,27 +1973,27 @@ void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *ou
|
1964
|
1973
|
STBTT_free(vertices, info->userdata);
|
1965
|
1974
|
}
|
1966
|
1975
|
|
1967
|
|
-void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
|
|
1976
|
+STBTT_DEF void stbtt_MakeGlyphBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int glyph)
|
1968
|
1977
|
{
|
1969
|
1978
|
stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, glyph);
|
1970
|
1979
|
}
|
1971
|
1980
|
|
1972
|
|
-unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
|
1981
|
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo *info, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
1973
|
1982
|
{
|
1974
|
1983
|
return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff);
|
1975
|
1984
|
}
|
1976
|
1985
|
|
1977
|
|
-void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
|
|
1986
|
+STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, float shift_x, float shift_y, int codepoint)
|
1978
|
1987
|
{
|
1979
|
1988
|
stbtt_MakeGlyphBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, shift_x, shift_y, stbtt_FindGlyphIndex(info,codepoint));
|
1980
|
1989
|
}
|
1981
|
1990
|
|
1982
|
|
-unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
|
1991
|
+STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff)
|
1983
|
1992
|
{
|
1984
|
1993
|
return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff);
|
1985
|
1994
|
}
|
1986
|
1995
|
|
1987
|
|
-void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
|
|
1996
|
+STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, int codepoint)
|
1988
|
1997
|
{
|
1989
|
1998
|
stbtt_MakeCodepointBitmapSubpixel(info, output, out_w, out_h, out_stride, scale_x, scale_y, 0.0f,0.0f, codepoint);
|
1990
|
1999
|
}
|
|
@@ -1995,7 +2004,7 @@ void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output
|
1995
|
2004
|
//
|
1996
|
2005
|
// This is SUPER-CRAPPY packing to keep source code small
|
1997
|
2006
|
|
1998
|
|
-extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
|
|
2007
|
+STBTT_DEF int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font location (use offset=0 for plain .ttf)
|
1999
|
2008
|
float pixel_height, // height of font in pixels
|
2000
|
2009
|
unsigned char *pixels, int pw, int ph, // bitmap to be filled in
|
2001
|
2010
|
int first_char, int num_chars, // characters to bake
|
|
@@ -2040,7 +2049,7 @@ extern int stbtt_BakeFontBitmap(const unsigned char *data, int offset, // font
|
2040
|
2049
|
return bottom_y;
|
2041
|
2050
|
}
|
2042
|
2051
|
|
2043
|
|
-void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
|
|
2052
|
+STBTT_DEF void stbtt_GetBakedQuad(stbtt_bakedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int opengl_fillrule)
|
2044
|
2053
|
{
|
2045
|
2054
|
float d3d_bias = opengl_fillrule ? 0 : -0.5f;
|
2046
|
2055
|
float ipw = 1.0f / pw, iph = 1.0f / ph;
|
|
@@ -2097,11 +2106,11 @@ typedef struct
|
2097
|
2106
|
unsigned char x;
|
2098
|
2107
|
} stbrp_node;
|
2099
|
2108
|
|
2100
|
|
-typedef struct
|
|
2109
|
+struct stbrp_rect
|
2101
|
2110
|
{
|
2102
|
2111
|
stbrp_coord x,y;
|
2103
|
2112
|
int id,w,h,was_packed;
|
2104
|
|
-} stbrp_rect;
|
|
2113
|
+};
|
2105
|
2114
|
|
2106
|
2115
|
static void stbrp_init_target(stbrp_context *con, int pw, int ph, stbrp_node *nodes, int num_nodes)
|
2107
|
2116
|
{
|
|
@@ -2143,7 +2152,7 @@ static void stbrp_pack_rects(stbrp_context *con, stbrp_rect *rects, int num_rect
|
2143
|
2152
|
// This is SUPER-AWESOME (tm Ryan Gordon) packing using stb_rect_pack.h. If
|
2144
|
2153
|
// stb_rect_pack.h isn't available, it uses the BakeFontBitmap strategy.
|
2145
|
2154
|
|
2146
|
|
-int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
|
|
2155
|
+STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int ph, int stride_in_bytes, int padding, void *alloc_context)
|
2147
|
2156
|
{
|
2148
|
2157
|
stbrp_context *context = (stbrp_context *) STBTT_malloc(sizeof(*context) ,alloc_context);
|
2149
|
2158
|
int num_nodes = pw - padding;
|
|
@@ -2174,13 +2183,13 @@ int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int pw, int
|
2174
|
2183
|
return 1;
|
2175
|
2184
|
}
|
2176
|
2185
|
|
2177
|
|
-void stbtt_PackEnd (stbtt_pack_context *spc)
|
|
2186
|
+STBTT_DEF void stbtt_PackEnd (stbtt_pack_context *spc)
|
2178
|
2187
|
{
|
2179
|
2188
|
STBTT_free(spc->nodes , spc->user_allocator_context);
|
2180
|
2189
|
STBTT_free(spc->pack_info, spc->user_allocator_context);
|
2181
|
2190
|
}
|
2182
|
2191
|
|
2183
|
|
-void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
|
|
2192
|
+STBTT_DEF void stbtt_PackSetOversampling(stbtt_pack_context *spc, unsigned int h_oversample, unsigned int v_oversample)
|
2184
|
2193
|
{
|
2185
|
2194
|
STBTT_assert(h_oversample <= STBTT_MAX_OVERSAMPLE);
|
2186
|
2195
|
STBTT_assert(v_oversample <= STBTT_MAX_OVERSAMPLE);
|
|
@@ -2313,7 +2322,7 @@ static float stbtt__oversample_shift(int oversample)
|
2313
|
2322
|
}
|
2314
|
2323
|
|
2315
|
2324
|
// rects array must be big enough to accommodate all characters in the given ranges
|
2316
|
|
-int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
|
|
2325
|
+STBTT_DEF int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
|
2317
|
2326
|
{
|
2318
|
2327
|
int i,j,k;
|
2319
|
2328
|
|
|
@@ -2343,7 +2352,7 @@ int stbtt_PackFontRangesGatherRects(stbtt_pack_context *spc, stbtt_fontinfo *inf
|
2343
|
2352
|
}
|
2344
|
2353
|
|
2345
|
2354
|
// rects array must be big enough to accommodate all characters in the given ranges
|
2346
|
|
-int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
|
|
2355
|
+STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
|
2347
|
2356
|
{
|
2348
|
2357
|
float recip_h = 1.0f / spc->h_oversample;
|
2349
|
2358
|
float recip_v = 1.0f / spc->v_oversample;
|
|
@@ -2413,7 +2422,7 @@ int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, stbtt_fontinfo
|
2413
|
2422
|
return return_value;
|
2414
|
2423
|
}
|
2415
|
2424
|
|
2416
|
|
-int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
|
|
2425
|
+STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, stbtt_pack_range *ranges, int num_ranges)
|
2417
|
2426
|
{
|
2418
|
2427
|
stbtt_fontinfo info;
|
2419
|
2428
|
int i,j,n, return_value = 1;
|
|
@@ -2447,7 +2456,7 @@ int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int f
|
2447
|
2456
|
return return_value;
|
2448
|
2457
|
}
|
2449
|
2458
|
|
2450
|
|
-int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
|
|
2459
|
+STBTT_DEF int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int font_index, float font_size,
|
2451
|
2460
|
int first_unicode_char_in_range, int num_chars_in_range, stbtt_packedchar *chardata_for_range)
|
2452
|
2461
|
{
|
2453
|
2462
|
stbtt_pack_range range;
|
|
@@ -2458,7 +2467,7 @@ int stbtt_PackFontRange(stbtt_pack_context *spc, unsigned char *fontdata, int fo
|
2458
|
2467
|
return stbtt_PackFontRanges(spc, fontdata, font_index, &range, 1);
|
2459
|
2468
|
}
|
2460
|
2469
|
|
2461
|
|
-void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
|
|
2470
|
+STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
|
2462
|
2471
|
{
|
2463
|
2472
|
float ipw = 1.0f / pw, iph = 1.0f / ph;
|
2464
|
2473
|
stbtt_packedchar *b = chardata + char_index;
|
|
@@ -2531,14 +2540,14 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8
|
2531
|
2540
|
return i;
|
2532
|
2541
|
}
|
2533
|
2542
|
|
2534
|
|
-int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2)
|
|
2543
|
+STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2)
|
2535
|
2544
|
{
|
2536
|
2545
|
return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2);
|
2537
|
2546
|
}
|
2538
|
2547
|
|
2539
|
2548
|
// returns results in whatever encoding you request... but note that 2-byte encodings
|
2540
|
2549
|
// will be BIG-ENDIAN... use stbtt_CompareUTF8toUTF16_bigendian() to compare
|
2541
|
|
-const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
|
|
2550
|
+STBTT_DEF const char *stbtt_GetFontNameString(const stbtt_fontinfo *font, int *length, int platformID, int encodingID, int languageID, int nameID)
|
2542
|
2551
|
{
|
2543
|
2552
|
stbtt_int32 i,count,stringOffset;
|
2544
|
2553
|
stbtt_uint8 *fc = font->data;
|
|
@@ -2635,7 +2644,7 @@ static int stbtt__matches(stbtt_uint8 *fc, stbtt_uint32 offset, stbtt_uint8 *nam
|
2635
|
2644
|
return 0;
|
2636
|
2645
|
}
|
2637
|
2646
|
|
2638
|
|
-int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags)
|
|
2647
|
+STBTT_DEF int stbtt_FindMatchingFont(const unsigned char *font_collection, const char *name_utf8, stbtt_int32 flags)
|
2639
|
2648
|
{
|
2640
|
2649
|
stbtt_int32 i;
|
2641
|
2650
|
for (i=0;;++i) {
|