12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
- 12,36,12,12,12,12,12,12,12,12,12,12,
+ 12,36,12,12,12,12,12,12,12,12,12,12
};
type = utf8d[byte];
*retunicode = ( (*state != 0) ? ( ( byte & 0x3fu ) | ( *retunicode << 6 ) ) : ( ( 0xff >> type ) & ( byte ) ) );
#define FM_GLYPH_CODEPOINT_CURSOR (0x1)
#define FM_GLYPH_CODEPOINT_REPLACEMENT (0xfffd)
-#define FM_ALIGN_LEFT (0x0)
-#define FM_ALIGN_CENTER (0x1)
-#define FM_ALIGN_RIGHT (0x2)
-
-#define FM_ALIGN_BASELINE (0x0)
-#define FM_ALIGN_TOP (0x4)
-#define FM_ALIGN_MIDDLE (0x8)
-#define FM_ALIGN_BOTTOM (0x10)
+public enum VerticalAlignment { baseline, top, middle, bottom };
+public class FMTextAlignment : uint16
+{
+public:
+ Alignment horzAlignment:2;
+ VerticalAlignment vertAlignment:2;
+};
public struct FMPathDraw
{
////
- static float getVertAlign( int align, int size )
+ static float getVertAlign( FMTextAlignment align, int size )
{
- if( align & FM_ALIGN_TOP )
+ if( align.vertAlignment == top )
return ascender * size;
- else if( align & FM_ALIGN_MIDDLE )
+ else if( align.vertAlignment == middle )
return middleAlign * size;
- else if( align & FM_ALIGN_BOTTOM )
+ else if( align.vertAlignment == bottom )
return descender * (float)size;
return 0.0f;
}
{
FMFont font;
uint16 size;
- uint16 align;
+ FMTextAlignment align;
uint16 blurradius;
uint16 blurscale;
};
state->font = 0;
state->blurradius = 0;
state->blurscale = 1;
- state->align = FM_ALIGN_LEFT | FM_ALIGN_BASELINE;
+ state->align = { left, baseline };
}
stringlength = strlen( string );
// Align horizontally
- if( state->align & FM_ALIGN_RIGHT )
+ if( state->align.horzAlignment == right )
x -= getTextWidth(string, stringlength );
- else if( state->align & FM_ALIGN_CENTER )
+ else if( state->align.horzAlignment == center )
x -= getTextWidth(string, stringlength ) >> 1;
// Align vertically
stringlength = strlen( string );
// Align horizontally
- if( state->align & FM_ALIGN_RIGHT )
+ if( state->align.horzAlignment == right )
x -= getTextWidth(string, stringlength );
- else if( state->align & FM_ALIGN_CENTER )
+ else if( state->align.horzAlignment == center )
x -= getTextWidth(string, stringlength ) >> 1;
// Align vertically
}
// Align horizontally
- if( state->align & FM_ALIGN_RIGHT )
+ if( state->align.horzAlignment == right )
x -= textwidth;
- else if( state->align & FM_ALIGN_CENTER )
+ else if( state->align.horzAlignment == center )
x -= textwidth >> 1;
// Align vertically
advance = x - startx;
/* Align horizontally */
- if( state->align & FM_ALIGN_RIGHT )
+ if( state->align.horzAlignment == right )
{
minx -= advance;
maxx -= advance;
}
- else if( state->align & FM_ALIGN_CENTER )
+ else if( state->align.horzAlignment == center )
{
minx -= advance * 0.5f;
maxx -= advance * 0.5f;